Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] question on ajlib:

How perfect is that?? All I did was extract the files from your previous email and rebuild ajlib and it worked !! Hoorraaayyy.

Seems to me like this is the beginning of the be-all end-all of simple plug=it-in logging, I didn't have to write anything except the classes to be logged.

Say the unit test is failing oddly, as though perhaps there was a change to another class:

     [iajc] C:\owen\dev\org.codehaus.ajlib\org.codehaus.ajlib\testsrc\org\codeha
us\ajlib\util\tracing\Log4jExecutionTracingTestCase.aj:12:0::0 The constructor ExecutionTracingTestCase.MockTracer(String) is undefined
     [iajc] error at assertEquals(ExecutionTracingTestCase.lastMockTracer.name,
TestTracedClass.class.getName());
 
When I went to http://fisheye.codehaus.org/changelog/ajlib-incubator/ I didn't see your change in the changelog: could be a timing thing. Seems like when a build happens there I will be able to download that and it will work, I must be out of sync.

THANKS to all of you so much,
owen

----- Original Message ----
From: Ron Bodkin <rbodkin@xxxxxxxxxxxxxx>
To: aspectj-users@xxxxxxxxxxx
Sent: Friday, October 17, 2008 12:13:08 AM
Subject: RE: [aspectj-users] question on ajlib:

I committed the changes to ajlib-incubator to fix these bugs and add a couple of tests for the class, which clearly needed them.

 

From: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Owen Corpening
Sent: Thursday, October 16, 2008 9:02 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] question on ajlib:

 

Ah, I had removed the pertypewithin(Traced) as part of my detective work ... however adding it back with the + as you said still does not give me weaveinfo showing:

 

Join point 'constructor-execution(void com.AjlibTest.DummyObject.<init>())' in Type 'com.AjlibTest.DummyObject' (DummyObject.java:2) advised by before advice from 'com.AjlibTest.TestTraceAspect' (Log4jExecutionTracing.aj:17)

 

And the println I put inside the before advice in Log4jExecutionTracing.aj is still not printing. Nevertheless this is defintely more progress than I made so far ...

 

All I have found is that removing pertypewithin(Traced+) and "staticinitialization(*) &&" causes me to get weaveinfo messages such as the above.

 

I am getting logging from the ExecutionTracing class, just the "tracer = new Log4jTracer(name);" is not getting executed, the tracer is still the printststream.

 

Thanks!!

owen

 

----- Original Message ----
From: Ramnivas Laddad <ramnivas@xxxxxxxxxxxxxxx>
To: aspectj-users@xxxxxxxxxxx
Sent: Thursday, October 16, 2008 8:36:29 PM
Subject: Re: [aspectj-users] question on ajlib:

It looks like there is a bug in Log4jExecutionTracing. You need to change pertypewithin(Traced) to pettypewithin(Traced+) in Log4jExecutionTracing.

 

Once I do that, I get the following output:

trace enter: com.AjlibTest.DummyObject() , this: com.AjlibTest.DummyObject@60420f

trace exit: com.AjlibTest.DummyObject()

trace enter: int com.AjlibTest.DummyObject.someMethod(int) , this: com.AjlibTest.DummyObject@60420f, args: arg 0 = 5

trace exit: int com.AjlibTest.DummyObject.someMethod(int), return = 7

 

BTW, the runtime check that you see is due to the if() pointcut used to enable/disable the tracing.

 

-Ramnivas

 

2008/10/16 Owen Corpening <owencorpening@xxxxxxxxx>

Well I repeat I am still coming up to speed on some of the non-beginner spots in aspectj ... so I put a println in the before advice in Log4jExecutionTracing -- it never printed anything.

 

So I hacked it by removing the "staticinitialization(*) && " and it prints, and I get the weaveinfo output as before but in addition I get 

 

Join point 'constructor-execution(void com.AjlibTest.DummyObject.<init>())' in Type 'com.AjlibTest.DummyObject' (DummyObject.java:2) advised by before advice from 'com.AjlibTest.TestTraceAspect' (Log4jExecutionTracing.aj:17) [with runtime test]

Join point 'method-execution(int com.AjlibTest.DummyObject.someMethod(int))' in Type 'com.AjlibTest.DummyObject' (DummyObject.java:4) advised by before advice from 'com.AjlibTest.TestTraceAspect' (Log4jExecutionTracing.aj:17) [with runtime test]

 

So it defintely was not weaving the Log4jExecutionTracing before advice. For verboseness here is my hacked Log4jExecutionTracing and my aspect extending it:

 

/**

 * @author Ron Bodkin with code drawn from Matthew Webster's example posted to aj-users 1/28/2005

 */

package org.codehaus.ajlib.util.tracing;

 

/**

 * Typical idiom of log4j tracing of method execution: trace to a different logger for

 * each type.

 */

public abstract aspect Log4jExecutionTracing extends ExecutionTracing  {

          protected interface Traced {}

         

          public pointcut scope() : within(Traced+);

         

          //TODO: test, e.g., what if staticinitialization of a type when tracing something?!

    //before(): staticinitialization(*) && inScope() {

    before(): inScope() {

          System.out.println("in log4j");

        String name = thisJoinPointStaticPart.getSignature().getDeclaringTypeName();

        tracer = new Log4jTracer(name);

          }

}

 

package com.AjlibTest;

import org.codehaus.ajlib.util.tracing.Log4jExecutionTracing;

public aspect TestTraceAspect extends Log4jExecutionTracing {

    declare parents: com.AjlibTest.DummyObject implements Traced;

}

 

Since this posting is as long as the Magna Carta already here are my HelloWorld and DummyObject classes:

 

package com.AjlibTest;

public class HelloWorld

{

          public static void main(String[] args)

          {

                   DummyObject ao = new DummyObject();

                   ao.someMethod(5);

          }

}

 

package com.AjlibTest;

public class DummyObject

{

          public int someMethod(int i)

          {

                   return 7;

          }

}

 

thanks,

owen

 

----- Original Message ----
From: Ron Bodkin <rbodkin@xxxxxxxxxxxxxx>
To: aspectj-users@xxxxxxxxxxx

Sent: Wednesday, October 15, 2008 9:11:51 PM
Subject: RE: [aspectj-users] question on ajlib:

Hi Owen,

 

This indicates that the before advice is in fact applying in your test. Could it be that you aren't seeing log output because the Log4jExecutionTracing aspect traces to a log4j logger at debug level, and that you need to enable debug output in your log4j configuration?

 

From: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Owen Corpening
Sent: Wednesday, October 15, 2008 4:24 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] question on ajlib:

 

Well it seems to have put the Traced interface on my DummyObject class ...

 

Description  Resource Path Location Type

Extending interface set for type 'com.AjlibTest.DummyObject' (DummyObject.java) to include 'org.codehaus.ajlib.util.tracing.Log4jExecutionTracing$Traced' (TestTraceAspect.aj)  aspectLib        Unknown  Java Problem

Join point 'constructor-execution(void com.AjlibTest.DummyObject.<init>())' in Type 'com.AjlibTest.DummyObject' (DummyObject.java:2) advised by afterReturning advice from 'com.AjlibTest.TestTraceAspect' (ExecutionTracing.aj:56) [with runtime test]    aspectLib        Unknown  Java Problem

Join point 'constructor-execution(void com.AjlibTest.DummyObject.<init>())' in Type 'com.AjlibTest.DummyObject' (DummyObject.java:2) advised by afterThrowing advice from 'com.AjlibTest.TestTraceAspect' (ExecutionTracing.aj:76) [with runtime test]    aspectLib        Unknown  Java Problem

Join point 'constructor-execution(void com.AjlibTest.DummyObject.<init>())' in Type 'com.AjlibTest.DummyObject' (DummyObject.java:2) advised by before advice from 'com.AjlibTest.TestTraceAspect' (ExecutionTracing.aj:45) [with runtime test]   aspectLib        Unknown  Java Problem

Join point 'method-execution(int com.AjlibTest.DummyObject.someMethod(int))' in Type 'com.AjlibTest.DummyObject' (DummyObject.java:4) advised by afterReturning advice from 'com.AjlibTest.TestTraceAspect' (ExecutionTracing.aj:51) [with runtime test]    aspectLib        Unknown  Java Problem

Join point 'method-execution(int com.AjlibTest.DummyObject.someMethod(int))' in Type 'com.AjlibTest.DummyObject' (DummyObject.java:4) advised by afterThrowing advice from 'com.AjlibTest.TestTraceAspect' (ExecutionTracing.aj:76) [with runtime test]    aspectLib        Unknown  Java Problem

Join point 'method-execution(int com.AjlibTest.DummyObject.someMethod(int))' in Type 'com.AjlibTest.DummyObject' (DummyObject.java:4) advised by before advice from 'com.AjlibTest.TestTraceAspect' (ExecutionTracing.aj:45) [with runtime test]   aspectLib        Unknown  Java Problem

 

 

----- Original Message ----
From: Andy Clement <andrew.clement@xxxxxxxxx>
To: aspectj-users@xxxxxxxxxxx
Sent: Wednesday, October 15, 2008 12:44:55 PM
Subject: Re: [aspectj-users] question on ajlib:

Hi Owen,

 

Does compiling with -showWeaveInfo show whether your declare parents is or is not working?

 

Andy.

2008/10/15 Owen Corpening <owencorpening@xxxxxxxxx>

Probably a syntactical error, the before() in Log4jExecutionTracing never gets executed, I bet my "declare parents" isn't right, first time I ever came across that, I guess I haven't been keeping up with aj1.5:

 

package com.AjlibTest;

import org.codehaus.ajlib.util.tracing.Log4jExecutionTracing;

public aspect TestTraceAspect extends Log4jExecutionTracing {

    declare parents: com.AjlibTest.DummyObject implements Traced;

}

 

my package looks like this:

./com/AjlibTest/DummyObject.java

./com/AjlibTest/HelloWorld.java

./com/AjlibTest/TestTraceAspect.aj

 

Anyone see my goof?

 

thanks,

owen

 

----- Original Message ----
From: Ron Bodkin <rbodkin@xxxxxxxxxxxxxx>
To: aspectj-users@xxxxxxxxxxx

Sent: Tuesday, October 14, 2008 12:00:12 AM
Subject: RE: [aspectj-users] question on ajlib:

Hi Owen,

 

Traced is a protected interface that is defined within Log4jExecutionTracing itself. You just use the aspect by extending it and using declare parents to make the relevant classes you want to trace implement traced, as in:

 

public aspect MyLog4jExecutionTracing extends Log4jExecutionTracing {

     declare parents: com.bigboxco.myapp..* implements Traced;

}

 

From: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Owen Corpening
Sent: Thursday, October 09, 2008 6:41 AM
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] question on ajlib:

 

With regards to ajlib:

 

There is a class Log4jExecutionTracing not covered in the unit tests and for which there are no examples of its usage. It uses a class called "Traced" that I don't see anywhere and I *think* that is at the core of my not comprehending how to use this class.

 

Basically if I have a test tracing aspect like this it works great (DummyObject is the class whose methods are to be traced):

 

package com.AjlibTest;

import org.codehaus.ajlib.util.tracing.ExecutionTracing;

public aspect TestTraceAspect extends ExecutionTracing

{

    public pointcut scope() : within(DummyObject);

    before(): scope()

    {

         System.out.println("Tracing");

    }

}

 

But if I change ExecutionTracing to Log4jExecutionTracing it doesn't weave anything (advice defined in com.AjlibTest.TestTraceAspect has not been applied [Xlint:adviceDidNotMatch]).

 

much appreciated,

Owen

 

 

 


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

 

 


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


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

 

 


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Back to the top