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 Object implements ServerPlatform
PUBLIC: Implementation of org.eclipse.persistence.platform.server.ServerPlatform

This 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()
for the desired behavior.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    INTERNAL: Answer "unknown" as a default for platforms that do not implement getModuleName()
    protected Class
    externalTransactionControllerClass: This is a user-specifiable class defining the class of external transaction controller to be set into the DatabaseSession
    static final String
    This System property "eclipselink.register.dev.mbean" when set to true will enable registration/unregistration of the DevelopmentServices MBean
    static final String
    This System property "eclipselink.register.run.mbean" when set to true will enable registration/unregistration of the RuntimeServices MBean
    protected String
    INTERNAL: Server name and version.
    protected boolean
     
    protected boolean
     
    protected ExecutorService
    Allow pooling of threads for asynchronous processing in RCM and other areas.
    protected int
    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

    Modifier and Type
    Method
    Description
    void
    INTERNAL: Clears statement cache of the wrapper connection.
    void
    INTERNAL: configureProfiler(): set default performance profiler used in this server.
    void
    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
    INTERNAL: disableRuntimeServices(): Configure the receiver such that no JMX/MBean will be registered to provide runtime services for my DatabaseSession at runtime.
    void
    INTERNAL: enableRuntimeServices(): Configure the receiver such that JMX/MBeans will be registered to provide runtime services for my DatabaseSession at runtime.
    protected void
    INTERNAL: Make sure that the DatabaseSession has not logged in yet.
    protected void
    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.
    INTERNAL: getDatabaseSession(): Answer the instance of DatabaseSession the receiver is helping.
    abstract Class
    INTERNAL: getExternalTransactionControllerClass(): Answer the class of external transaction controller to use For this server platform.
    int
    INTERNAL: Get JNDIConnector lookupType value for this platform.
    INTERNAL: getModuleName(): Answer the name of the module (jar name) that my session is associated with.
    org.eclipse.persistence.internal.helper.JPAClassLoaderHolder
    getNewTempClassLoader(jakarta.persistence.spi.PersistenceUnitInfo puInfo)
    INTERNAL: JIRA EJBTHREE-572 requires that we use the real classLoader in place of the getNewTempClassLoader().
    INTERNAL: Get Partition ID.
    INTERNAL: getServerLog(): Return the ServerLog for this platform Return the default ServerLog in the base
    PUBLIC: getServerNameAndVersion(): Talk to the relevant server class library, and get the server name and version
    INTERNAL: Return the thread pool, initializing if required.
    int
    Return the thread pool size.
    void
    INTERNAL: initializeExternalTransactionController(): Populate the DatabaseSession's external transaction controller with an instance of my transaction controller class.
    protected void
    INTERNAL: initializeServerNameAndVersion(): Talk to the relevant server class library, and get the server name and version Default is "unknown"
    boolean
    INTERNAL: isCMP(): Answer true if we're in the context of CMP (i.e.
    boolean
    INTERNAL: Check whether JTA 1.1 API is available.
    boolean
    INTERNAL: isJTAEnabled(): Answer true if the DatabaseSession's external transaction controller class will be populated with my transaction controller class at runtime.
    boolean
    INTERNAL: isRuntimeServicesEnabled(): Answer true if the JMX/MBean providing runtime services for the receiver's DatabaseSession will be deployed at runtime.
    boolean
    INTERNAL: isRuntimeServicesEnabledDefault(): Answer true if the JMX/MBean providing runtime services for the receiver's DatabaseSession will be deployed at runtime.
    void
    INTERNAL: launchContainerRunnable(Runnable runnable): Use the container library to start the provided Runnable.
    void
    INTERNAL: registerMBean(): Create and deploy the JMX MBean to provide runtime services for my databaseSession.
    void
    INTERNAL: serverSpecificRegisterMBean(): Server specific implementation of the creation and deployment of the JMX MBean to provide runtime services for my databaseSession.
    void
    INTERNAL: serverSpecificUnregisterMBean(): Server specific implementation of the unregistration of the JMX MBean from its server.
    void
    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.
    void
    INTERNAL: Set the thread pool to use.
    void
    setThreadPoolSize(int threadPoolSize)
    Set the thread pool size.
    boolean
    INTERNAL: shouldUseDriverManager(): Indicates whether DriverManager should be used while connecting DefaultConnector.
    void
    INTERNAL: perform any require shutdown tasks.
    void
    INTERNAL: unregisterMBean(): Unregister the JMX MBean that was providing runtime services for my databaseSession.
    INTERNAL: This method is used to unwrap the connection wrapped by the application server.
    boolean
    INTERNAL: Some servers may support partitioning
    boolean
    wasFailureCommunicationBased(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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • JMX_REGISTER_DEV_MBEAN_PROPERTY

      public static final 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:
    • JMX_REGISTER_RUN_MBEAN_PROPERTY

      public static final 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:
    • DEFAULT_SERVER_NAME_AND_VERSION

      public static final 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 Class externalTransactionControllerClass
      externalTransactionControllerClass: This is a user-specifiable class defining the class of external transaction controller to be set into the DatabaseSession
    • serverNameAndVersion

      protected String serverNameAndVersion
      INTERNAL: Server name and version.
    • threadPoolSize

      protected int threadPoolSize
      Allow the thread pool size to be configured.
    • threadPool

      protected volatile ExecutorService threadPool
      Allow pooling of threads for asynchronous processing in RCM and other areas.
  • Constructor Details

    • 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 Details

    • 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 interface ServerPlatform
      Returns:
      DatabaseSession databaseSession
    • getServerNameAndVersion

      public String getServerNameAndVersion()
      PUBLIC: getServerNameAndVersion(): Talk to the relevant server class library, and get the server name and version
      Specified by:
      getServerNameAndVersion in interface ServerPlatform
      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 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 interface ServerPlatform
      Returns:
      String moduleName
    • getExternalTransactionControllerClass

      public abstract 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 interface ServerPlatform
      Returns:
      Class externalTransactionControllerClass
      See Also:
    • setExternalTransactionControllerClass

      public void setExternalTransactionControllerClass(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 interface ServerPlatform
      See Also:
    • 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 interface ServerPlatform
      See Also:
    • 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:
    • 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 interface ServerPlatform
      Returns:
      boolean isJTAEnabled
      See Also:
    • isJTA11

      public boolean isJTA11()
      INTERNAL: Check whether JTA 1.1 API is available.
      Returns:
      value of true when JTA 1.1 API is available or false otherwise.
    • 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 for isRuntimeServicesEnabled() for a ServerPlatform. By default this is false but some platforms can choose to have MBeans deployed by default.
      Specified by:
      isRuntimeServicesEnabledDefault in interface ServerPlatform
    • 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 interface ServerPlatform
      Returns:
      boolean isRuntimeServicesEnabled
      See Also:
    • 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 interface ServerPlatform
      See Also:
    • 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:
    • 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 interface ServerPlatform
      See Also:
    • unwrapConnection

      public Connection unwrapConnection(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 interface ServerPlatform
    • launchContainerRunnable

      public void launchContainerRunnable(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 interface ServerPlatform
      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 interface ServerPlatform
      Returns:
      org.eclipse.persistence.logging.SessionLog
    • getThreadPoolSize

      public int getThreadPoolSize()
      Return the thread pool size.
      Specified by:
      getThreadPoolSize in interface ServerPlatform
    • setThreadPoolSize

      public void setThreadPoolSize(int threadPoolSize)
      Set the thread pool size.
      Specified by:
      setThreadPoolSize in interface ServerPlatform
    • getThreadPool

      public ExecutorService getThreadPool()
      INTERNAL: Return the thread pool, initializing if required.
    • setThreadPool

      public void setThreadPool(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 interface ServerPlatform
      Returns:
      boolean
    • wasFailureCommunicationBased

      public boolean wasFailureCommunicationBased(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 interface ServerPlatform
    • getNewTempClassLoader

      public org.eclipse.persistence.internal.helper.JPAClassLoaderHolder getNewTempClassLoader(jakarta.persistence.spi.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 interface ServerPlatform
      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(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 interface ServerPlatform
    • 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 interface ServerPlatform
      See Also:
    • unregisterMBean

      public void unregisterMBean()
      INTERNAL: unregisterMBean(): Unregister the JMX MBean that was providing runtime services for my databaseSession.
      Specified by:
      unregisterMBean in interface ServerPlatform
      See Also:
    • shutdown

      public void shutdown()
      INTERNAL: perform any require shutdown tasks.
      Specified by:
      shutdown in interface ServerPlatform
    • 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.
      See Also:
    • 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.
      See Also:
    • getJNDIConnectorLookupType

      public int getJNDIConnectorLookupType()
      Description copied from interface: ServerPlatform
      INTERNAL: Get JNDIConnector lookupType value for this platform.
      Specified by:
      getJNDIConnectorLookupType in interface ServerPlatform
      Returns:
      Return JNDIConnector.COMPOSITE_NAME_LOOKUP.
    • getPartitionID

      public String getPartitionID()
      Description copied from interface: ServerPlatform
      INTERNAL: Get Partition ID.
      Specified by:
      getPartitionID in interface ServerPlatform
      Returns:
      partition ID
    • usesPartitions

      public boolean usesPartitions()
      Description copied from interface: ServerPlatform
      INTERNAL: Some servers may support partitioning
      Specified by:
      usesPartitions in interface ServerPlatform
      Returns:
      true if server supports partitions, false otherwise