[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 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.