Take a look at pertypewithin() aspect association introduced in AspectJ5.

-Ramnivas

On Nov 8, 2007 3:42 PM, Bhaskar Maddala <[EMAIL PROTECTED]> wrote:

> Hello,
>
>   Is there any way to introduce a static member variable to all
> classes in a package.
>
>   Following is a synopsis of what I would like to accomplish.
>
>   Here is the java functionality that I need
>
>   package foo;
>   import crazy.Trace;
>   class T
>   {
>       private static final Trace TRACE = new Trace("$$ foo/T Version 2.24
> ");
>       T(Object... args)
>       {
>               TRACE.entering("T(Object... args");
>               try
>               {
>                    ......
>                    ......
>               }
>               finally
>               {
>                     TRACE.exiting("T(Object... args");
>               }
>       }
>
>       void dooT(Object... args)
>       {
>               TRACE.entering("dooT(Object... args");
>               try
>               {
>                    ......
>                    ......
>               }
>               finally
>               {
>                     TRACE.exiting("dooT(Object... args");
>               }
>       }
>   }
>   // similar class P
>
>   Here is how I would like to achieve it using aspects
>
>  class T
>   {
>       T(Object... args)
>       {
>             ......
>             ......
>       }
>
>       void dooT(Object... args)
>       {
>               ......
>               ......
>       }
>   }
>
>   // similar class P
>
>   package foo;
>   aspect L
>   {
>       pointcut scope() : within(foo..*);
>       pointcut methods() : scope() && execution(* *.*(..));
>
>       before() : methods()
>       {
>          TRACE.entering(thisJoinPointStaticPart.getSignature
> ().toLongString(),
> thisJoinPoint.getArgs());
>       }
>
>       after() : methods()
>       {
>           TRACE.exiting(thisJoinPointStaticPart.getSignature
> ().toLongString());
>       }
>   }
>
>    The part of this that has been stumped is how would I introduce
> the private static final Trace reference in all classes in the
> package.
>
> Thanks
> Bhaskar
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to