The Spring Framework

org.springframework.orm.toplink
Class SessionBrokerSessionFactory

java.lang.Object
  extended by org.springframework.orm.toplink.AbstractSessionFactory
      extended by org.springframework.orm.toplink.SessionBrokerSessionFactory
All Implemented Interfaces:
SessionFactory

public class SessionBrokerSessionFactory
extends AbstractSessionFactory

Spring SessionFactory implementation allowing users to inject a TopLink Session built from a TopLink SessionBroker. SessionBrokers are used identically to any other TopLink Session. DAO code should never have to distinguish between Sessions which broker requests to multiple databases and Sessions which manage requests to a single database. The only pertinent difference in the SessionBroker api involves the method for obtaining a thread-safe "client" Session from the SessionBroker. Instead of the typical acquireClientSession method, this SessionFactory implementation uses the acquireClientSessionBroker method. If a SessionBroker aggregates non thread-safe DatabaseSessions, the factory will throw UnsupportedOperationExceptions if used to create managed or transaction-aware Sessions.

Since:
1.2.6
Author:
James Clark, Juergen Hoeller
See Also:
ServerSessionFactory, ServerSession.acquireClientSession(), SessionBroker.acquireClientSessionBroker()

Field Summary
 
Fields inherited from class org.springframework.orm.toplink.AbstractSessionFactory
logger
 
Constructor Summary
SessionBrokerSessionFactory(oracle.toplink.sessionbroker.SessionBroker broker)
          Create a new SessionBrokerSessionFactory for the given SessionBroker.
 
Method Summary
 void close()
          Shut the pre-configured TopLink SessionBroker down.
protected  oracle.toplink.sessions.Session createClientSession()
          Create a plain client SessionBroker for this factory's ServerSession.
 oracle.toplink.sessions.Session createSession()
          Try to create a client Session; fall back to the master Session, if no client Session can be created (because of the session broker's configuration).
protected  oracle.toplink.sessions.Session getMasterSession()
          Return this factory's SessionBroker as-is.
 
Methods inherited from class org.springframework.orm.toplink.AbstractSessionFactory
createManagedClientSession, createTransactionAwareSession, createTransactionAwareSession
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SessionBrokerSessionFactory

public SessionBrokerSessionFactory(oracle.toplink.sessionbroker.SessionBroker broker)
Create a new SessionBrokerSessionFactory for the given SessionBroker.

Parameters:
broker - the TopLink SessionBroker to fetch Sessions from
Method Detail

createSession

public oracle.toplink.sessions.Session createSession()
                                              throws oracle.toplink.exceptions.TopLinkException
Try to create a client Session; fall back to the master Session, if no client Session can be created (because of the session broker's configuration).

Specified by:
createSession in interface SessionFactory
Overrides:
createSession in class AbstractSessionFactory
Returns:
the new TopLink Session
Throws:
oracle.toplink.exceptions.TopLinkException - in case of errors
See Also:
createClientSession(), getMasterSession()

getMasterSession

protected oracle.toplink.sessions.Session getMasterSession()
Return this factory's SessionBroker as-is.

Specified by:
getMasterSession in class AbstractSessionFactory

createClientSession

protected oracle.toplink.sessions.Session createClientSession()
                                                       throws oracle.toplink.exceptions.TopLinkException
Create a plain client SessionBroker for this factory's ServerSession.

Specified by:
createClientSession in class AbstractSessionFactory
Throws:
oracle.toplink.exceptions.TopLinkException - if creation of a client Session failed
See Also:
SessionBroker.acquireClientSessionBroker()

close

public void close()
Shut the pre-configured TopLink SessionBroker down.

See Also:
DatabaseSession.logout(), Session.release()

The Spring Framework

Copyright © 2002-2007 The Spring Framework.