org.compass.core.support.session
Class CompassSessionTransactionalProxy

java.lang.Object
  extended by org.compass.core.support.session.CompassSessionTransactionalProxy
All Implemented Interfaces:
Serializable, InvocationHandler

public class CompassSessionTransactionalProxy
extends Object
implements InvocationHandler, Serializable

InvocationHandler for CompassSession. Used within already transactional context in order to simplify the usage of CompassSession. With this wrapper, there is no need to call openSession, or close() on the session. There is no need to use Compass transaction API as well.

Author:
kimchy
See Also:
Serialized Form

Constructor Summary
CompassSessionTransactionalProxy(Compass compass)
          Constrcuts a new invocation handler based on the session.
 
Method Summary
 Object invoke(Object proxy, Method method, Object[] args)
          Since Compass already does most of the session management, this wrapper around CompassSession invocation simply uses Compass.openSession() and invoke the appropiate method on the session returned.
static CompassSession newProxy(Compass compass)
          Creates a new proxied CompassSession that can be used within an already running transcational context without worrying about session management API or transcation management API.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompassSessionTransactionalProxy

public CompassSessionTransactionalProxy(Compass compass)
Constrcuts a new invocation handler based on the session. Allows for proxing CompassSession for simpler API usage within a transactional context.

Parameters:
compass - The Compass instance to use for session creation
Method Detail

newProxy

public static CompassSession newProxy(Compass compass)
Creates a new proxied CompassSession that can be used within an already running transcational context without worrying about session management API or transcation management API.

Parameters:
compass - The compass instance used to create the session
Returns:
A proxied session for simpler session usage within an already running transactional context

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Since Compass already does most of the session management, this wrapper around CompassSession invocation simply uses Compass.openSession() and invoke the appropiate method on the session returned. Compass will make sure that this is the correct session within the context.

Specified by:
invoke in interface InvocationHandler
Throws:
Throwable


Copyright (c) 2004-2009 The Compass Project.