Top Description Fields Constructors Methods
org.eclipse.persistence.sessions.factories

public Class SessionManager

extends Object
Class Inheritance
Imports
java.security.AccessController, .PrivilegedActionException, java.util.ArrayList, .Collection, .Collections, .Iterator, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, org.eclipse.persistence.exceptions.ServerPlatformException, .ValidationException, org.eclipse.persistence.internal.security.PrivilegedAccessHelper, .PrivilegedGetClassLoaderForClass, org.eclipse.persistence.internal.sessions.AbstractSession, org.eclipse.persistence.internal.sessions.factories.model.SessionConfigs, org.eclipse.persistence.logging.AbstractSessionLog, .SessionLog, org.eclipse.persistence.platform.server.ServerPlatform, .ServerPlatformUtils, org.eclipse.persistence.sessions.DatabaseSession, .Session

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:

Author
James Sutherland
Since
TOPLink/Java 3.0

Field Summary

Modifier and TypeField and Description
private String
protected AbstractSession
private static volatile ServerPlatform
private static final Object[]
private static SessionLog
protected static volatile SessionManager
private static volatile ConcurrentMap<String, SessionManager>
protected ConcurrentMap<String, Session>
protected static boolean
protected static boolean
shouldUseSchemaValidation

Allow for usage of schema validation to be configurable.

private static volatile boolean

Constructor Summary

AccessConstructor and Description
public
SessionManager()

PUBLIC: The default constructor to create a new session manager.

Method Summary

Modifier and TypeMethod and Description
public void
addSession(Session
session to be added to the session manager
session
)

INTERNAL: Add an named session to the hashtable.

public void
addSession(String
session name
sessionName
,
Session
session to be added to the session manager
session
)

ADVANCED: add an named session to the hashtable.

public void
destroy()

PUBLIC: Destroy current session manager instance.

private void
destroy(Session session)

public void
destroyAllSessions()

INTERNAL: Destroy all sessions held onto by this manager.

public void
destroySession(String
name of the session to be destroyed
sessionName
)

INTERNAL: Destroy the session defined by sessionName on this manager.

public static Collection<SessionManager>

Returns:

all SessionManager instances
getAllManagers
()

ADVANCED: Return all session managers.

public Session

Returns:

default session
getDefaultSession
()

PUBLIC: Return the default session.

public synchronized SessionConfigs

Returns:

parsed session configuration
getInternalMWConfigObjects
(String
resource to load
resourceName
,
ClassLoader
ClassLoader used to load the resource
objectClassLoader
)

INTERNAL: This method is to be used to load config objects for the Mapping Workbench only.

public synchronized SessionConfigs

Returns:

parsed session configuration
getInternalMWConfigObjects
(String
resource to load
resourceName
,
ClassLoader
ClassLoader used to load the resource
objectClassLoader
,
boolean
whether to validate the resource passed in
validate
)

INTERNAL: This method is to be used to load config objects for the Mapping Workbench only.

public static SessionManager

Returns:

the session manager for current context
getManager
()

PUBLIC: Return the session manager for current context.

private static String
public AbstractSession

Returns:

session with given session name
getSession
(String
session name
sessionName
)

PUBLIC: Return the session by name.

public AbstractSession

Returns:

session with given session name
getSession
(String
session name
sessionName
,
boolean
whether the session should be logged in
shouldLoginSession
)

PUBLIC: Return the session by name.

public AbstractSession

Returns:

session with given session name
getSession
(String
session name
sessionName
,
boolean
whether the session should be logged in
shouldLoginSession
,
boolean
whether the session should be refreshed
shouldRefreshSession
)

PUBLIC: Return the session by name.

public AbstractSession

Returns:

session with given session name
getSession
(String
session name
sessionName
,
Object
object to get the ClassLoader from
objectBean
)

PUBLIC: Return the session by name, using the classloader of the Object specified.

public AbstractSession

Returns:

session with given session name
getSession
(String
session name
sessionName
,
String
file name containing session definition
filename
)

PUBLIC: Return the session by name, in the file specified.

public AbstractSession

Returns:

session with given session name
getSession
(String
session name
sessionName
,
String
file name containing session definition
filename
,
ClassLoader
ClassLoader used to load the original session
classLoader
)

PUBLIC: Return the session by name, in the file specified, using the class loader to find the resource.

public AbstractSession

Returns:

session with given session name
getSession
(String
session name
sessionName
,
ClassLoader
ClassLoader used to load the original session
objectClassLoader
)

PUBLIC: Return the session by name.

public AbstractSession

Returns:

session with given session name
getSession
(XMLSessionConfigLoader
XMLSessionConfigLoader containing session configuration
loader
,
String
session name
sessionName
,
ClassLoader
ClassLoader used to load the original session
objectClassLoader
)

PUBLIC: Return the session by name, loading the configuration from the file specified in the XMLSessionConfigLoader.

public AbstractSession

Returns:

session with given session name
getSession
(XMLSessionConfigLoader
XMLSessionConfigLoader containing session configuration
loader
,
String
session name
sessionName
,
ClassLoader
ClassLoader used to load the original session
objectClassLoader
,
boolean
whether the session should be logged in
shouldLoginSession
,
boolean
whether the session should be refreshed
shouldRefreshSession
)

PUBLIC: Return the session by name, loading the configuration from the file specified in the loader.

public AbstractSession

Returns:

session with given session name
getSession
(XMLSessionConfigLoader
XMLSessionConfigLoader containing session configuration
loader
,
String
session name
sessionName
,
ClassLoader
ClassLoader used to load the original session
objectClassLoader
,
boolean
whether the session should be logged in
shouldLoginSession
,
boolean
whether the session should be refreshed
shouldRefreshSession
,
boolean
whether to compare class loaders used to load given session
shouldCheckClassLoader
)

PUBLIC: Return the session by name, loading the configuration from the file specified in the loader.

public AbstractSession

Returns:

session with given session name
getSession
(XMLSessionConfigLoader
XMLSessionConfigLoader containing session configuration
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.

public ConcurrentMap<String, Session>

Returns:

all sessions known by this session manager
getSessions
()

INTERNAL: Return a hashtable on all sessions.

private static void
init()

protected static SessionManager

Returns:

initialized session manager
initializeManager
()

INTERNAL: Initialize the singleton session manager.

private void
logAndThrowException(int level, RuntimeException exception)

INTERNAL: Log exceptions to the default log then throw them.

public void
setDefaultSession(Session
default session
defaultSession
)

PUBLIC: Set the default session.

public static void
setManager(SessionManager
session manager for current context
theManager
)

INTERNAL: Set the singleton session manager.

public void
setSessions(ConcurrentMap<String, Session>
sessions for this session manager
sessions
)

INTERNAL: Set a hashtable of all sessions

public static void
setShouldUseSchemaValidation(boolean
true if schema validation should be used when parsing the 10g (10.1.3) sessions XML, false otherwise
useSchemaValidation
)

PUBLIC: Set if schema validation will be used when parsing the 10g (10.1.3) sessions XML.

public static boolean

Returns:

true if schema validation will be used when parsing the 10g (10.1.3) sessions XML, false otherwise
shouldUseSchemaValidation
()

PUBLIC: Return if schema validation will be used when parsing the 10g (10.1.3) sessions XML.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contextback to summary
private String context
defaultSessionback to summary
protected AbstractSession defaultSession
detectedPlatformback to summary
private static volatile ServerPlatform detectedPlatform
lockback to summary
private static final Object[] lock
LOGback to summary
private static SessionLog LOG
managerback to summary
protected static volatile SessionManager manager
managersback to summary
private static volatile ConcurrentMap<String, SessionManager> managers
sessionsback to summary
protected ConcurrentMap<String, Session> sessions
shouldPerformDTDValidationback to summary
protected static boolean shouldPerformDTDValidation
shouldUseSchemaValidationback to summary
protected static boolean shouldUseSchemaValidation

Allow for usage of schema validation to be configurable.

supportPartitionsback to summary
private static volatile boolean supportPartitions

Constructor Detail

SessionManagerback to summary
public SessionManager()

PUBLIC: The default constructor to create a new session manager.

Method Detail

addSessionback to summary
public void addSession(Session session)

INTERNAL: Add an named session to the hashtable. Session must have a name prior to setting into session manager.

Parameters
session:Session

session to be added to the session manager

addSessionback to summary
public void addSession(String sessionName, Session session)

ADVANCED: add an named session to the hashtable.

Parameters
sessionName:String

session name

session:Session

session to be added to the session manager

destroyback to summary
public void destroy()

PUBLIC: Destroy current session manager instance.

destroyback to summary
private void destroy(Session session)
destroyAllSessionsback to summary
public void destroyAllSessions()

INTERNAL: Destroy all sessions held onto by this manager.

destroySessionback to summary
public void destroySession(String sessionName)

INTERNAL: Destroy the session defined by sessionName on this manager.

Parameters
sessionName:String

name of the session to be destroyed

getAllManagersback to summary
public static Collection<SessionManager> getAllManagers()

ADVANCED: Return all session managers. This allows global access to all instances of SessionManager.

Returns:Collection<SessionManager>

all SessionManager instances

getDefaultSessionback to summary
public Session 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:Session

default session

getInternalMWConfigObjectsback to summary
public synchronized 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:String

resource to load

objectClassLoader:ClassLoader

ClassLoader used to load the resource

Returns:SessionConfigs

parsed session configuration

getInternalMWConfigObjectsback to summary
public synchronized 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:String

resource to load

objectClassLoader:ClassLoader

ClassLoader used to load the resource

validate:boolean

whether to validate the resource passed in

Returns:SessionConfigs

parsed session configuration

getManagerback to summary
public static SessionManager getManager()

PUBLIC: Return the session manager for current context. This allow global access to a set of named sessions.

Returns:SessionManager

the session manager for current context

getPartitionIDback to summary
private static String getPartitionID()
getSessionback to summary
public AbstractSession getSession(String sessionName)

PUBLIC: Return the session by name.

Parameters
sessionName:String

session name

Returns:AbstractSession

session with given session name

getSessionback to summary
public AbstractSession getSession(String sessionName, boolean shouldLoginSession)

PUBLIC: Return the session by name. Log the session in only if specified.

Parameters
sessionName:String

session name

shouldLoginSession:boolean

whether the session should be logged in

Returns:AbstractSession

session with given session name

getSessionback to summary
public 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:String

session name

shouldLoginSession:boolean

whether the session should be logged in

shouldRefreshSession:boolean

whether the session should be refreshed

Returns:AbstractSession

session with given session name

getSessionback to summary
public 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:String

session name

objectBean:Object

object to get the ClassLoader from

Returns:AbstractSession

session with given session name

getSessionback to summary
public AbstractSession getSession(String sessionName, String filename)

PUBLIC: Return the session by name, in the file specified. Login the session.

Parameters
sessionName:String

session name

filename:String

file name containing session definition

Returns:AbstractSession

session with given session name

getSessionback to summary
public 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:String

session name

filename:String

file name containing session definition

classLoader:ClassLoader

ClassLoader used to load the original session

Returns:AbstractSession

session with given session name

getSessionback to summary
public 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:String

session name

objectClassLoader:ClassLoader

ClassLoader used to load the original session

Returns:AbstractSession

session with given session name

getSessionback to summary
public 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

XMLSessionConfigLoader containing session configuration

sessionName:String

session name

objectClassLoader:ClassLoader

ClassLoader used to load the original session

Returns:AbstractSession

session with given session name

getSessionback to summary
public 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

XMLSessionConfigLoader containing session configuration

sessionName:String

session name

objectClassLoader:ClassLoader

ClassLoader used to load the original session

shouldLoginSession:boolean

whether the session should be logged in

shouldRefreshSession:boolean

whether the session should be refreshed

Returns:AbstractSession

session with given session name

getSessionback to summary
public 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

XMLSessionConfigLoader containing session configuration

sessionName:String

session name

objectClassLoader:ClassLoader

ClassLoader used to load the original session

shouldLoginSession:boolean

whether the session should be logged in

shouldRefreshSession:boolean

whether the session should be refreshed

shouldCheckClassLoader:boolean

whether to compare class loaders used to load given session

Returns:AbstractSession

session with given session name

getSessionback to summary
public 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

XMLSessionConfigLoader containing session configuration

Returns:AbstractSession

session with given session name

getSessionsback to summary
public ConcurrentMap<String, Session> getSessions()

INTERNAL: Return a hashtable on all sessions.

Returns:ConcurrentMap<String, Session>

all sessions known by this session manager

initback to summary
private static void init()
initializeManagerback to summary
protected static SessionManager initializeManager()

INTERNAL: Initialize the singleton session manager.

Returns:SessionManager

initialized session manager

logAndThrowExceptionback to summary
private void logAndThrowException(int level, RuntimeException exception) throws RuntimeException

INTERNAL: Log exceptions to the default log then throw them.

setDefaultSessionback to summary
public void setDefaultSession(Session defaultSession)

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:Session

default session

setManagerback to summary
public static void setManager(SessionManager theManager)

INTERNAL: Set the singleton session manager. This allows global access to a set of named sessions.

Parameters
theManager:SessionManager

session manager for current context

setSessionsback to summary
public void setSessions(ConcurrentMap<String, Session> sessions)

INTERNAL: Set a hashtable of all sessions

Parameters
sessions:ConcurrentMap<String, Session>

sessions for this session manager

setShouldUseSchemaValidationback to summary
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:boolean

true if schema validation should be used when parsing the 10g (10.1.3) sessions XML, false otherwise

shouldUseSchemaValidationback to summary
public static boolean shouldUseSchemaValidation()

PUBLIC: Return if schema validation will be used when parsing the 10g (10.1.3) sessions XML.

Returns:boolean

true if schema validation will be used when parsing the 10g (10.1.3) sessions XML, false otherwise