Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Introduction on more than just one class

I was wandering how I could use the Logger (jdk 1.4 or Log4j) defined on the class.

The slow solution would be to reaccess the Logger with something like that :

public void (Foo*).bar() {
    Logger.getLogger (this.getClass().getName ()).info ("Entering : " + xxx);
}
The xxx is the code needed to properly show the parameters of the method jp.getParameterNamess () jp.getParameterTypes ().

What I'd want is to have an interface defined like this :

interface Loggable
{
	private Logger getLogger ();
}

Then I could try to have all the Loggable classes being logged with someting like :

public void (Foo*).bar() {
    getLogger ().info ("Entering : " + xxx);
}

Everything else being "constant".

Tia,

\T,






PETER.FRIESE@xxxxxxxxxxxxx wrote:
Hi,

I want to introduce a method on more than one class - is there a way to do
this?

Sample code (this is what I can do now):

--------------------- 8< --------------------------
public aspect FooAspect {
  public void Foo1.bar() {
    System.out.println("An introduced method");
  }
}

public class Foo1 {
}
--------------------- >8 --------------------------

Sample code (what I would like to do):

--------------------- 8< --------------------------
public aspect FooAspect {
  public void [Foo1, Foo2, Foo3].bar() {
    System.out.println("An introduced method");
  }
}

public class Foo1 {
}

public class Foo2 {
}

public class Foo3 {
}
--------------------- >8 --------------------------

TIA,
Peter
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users



--
Thomas SMETS
SCJP2 - Brussels

http://tsmets.lautre.net



Back to the top