Class SessionManager
java.lang.Object
org.eclipse.persistence.sessions.factories.SessionManager
Purpose: Global session location.
Description: This allows for a global session local which can be accessed globally from other classes. This is needed for EJB data stores as they must have a globally accessible place to access the session. This can be by EJB session beans, BMP beans and CMP beans as well as Servlets and other three-tier services.
Responsibilities:
- Store a global session.
- Allow the storage of alternative sessions as well.
- Author:
- James Sutherland
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.eclipse.persistence.internal.sessions.AbstractSession
protected static SessionManager
protected ConcurrentMap<String,
Session> protected static boolean
protected static boolean
Allow for usage of schema validation to be configurable. -
Constructor Summary
ConstructorDescriptionPUBLIC: The default constructor to create a new session manager. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSession
(String sessionName, Session session) ADVANCED: add an named session to the hashtable.void
addSession
(Session session) INTERNAL: Add an named session to the hashtable.void
destroy()
PUBLIC: Destroy current session manager instance.void
INTERNAL: Destroy all sessions held onto by this manager.void
destroySession
(String sessionName) INTERNAL: Destroy the session defined by sessionName on this manager.static Collection<SessionManager>
ADVANCED: Return all session managers.PUBLIC: Return the default session.org.eclipse.persistence.internal.sessions.factories.model.SessionConfigs
getInternalMWConfigObjects
(String resourceName, ClassLoader objectClassLoader) INTERNAL: This method is to be used to load config objects for the Mapping Workbench only.org.eclipse.persistence.internal.sessions.factories.model.SessionConfigs
getInternalMWConfigObjects
(String resourceName, ClassLoader objectClassLoader, boolean validate) INTERNAL: This method is to be used to load config objects for the Mapping Workbench only.static SessionManager
PUBLIC: Return the session manager for current context.org.eclipse.persistence.internal.sessions.AbstractSession
getSession
(String sessionName) PUBLIC: Return the session by name.org.eclipse.persistence.internal.sessions.AbstractSession
getSession
(String sessionName, boolean shouldLoginSession) PUBLIC: Return the session by name.org.eclipse.persistence.internal.sessions.AbstractSession
getSession
(String sessionName, boolean shouldLoginSession, boolean shouldRefreshSession) PUBLIC: Return the session by name.org.eclipse.persistence.internal.sessions.AbstractSession
getSession
(String sessionName, ClassLoader objectClassLoader) PUBLIC: Return the session by name.org.eclipse.persistence.internal.sessions.AbstractSession
getSession
(String sessionName, Object objectBean) PUBLIC: Return the session by name, using the classloader of the Object specified.org.eclipse.persistence.internal.sessions.AbstractSession
getSession
(String sessionName, String filename) PUBLIC: Return the session by name, in the file specified.org.eclipse.persistence.internal.sessions.AbstractSession
getSession
(String sessionName, String filename, ClassLoader classLoader) PUBLIC: Return the session by name, in the file specified, using the class loader to find the resource.org.eclipse.persistence.internal.sessions.AbstractSession
getSession
(XMLSessionConfigLoader loader) PUBLIC: Return the session by name, loading the configuration from the file specified in the loader, using the loading options provided on the loader.org.eclipse.persistence.internal.sessions.AbstractSession
getSession
(XMLSessionConfigLoader loader, String sessionName, ClassLoader objectClassLoader) PUBLIC: Return the session by name, loading the configuration from the file specified in the XMLSessionConfigLoader.org.eclipse.persistence.internal.sessions.AbstractSession
getSession
(XMLSessionConfigLoader loader, String sessionName, ClassLoader objectClassLoader, boolean shouldLoginSession, boolean shouldRefreshSession) PUBLIC: Return the session by name, loading the configuration from the file specified in the loader.org.eclipse.persistence.internal.sessions.AbstractSession
getSession
(XMLSessionConfigLoader loader, String sessionName, ClassLoader objectClassLoader, boolean shouldLoginSession, boolean shouldRefreshSession, boolean shouldCheckClassLoader) PUBLIC: Return the session by name, loading the configuration from the file specified in the loader.INTERNAL: Return a hashtable on all sessions.protected static SessionManager
INTERNAL: Initialize the singleton session manager.void
setDefaultSession
(Session defaultSession) PUBLIC: Set the default session.static void
setManager
(SessionManager theManager) INTERNAL: Set the singleton session manager.void
setSessions
(ConcurrentMap sessions) INTERNAL: Set a hashtable of all sessionsstatic void
setShouldUseSchemaValidation
(boolean useSchemaValidation) PUBLIC: Set if schema validation will be used when parsing the 10g (10.1.3) sessions XML.static boolean
PUBLIC: Return if schema validation will be used when parsing the 10g (10.1.3) sessions XML.
-
Field Details
-
shouldUseSchemaValidation
protected static boolean shouldUseSchemaValidationAllow for usage of schema validation to be configurable. -
manager
-
defaultSession
protected org.eclipse.persistence.internal.sessions.AbstractSession defaultSession -
sessions
-
shouldPerformDTDValidation
protected static boolean shouldPerformDTDValidation
-
-
Constructor Details
-
SessionManager
public SessionManager()PUBLIC: The default constructor to create a new session manager.
-
-
Method Details
-
shouldUseSchemaValidation
public static boolean shouldUseSchemaValidation()PUBLIC: Return if schema validation will be used when parsing the 10g (10.1.3) sessions XML.- Returns:
true
if schema validation will be used when parsing the 10g (10.1.3) sessions XML,false
otherwise
-
setShouldUseSchemaValidation
public static void setShouldUseSchemaValidation(boolean useSchemaValidation) PUBLIC: Set if schema validation will be used when parsing the 10g (10.1.3) sessions XML. By default schema validation is on, but can be turned off if validation problems occur, or to improve parsing performance.- Parameters:
useSchemaValidation
-true
if schema validation should be used when parsing the 10g (10.1.3) sessions XML,false
otherwise
-
addSession
INTERNAL: Add an named session to the hashtable. Session must have a name prior to setting into session manager.- Parameters:
session
- session to be added to the session manager
-
addSession
ADVANCED: add an named session to the hashtable.- Parameters:
sessionName
- session namesession
- session to be added to the session manager
-
getDefaultSession
PUBLIC: Return the default session. The session configuration is stored in a sessions.xml file in a directory on your classpath. Other sessions are supported through the getSession by name API.- Returns:
- default session
-
destroy
public void destroy()PUBLIC: Destroy current session manager instance. -
destroySession
INTERNAL: Destroy the session defined by sessionName on this manager.- Parameters:
sessionName
- name of the session to be destroyed
-
destroyAllSessions
public void destroyAllSessions()INTERNAL: Destroy all sessions held onto by this manager. -
getInternalMWConfigObjects
public org.eclipse.persistence.internal.sessions.factories.model.SessionConfigs getInternalMWConfigObjects(String resourceName, ClassLoader objectClassLoader) INTERNAL: This method is to be used to load config objects for the Mapping Workbench only. Do not call this method.- Parameters:
resourceName
- resource to loadobjectClassLoader
- ClassLoader used to load the resource- Returns:
- parsed session configuration
-
getInternalMWConfigObjects
public org.eclipse.persistence.internal.sessions.factories.model.SessionConfigs getInternalMWConfigObjects(String resourceName, ClassLoader objectClassLoader, boolean validate) INTERNAL: This method is to be used to load config objects for the Mapping Workbench only. Do not call this method.- Parameters:
resourceName
- resource to loadobjectClassLoader
- ClassLoader used to load the resourcevalidate
- whether to validate the resource passed in- Returns:
- parsed session configuration
-
getManager
PUBLIC: Return the session manager for current context. This allow global access to a set of named sessions.- Returns:
- the session manager for current context
-
getAllManagers
ADVANCED: Return all session managers. This allows global access to all instances of SessionManager.- Returns:
- all SessionManager instances
-
initializeManager
INTERNAL: Initialize the singleton session manager.- Returns:
- initialized session manager
-
getSession
PUBLIC: Return the session by name.- Parameters:
sessionName
- session name- Returns:
- session with given session name
-
getSession
public org.eclipse.persistence.internal.sessions.AbstractSession getSession(String sessionName, boolean shouldLoginSession) PUBLIC: Return the session by name. Log the session in only if specified.- Parameters:
sessionName
- session nameshouldLoginSession
- whether the session should be logged in- Returns:
- session with given session name
-
getSession
public org.eclipse.persistence.internal.sessions.AbstractSession getSession(String sessionName, boolean shouldLoginSession, boolean shouldRefreshSession) PUBLIC: Return the session by name. Log the session in only if specified. Refresh the session only if specified.- Parameters:
sessionName
- session nameshouldLoginSession
- whether the session should be logged inshouldRefreshSession
- whether the session should be refreshed- Returns:
- session with given session name
-
getSession
public org.eclipse.persistence.internal.sessions.AbstractSession getSession(String sessionName, Object objectBean) PUBLIC: Return the session by name, using the classloader of the Object specified. This method is used in older versions of BMP support This method will cause the class loader of the provided object to be compared with the classloader used to load the original session of this name, with this classloader. If they are not the same then the session will be refreshed.- Parameters:
sessionName
- session nameobjectBean
- object to get the ClassLoader from- Returns:
- session with given session name
-
getSession
public org.eclipse.persistence.internal.sessions.AbstractSession getSession(String sessionName, String filename) PUBLIC: Return the session by name, in the file specified. Login the session.- Parameters:
sessionName
- session namefilename
- file name containing session definition- Returns:
- session with given session name
-
getSession
public org.eclipse.persistence.internal.sessions.AbstractSession getSession(String sessionName, String filename, ClassLoader classLoader) PUBLIC: Return the session by name, in the file specified, using the class loader to find the resource. This method will cause the class loader to be compared with the classloader used to load the original session of this name. If they are not the same then the session will be refreshed.- Parameters:
sessionName
- session namefilename
- file name containing session definitionclassLoader
- ClassLoader used to load the original session- Returns:
- session with given session name
-
getSession
public org.eclipse.persistence.internal.sessions.AbstractSession getSession(String sessionName, ClassLoader objectClassLoader) PUBLIC: Return the session by name. Provide the class loader for loading the project, the configuration file and the deployed classes. E.g. SessionManager.getManager().getSession("mySession", MySessionBean.getClassLoader()); This method will cause the class loader to be compared with the classloader used to load the original session of this name. If they are not the same then the session will be refreshed.- Parameters:
sessionName
- session nameobjectClassLoader
- ClassLoader used to load the original session- Returns:
- session with given session name
-
getSession
public org.eclipse.persistence.internal.sessions.AbstractSession getSession(XMLSessionConfigLoader loader, String sessionName, ClassLoader objectClassLoader) PUBLIC: Return the session by name, loading the configuration from the file specified in the XMLSessionConfigLoader. Provide the class loader for loading the project, the configuration file and the deployed classes. This method will cause the class loader to be compared with the classloader used to load the original session of this name. If they are not the same then the session will be refreshed.- Parameters:
loader
-XMLSessionConfigLoader
containing session configurationsessionName
- session nameobjectClassLoader
- ClassLoader used to load the original session- Returns:
- session with given session name
-
getSession
public org.eclipse.persistence.internal.sessions.AbstractSession getSession(XMLSessionConfigLoader loader, String sessionName, ClassLoader objectClassLoader, boolean shouldLoginSession, boolean shouldRefreshSession) PUBLIC: Return the session by name, loading the configuration from the file specified in the loader. Provide the class loader for loading the project, the configuration file and the deployed classes. Pass in true for shouldLoginSession if the session returned should be logged in before returned otherwise false. Pass in true for shouldRefreshSession if the XMLSessionConfigLoader should reparse the configuration file for new sessions. False, will cause the XMLSessionConfigLoader not to parse the file again.- Parameters:
loader
-XMLSessionConfigLoader
containing session configurationsessionName
- session nameobjectClassLoader
- ClassLoader used to load the original sessionshouldLoginSession
- whether the session should be logged inshouldRefreshSession
- whether the session should be refreshed- Returns:
- session with given session name
-
getSession
public org.eclipse.persistence.internal.sessions.AbstractSession getSession(XMLSessionConfigLoader loader, String sessionName, ClassLoader objectClassLoader, boolean shouldLoginSession, boolean shouldRefreshSession, boolean shouldCheckClassLoader) PUBLIC: Return the session by name, loading the configuration from the file specified in the loader. Provide the class loader for loading the project, the configuration file and the deployed classes. Pass in true for shouldLoginSession if the session returned should be logged in before returned otherwise false. Pass in true for shouldRefreshSession if the XMLSessionConfigLoader should reparse the configuration file for new sessions. False, will cause the XMLSessionConfigLoader not to parse the file again. Pass true for shouldCheckClassLoader will cause the class loader to be compared with the classloader used to load the original session of this name. If they are not the same then the session will be refreshed, this can be used for re-deployment.- Parameters:
loader
-XMLSessionConfigLoader
containing session configurationsessionName
- session nameobjectClassLoader
- ClassLoader used to load the original sessionshouldLoginSession
- whether the session should be logged inshouldRefreshSession
- whether the session should be refreshedshouldCheckClassLoader
- whether to compare class loaders used to load given session- Returns:
- session with given session name
-
getSession
public org.eclipse.persistence.internal.sessions.AbstractSession getSession(XMLSessionConfigLoader loader) PUBLIC: Return the session by name, loading the configuration from the file specified in the loader, using the loading options provided on the loader.- Parameters:
loader
-XMLSessionConfigLoader
containing session configuration- Returns:
- session with given session name
-
setSessions
INTERNAL: Set a hashtable of all sessions- Parameters:
sessions
- sessions for this session manager
-
getSessions
INTERNAL: Return a hashtable on all sessions.- Returns:
- all sessions known by this session manager
-
setDefaultSession
PUBLIC: Set the default session. If not set the session configuration is stored in a sessions.xml file in a TopLink directory on your classpath. Other sessions are supported through the getSession by name API.- Parameters:
defaultSession
- default session
-
setManager
INTERNAL: Set the singleton session manager. This allows global access to a set of named sessions.- Parameters:
theManager
- session manager for current context
-