Please use the google group to ask questions - thanks.

by imario 27 Feb 09:55
exclude specific properties from weaving

Hi!

I've starte to use AspectJ to enhance some classes (also entities) with PropertyChangeSupport.
Everything works so far, except that I did not manage to have a field I need woven into the class in a way that Avaje will ignore it, e.g. by weaving it transient.
The only workaround I do have at the moment is the same Avaje uses for its own added properties. I simply ignore fields with a specific prefix.

Do you think it is possible to apply this patch? Or would you like to see a more configurable approach?

Index: ../ebean/src/com/avaje/ebean/server/deploy/parse/CreateProperties.java
===================================================================
--- ../ebean/src/com/avaje/ebean/server/deploy/parse/CreateProperties.java (revision 151)
+++ ../ebean/src/com/avaje/ebean/server/deploy/parse/CreateProperties.java Fri Feb 27 09:33:39 CET 2009
@@ -93,7 +92,7 @@
for (int i = 0; i < fields.length; i++) {

Field field = fields[i];
- if (field.getName().startsWith("_ebean_")){
+ if (field.getName().startsWith("_ebean_") || field.getName().startsWith("ajc$instance$")){
// not interested in ebean added fields

} else if (Modifier.isStatic(field.getModifiers())) {


Thanks!
Ciao,
Mario

27 Feb 10:38
by Rob

I'm fine with "ajc$instance$" ... probably there should be some configuration to allow for the next unpredicted enhancement. Allowing people to specify a list of field name prefixes that should be ignored (over and above "_ebean_" and "ajc$instance$".

Interesting ... I was just the other day looking at "ClassBuilder" ... adding PropertyChangeSupport via enhancement. Perhaps it would be a good thing for Ebean enhancement to be able to support as well?

This was it: http://code.google.com/p/javabuilders/wiki/ClassBuilder

27 Feb 12:53
by imario

When doing the AspectJ stuff I thought about creating a EntityBean Aspect to not require to use the ebean weaver, which is fine, but I want to lower the used "weavers".

I'd suggest to use AspectJ as there is already IDE support and I think if one is doing AOP it will be done with AspectJ.
I think there is also a maven task for compile-time weaving.

If you would like to, I can donate the created aspect for PropertyChangeSupport to Avaje.
At least, I planned to donate any EntityBean aspect if I manage to create on.

Ciao,
Mario

28 Feb 03:12
by Rob

> I thought about creating a EntityBean Aspect to not require to use the ebean weaver
Thats interesting...

> I'd suggest to use AspectJ as there is already IDE support ...
To be honest I'm very happy using ASM... yes its a low level ("bare metal") approach ... but it means I have full control over the final byte code.

> also a maven task for compile-time weaving.
I think of ant/maven enhancement tasks as "build" time weaving... and I'd put the Eclipse Ebean plugin (that adds enhancement on save in eclipse... as "compile-time" weaving.

The Ant/Maven tasks really are relatively easy - yes I should have a maven enhancement task... I actually think someone already has done that.

If you would like to, I can donate the created aspect for PropertyChangeSupport to Avaje.
Yes, that could be interesting... but note the current Ebean entity enhancement already gets close due to "dirty" checking on setters etc. That is, there is already EntityBeanIntercept.preSetter(propName, newValue, oldValue) called ... so I'd probably be better off just hooking that into PropertyChangeSupport.

... but I would be very interested to see what exactly you are doing there ... and whether it is a good idea to support that with Ebean's current ASM based enhancement.

> I think if one is doing AOP it will be done with AspectJ
IMO it depends on who the "one" is... I think using ASM directly (as I do with Ebean and as Toplink/Eclipselink do) is great for framework type development because of the level of control you get... and because the AOP/Enhancement is well defined.

... with AOP for application development (rather than framework development)... I could imagine you want to use something higher level than ASM.

... but yes, I'm very happy using ASM - I think it is fantastic.

01 Mar 08:48
by Rob

Create a New Topic

Title:
Body:
 
Introduction User Guide (pdf) Install/Configure Public JavaDoc Whitepapers
General Database Specific Byte Code Deployment Annotations Features
Top Bugs Top Enhancements
woResponse