Werner Punz schrieb:

> Actually if you want to combine an object with component bindings with an
> object with session scope, there is a way without breaking anything.
> Spring 2.0
> 
> Spring 2.0 has the so called aop:scoped-proxy constructs which allow
> to combine various objects of different scope in a clean manner.
> 
> With that you can combine longer scoped objects with smaller scoped ones
> without breaking anything.
> 

To be more precise on this issue:
What you can do is following:
Use Spring 2.0 as your IoC provider.

Then declare your controller objects as usual(you also can use session
scoped beans)

Inject controller objects which hold the component bindings into your
long living beans, those objects have to be aop:scoped-proxy objects
with a lifecycle value of request.

What happens is that the binding objects are regenerated at every
request cycle no matter how long your actual beans really live.

an el accessor path could look like following

binding="#{sessionscopedbean.requestscopedbindingholder.binding}"

A declaration in spring could look like following:

<bean name="requestscopedbindingholder" id="requestscopedbindingholder"
class="xxx.yyy.Requestscopedbindingholder" lazy-init="true"
scope="request"  autowire="byName">
        <aop:scoped-proxy ></aop:scoped-proxy>
   </bean>

<bean name="sessionscopedbean" id="sessionscopedbean"
class="xxx.yyy.Sessionscopedbean" lazy-init="true" scope="session"
autowire="byName">
        
   </bean>


both are autowired over their attributes (you also can manually wire them...

What happens then is that the requestscopedbindingholder is dropped at
the end of a request and renerated at the next one at the first access
(lazy init= true)

and hence you do not run into duplicate id problems tangling references
on component bindings.

>From the outside the session scope bean keeps the reference to the proxy
encapsuling the request scoped bean.


Actually from my personal experience the aop:scoped-proxy mechanism is
heavens sent if you work with dialog systems (not only for component
bindings, but also if you want to keep reference to form controllers
etc...)...

Reply via email to