Vita Rara: A Life Uncommon

The same issue with Spring Reloading Script Proxy

Hi,

I stumbled in the same problem of Spring giving a Proxy object for scripts that are reloaded. I did some reflection investigation and found out that the actual script instance is behind $Proxy.targetSource.target. Now, if only Struts 2 could take ognl expressions for <action method="...">, we could write

<action ... method="myAction.targetSource.target.execute">...

and we could use the auto-reloading scripted beans from Spring context. (myAction is obviously the Spring bean)

I really don't see how the problem with reloaded script could be solved - because the reference to the script instance is already given away to other parts of the code, and you cannot change it, so you are forced to use a proxy.

On the other hand let's assume you added a new method (let's say "execute"). At the time of initial instantiation this method didn't exist, so you couldn't expose it in the Proxy. Then you add it, but the Proxy instance is already referenced by other parts of the application. So if someone did $Proxy.getClass().getMethod("execute"...) on the Proxy, there's no way for the Proxy to intercept it and return the newly defined script method (at least that I know of). Therefore the proxy is limited to exposing only well-known methods, defined in the script, such as those of the superclass and implemented interfaces.

Reply

Please solve the math problem above and type in the result. e.g. for 1+1, type 2
  • Allowed HTML tags: <a> <img> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <h1> <h2> <h3>
  • Lines and paragraphs break automatically.
More information about formatting options