RE: [aspectwerkz-user] Advice weaving problem when using hot deployment w/ annotation

"Vincent Massol" <[email protected]>
Newsgroups gmane.comp.java.aspectwerkz.user
Message-ID <[email protected]>
Hi Alex,

> -----Original Message-----
> From: Alexandre Vasseur [mailto:[email protected]]
> Sent: jeudi 24 mars 2005 09:29
> To: [email protected]
> Subject: Re: [aspectwerkz-user] Advice weaving problem when using hot
> deployment w/ annotation
> 
> Hi Vincent
> 
> Your project does not contain any aop.xml file.
> Even with hot deployment, one such file must be there.

Ah! I think it should be made clear in the
http://aspectwerkz.codehaus.org/dynamic_aop.html document. That would help.

> In that file you have two options:
> - declare the aspect that you will hotdeploy / undeploy (deployed at
> startup) using the usual <aspect class=../>
> - declare a <deployment-scope where you say : at that place I do allow
> aspect deployment / undeployment (whatever the aspect is)

Ok, I think I prefer this option as I want the user to define their own
annotations. I've found Jonas' blog post (http://tinyurl.com/4z6ay) about
JMX monitoring which does something similar to what I'd like to achieve.

However at some point in his tutorial he says: "This can be done either in
the META-INF/aop.xml file or using annotations in the aspect class". This
seems to imply that I may not need an aop.xml file at all. Is that right? 

Is that what is described here:
http://aspectwerkz.codehaus.org/dynamic_aop.html#Deployment_scopes?

I wonder in that case how AW discovers what to weave?

BTW when you don't package your code in a JAR (.class files in a directory)
where do you put the aop.xml file? Is it enough that it is in the CP? Anyway
I'll try it now...

> If you are using a deployment-scope, you can then use the Deployer API
> to deploy at that scope. There should be some sample around else it is
> probably like that :
> SystemDefinitionContainer.getDefinition(uuid,
> ClassLoader).getDeploymentScope(scopeName)

Yep, found that.
 
> There is no hotswap occuring in your current app, since the scope was
> empty and there was no aspect declared.
> Also, does the maven build magic handle AnnotationC ?

Hmmm... I thought this done at runtime by the hot deployment... I guess it's
not, right?

> (PS: can't you play with Java 5 - that s much easier)

If the hot deployment does not automatically run AnnotationC, then I think
I'll switch to Java 5 and so be it... :-)

Thanks
-Vincent

> 
> Alex
> 
> 
> On Wed, 23 Mar 2005 23:20:54 +0100, Vincent Massol <[email protected]>
> wrote:
> > Hi there,
> >
> > I'm trying to test hot deployment of aspects using annotations but
> there's
> > something I don't understand. The problem at execution is that there are
> no
> > errors as if the weaving does not occur. I can see that the Aspects are
> > loaded as I get the following in the console:
> >
> > Deployer::INFO - deploying aspect [org.apache.cactus2.SampleTest] in
> class
> > loader [sun.misc.Launcher$AppClassLoader@53ba3d]
> > Deployer::INFO - undeploying aspect [org.apache.cactus2.SampleTest] from
> > class loader [sun.misc.Launcher$AppClassLoader@53ba3d]
> >
> > But there should also be "it works" printed on the console
> >
> > I have 3 very simple classes:
> >
> > public class CactusTestSetup extends TestSetup
> > {
> >     private Test wrappedTest;
> >     private DeploymentHandle deploymentHandle;
> >
> >     public CactusTestSetup(Test test)
> >     {
> >         super(test);
> >         this.wrappedTest = test;
> >     }
> >
> >     public void setUp()
> >     {
> >         this.deploymentHandle =
> >             Deployer.deploy(this.wrappedTest.getClass());
> >     }
> >
> >     public void tearDown()
> >     {
> >         Deployer.undeploy(this.deploymentHandle);
> >     }
> > }
> >
> > public class Sample
> > {
> >     private int counter = 0;
> >
> >     public void doGet()
> >     {
> >         counter++;
> >     }
> >
> >     public int getCounter()
> >     {
> >         return this.counter;
> >     }
> > }
> >
> > public class SampleTest extends TestCase
> > {
> >     public SampleTest(String name)
> >     {
> >         super(name);
> >     }
> >
> >     public static Test suite()
> >     {
> >         TestSuite suite = new TestSuite();
> >         suite.addTest(
> >             new CactusTestSetup(new SampleTest("testMethodToTest")));
> >         return suite;
> >     }
> >
> >     /**
> >      * @Around("execution(public void
> org.apache.cactus2.Sample.doGet(..))")
> >      */
> >     public void redirect(JoinPoint jp) throws Throwable
> >     {
> >         System.out.println("it works");
> >     }
> >
> >     public void testMethodToTest()
> >     {
> >         Sample sample = new Sample();
> >         sample.doGet();
> >         assertEquals(0, sample.getCounter());
> >     }
> > }
> >
> > I know that I'm also supposed to have the AspectWerkz native library in
> my
> > path and I was expecting to get some failure because I don't have them
> yet.
> > I guess I should try adding them but still this is puzzling me.
> >
> > Thanks
> > -Vincent
> >
> >
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.