org.objectweb.jonas.dbm
Class DataBaseServiceImpl

java.lang.Object
  |
  +--org.objectweb.jonas.service.AbsServiceImpl
        |
        +--org.objectweb.jonas.dbm.DataBaseServiceImpl
All Implemented Interfaces:
DataBaseService, DataBaseServiceImplMBean, Service

public class DataBaseServiceImpl
extends AbsServiceImpl
implements DataBaseService, DataBaseServiceImplMBean

DatabaseService acts as a factory for the DataSource objects. Its goal is to create such objects and to register them in JNDI

Author:
Philippe Durieux Contributor(s): 00/18/04 Jun Inamori (j-office@osa.att.ne.jp) New implementation of unbindDataSources for closing correctly all connections at server shutdown. 03/01/14 Adriana Danes Highlight Configuration properties Change createDataSource() signature : take additional argument, the datasource name Manage binded datasources (mapping of jndi name to datasource name) Use datasource name for naming MBeans (instead of jndi name) Modify MBean methods to take into account the previous points.

Constructor Summary
DataBaseServiceImpl()
           
 
Method Summary
 void createDataSource(java.lang.String datasourceName, java.util.Properties dsd)
          Creates a ConnectionManager (implementation of sql.dataSource).
 void doInit(javax.naming.Context ctx)
          Initialization of the DataBase service.
 void doStart()
          Starting DataBase service Initialization of the service is already done.
 void doStop()
          Stopping DataBase service Unbind DataSources
 ConnectionManager getConnectionManager(java.lang.String dsname)
          get ConnectionManager for the datasource having this JNDI name.
 java.lang.Integer getCurrentNumberOfDataSource()
          MBean method:
 java.lang.String getDatasourceName(java.lang.String jndiName)
          MBean method allowing to determine the datasource name from its jndi name
 java.util.Properties getDataSourcePropertiesFile(java.lang.String dsFile)
          MBean method:
 java.lang.Integer getTotalCurrentNumberOfJDBCConnectionOpen()
          MBean method:
static JonasXAPoolDataSource getXAPoolDataSource(java.lang.String dsname)
          get the XAPoolDataSource matching the DataSource name
 boolean isLoadedDataSource(java.lang.String dsName)
          MBean method:
 void loadDataSource(java.lang.String name, java.util.Properties prop)
          MBean method: load a new datasource
 void traceJdbc()
          Propagation of the new configuration of the trace functionnalities in the driver
 void unbindDataSources()
          Unbind dataSource names from the Naming
 void unloadDataSource(java.lang.String name)
          MBean method:
 
Methods inherited from class org.objectweb.jonas.service.AbsServiceImpl
getName, init, isStarted, setName, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.jonas.service.Service
getName, init, isStarted, setName, start, stop
 

Constructor Detail

DataBaseServiceImpl

public DataBaseServiceImpl()
Method Detail

doInit

public void doInit(javax.naming.Context ctx)
            throws ServiceException
Initialization of the DataBase service. Configuration information is passed thru a Context object.
Overrides:
doInit in class AbsServiceImpl

doStart

public void doStart()
             throws ServiceException
Starting DataBase service Initialization of the service is already done.
Overrides:
doStart in class AbsServiceImpl

doStop

public void doStop()
            throws ServiceException
Stopping DataBase service Unbind DataSources
Overrides:
doStop in class AbsServiceImpl

createDataSource

public void createDataSource(java.lang.String datasourceName,
                             java.util.Properties dsd)
                      throws java.lang.Exception
Creates a ConnectionManager (implementation of sql.dataSource).
Specified by:
createDataSource in interface DataBaseService
Parameters:
datasourceName - - datasource name
dsd - - a set of properties that describes a dataSource and the ConnectionPool

If datasource.factory is set, we create a JonasXAPoolDataSource. If not set, we create an old fashioned ConnectionManager


traceJdbc

public void traceJdbc()
Propagation of the new configuration of the trace functionnalities in the driver

unbindDataSources

public void unbindDataSources()
                       throws javax.naming.NamingException
Description copied from interface: DataBaseService
Unbind dataSource names from the Naming
Specified by:
unbindDataSources in interface DataBaseService

getXAPoolDataSource

public static JonasXAPoolDataSource getXAPoolDataSource(java.lang.String dsname)
get the XAPoolDataSource matching the DataSource name

getConnectionManager

public ConnectionManager getConnectionManager(java.lang.String dsname)
get ConnectionManager for the datasource having this JNDI name.

getCurrentNumberOfDataSource

public java.lang.Integer getCurrentNumberOfDataSource()
MBean method:
Specified by:
getCurrentNumberOfDataSource in interface DataBaseServiceImplMBean
Returns:
Integer Total Number of Datasource available in JOnAS

getTotalCurrentNumberOfJDBCConnectionOpen

public java.lang.Integer getTotalCurrentNumberOfJDBCConnectionOpen()
MBean method:
Specified by:
getTotalCurrentNumberOfJDBCConnectionOpen in interface DataBaseServiceImplMBean
Returns:
Integer Total Number of JDBC connection open

isLoadedDataSource

public boolean isLoadedDataSource(java.lang.String dsName)
MBean method:
Returns:
true if the datasource having thid jndi name is loaded

unloadDataSource

public void unloadDataSource(java.lang.String name)
MBean method:
Specified by:
unloadDataSource in interface DataBaseServiceImplMBean
Parameters:
name - of the data source to unload

getDataSourcePropertiesFile

public java.util.Properties getDataSourcePropertiesFile(java.lang.String dsFile)
                                                 throws java.lang.Exception
MBean method:
Specified by:
getDataSourcePropertiesFile in interface DataBaseServiceImplMBean
Returns:
datasource properties from a local file

loadDataSource

public void loadDataSource(java.lang.String name,
                           java.util.Properties prop)
                    throws java.rmi.RemoteException
MBean method: load a new datasource
Specified by:
loadDataSource in interface DataBaseServiceImplMBean
Parameters:
name - datasource name
prop - datasource properties

getDatasourceName

public java.lang.String getDatasourceName(java.lang.String jndiName)
MBean method allowing to determine the datasource name from its jndi name
Specified by:
getDatasourceName in interface DataBaseServiceImplMBean
Parameters:
jndiName - The jndi name of a datasource
Returns:
The datasource name