From: Lachezar D. <l.d...@gm...> - 2008-06-09 14:38:23
|
Web Controllers are singletons by design, they get instantiated only once, with the option to instantiate a controller upon first request, and handle all matching requests. Probably the 'easiest' way to achieve what you need is to declare a scoped proxy for your controller, that should be Request Scoped. <beans ... xmlns:aop="http://www.springframework.org/schema/aop" > <bean id="..." class="..." scope="request"> <aop:scoped-proxy proxy-target-class="true" /> ... </bean> </beans> Did you check the ThrowAwayController class? I have not used it, however it seems it provides some one-time-use-only work flow. It is not my <job> to criticize your design, but Controllers should be stateless services. Putting state in the controller is probably a good way to get a bad headache. And if your Controller IS stateless I don;t see a reason why it can't be singleton scoped. 2008/6/9, Jaga <v.j...@gm...>: > > > Actual code snippet where the bean is being referred. > > > > <?xml version="1.0" encoding="UTF-8"?> > <beans xmlns="http://www.springframework.org/schema/beans" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://www.springframework.org/schema/beans > http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> > > > <bean id="assetExposureReportController" > class="com.sp.cms.cdointerface.portlet.controller.AssetExposureReportController" > scope="prototype"> > <property name="sessionForm" value="true"/> > <property name="commandName"><value>formBean</value></property> > <property > name="commandClass"><value>com.sp.cms.cdointerface.portlet.form.AssetExposureReportFormBean</value></property> > </bean> > > On accessing this bean in multiple browsers, recently accessed instance's > value is retrieved across the browsers. > > -- > Jag > > > > > Jaga wrote: > > > > hi, > > > > When I tried with the prototype scope in spring, on opening two browsers > > there > > is only one instance is created. > > > > Hence the value of the recently accessed instance by the user is > > retrieved. > > > > version used: spring-beans-2.0.xsd > > > > Snippet: > > > > <?xml version="1.0" encoding="UTF-8"?> > > <beans xmlns="http://www.springframework.org/schema/beans" > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > xsi:schemaLocation="http://www.springframework.org/schema/beans > > http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> > > > > <bean id="obj1" class="com.dto.Class1" scope="prototype"> > > </bean> > > > > Please help. > > > > > > -- > > View this message in context: http://www.nabble.com/Protype-Scope-of-Spring-Bean---creates-problematic-singleton-instance-tp17727103p17729307.html > > Sent from the springframework-developer mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > |