Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] interecepting of all calls and forwarding them, aspect methods and private fields

Question 1:

Let's say I have two classes: Stopped and StoppedStub. During testing I want all calls to Stopped
be forwarded to StoppedStub. The only way I know of doing that is to catch each and every method
call Stoppped and then forward this call to the same method but on StoppedStub (this is where
interfaces come in handy). I was wondering if there was a way to do this automatically.

So, instead of this:

public aspect StoppedStubIns {
	pointcut a(): call(void Stopped.a());
	pointcut b(): call(void Stopped.b());
	
	around(): a() {
		StoppedStub.a();
	}

	around(): b() {
		StoppedStub.b();
	}
}

I want a way to do this:

public aspect StoppedStubIns {
	pointcut allCalls(): call(void Stopped.*());
	
	around(): allCalls() {
		StoppedStub.["method invoked on Stopped"]();
	}
}

--------------------------------

Question 2:

Aspects can introduce private variables to classes and only the aspect that introduced the private
variable can access that variable. I was wondering if it was possible for methods in aspects to
access a class' private variable that it did not introduce. This would be handy for testing-only
methods.

Thanks, WD.

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca


Back to the top