Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] hooking into app server

I am fairly new (just a few days) to aspectj but after some initial problems am now doing this, (but perhaps not doing it the best way).

Here are the things i am doing:

Note: for a while i could not get things to work,. It was hard to find out what was going wrong, e.g. no logs.


* In the Glassfish Admin Console (e.g. port 4848)/Application Server/JVM Settings/JVM Options
I added
-javaagent:<path>\aspectjweaver.jar
-Daj.weaving.verbose=true

Question#1: I wish i knew all of the -D options, and what they did??


* I place my aspects-filter.jar right now in glassfish/domains/domain1/lib
I had better success when i narrowed down my aspect's scope.

Question#2: If i place it in the application classpath MY_APP/WEB-INF/lib will the weaving only apply to the classes loaded by the application classloader


* build.xml

        <iajc srcdir="${src.dir}/aop" destdir="${build.dir}/aop"
            debug="true" source="1.6" target="1.6">
            <classpath refid="compile.class.path" />
        </iajc>

Note: I believe this defaults to 1.3 or something. I had better success after changing this

* WEB-INF/aop.xml

<aspectj>
    <aspects>
        <aspect name="aspects.FilterAspect" />
    </aspects>
    <weaver options="-XmessageHandlerClass:aspects.AspectJMessageHandler">
        <!--
            <weaver options="-verbose -showWeaveInfo">
        -->
        <dump within="blah.*"/>
    </weaver>
</aspectj>

Question#3: I wish i knew all of the weaver options, and what they did??

Question#4: I wish you could configure where to dump the classes??

Note: There are not many good examples of this aop.xml file


* IMessageHandler
I had better success after i started using this.

package aspects;

import org.aspectj.bridge.AbortException;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.IMessage.Kind;

public class AspectJMessageHandler implements org.aspectj.bridge.IMessageHandler {
    public void dontIgnore(Kind arg0) {
    }

    public boolean handleMessage(IMessage arg0) throws AbortException {
        // note i actually write the message to a log, basically log(new Date() + " " + arg0)
        return true;
    }

    public void ignore(Kind arg0) {
    }

    public boolean isIgnoring(Kind arg0) {
        return false;
    }
}


* Questions: What does this mean??


debug weaving 'com.sun.jbi.filebc.extensions.FileExtensionRegistry'
info AspectJ Weaver Version 1.6.1 built on Thursday Jul 3, 2008 at 18:35:41 GMT                       
info register classloader com.sun.jbi.framework.CustomClassLoader@1af5d23                                 a) this line
info using configuration file:/C:/glassfish/domains/domain1/lib/aspects-filter.jar!/META-INF/aop.xml
info register aspect aspects.FilterAspect
debug weaving 'com.sun.encoder.MetaRef'                                                                                       b) this line
...
debug weaving 'org.apache.xml.resolver.readers.OASISXMLCatalogReader'
debug weaving 'org.apache.xml.resolver.readers.SAXCatalogParser'
debug cannot weave 'javax.wsdl.factory.WSDLFactory'
debug cannot weave 'javax.wsdl.WSDLException'
debug cannot weave 'javax.wsdl.factory.WSDLFactory$1'                                                               c) this line



Andy Clement wrote:
Hi,

I can't answer the question...  but how to integrate ltw with appserver <insert app server name here> comes up on the list now and again.  So I've created an FAQ entry for it.  If anyone reading this can help me flesh it out from the purely general advice it currently includes (which Ramnivas wrote, thanks Ramnivas!), I will put it in there right away.

Current FAQ entry:
http://www.eclipse.org/aspectj/doc/released/faq.php#q:ltwAppServers

Bug entry where anyone wishing to contribute can add instructions/guidelines for an application server:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=248743

Andy.

2008/9/25 <andymorton@xxxxxxxxxxxxxx>
Hi.

I have a several applications deployed in an application server (sun app server / glassfish) and have written several aspects to hook into the current applications (for logging purposes).

I understand this is done via load time weaving.

However, I added the javaagent into the VM options, and it resulted in my applications not starting up right.

I have exported my aspects as a jar, and want them to become active whenever I put them in a specific directory.
Do i put the aop.xml in this jar? Or does it sit somewhere else??

Im quite confused about the whole deployment issue, but believe that my aspects are working ok...
Can anyone point me in the appropriate direction?

Regards,
Andrew

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



_______________________________________________ aspectj-users mailing list aspectj-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/aspectj-users

Back to the top