Class SessionHandler

  • All Implemented Interfaces:
    org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

    public class SessionHandler
    extends java.lang.Object
    implements org.aopalliance.intercept.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
    • Constructor Summary

      Constructors 
      Constructor Description
      SessionHandler​(org.hibernate.SessionFactory factory)
      Constructor taking a SessionFactory.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cleanThread()  
      protected java.lang.Object getThis​(org.aopalliance.intercept.MethodInvocation invocation)  
      java.lang.Object invoke​(org.aopalliance.intercept.MethodInvocation invocation)
      delegates to HibernateInterceptor or manages sessions internally, based on the type of service.
      protected void putStatus​(org.aopalliance.intercept.MethodInvocation invocation, ome.tools.hibernate.SessionStatus status)  
      protected ome.tools.hibernate.SessionStatus removeStatus​(org.aopalliance.intercept.MethodInvocation invocation)  
      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 SessionFactory. A new HibernateInterceptor will be created.
        Parameters:
        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
      • getThis

        protected java.lang.Object getThis​(org.aopalliance.intercept.MethodInvocation invocation)
      • putStatus

        protected void putStatus​(org.aopalliance.intercept.MethodInvocation invocation,
                                 ome.tools.hibernate.SessionStatus status)
      • removeStatus

        protected ome.tools.hibernate.SessionStatus removeStatus​(org.aopalliance.intercept.MethodInvocation invocation)
      • cleanThread

        public void cleanThread()
      • invoke

        public java.lang.Object invoke​(org.aopalliance.intercept.MethodInvocation invocation)
                                throws java.lang.Throwable
        delegates to HibernateInterceptor or manages sessions internally, based on the type of service.
        Specified by:
        invoke in interface org.aopalliance.intercept.MethodInterceptor
        Throws:
        java.lang.Throwable