-
1. Re: annotation-introduction + aspect oriented annotations
kabirkhan Nov 28, 2006 9:08 PM (in response to fabiocsilva)Within the annotation-introduction you have a few different "verbs":
constructor - introduces annotation onto a constructor
method - introduces onto a method
field - introduces onto a field
class - introduces onto a class
What you have there is the same aspackage gui.complaints; public class SomeClass{ @SystemRecord public SomeClass(){} }
I think what you want is<annotation-introduction expr="class(gui.complaints.*)"> @util.SystemRecord </annotation-introduction> <bind pointcut="call(@util.SystemRecord->new(..))"> <interceptor class="aspects.SystemRecordInterceptor"/> </bind>
-
2. Re: annotation-introduction + aspect oriented annotations
fabiocsilva Nov 28, 2006 10:04 PM (in response to fabiocsilva)The code not yet is executing.
SystemRecord.java : package util; import java.lang.annotation.ElementType; import java.lang.annotation.Target; @Target({ElementType.CONSTRUCTOR}) public @interface SystemRecord { }
SomeClass.java : :) package gui.complaints; public class SomeClass { public SomeClass() { } }
Main class: package test; import gui.complaints.SomeClass; public class Main { public static void main(String[] args) { new SomeClass(); } }
jboss-aop.xml : <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <aop> <annotation-introduction expr="class(gui.complaints.*)"> @util.SystemRecord </annotation-introduction> <bind pointcut="call(@util.SystemRecord->new())"> <interceptor class="aspects.SystemRecordInterceptor" /> </bind> </aop>
I made the following modifications to test annotation binding:jboss-aop.xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <aop> <bind pointcut="call(@util.SystemRecord->new())"> <interceptor class="aspects.SystemRecordInterceptor" /> </bind> </aop>
package gui.complaints; public class SomeClass { @util.SystemRecord public SomeClass() { } }
result:nothing
when I changed the jboss-aop.xml for<bind pointcut="call(*->@util.SystemRecord())">...
result:[java] defrost(): test.Main_1_ConByMInvocation was pruned. [java] java.lang.RuntimeException: defrost(): test.Main_1_ConByMInvocation was pruned. [java] at javassist.CtClassType.checkPruned(CtClassType.java:1284) [java] at javassist.CtClassType.defrost(CtClassType.java:276) [java] at org.jboss.aop.instrument.OptimizedInvocations.defrostClassIfExists(OptimizedInvocations.java:66) [java] at org.jboss.aop.instrument.OptimizedInvocations.makeInvocationClass(OptimizedInvocations.java:105) [java] at org.jboss.aop.instrument.OptimizedCallerInvocations.createOptimizedConCalledByMethodInvocationClass(OptimizedCallerInvocations.java:280) [java] at org.jboss.aop.instrument.OptimizedCallerTransformer$OptimizedCallerExprEditor.setupMethod(OptimizedCallerTransformer.java:91) [java] at org.jboss.aop.instrument.CallerTransformer$CallerExprEditor.modifyMethod(CallerTransformer.java:468) [java] at org.jboss.aop.instrument.CallerTransformer$CallerExprEditor.edit(CallerTransformer.java:452) [java] at javassist.expr.ExprEditor.loopBody(ExprEditor.java:198) [java] at javassist.expr.ExprEditor.doit(ExprEditor.java:90) [java] at javassist.CtBehavior.instrument(CtBehavior.java:526) [java] at org.jboss.aop.instrument.CallerTransformer.applyCallerPointcuts(CallerTransformer.java:90) [java] at org.jboss.aop.instrument.Instrumentor.applyCallerPointcuts(Instrumentor.java:537) [java] at org.jboss.aop.instrument.Instrumentor.transform(Instrumentor.java:657) [java] at org.jboss.aop.AspectManager.translate(AspectManager.java:908) [java] at org.jboss.aop.AspectManager.transform(AspectManager.java:820) [java] at org.jboss.aop.standalone.AOPTransformer.aspectTransform(AOPTransformer.java:88) [java] at org.jboss.aop.standalone.AOPTransformer.transform(AOPTransformer.java:75) [java] at sun.instrument.TransformerManager.transform(TransformerManager.java:122) [java] at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:155) [java] at java.lang.ClassLoader.defineClass1(Native Method) [java] at java.lang.ClassLoader.defineClass(ClassLoader.java:620) [java] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) [java] at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) [java] at java.net.URLClassLoader.access$100(URLClassLoader.java:56) [java] at java.net.URLClassLoader$1.run(URLClassLoader.java:195) [java] at java.security.AccessController.doPrivileged(Native Method) [java] at java.net.URLClassLoader.findClass(URLClassLoader.java:188) [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:306) [java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268) [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:251) [java] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) [java] javassist.CannotCompileException: by java.lang.RuntimeException: defrost(): test.Main_1_ConByMInvocation was pruned. [java] at org.jboss.aop.instrument.CallerTransformer$CallerExprEditor.edit(CallerTransformer.java:460) [java] at javassist.expr.ExprEditor.loopBody(ExprEditor.java:198) [java] at javassist.expr.ExprEditor.doit(ExprEditor.java:90) [java] at javassist.CtBehavior.instrument(CtBehavior.java:526) [java] at org.jboss.aop.instrument.CallerTransformer.applyCallerPointcuts(CallerTransformer.java:90) [java] at org.jboss.aop.instrument.Instrumentor.applyCallerPointcuts(Instrumentor.java:537) [java] at org.jboss.aop.instrument.Instrumentor.transform(Instrumentor.java:657) [java] at org.jboss.aop.AspectManager.translate(AspectManager.java:908) [java] at org.jboss.aop.AspectManager.transform(AspectManager.java:820) [java] at org.jboss.aop.standalone.AOPTransformer.aspectTransform(AOPTransformer.java:88) [java] at org.jboss.aop.standalone.AOPTransformer.transform(AOPTransformer.java:75) [java] at sun.instrument.TransformerManager.transform(TransformerManager.java:122) [java] at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:155) [java] at java.lang.ClassLoader.defineClass1(Native Method) [java] at java.lang.ClassLoader.defineClass(ClassLoader.java:620) [java] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) [java] at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) [java] at java.net.URLClassLoader.access$100(URLClassLoader.java:56) [java] at java.net.URLClassLoader$1.run(URLClassLoader.java:195) [java] at java.security.AccessController.doPrivileged(Native Method) [java] at java.net.URLClassLoader.findClass(URLClassLoader.java:188) [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:306) [java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268) [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:251) [java] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) [java] Caused by: java.lang.RuntimeException: defrost(): test.Main_1_ConByMInvocation was pruned. [java] at javassist.CtClassType.checkPruned(CtClassType.java:1284) [java] at javassist.CtClassType.defrost(CtClassType.java:276) [java] at org.jboss.aop.instrument.OptimizedInvocations.defrostClassIfExists(OptimizedInvocations.java:66) [java] at org.jboss.aop.instrument.OptimizedInvocations.makeInvocationClass(OptimizedInvocations.java:105) [java] at org.jboss.aop.instrument.OptimizedCallerInvocations.createOptimizedConCalledByMethodInvocationClass(OptimizedCallerInvocations.java:280) [java] at org.jboss.aop.instrument.OptimizedCallerTransformer$OptimizedCallerExprEditor.setupMethod(OptimizedCallerTransformer.java:91) [java] at org.jboss.aop.instrument.CallerTransformer$CallerExprEditor.modifyMethod(CallerTransformer.java:468) [java] at org.jboss.aop.instrument.CallerTransformer$CallerExprEditor.edit(CallerTransformer.java:452) [java] ... 24 more [java] [error] failed to transform: test.Main.. Do verbose mode if you want full stack trace.
What is this ? -
3. Re: annotation-introduction + aspect oriented annotations
fabiocsilva Nov 28, 2006 10:16 PM (in response to fabiocsilva)
I corrected the last error erasing the folder of build and recriando it. The main problem, however, still persists. -
4. Re: annotation-introduction + aspect oriented annotations
kabirkhan Nov 29, 2006 6:46 AM (in response to fabiocsilva)Try changing the @Target of your annotation to ELementType.TYPE. Annotation introductions are compiled in to the bytecode, and if it has the wrong target it will not be recognised.
-
5. Re: annotation-introduction + aspect oriented annotations
fabiocsilva Nov 29, 2006 8:21 PM (in response to fabiocsilva)Nothing... :(:(:(
The wiki of JBoss AOP has an example of annotation-introduction. However it did not execute in my pc. I am using JBoss IDE 2.0-Beta2 -
6. Re: annotation-introduction + aspect oriented annotations
fabiocsilva Nov 29, 2006 8:49 PM (in response to fabiocsilva)Somebody would have some ready example of annotation-introduction to order for me?
-
7. Re: annotation-introduction + aspect oriented annotations
kabirkhan Nov 29, 2006 9:06 PM (in response to fabiocsilva)"fabiocsilva" wrote:
Nothing... :(:(:(
THis is not a proper description of your problem"fabiocsilva" wrote:
I am using JBoss IDE 2.0-Beta2
Do not use the IDE, I have no idea if it would have any bearing on your problem or not, but it has not been maintained for over a year."fabiocsilva" wrote:
Somebody would have some ready example of annotation-introduction to order for me?
You can find some examples in the jboss aop testsuite:
Check out jboss aop http://wiki.jboss.org/wiki/Wiki.jsp?page=BuildingJBossAOPFromSubversion
The regression tests (aop/src/resources/test/regression/jboss-aop.xml) contain some examples of annotation introductions
http://anonsvn.jboss.org/repos/jbossas/projects/aop/trunk/aop/src/resources/test/regression/jboss-aop.xml
If you can't get annotation introductions to work, try an annotation override instead<annotaton>
-
8. Re: annotation-introduction + aspect oriented annotations
fabiocsilva Nov 29, 2006 9:31 PM (in response to fabiocsilva)Ok, I used the expression ?Nothing?: (: (: (? to indicate that the suggestion ?ElementType.TYPE? did not correct the problem. I go to make tests with the cited examples and later I publish the result.
-
9. Re: annotation-introduction + aspect oriented annotations
fabiocsilva Dec 1, 2006 6:52 PM (in response to fabiocsilva)I made download of version 1.5, but build did not function.
error:
_default:compile-classes:
BUILD FAILED
/home/fabio/uneb/projeto/bibliotecas/jboss-aop/svn/jboss-as-with-aop/tools/etc/buildmagic/buildmagic.ent:439: Could not create task or type of type: depend.
Ant could not find the task or a class this task relies upon.
buildmagic.ent:<!-- Remove classes which depend on changed files, so they will rebuild. --> <depend srcdir="${source.java}:${build.gen-src}" destdir="${build.classes}" dump="${javac.depend.dump}" closure="${javac.depend.closure}"> <include name="${javac.includes}"/> <exclude name="${javac.excludes}"/> </depend>
-
10. Re: annotation-introduction + aspect oriented annotations
fabiocsilva Dec 2, 2006 8:00 AM (in response to fabiocsilva)RESOLVED:
It really has a problem with JBoss IDE. After some compilations the file jboss-aop.xml is ignored. Then I used "ant" and the way based on annotations of JBoss AOP. Running ! -
11. Re: annotation-introduction + aspect oriented annotations
kabirkhan Dec 15, 2006 12:29 PM (in response to fabiocsilva)Yes, the AOP IDE is out of date - DO NOT USE IT