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 <[EMAIL PROTECTED]>
To: aspectj-users@eclipse.org
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:[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Owen Corpening
Sent: Wednesday, October 15, 2008 4:24 PM
To: aspectj-users@eclipse.org
Subject: Re: [aspectj-users] question on ajlib:
 
Well
it seems to have put the Traced interface on my DummyObject class ...
 
Description  ResourcePathLocationType
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 <[EMAIL PROTECTED]>
To: aspectj-users@eclipse.org
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 <[EMAIL PROTECTED]>
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 <[EMAIL PROTECTED]>
To: aspectj-users@eclipse.org
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:[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Owen Corpening
Sent: Thursday, October 09, 2008 6:41 AM
To: aspectj-users@eclipse.org
Subject: [aspectj-users] question on ajlib:
 
With regards to ajlib:
http://fisheye.codehaus.org/browse/ajlib-incubator/org.codehaus.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@eclipse.org
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@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to