Class ServerPlatformBase
- java.lang.Object
-
- org.eclipse.persistence.platform.server.ServerPlatformBase
-
- All Implemented Interfaces:
ServerPlatform
- Direct Known Subclasses:
CustomServerPlatform
,JMXServerPlatformBase
,NoServerPlatform
,Oc4jPlatform
,SAPNetWeaver_7_1_Platform
public abstract class ServerPlatformBase extends java.lang.Object implements ServerPlatform
PUBLIC: Implementation of org.eclipse.persistence.platform.server.ServerPlatformThis is the abstract superclass of all platforms for all servers. Each DatabaseSession contains an instance of the receiver, to help the DatabaseSession determine:
- Which external transaction controller to use
- Whether or not to enable JTA (external transaction control)
- How to register/unregister for runtime services (JMX/MBean)
- Whether or not to enable runtime services
- How to launch container Threads
Subclasses already exist to provide configurations for Oc4J, WebLogic, JBoss, NetWeaver, GlassFish and WebSphere.
If the user wants a different external transaction controller class or to provide some different behavior than the provided ServerPlatform(s), we recommend subclassing org.eclipse.persistence.platform.server.ServerPlatformBase (or a subclass), and overriding:
- ServerPlatformBase.getExternalTransactionControllerClass()
- ServerPlatformBase.registerMBean()
- ServerPlatformBase.unregisterMBean()
- See Also:
ServerPlatform
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_SERVER_NAME_AND_VERSION
INTERNAL: Answer "unknown" as a default for platforms that do not implement getModuleName()protected java.lang.Class
externalTransactionControllerClass
externalTransactionControllerClass: This is a user-specifiable class defining the class of external transaction controller to be set into the DatabaseSessionstatic java.lang.String
JMX_REGISTER_DEV_MBEAN_PROPERTY
This System property "eclipselink.register.dev.mbean" when set to true will enable registration/unregistration of the DevelopmentServices MBeanstatic java.lang.String
JMX_REGISTER_RUN_MBEAN_PROPERTY
This System property "eclipselink.register.run.mbean" when set to true will enable registration/unregistration of the RuntimeServices MBeanprotected java.lang.String
serverNameAndVersion
INTERNAL: Server name and version.protected boolean
shouldRegisterDevelopmentBean
protected boolean
shouldRegisterRuntimeBean
protected java.util.concurrent.ExecutorService
threadPool
Allow pooling of threads for asynchronous processing in RCM and other areas.protected int
threadPoolSize
Allow the thread pool size to be configured.
-
Constructor Summary
Constructors Constructor Description ServerPlatformBase(DatabaseSession newDatabaseSession)
INTERNAL: Default Constructor: Initialize so that runtime services and JTA are enabled.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
clearStatementCache(java.sql.Connection connection)
INTERNAL: Clears statement cache of the wrapper connection.void
configureProfiler(Session session)
INTERNAL: configureProfiler(): set default performance profiler used in this server.void
disableJTA()
INTERNAL: disableJTA(): Configure the receiver such that my external transaction controller class will be ignored, and will NOT be used to populate DatabaseSession's external transaction controller class at runtime.void
disableRuntimeServices()
INTERNAL: disableRuntimeServices(): Configure the receiver such that no JMX/MBean will be registered to provide runtime services for my DatabaseSession at runtime.void
enableRuntimeServices()
INTERNAL: enableRuntimeServices(): Configure the receiver such that JMX/MBeans will be registered to provide runtime services for my DatabaseSession at runtime.protected void
ensureNotLoggedIn()
INTERNAL: Make sure that the DatabaseSession has not logged in yet.protected void
externalTransactionControllerNotNullWarning()
INTERNAL: externalTransactionControllerNotNullWarning(): When the external transaction controller is being initialized, we warn the developer if they have already defined the external transaction controller in some way other than subclassing ServerPlatformBase.DatabaseSession
getDatabaseSession()
INTERNAL: getDatabaseSession(): Answer the instance of DatabaseSession the receiver is helping.abstract java.lang.Class
getExternalTransactionControllerClass()
INTERNAL: getExternalTransactionControllerClass(): Answer the class of external transaction controller to use For this server platform.int
getJNDIConnectorLookupType()
INTERNAL: Get JNDIConnector lookupType value for this platform.java.lang.String
getModuleName()
INTERNAL: getModuleName(): Answer the name of the module (jar name) that my session is associated with.org.eclipse.persistence.internal.helper.JPAClassLoaderHolder
getNewTempClassLoader(PersistenceUnitInfo puInfo)
INTERNAL: JIRA EJBTHREE-572 requires that we use the real classLoader in place of the getNewTempClassLoader().java.lang.String
getPartitionID()
INTERNAL: Get Partition ID.SessionLog
getServerLog()
INTERNAL: getServerLog(): Return the ServerLog for this platform Return the default ServerLog in the basejava.lang.String
getServerNameAndVersion()
PUBLIC: getServerNameAndVersion(): Talk to the relevant server class library, and get the server name and versionjava.util.concurrent.ExecutorService
getThreadPool()
INTERNAL: Return the thread pool, initializing if required.int
getThreadPoolSize()
Return the thread pool size.void
initializeExternalTransactionController()
INTERNAL: initializeExternalTransactionController(): Populate the DatabaseSession's external transaction controller with an instance of my transaction controller class.protected void
initializeServerNameAndVersion()
INTERNAL: initializeServerNameAndVersion(): Talk to the relevant server class library, and get the server name and version Default is "unknown"boolean
isCMP()
INTERNAL: isCMP(): Answer true if we're in the context of CMP (i.e. the container created me)boolean
isJTAEnabled()
INTERNAL: isJTAEnabled(): Answer true if the DatabaseSession's external transaction controller class will be populated with my transaction controller class at runtime.boolean
isRuntimeServicesEnabled()
INTERNAL: isRuntimeServicesEnabled(): Answer true if the JMX/MBean providing runtime services for the receiver's DatabaseSession will be deployed at runtime.boolean
isRuntimeServicesEnabledDefault()
INTERNAL: isRuntimeServicesEnabledDefault(): Answer true if the JMX/MBean providing runtime services for the receiver's DatabaseSession will be deployed at runtime.void
launchContainerRunnable(java.lang.Runnable runnable)
INTERNAL: launchContainerRunnable(Runnable runnable): Use the container library to start the provided Runnable.void
registerMBean()
INTERNAL: registerMBean(): Create and deploy the JMX MBean to provide runtime services for my databaseSession.void
serverSpecificRegisterMBean()
INTERNAL: serverSpecificRegisterMBean(): Server specific implementation of the creation and deployment of the JMX MBean to provide runtime services for my databaseSession.void
serverSpecificUnregisterMBean()
INTERNAL: serverSpecificUnregisterMBean(): Server specific implementation of the unregistration of the JMX MBean from its server.void
setExternalTransactionControllerClass(java.lang.Class newClass)
INTERNAL: setExternalTransactionControllerClass(Class newClass): Set the class of external transaction controller to use in the DatabaseSession.void
setIsCMP(boolean isThisCMP)
INTERNAL: setIsCMP(boolean): Define whether or not we're in the context of CMP (i.e. the container created me)void
setThreadPool(java.util.concurrent.ExecutorService threadPool)
INTERNAL: Set the thread pool to use.void
setThreadPoolSize(int threadPoolSize)
Set the thread pool size.boolean
shouldUseDriverManager()
INTERNAL: shouldUseDriverManager(): Indicates whether DriverManager should be used while connecting DefaultConnector.void
shutdown()
INTERNAL: perform any require shutdown tasks.void
unregisterMBean()
INTERNAL: unregisterMBean(): Unregister the JMX MBean that was providing runtime services for my databaseSession.java.sql.Connection
unwrapConnection(java.sql.Connection connection)
INTERNAL: This method is used to unwrap the connection wrapped by the application server.boolean
usesPartitions()
INTERNAL: Some servers may support partitioningboolean
wasFailureCommunicationBased(java.sql.SQLException exception, org.eclipse.persistence.internal.databaseaccess.Accessor connection, org.eclipse.persistence.internal.sessions.AbstractSession sessionForProfile)
INTERNAL: A call to this method will perform a platform based check on the connection and exception error code to determine if the connection is still valid or if a communication error has occurred.
-
-
-
Field Detail
-
JMX_REGISTER_DEV_MBEAN_PROPERTY
public static final java.lang.String JMX_REGISTER_DEV_MBEAN_PROPERTY
This System property "eclipselink.register.dev.mbean" when set to true will enable registration/unregistration of the DevelopmentServices MBean- See Also:
- Constant Field Values
-
JMX_REGISTER_RUN_MBEAN_PROPERTY
public static final java.lang.String JMX_REGISTER_RUN_MBEAN_PROPERTY
This System property "eclipselink.register.run.mbean" when set to true will enable registration/unregistration of the RuntimeServices MBean- See Also:
- Constant Field Values
-
DEFAULT_SERVER_NAME_AND_VERSION
public static final java.lang.String DEFAULT_SERVER_NAME_AND_VERSION
INTERNAL: Answer "unknown" as a default for platforms that do not implement getModuleName()
-
shouldRegisterDevelopmentBean
protected boolean shouldRegisterDevelopmentBean
-
shouldRegisterRuntimeBean
protected boolean shouldRegisterRuntimeBean
-
externalTransactionControllerClass
protected java.lang.Class externalTransactionControllerClass
externalTransactionControllerClass: This is a user-specifiable class defining the class of external transaction controller to be set into the DatabaseSession
-
serverNameAndVersion
protected java.lang.String serverNameAndVersion
INTERNAL: Server name and version.
-
threadPoolSize
protected int threadPoolSize
Allow the thread pool size to be configured.
-
threadPool
protected volatile java.util.concurrent.ExecutorService threadPool
Allow pooling of threads for asynchronous processing in RCM and other areas.
-
-
Constructor Detail
-
ServerPlatformBase
public ServerPlatformBase(DatabaseSession newDatabaseSession)
INTERNAL: Default Constructor: Initialize so that runtime services and JTA are enabled. Set the DatabaseSession that I will be helping.- Parameters:
newDatabaseSession
- The instance of DatabaseSession that I am helping.
-
-
Method Detail
-
configureProfiler
public void configureProfiler(Session session)
INTERNAL: configureProfiler(): set default performance profiler used in this server.
-
getDatabaseSession
public DatabaseSession getDatabaseSession()
INTERNAL: getDatabaseSession(): Answer the instance of DatabaseSession the receiver is helping.- Specified by:
getDatabaseSession
in interfaceServerPlatform
- Returns:
- DatabaseSession databaseSession
-
getServerNameAndVersion
public java.lang.String getServerNameAndVersion()
PUBLIC: getServerNameAndVersion(): Talk to the relevant server class library, and get the server name and version- Specified by:
getServerNameAndVersion
in interfaceServerPlatform
- Returns:
- String serverNameAndVersion
-
initializeServerNameAndVersion
protected void initializeServerNameAndVersion()
INTERNAL: initializeServerNameAndVersion(): Talk to the relevant server class library, and get the server name and version Default is "unknown"
-
getModuleName
public java.lang.String getModuleName()
INTERNAL: getModuleName(): Answer the name of the module (jar name) that my session is associated with. Answer "unknown" if there is no module name available. Default behavior is to return "unknown".- Specified by:
getModuleName
in interfaceServerPlatform
- Returns:
- String moduleName
-
getExternalTransactionControllerClass
public abstract java.lang.Class getExternalTransactionControllerClass()
INTERNAL: getExternalTransactionControllerClass(): Answer the class of external transaction controller to use For this server platform. This is read-only. If the user wants a different external transaction controller class than the provided ServerPlatform(s), we recommend subclassing org.eclipse.persistence.platform.server.ServerPlatformBase (or a subclass), and overriding: ServerPlatformBase.getExternalTransactionControllerClass() for the desired behavior.- Specified by:
getExternalTransactionControllerClass
in interfaceServerPlatform
- Returns:
- Class externalTransactionControllerClass
- See Also:
JTATransactionController
,isJTAEnabled()
,disableJTA()
-
setExternalTransactionControllerClass
public void setExternalTransactionControllerClass(java.lang.Class newClass)
INTERNAL: setExternalTransactionControllerClass(Class newClass): Set the class of external transaction controller to use in the DatabaseSession. This is defined by the user via the sessions.xml.- Specified by:
setExternalTransactionControllerClass
in interfaceServerPlatform
- See Also:
JTATransactionController
,isJTAEnabled()
,disableJTA()
,initializeExternalTransactionController()
-
initializeExternalTransactionController
public void initializeExternalTransactionController()
INTERNAL: initializeExternalTransactionController(): Populate the DatabaseSession's external transaction controller with an instance of my transaction controller class. To change the external transaction controller class, we recommend creating a subclass of ServerPlatformBase, and overriding getExternalTransactionControllerClass().- Specified by:
initializeExternalTransactionController
in interfaceServerPlatform
- See Also:
ServerPlatformBase
-
externalTransactionControllerNotNullWarning
protected void externalTransactionControllerNotNullWarning()
INTERNAL: externalTransactionControllerNotNullWarning(): When the external transaction controller is being initialized, we warn the developer if they have already defined the external transaction controller in some way other than subclassing ServerPlatformBase.- See Also:
getExternalTransactionControllerClass()
-
isJTAEnabled
public boolean isJTAEnabled()
INTERNAL: isJTAEnabled(): Answer true if the DatabaseSession's external transaction controller class will be populated with my transaction controller class at runtime. If the transaction controller class is overridden in the DatabaseSession, my transaction controller class will be ignored. Answer true if TopLink will be configured to register for callbacks for beforeCompletion and afterCompletion.- Specified by:
isJTAEnabled
in interfaceServerPlatform
- Returns:
- boolean isJTAEnabled
- See Also:
getExternalTransactionControllerClass()
,disableJTA()
-
isRuntimeServicesEnabledDefault
public boolean isRuntimeServicesEnabledDefault()
INTERNAL: isRuntimeServicesEnabledDefault(): Answer true if the JMX/MBean providing runtime services for the receiver's DatabaseSession will be deployed at runtime. Provide the default value forisRuntimeServicesEnabled()
for a ServerPlatform. By default this isfalse
but some platforms can choose to have MBeans deployed by default.- Specified by:
isRuntimeServicesEnabledDefault
in interfaceServerPlatform
-
isRuntimeServicesEnabled
public boolean isRuntimeServicesEnabled()
INTERNAL: isRuntimeServicesEnabled(): Answer true if the JMX/MBean providing runtime services for the receiver's DatabaseSession will be deployed at runtime.- Specified by:
isRuntimeServicesEnabled
in interfaceServerPlatform
- Returns:
- boolean isRuntimeServicesEnabled
- See Also:
disableRuntimeServices()
-
disableRuntimeServices
public void disableRuntimeServices()
INTERNAL: disableRuntimeServices(): Configure the receiver such that no JMX/MBean will be registered to provide runtime services for my DatabaseSession at runtime.- Specified by:
disableRuntimeServices
in interfaceServerPlatform
- See Also:
isRuntimeServicesEnabled()
-
enableRuntimeServices
public void enableRuntimeServices()
INTERNAL: enableRuntimeServices(): Configure the receiver such that JMX/MBeans will be registered to provide runtime services for my DatabaseSession at runtime.- See Also:
isRuntimeServicesEnabled()
- Since:
- EclipseLink 2.2.0
-
disableJTA
public void disableJTA()
INTERNAL: disableJTA(): Configure the receiver such that my external transaction controller class will be ignored, and will NOT be used to populate DatabaseSession's external transaction controller class at runtime. TopLink will NOT be configured to register for callbacks for beforeCompletion and afterCompletion.- Specified by:
disableJTA
in interfaceServerPlatform
- See Also:
getExternalTransactionControllerClass()
,isJTAEnabled()
-
unwrapConnection
public java.sql.Connection unwrapConnection(java.sql.Connection connection)
INTERNAL: This method is used to unwrap the connection wrapped by the application server. TopLink needs this unwrapped connection for certain database vendor specific support. (i.e. TIMESTAMPTZ,NCHAR,XMLTYPE) Be default we will use the connection's metadata to try to get the connection- Specified by:
unwrapConnection
in interfaceServerPlatform
-
launchContainerRunnable
public void launchContainerRunnable(java.lang.Runnable runnable)
INTERNAL: launchContainerRunnable(Runnable runnable): Use the container library to start the provided Runnable. Default behavior is to use Thread(runnable).start()- Specified by:
launchContainerRunnable
in interfaceServerPlatform
- Parameters:
runnable
- : the instance of runnable to be "started"
-
ensureNotLoggedIn
protected void ensureNotLoggedIn()
INTERNAL: Make sure that the DatabaseSession has not logged in yet. Throw a ValidationException if we have.
-
getServerLog
public SessionLog getServerLog()
INTERNAL: getServerLog(): Return the ServerLog for this platform Return the default ServerLog in the base- Specified by:
getServerLog
in interfaceServerPlatform
- Returns:
- org.eclipse.persistence.logging.SessionLog
-
getThreadPoolSize
public int getThreadPoolSize()
Return the thread pool size.- Specified by:
getThreadPoolSize
in interfaceServerPlatform
-
setThreadPoolSize
public void setThreadPoolSize(int threadPoolSize)
Set the thread pool size.- Specified by:
setThreadPoolSize
in interfaceServerPlatform
-
getThreadPool
public java.util.concurrent.ExecutorService getThreadPool()
INTERNAL: Return the thread pool, initializing if required.
-
setThreadPool
public void setThreadPool(java.util.concurrent.ExecutorService threadPool)
INTERNAL: Set the thread pool to use.
-
isCMP
public boolean isCMP()
INTERNAL: isCMP(): Answer true if we're in the context of CMP (i.e. the container created me)- Returns:
- boolean
-
setIsCMP
public void setIsCMP(boolean isThisCMP)
INTERNAL: setIsCMP(boolean): Define whether or not we're in the context of CMP (i.e. the container created me)
-
shouldUseDriverManager
public boolean shouldUseDriverManager()
INTERNAL: shouldUseDriverManager(): Indicates whether DriverManager should be used while connecting DefaultConnector.- Specified by:
shouldUseDriverManager
in interfaceServerPlatform
- Returns:
- boolean
-
wasFailureCommunicationBased
public boolean wasFailureCommunicationBased(java.sql.SQLException exception, org.eclipse.persistence.internal.databaseaccess.Accessor connection, org.eclipse.persistence.internal.sessions.AbstractSession sessionForProfile)
INTERNAL: A call to this method will perform a platform based check on the connection and exception error code to determine if the connection is still valid or if a communication error has occurred. If a communication error has occurred then the query may be retried. If this platform is unable to determine if the error was communication based it will return false forcing the error to be thrown to the user.- Specified by:
wasFailureCommunicationBased
in interfaceServerPlatform
-
getNewTempClassLoader
public org.eclipse.persistence.internal.helper.JPAClassLoaderHolder getNewTempClassLoader(PersistenceUnitInfo puInfo)
Description copied from interface:ServerPlatform
INTERNAL: JIRA EJBTHREE-572 requires that we use the real classLoader in place of the getNewTempClassLoader(). The override code should stay in place until the UCL3 loader does not throw a NPE on loadClass()- Specified by:
getNewTempClassLoader
in interfaceServerPlatform
- Parameters:
puInfo
- - the persistence unit info- Returns:
- ClassLoaderHolder - a composite object containing the classLoader and the flag that is true if the classLoader returned is temporary
- See Also:
JPAClassLoaderHolder
-
clearStatementCache
public void clearStatementCache(java.sql.Connection connection)
INTERNAL: Clears statement cache of the wrapper connection. Required by Oracle proxy authentication: currently connection statement cache becomes invalid on switching to/from proxy session. This method is called by OracleJDBC_10_1_0_2ProxyConnectionCustomizer before opening proxy session and before closing it.- Specified by:
clearStatementCache
in interfaceServerPlatform
-
registerMBean
public void registerMBean()
INTERNAL: registerMBean(): Create and deploy the JMX MBean to provide runtime services for my databaseSession. Default is to do nothing.- Specified by:
registerMBean
in interfaceServerPlatform
- See Also:
isRuntimeServicesEnabled()
,disableRuntimeServices()
,unregisterMBean()
-
unregisterMBean
public void unregisterMBean()
INTERNAL: unregisterMBean(): Unregister the JMX MBean that was providing runtime services for my databaseSession.- Specified by:
unregisterMBean
in interfaceServerPlatform
- See Also:
isRuntimeServicesEnabled()
,disableRuntimeServices()
,registerMBean()
-
shutdown
public void shutdown()
INTERNAL: perform any require shutdown tasks.- Specified by:
shutdown
in interfaceServerPlatform
-
serverSpecificUnregisterMBean
public void serverSpecificUnregisterMBean()
INTERNAL: serverSpecificUnregisterMBean(): Server specific implementation of the unregistration of the JMX MBean from its server. Default is to do nothing. This should be subclassed if required.
-
serverSpecificRegisterMBean
public void serverSpecificRegisterMBean()
INTERNAL: serverSpecificRegisterMBean(): Server specific implementation of the creation and deployment of the JMX MBean to provide runtime services for my databaseSession. Default is to do nothing. This should be subclassed if required.
-
getJNDIConnectorLookupType
public int getJNDIConnectorLookupType()
Description copied from interface:ServerPlatform
INTERNAL: Get JNDIConnector lookupType value for this platform.- Specified by:
getJNDIConnectorLookupType
in interfaceServerPlatform
- Returns:
- Return JNDIConnector.COMPOSITE_NAME_LOOKUP.
-
getPartitionID
public java.lang.String getPartitionID()
Description copied from interface:ServerPlatform
INTERNAL: Get Partition ID.- Specified by:
getPartitionID
in interfaceServerPlatform
- Returns:
- partition ID
-
usesPartitions
public boolean usesPartitions()
Description copied from interface:ServerPlatform
INTERNAL: Some servers may support partitioning- Specified by:
usesPartitions
in interfaceServerPlatform
- Returns:
- true if server supports partitions, false otherwise
-
-