public class SessionHandler extends Object implements MethodInterceptor, org.springframework.context.ApplicationContextAware
HibernateInterceptor
for stateless
services but which keeps a WeakHashMap
of sessions keyed by
the stateful service reference.
original idea from:
http://opensource2.atlassian.com/confluence/spring/pages/viewpage.action?pageId=1447
See also: http://sourceforge.net/forum/message.php?msg_id=2455707
http://forum.springframework.org/archive/index.php/t-10344.html
http://opensource2.atlassian.com/projects/spring/browse/SPR-746
and these: http://www.hibernate.org/43.html#A5
http://www.carbonfive.com/community/archives/2005/07/ive_been_meanin.html
http://www.hibernate.org/377.htmlConstructor and Description |
---|
SessionHandler(org.hibernate.SessionFactory factory)
constructor taking a
DataSource and a SessionFactory . |
Modifier and Type | Method and Description |
---|---|
void |
cleanThread() |
Object |
invoke(MethodInvocation invocation)
delegates to
HibernateInterceptor or manages sessions internally,
based on the type of service. |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
Set the ApplicationContext that this object runs in.
|
public SessionHandler(org.hibernate.SessionFactory factory)
dataSource
- Not null.factory
- Not null.public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
org.springframework.context.ApplicationContextAware
Invoked after population of normal bean properties but before an init callback such
as InitializingBean.afterPropertiesSet()
or a custom init-method. Invoked after ResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader)
,
ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)
and
MessageSourceAware
, if applicable.
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
applicationContext
- the ApplicationContext object to be used by this objectorg.springframework.context.ApplicationContextException
- in case of context initialization errorsorg.springframework.beans.BeansException
- if thrown by application context methodsBeanInitializationException
public void cleanThread()
public Object invoke(MethodInvocation invocation) throws Throwable
HibernateInterceptor
or manages sessions internally,
based on the type of service.invoke
in interface MethodInterceptor
Throwable
Version: 4.4.12-ice34-b116
Copyright © 2014 The University of Dundee & Open Microscopy Environment. All Rights Reserved.