|
From: Rod J. <rod...@in...> - 2003-11-04 13:55:32
|
Cameron,
Just wanted to let you know that I will look at this, probably towards the
end of the week. Let me know if you progress in the meantime...
Regards,
Rod
----- Original Message -----
From: "Cameron Braid" <ca...@da...>
To: <spr...@li...>
Sent: Monday, November 03, 2003 11:27 AM
Subject: [Springframework-developer] How to use the ProxyFactory to enhance
an instance
> I was experimenting with generating AOP proxies.
>
> I want to create a proxy that is a superclass of an action, to allow me to
add transactional interceptors.
>
> I tried using
>
> Object action = createAction();
> ProxyFactory proxyFactory = new ProxyFactory(action);
> proxyFactory.addInterceptor(.. my interceptor ...);
> return proxyFactory.getProxy();
>
> though this uses a J2SE proxy, which only works on the defined interfaces.
>
> I tried to get the aop proxy factory to use cblib by doing this :
>
> Object action = createAction();
> ProxyFactory proxyFactory = new ProxyFactory(action);
> proxyFactory.setInterfaces(new Class[]{});
> proxyFactory.addInterceptor(transactionInterceptor);
> proxyFactory.addInterceptor(new InvokerInterceptor(action));
> return proxyFactory.getProxy();
>
> to create a proxy that has a target, but I need to remove the interfaces
otherwise a J2SE proxy will be created.
>
> This works ok, except for the fact that I am using an instance of the
action for the target, and cglib creates a new instance from the call to
enhance
>
> Enhancer.enhance(config.getTarget().getClass(),
config.getProxiedInterfaces(), ...)
>
> Is there any way that the proxy factory can be rigged to allow
specification of a target class, without an instance, then instead of me
creating an instance, cglib can create it for me ?
>
> Something like
>
> Class actionClazz = getActionClass()
> ProxyFactory proxyFactory = new ProxyFactory(actionClazz);
> proxyFactory.addInterceptor(transactionInterceptor);
> proxyFactory.addInterceptor(new ProxyTargetInvokerInterceptor());
> return proxyFactory.getProxy();
>
> Though I don't know how the invoker interceptor will work, since there is
no actual target external to the proxy.
> Maybe a new ProxyTargetInvokerInterceptor() could be added. Without it,
invocations on the proxy would be exhibit the same behaviour as if an
InvokerInterceptor didn't exist at all.
>
> I dunno if I have made this very clear.. I am new to the AOP terminoligy .
>
> Cameron.
>
>
> --
> Any damn fool can write code that a computer can understand...
> The trick is to write code that humans can understand.
> [Martin Fowler
http://www.martinfowler.com/distributedComputing/refactoring.pdf]-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program. Does
SourceForge.net help you be more productive? Does it help you create better
code? SHARE THE LOVE, and help us help YOU! Click Here:
http://sourceforge.net/donate/
_______________________________________________ Springframework-developer
mailing list Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|