Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Question on Tracing Aspect




Manjula,

Use thisJoinPointStaticPart.getSignature().getDeclaringType() in advice for
the staticinitialization join point.

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/

Manjula Jayaraman <manjuv123@xxxxxxxxx>@eclipse.org on 09/05/2005 23:42:39

Please respond to aspectj-users@xxxxxxxxxxx

Sent by:    aspectj-users-bounces@xxxxxxxxxxx


To:    aspectj-users@xxxxxxxxxxx
cc:
Subject:    Re: [aspectj-users] Question on Tracing Aspect


Thanks Matthew.

Actually, my logger takes the "Class" as an input as
below:

public class EspressoLogger {

             public static Logger getLogger(Class userClass) {
                         ......
             }

}

I will call this as:

EspressoLogger.getLogger(Test.class);

So for each class, how do i do that?

Thanks,
Manjula

--- Matthew Webster <matthew_webster@xxxxxxxxxx>
wrote:

>
>
>
>
> Manjula,
>
> Use either
>
thisJoinPointStaticPart.getSignature().getDeclaringType()
> or
>
thisJoinPointStaticPart.getSignature().getDeclaringTypeName().
> I think you
> have ended up with java.lang.String.
>
> Matthew Webster
> AOSD Project
> Java Technology Centre, MP146
> IBM Hursley Park, Winchester,  SO21 2JN, England
> Telephone: +44 196 2816139 (external) 246139
> (internal)
> Email: Matthew Webster/UK/IBM @ IBMGB,
> matthew_webster@xxxxxxxxxx
> http://w3.hursley.ibm.com/~websterm/
>
> Manjula Jayaraman <manjuv123@xxxxxxxxx>@eclipse.org
> on 09/05/2005 05:14:14
>
> Please respond to aspectj-users@xxxxxxxxxxx
>
> Sent by:    aspectj-users-bounces@xxxxxxxxxxx
>
>
> To:    aspectj-users@xxxxxxxxxxx
> cc:
> Subject:    Re: [aspectj-users] Question on Tracing
> Aspect
>
>
> Thanks Matthew. As i mentioned before, i'm using
> staticinitialization to get the logger as follows:
>
>
EspressoTrace.initLogger(EspressoLogger.getLogger(thisJoinPointStaticPart.getSignature().getDeclaringTypeName().getClass()));

>
>
>
> When i use the above, i don't see the correct class
> name in the log statement.  Could you please let me
> know what's that i'm missing?
>
> Thanks,
> Manjula
>
>
> Manjula,
>
> You have 3 choices:
> 1. Using a logging framework like java.util.logging
> in
> the example which
> has separate configuration. Each time you start you
> program you can chose
> which classes get logged. The aspect implementation
> is
> efficient enough
> that having the logging woven but disabled will only
> have a minor impact on
> application performance.
> 2. Use an aspect enabling/disabling technique
> described by Adrian Colyer in
> his blog:
>
http://www.aspectprogrammer.org/blogs/adrian/2005/03/perinstance_asp.html,
>
http://aspectprogrammer.org/modules/sections/index.php?op=printpage&artid=2
> 3. Use the load-time weaving feature that will be in
> the final version of
> AspectJ 5:
>
http://www.eclipse.org/aspectj/doc/ajdk15notebook/index.html
>
> Matthew Webster
> AOSD Project
> Java Technology Centre, MP146
> IBM Hursley Park, Winchester,  SO21 2JN, England
> Telephone: +44 196 2816139 (external) 246139
> (internal)
> Email: Matthew Webster/UK/IBM @ IBMGB,
> matthew_webster@xxxxxxxxxx
> http://w3.hursley.ibm.com/~websterm/
> --- Manjula Jayaraman <manjuv123@xxxxxxxxx> wrote:
>
> > Thanks Matthew. I used staticinitialization and it
> > worked for me.
> >
> > Another question is that is there a dynamic waying
> > of
> > turning off aspects J in the production. For
> > example,
> > i've an aspect EspressoTraceAspect for tracing. If
> i
> > want to disable it, i've to change the pointcut
> and
> > recompile and redeploy that in the production. Is
> > there another way without going through this
> > compilation?
> >
> > Thanks in advance,
> > Manjula
> >
> >
> > --- Matthew Webster <matthew_webster@xxxxxxxxxx>
> > wrote:
> > >
> > >
> > >
> > >
> > > Manjula,
> > >
> > > Please see my append to aspectj-dev for a good
> > > tracing aspect example:
> > >
> >
>
http://dev.eclipse.org/mhonarc/lists/aspectj-dev/msg01261.html.
> > > If you want
> > > per-thread tracing i.e. one logger per thread
> > > instead of the usual one
> > > logger per class you will need to make your
> Logger
> > a
> > > ThreadLocal. Only do
> > > this if you want to control tracing on a
> > per-thread
> > > basis because most
> > > implementations allow you to distinguish outputs
> > > produced on different
> > > threads.
> > >
> > > Matthew Webster
> > > AOSD Project
> > > Java Technology Centre, MP146
> > > IBM Hursley Park, Winchester,  SO21 2JN, England
> > > Telephone: +44 196 2816139 (external) 246139
> > > (internal)
> > > Email: Matthew Webster/UK/IBM @ IBMGB,
> > > matthew_webster@xxxxxxxxxx
> > > http://w3.hursley.ibm.com/~websterm/
> > >
> > > Manjula Jayaraman
> > <manjuv123@xxxxxxxxx>@eclipse.org
> > > on 03/05/2005 23:27:04
> > >
> > > Please respond to aspectj-users@xxxxxxxxxxx
> > >
> > > Sent by:    aspectj-users-bounces@xxxxxxxxxxx
> > >
> > >
> > > To:    aspectj-users@xxxxxxxxxxx
> > > cc:
> > > Subject:    [aspectj-users] Question on Tracing
> > > Aspect
> > >
> > >
> > > Hi All,
> > >
> > > I'm new to Aspect J. I wrote my first aspect
> using
> > > Aspect J for tracing. I would like to log a
> > message
> > > upon entry and exit of all the methods in ALL
> the
> > > packages in my project.
> > >
> > > I've a class called EspressoLog as follows:
> > >
> > > public class EspressoTrace {
> > >
> > >         private static Logger logger = null;
> > >
> > >         public static void initLogger(Logger l)
> {
> > >                 logger = l;
> > >         }
> > >         public static void traceEntry(String
> > > message)
> > > {
> > >                 logger.debug("Entering : " +
> > > message);
> > >         }
> > >
> > >         public static void traceExit(String
> > message)
> > > {
> > >                 logger.debug("Exiting : " +
> > > message);
> > >         }
> > > }
> > >
> > > I've another class as follows
> > >
> > > aspect EspressoTraceAspect {
> > >
> > >         private Logger logger;
> > >
> > >
> > >         pointcut traceCall() : target(*) &&
> > > execution(public *
> > > com.apple.ist.espresso.xmlparser..*(..));
> > >
> > >         before() : traceCall() {
> > >
> > >
> >
>
EspressoTrace.initLogger(EspressoLogger.getLogger(thisJoinPointStaticPart.getSignature().getName().getClass()));

>
> > >
> > >                 EspressoTrace.traceEntry("" +
> > >
> thisJoinPointStaticPart.getSignature().getName());
> > >         }
> > >
> > >         after() : traceCall() {
> > >                 EspressoTrace.traceExit("" +
> > >
> thisJoinPointStaticPart.getSignature().getName());
> > >         }
> > >
> > > }
> > >
> > >
> > > My problem is that i'm calling initLogger every
> > time
> > > in before method of my EspressoTraceAspect. But
> > the
> > > efficient way to do this is to call only once
> per
> > > invocation of a class not before the invocation
> of
> > > each method in that class. how can i achieve
> this?
> > >
> > >
> > > Also, if the same class is called through
> multiple
> > > threads having the Logger attribute as static in
> > > EspressoTraceAspect would not help. How should i
> > > handle that?
> > >
> > > Thanks for any input in advance,
> > > Manjula
> > >
> > >
> __________________________________________________
> > > 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
> > >
> > >
> > > _______________________________________________
> > > 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
> >
>
>
>
> Discover Yahoo!
> Find restaurants, movies, travel and more fun for
> the weekend. Check it
> out!
> http://discover.yahoo.com/weekend.html
>
> _______________________________________________
> 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
>



__________________________________
Yahoo! Mail Mobile
Take Yahoo! Mail with you! Check email on your mobile phone.
http://mobile.yahoo.com/learn/mail
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users




Back to the top