XDoclet, JBOSS-AOP Example3

X

X_AWemner_X

http://www.onjava.com/pub/a/onjava/2003/05/28/aop_jboss.html?page=2
http://www.jboss.org/index.html?module=html&op=userdisplay&id=developers/pro
jects/jboss/aop
http://xdoclet.sourceforge.net/

Ive just read first about XDoclet and jboss-AspectOrientedProgramming
articles. Below is a small example from jboss-aop standalone tutorial from
onjava site.

I did not download anything yet, but wanted to ask how it can work at first
place. See example code below and especially "Tracing tracing =
(Tracing)pojo;" cast. It should not work as POJO class does not implement
such tracing. Ok, aop does the magic and it does work. Then see example how
to compile and run it.

This is where Im lost in space: running "javac *.java" should give us
castexception at compile time. Clearly it does not do so.

What is that magic bullet to fool java compiler run successfully. Is it
that, they do not actually run a regular com.sun.compiler?
[compile and running instructions]
To compile and run this example:
$ cd oreilly-aop/example3
$ export CLASSPATH=.;jboss-common.jar;jboss-aop.jar;javassist.jar
$ javac *.java
$ java -Djava.system.class.loader=org.jboss.aop.standalone.SystemClassLoader
POJO

[example 3 code]
public class POJO {
public POJO() {}

public void helloWorld() { System.out.println("Hello World!"); }

/**
* @jboss-aop.metadata group="tracing"
* filter="true"
*/
public static void main(String[] args) {
POJO pojo = new POJO();
Tracing tracing = (Tracing)pojo;
pojo.helloWorld();
System.out.println("Turn off tracing");
tracing.disableTracing();
pojo.helloWorld();
System.out.println("Turn on tracing");
tracing.enableTracing();
pojo.helloWorld();
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top