Note: this is a temporary solution. Not very clean because aspects are global for all applications in the container. In the future, a better solution will be available.
Application servers are typically quite sensitive to out-of-the ordinary applications mainly because of specialized class loading strategies. Aspect Frameworks can thus experience problems when used inside an application server. JAsCo is no exception to this. In order to make JAsCo work in these kind of environments, special care has to be taken.
There are two options to run JAsCo inside an application server: either by using the preprocessor or by using HotSwap 2. The preprocessor (TransformBean) has the advantage that it is easier to set up, but is less flexible and generally also slower. HotSwap 2 on the other hand is faster and more flexible, but more error prone as run-time byte-code instrumentation is employed. The following two sections explain these two alternatives and uses Apache Tomcat as concrete example:
The following solution is no longer supported, it might or might not work for you, we are working to provide a better solution...
When running an application server using the JAsCo HotSwap framework, all classes are first pre-processed and afterwards altered to include aspect code when aspects are there. Watch out for:
For detailed information about HotSwap 2 and its options, consult the HotSwap2 guide.
For Apache Tomcat this means that you have to follow the following steps to run JAsCo using HotSwap2:
Note: This solution is only availble since 0.8 final (not the betas!)
This solution is probably the most stable one but also the slowest performance wise.
When JAsCo should automatically detect connectors, use the following strategy:
When you want to load connectors from your application yourself, use the following strategy:
In order to manually add new connectors and their aspects at run-time, do the following:
jasco.Jasco.loadConnector(Connector.<classnameOfMyConnector>.getConnector());
Or when the connector is not yet compiled, but still in JAsCO source format:
jasco.Jasco.compileAndLoadConnector(<FullFileNameOfConnectorSource>);
(Javadoc of jasco.Jasco class: http://ssel.vub.ac.be/jasco/nightly/doc/jasco/Jasco.html