|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nakedobjects.runtime.context.NakedObjectsContext
public abstract class NakedObjectsContext
Provides singleton access to the current (session scoped) NakedObjectSession, along with
convenience methods to obtain application-scoped components and also any transaction-scoped components
TransactionScopedComponents if a NakedObjectTransaction
is in progress.
Somewhat analogous to (the static methods in) HibernateUtil.
| Nested Class Summary | |
|---|---|
protected static class |
NakedObjectsContext.ContextReplacePolicy
Whether the singleton itself may be replaced. |
protected static class |
NakedObjectsContext.SessionClosePolicy
|
| Constructor Summary | |
|---|---|
protected |
NakedObjectsContext(NakedObjectsContext.ContextReplacePolicy replacePolicy,
NakedObjectsContext.SessionClosePolicy sessionClosePolicy,
NakedObjectSessionFactory sessionFactory)
Creates a new instance of the NakedObjectSession holder. |
| Method Summary | |
|---|---|
abstract java.lang.String[] |
allSessionIds()
All known session Ids. |
protected void |
applySessionClosePolicy()
Helper method for subclasses' implementation of openSessionInstance(AuthenticationSession). |
static void |
closeAllSessions()
Convenience method to close all sessions. |
protected abstract void |
closeAllSessionsInstance()
Shutdown the application. |
static void |
closeSession()
Convenience method to close the current NakedObjectSession. |
void |
closeSessionInstance()
Closes the NakedObjectSession for the current context. |
void |
debugData(DebugString debug)
|
static DebugInfo[] |
debugSession()
|
static DebugInfo[] |
debugSystem()
|
protected void |
doClose()
Overridable hook method called from closeSessionInstance(), allowing subclasses to clean up
(for example datastructures). |
static boolean |
exists()
Whether a singleton has been created using getInstance(). |
static AuthenticationManager |
getAuthenticationManager()
Convenience method. |
static AuthenticationSession |
getAuthenticationSession()
|
static AuthorizationManager |
getAuthorizationManager()
Convenience method. |
static NakedObjectConfiguration |
getConfiguration()
Convenience method. |
static NakedObjectTransaction |
getCurrentTransaction()
Convenience method, returning the current transaction (if any). |
static DeploymentType |
getDeploymentType()
Convenience method. |
static NakedObjectsContext |
getInstance()
Returns the singleton providing access to the set of execution contexts. |
static MessageBroker |
getMessageBroker()
Convenience method, returning the MessageBroker of the current
transaction. |
static PersistenceSession |
getPersistenceSession()
Convenience method. |
static java.util.List<java.lang.Object> |
getServices()
|
static NakedObjectSession |
getSession()
Convenience method returning the current NakedObjectSession. |
static NakedObjectSession |
getSession(java.lang.String sessionId)
Convenience method to return NakedObjectSession for specified
NakedObjectSession.getId(). |
static NakedObjectSessionFactory |
getSessionFactory()
Convenience method returning the NakedObjectSessionFactory of the current session. |
NakedObjectSessionFactory |
getSessionFactoryInstance()
As injected in constructor. |
static java.lang.String |
getSessionId()
Convenience method to return the current NakedObjectSession's
id. |
abstract NakedObjectSession |
getSessionInstance()
Locates the current NakedObjectSession. |
protected abstract NakedObjectSession |
getSessionInstance(java.lang.String sessionId)
The NakedObjectSession for specified NakedObjectSession.getId(). |
static SpecificationLoader |
getSpecificationLoader()
Convenience method. |
static TemplateImageLoader |
getTemplateImageLoader()
Convenience method. |
static NakedObjectTransactionManager |
getTransactionManager()
Convenience methods |
static UpdateNotifier |
getUpdateNotifier()
Convenience method, returning the UpdateNotifier of the current
transaction. |
static UserProfile |
getUserProfile()
Convenience method. |
static UserProfileLoader |
getUserProfileLoader()
|
static boolean |
inSession()
|
static boolean |
inTransaction()
|
boolean |
isContextReplaceable()
Whether a context singleton can simply be replaced or not. |
boolean |
isSessionAutocloseable()
Whether any open session can be automatically closed on
open. |
static NakedObjectSession |
openSession(AuthenticationSession authenticationSession)
Convenience method to open a new NakedObjectSession. |
abstract NakedObjectSession |
openSessionInstance(AuthenticationSession session)
Creates a new NakedObjectSession and binds into the current context. |
static void |
setConfiguration(NakedObjectConfiguration configuration)
|
static void |
testReset()
Resets the singleton, so another can created. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.nakedobjects.metamodel.commons.debug.DebugInfo |
|---|
debugTitle |
| Constructor Detail |
|---|
protected NakedObjectsContext(NakedObjectsContext.ContextReplacePolicy replacePolicy,
NakedObjectsContext.SessionClosePolicy sessionClosePolicy,
NakedObjectSessionFactory sessionFactory)
NakedObjectSession holder.
Will throw an exception if an instance has already been created and is not
NakedObjectsContext.ContextReplacePolicy.REPLACEABLE.
| Method Detail |
|---|
public static NakedObjectsContext getInstance()
public static boolean exists()
getInstance().
public static void testReset()
#NakedObjects()public final NakedObjectSessionFactory getSessionFactoryInstance()
public final boolean isContextReplaceable()
public final boolean isSessionAutocloseable()
closed on
open.
protected void applySessionClosePolicy()
openSessionInstance(AuthenticationSession).
public abstract NakedObjectSession openSessionInstance(AuthenticationSession session)
NakedObjectSession and binds into the current context.
java.lang.IllegalStateException - if already opened.public final void closeSessionInstance()
NakedObjectSession for the current context.
Ignored if already closed.
protected void doClose()
closeSessionInstance(), allowing subclasses to clean up
(for example datastructures).
The current NakedObjectSession will already have been
closed.
protected abstract void closeAllSessionsInstance()
public abstract NakedObjectSession getSessionInstance()
NakedObjectSession.
This might just be a singleton (eg NakedObjectsContextStatic), or could be retrieved from the
thread (eg NakedObjectsContextThreadLocal).
protected abstract NakedObjectSession getSessionInstance(java.lang.String sessionId)
NakedObjectSession for specified NakedObjectSession.getId().
public abstract java.lang.String[] allSessionIds()
Provided primarily for debugging.
public static NakedObjectSession openSession(AuthenticationSession authenticationSession)
NakedObjectSession.
openSessionInstance(AuthenticationSession)public static void closeSession()
NakedObjectSession.
closeSessionInstance()public static NakedObjectSession getSession(java.lang.String sessionId)
NakedObjectSession for specified
NakedObjectSession.getId().
Provided primarily for debugging.
getSessionInstance(String)public static void closeAllSessions()
public static NakedObjectSessionFactory getSessionFactory()
NakedObjectSessionFactory of the current session.
public static NakedObjectConfiguration getConfiguration()
NakedObjectSessionFactory.getConfiguration()public static void setConfiguration(NakedObjectConfiguration configuration)
public static DeploymentType getDeploymentType()
NakedObjectSessionFactory.getDeploymentType()public static SpecificationLoader getSpecificationLoader()
NakedObjectSessionFactory.getSpecificationLoader()public static AuthenticationManager getAuthenticationManager()
NakedObjectSessionFactory.getAuthenticationManager()public static AuthorizationManager getAuthorizationManager()
NakedObjectSessionFactory.getAuthorizationManager()public static TemplateImageLoader getTemplateImageLoader()
NakedObjectSessionFactory.getTemplateImageLoader()public static UserProfileLoader getUserProfileLoader()
public static java.util.List<java.lang.Object> getServices()
public static boolean inSession()
public static NakedObjectSession getSession()
NakedObjectSession.
public static java.lang.String getSessionId()
current NakedObjectSession's
id.
NakedObjectSession.getId()public static AuthenticationSession getAuthenticationSession()
NakedObjectSession.getAuthenticationSession()public static PersistenceSession getPersistenceSession()
NakedObjectSession.getPersistenceSession()public static UserProfile getUserProfile()
NakedObjectSession.getUserProfile()public static NakedObjectTransactionManager getTransactionManager()
NakedObjectSession.getPersistenceSession(),
PersistenceSession.getTransactionManager()public static boolean inTransaction()
public static NakedObjectTransaction getCurrentTransaction()
transaction (if any).
Transactions are managed using the NakedObjectTransactionManager obtainable from the
NakedObjectSession's PersistenceSession.
NakedObjectSession.getCurrentTransaction(),
PersistenceSession.getTransactionManager()public static MessageBroker getMessageBroker()
MessageBroker of the current
transaction.
public static UpdateNotifier getUpdateNotifier()
UpdateNotifier of the current
transaction.
public static DebugInfo[] debugSystem()
public static DebugInfo[] debugSession()
public void debugData(DebugString debug)
debugData in interface DebugInfo
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||