RE: ThreadLocal pattern using Spring

Hi,

Spring and Vaadin can’t do this out-of-the-box, but it would be possible. I haven’t done this myself, by the way, so I might be missing something.

  1. Make sure you have the
   <listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
  </listener>

[/code] added to your web.xml, to allow session scoped beans.

2) Add your application bean to the spring context, with a session scope[code]

<bean scope="session" id="application" class="com.acme.thing.MySuperApplication">
  1. Create your extension of com.vaadin.terminal.gwt.server.AbstractApplicationServlet, implementing getNewApplication(HttpServletRequest request) and getApplicationClass() (both looking stuff up from the context)

  2. Change your web.xml to use your new ApplicationServlet.

As I say, I’ve not tried it - but it all looks feasiblle and not very tricky.

Cheers,

Charles

Hey , thanks for the reply , I have some missing details , sorry for the confuse ,

I’m already using the
Spring add-on
, I have already

			  <servlet>
			  	<servlet-name>Spring Integration</servlet-name>
			  	<servlet-class>com.x.springsource.SpringApplicationServlet</servlet-class>
			  	<init-param>
			  		<param-name>applicationBeanName</param-name>
			  		<param-value>app</param-value>
			  	</init-param>
			  </servlet>
			  
			  <session-config>
    			<session-timeout>30</session-timeout>
			</session-config>
			  
			 <listener>
			 	 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
			 </listener>
			  
			 <listener>
			  	<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
			 </listener>
			  
			  <context-param>
			  	<description>Vaadin production mode</description>
			  	<param-name>productionMode</param-name>
			  	<param-value>false</param-value>
			  </context-param>
  

			  <context-param>
			    <param-name>log4jConfigLocation</param-name>
			    <param-value>/WEB-INF/log4j.xml</param-value>
			  </context-param>
			  

			  
			  <servlet-mapping>
			  	<servlet-name>Spring Integration</servlet-name>
			  	<url-pattern>/*</url-pattern>
			  </servlet-mapping>
  
  
				  <listener>
				    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
				  </listener

and

[code]
[/code]

the addon class using : ( complete code and more info are in the add on )

public class SpringApplicationServlet extends AbstractApplicationServlet {

All working good , now the question is how in additional to use the ThreadLocal pattern using Spring according to the explain in the Vaadin Book :bashful: