|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsf.qof.session.SessionContextFactory
public class SessionContextFactory
Implementation of a session context factory.
SessionContextFactory
provides factory methods to create and cache
SessionContext
objects.
The SessionContextFactory
can be used in the following way:
DataSource ds = ... // get the data source from somewhere // register the data source with the default session context SessionContextFactory.setDataSource(ds); ... // get the default session context SessionContext ctx = SessionContextFactory.getContext(); // start a new session ctx.startSession(); // start a new transaction ctx.getUserTransaction().begin(); // get the database connection for the current session Connection con = ctx.getConnection(); // do something with the connection ... // commit and end the current transaction ctx.getUserTransaction().commit(); // stop the session ctx.stopSession();
SessionContext
,
UserTransaction
Nested Class Summary | |
---|---|
protected static class |
SessionContextFactory.DefaultSessionContext
Internal implementation of SessionContext . |
protected static class |
SessionContextFactory.DefaultUserTransaction
Internal implementation of UserTransaction . |
Method Summary | |
---|---|
static SessionContext |
getContext()
Creates and returns the default SessionContext . |
static SessionContext |
getContext(String contextName)
Creates and returns the SessionContext for a given context name. |
static void |
setDataSource(DataSource dataSource)
Registers a DataSource with the default session context. |
static void |
setDataSource(String contextName,
DataSource dataSource)
Registers a DataSource with the specified session context. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static SessionContext getContext()
SessionContext
.
public static SessionContext getContext(String contextName)
SessionContext
for a given context name.
contextName
- the context name
public static void setDataSource(DataSource dataSource)
DataSource
with the default session context.
dataSource
- the data sourcepublic static void setDataSource(String contextName, DataSource dataSource)
DataSource
with the specified session context.
contextName
- the session context namedataSource
- the data source
|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |