JBoss.org Community Documentation
Running a precompiled aop application is quite similar to running a normal java
application. In addition to the classpath required for your application you need
to specify the files required for aop, which are the files in the distribution's
lib/
folder.
As an alternative, you can replace all those jars by
jboss-aop-single.jar
, that bundles the
libraries used by JBoss AOP with JBoss AOP class files in a single jar.
JBoss AOP finds XML configuration files in these two ways:
jboss.aop.path
system property. (You can specify
multiple files or directories separated by ':' (*nix) or ';' (Windows), i.e.
-Djboss.aop.path=jboss-aop.xml;metadata-aop.xml
)
If you specify a directory, all
aop.xml
files will be loaded from there as well.
/META-INF/jboss-aop.xml
. So, if you package your jars and put your JBoss AOP
XML files within /META-INF/jboss-aop.xml
, JBoss AOP will find these files.
If you are using annotated bindings (See Chapter "Annotated Bindings"), you must tell JBoss AOP
which JARS or directories that may have annotated @Aspects. To do this you must set the
jboss.aop.class.path
system property. (You can specify
multiple jars or directories separated by ':' (*nix) or ';' (Windows), i.e.
-Djboss.aop.class.path=aspects.jar;classes
)
So to run a precompiled AOP application, where your jboss-aop.xml file is not part of a jar, you enter this at a command prompt:
$ java -cp=<classpath as described above> -Djboss.aop.path=<path to jboss-aop.xml> \ -Djboss.aop.class.path=aspects.jar com.blah.MyMainClass
To run a precompiled AOP application, where your application contains a jar with a META-INF/jboss-aop.xml file, you would need to do this from the command-line:
$ java -cp=<classpath as described above> com.blah.MyMainClass
In the /bin folder of the distribution we have provided batch/script files to make this easier. It includes all the aop libs for you, so you just have to worry about your files. The usage:
$ run-precompiled classpath [-aoppath path_to_aop.xml] [-aopclasspath path_to_annotated] \ com.blah.MyMainClass [args...]
If your application is not in a jar with a META-INF/jboss-aop.xml file, you must
specify the path to your
*-aop.xml
files in the
-aoppath
parameter, and if your class comtains aspects configured
via annotations (
@Aspect
etc.) you must pass in this classpath
via the
-aopclasspath
parameter.