ome.tools.hibernate
Class SessionHandler

java.lang.Object
  extended by ome.tools.hibernate.SessionHandler
All Implemented Interfaces:
Advice, Interceptor, MethodInterceptor, org.springframework.context.ApplicationContextAware

public class SessionHandler
extends Object
implements MethodInterceptor, org.springframework.context.ApplicationContextAware

interceptor which delegates to 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.html

Since:
3.0
Version:
3.0 (Internal version: $Rev: 3420 $ $Date: 2009-02-03 12:00:02 +0000 (Tue, 03 Feb 2009) $)
Author:
Josh Moore      josh.moore@gmx.de

Constructor Summary
SessionHandler(org.hibernate.SessionFactory factory)
          constructor taking a DataSource and a SessionFactory.
 
Method Summary
 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SessionHandler

public SessionHandler(org.hibernate.SessionFactory factory)
constructor taking a DataSource and a SessionFactory. A new HibernateInterceptor will be created.

Parameters:
dataSource - Not null.
factory - Not null.
Method Detail

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
                           throws org.springframework.beans.BeansException
Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
Throws:
org.springframework.beans.BeansException

cleanThread

public void cleanThread()

invoke

public Object invoke(MethodInvocation invocation)
              throws Throwable
delegates to HibernateInterceptor or manages sessions internally, based on the type of service.

Specified by:
invoke in interface MethodInterceptor
Throws:
Throwable


OmeroJava Api

Version: Beta4.2.1-r8614-Beta4.2-b41

Copyright © 2009 The University of Dundee. All Rights Reserved.