Skip to main content

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

Sorry, stupid use of around... my mistake, forgot to call joinpoint.proceed()
really stupid

On 3/6/07, Vinicius Carvalho <java.vinicius@xxxxxxxxx> wrote:
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



--
JBoss Certified Advanced J2EE Developer
IBM Certified SOA Solution Designer
IBM Database Associate - DB2 UDB V8.1 Family
Sun Certified Enterprise Architect (Part I)


Back to the top