Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Replacing an instantiated object

Hello there! I'd like to know if it is possibly to replace an instance
of a class by something else using aspects.
Here's what I've done so far:

@AfterReturning(pointcut="call (public MyClass+.new(..))",returning="o")
	public void proxyReturn(Object o){
		
		o = ProxyFactory.createProxy(o.getClass(),o);
	}

What I need to do is replace a call:

MyClass c = new MyClass();

and return the proxy instead of the original class. Altough the
afterreturning gets called, the user does not get back a proxy
reference. I've tried around, but it throws a null point (which makes
sense to me since the instance is not yet created).

Any way of doing this?

Best regards


Back to the top