Hi All,
I am creating thread local using ThreadlocalTargetSource. The application when deployed on weblogic application server, its observerved that the thread local variable not getting cleared and hence subsequence request get the old thread local values.
Note :- We are using weblogic 11g and spring 3.0
The thread local are configured as follows
<bean id="ohiContext" class="com.oracle.healthinsurance.context.OhiConte xt"
scope="prototype">
<property name="locale">
<value>#{ohiDatagridContext.defaultLocale}</value>
</property>
<property name="username">
<value>10</value>
</property>
</bean>
<bean id="ohiContextThreadLocalTs" class="org.springframework.aop.target.ThreadLocalT argetSource">
<property name="targetBeanName">
<value>ohiContext</value>
</property>
</bean>
<bean id="ohiBusinessContext" class="org.springframework.aop.framework.ProxyFact oryBean">
<property name="targetSource"><ref local="ohiContextThreadLocalTs"/></property>
<property name="proxyTargetClass"><value>true</value></property>
</bean>
The OhiContext looks like
public class OhiContext extends HashMap<Object, Object> implements DisposableBean {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(OhiContext.class);
private static final long serialVersionUID = 1L;
private static final String KEY_USERNAME = "username";
private static final String KEY_LOCALE = "locale";
public void setLocale(Locale locale) {
if (locale == null) {
// TODO: is this correct behavior?
this.put(KEY_LOCALE, MLSHandlerUtil.getDefaultLocale());
} else {
this.put(KEY_LOCALE, locale);
}
logger.debug("setLocale(Locale) - Thread Local set >>> " +
this.values());
logger.debug("setLocale(Locale) - Thread Local Set <<<< " +
this.keySet());
}
public void setUsername(Long username) {
logger.debug("setUsername(Long) - Thread Local set >>> " + username);
this.put(KEY_USERNAME, username);
}
public Long getUsername() {
return (Long) this.get(KEY_USERNAME);
}
public Locale getLocale() {
return (Locale) this.get(KEY_LOCALE);
}
@Override
public void destroy() throws Exception {
this.clear();
}
}


Reply With Quote