|
From: Cameron B. <ca...@da...> - 2003-11-03 11:28:20
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
I was experimenting with generating AOP proxies.<br>
<br>
I want to create a proxy that is a superclass of an action, to allow me
to add transactional interceptors.<br>
<br>
I tried using <br>
<br>
Object action = createAction();<br>
ProxyFactory proxyFactory = new ProxyFactory(action);<br>
proxyFactory.addInterceptor(.. my interceptor ...);<br>
return proxyFactory.getProxy();<br>
<br>
though this uses a J2SE proxy, which only works on the defined
interfaces.<br>
<br>
I tried to get the aop proxy factory to use cblib by doing this :<br>
<br>
Object action = createAction();<br>
ProxyFactory proxyFactory = new ProxyFactory(action);<br>
proxyFactory.setInterfaces(new Class[]{});<br>
proxyFactory.addInterceptor(transactionInterceptor);<br>
proxyFactory.addInterceptor(new InvokerInterceptor(action));<br>
return proxyFactory.getProxy();<br>
<br>
to create a proxy that has a target, but I need to remove the
interfaces otherwise a J2SE proxy will be created.<br>
<br>
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<br>
<br>
Enhancer.enhance(config.getTarget().getClass(),
config.getProxiedInterfaces(), ...)<br>
<br>
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 ?<br>
<br>
Something like<br>
<br>
Class actionClazz = getActionClass()<br>
ProxyFactory proxyFactory = new ProxyFactory(actionClazz); <br>
proxyFactory.addInterceptor(transactionInterceptor);<br>
proxyFactory.addInterceptor(new
ProxyTargetInvokerInterceptor());<br>
return proxyFactory.getProxy();<br>
<br>
Though I don't know how the invoker interceptor will work, since there
is no actual target external to the proxy.<br>
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.<br>
<br>
I dunno if I have made this very clear.. I am new to the AOP
terminoligy .<br>
<br>
Cameron.
<style type="text/css"><!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }-->
</style><!-- ======================================================== -->
<!-- = Java Sourcecode to HTML automatically converted code = --><!-- = Java to HTML Converter V3.2 2003 by Markus Gebhard ma...@ja... = -->
<!-- = Further information: http://www.java2html.de = -->
<center> </center>
<br>
<pre cols="72" class="moz-signature">--
Any damn fool can write code that a computer can understand...
The trick is to write code that humans can understand.
[Martin Fowler <a class="moz-txt-link-freetext" href="http://www.martinfowler.com/distributedComputing/refactoring.pdf">http://www.martinfowler.com/distributedComputing/refactoring.pdf</a>]</pre>
</body>
</html>
|
|
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
|