org.objectweb.jonas.dbm
Class DataBaseServiceImpl

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by org.objectweb.jonas.management.ReconfigDispatcher
          extended by org.objectweb.jonas.service.AbsServiceImpl
              extended by org.objectweb.jonas.dbm.DataBaseServiceImpl
All Implemented Interfaces:
javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, DataBaseService, DataBaseServiceImplMBean, ReconfigDispatcherMBean, 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.

03/05/25 Introduce pool size configuration 04/09/20 Create JSR77 MBeans JDBCResource, JDBCDataSource JDBCDriver


Field Summary
static java.lang.String CONNCHECKLEVEL
           
static java.lang.String CONNMAXAGE
           
static java.lang.String CONNTESTSTMT
           
static java.lang.String JDBCResourceName
          Our naming convention for JDBCResource ObjectName (value of the 'name' key property)
static java.lang.String MAXOPENTIME
           
static java.lang.String PSTMTMAX
           
 
Fields inherited from class org.objectweb.jonas.management.ReconfigDispatcher
RECONFIG_TYPE, SAVE_RECONFIG_TYPE
 
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 Datasource
 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.util.List getDataSourcePropertiesFiles()
          MBean method:
 java.util.Collection getDSList()
          return the list of the datasources
 java.lang.Integer getTotalCurrentNumberOfJDBCConnectionOpen()
          MBean method:
 boolean isLoadedDataSource(java.lang.String dsName)
          MBean method:
 void loadDataSource(java.lang.String name, java.util.Properties prop, java.lang.Boolean loadFromFile)
          MBean method: load a new datasource
 void unbindDataSources()
          Unbind dataSource names from the registry, unregister MBeans
 void unloadDataSource(java.lang.String name)
          MBean method:
 
Methods inherited from class org.objectweb.jonas.service.AbsServiceImpl
getDomainName, getJonasServerName, getName, init, isStarted, setName, start, stop
 
Methods inherited from class org.objectweb.jonas.management.ReconfigDispatcher
addNotificationListener, getFilter, getHandback, getListener, getNotificationInfo, initLogger, removeNotificationListener, sendReconfigNotification, sendSaveNotification
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
handleNotification, removeNotificationListener, sendNotification
 
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
 

Field Detail

CONNCHECKLEVEL

public static final java.lang.String CONNCHECKLEVEL
See Also:
Constant Field Values

CONNMAXAGE

public static final java.lang.String CONNMAXAGE
See Also:
Constant Field Values

MAXOPENTIME

public static final java.lang.String MAXOPENTIME
See Also:
Constant Field Values

CONNTESTSTMT

public static final java.lang.String CONNTESTSTMT
See Also:
Constant Field Values

PSTMTMAX

public static final java.lang.String PSTMTMAX
See Also:
Constant Field Values

JDBCResourceName

public static final java.lang.String JDBCResourceName
Our naming convention for JDBCResource ObjectName (value of the 'name' key property)

See Also:
Constant Field Values
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.

Specified by:
doInit in class AbsServiceImpl
Parameters:
ctx - configuration of the service
Throws:
ServiceException - service initialization failed

doStart

public void doStart()
             throws ServiceException
Starting DataBase service Initialization of the service is already done.

Specified by:
doStart in class AbsServiceImpl
Throws:
ServiceException - service start-up failed

doStop

public void doStop()
            throws ServiceException
Stopping DataBase service Unbind Datasource

Specified by:
doStop in class AbsServiceImpl
Throws:
ServiceException - service stopping failed

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
Throws:
java.lang.Exception

unbindDataSources

public void unbindDataSources()
                       throws javax.naming.NamingException
Unbind dataSource names from the registry, unregister MBeans

Specified by:
unbindDataSources in interface DataBaseService
Throws:
javax.naming.NamingException

getConnectionManager

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


getDSList

public java.util.Collection getDSList()
return the list of the datasources

Returns:

getDataSourcePropertiesFiles

public java.util.List getDataSourcePropertiesFiles()
                                            throws java.lang.Exception
MBean method:

Specified by:
getDataSourcePropertiesFiles in interface DataBaseServiceImplMBean
Returns:
the list of properties files describing datasources found in JONAS_BASE/conf
Throws:
java.lang.Exception

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:

Specified by:
isLoadedDataSource in interface DataBaseServiceImplMBean
Parameters:
dsName - the name of the datasource to be checked if loaded
Returns:
true if the datasource having thid jndi name is loadd

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
Throws:
java.lang.Exception

loadDataSource

public void loadDataSource(java.lang.String name,
                           java.util.Properties prop,
                           java.lang.Boolean loadFromFile)
                    throws ServiceException
MBean method: load a new datasource

Specified by:
loadDataSource in interface DataBaseServiceImplMBean
Parameters:
name - datasource name
prop - datasource properties
loadFromFile - if false the datasource creation was dynamicaly invoked by a management operation providing the properties in the prop object.
Throws:
ServiceException - datasource could not be created

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