org.ow2.jonas.dbm.internal
Class JOnASDataBaseManagerService

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by org.ow2.jonas.lib.reconfig.ReconfigEmitter
          extended by org.ow2.jonas.lib.service.AbsServiceImpl
              extended by org.ow2.jonas.dbm.internal.JOnASDataBaseManagerService
All Implemented Interfaces:
NotificationBroadcaster, NotificationEmitter, DataBaseService, DBMConstants, JOnASDataBaseManagerServiceMBean, Service

public class JOnASDataBaseManagerService
extends AbsServiceImpl
implements DataBaseService, JOnASDataBaseManagerServiceMBean, DBMConstants

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 bound 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 String JDBC_RESOURCE_NAME
          Our naming convention for JDBCResource ObjectName (value of the 'name' key property).
 
Fields inherited from class org.ow2.jonas.lib.reconfig.ReconfigEmitter
RECONFIG_TYPE, SAVE_RECONFIG_TYPE
 
Fields inherited from interface org.ow2.jonas.dbm.internal.DBMConstants
ADJUSTPERIOD, CLASSNAME, CONNCHECKLEVEL, CONNMAXAGE, CONNTESTSTMT, DEF_ADJUSTPERIOD, DEF_CLASSNAME, DEF_CONNCHECKLEVEL, DEF_CONNMAXAGE, DEF_CONNTESTSTMT, DEF_DESCRIPTION, DEF_ISOLATIONLEVEL, DEF_MAPPERNAME, DEF_MAXCONPOOL, DEF_MAXOPENTIME, DEF_MAXWAITERS, DEF_MAXWAITTIME, DEF_MINCONPOOL, DEF_PASSWORD, DEF_PSTMTMAX, DEF_SAMPLINGPERIOD, DEF_URL, DEF_USERNAME, DESCRIPTION, ISOLATIONLEVEL, MAPPERNAME, MAXCONPOOL, MAXOPENTIME, MAXWAITERS, MAXWAITTIME, MINCONPOOL, NAME, PASSWORD, PSTMTMAX, SAMPLINGPERIOD, URL, USERNAME
 
Constructor Summary
JOnASDataBaseManagerService()
           
 
Method Summary
 void createDataSource(String datasourceName, Properties dsd)
          Creates a ConnectionManager (implementation of DataSource).
 void doStart()
          Starting DataBase service Initialization of the service is already done.
 void doStop()
          Stopping DataBase service.
 ConnectionManager getConnectionManager(String dsname)
          get ConnectionManager for the datasource having this JNDI name.
 Integer getCurrentNumberOfDataSource()
          MBean method.
 String getDatasourceName(String jndiName)
          MBean method allowing to determine the datasource name from its jndi name.
 Properties getDataSourcePropertiesFile(String dsFile)
          MBean method.
 List getDataSourcePropertiesFiles()
          MBean method.
 Collection<ConnectionManager> getDSList()
          return the list of the datasources.
 Integer getTotalCurrentNumberOfJDBCConnectionOpen()
          MBean method.
 boolean isLoadedDataSource(String dsName)
          MBean method.
 void loadDataSource(String name, Properties prop, Boolean loadFromFile)
          MBean method.
 void setDatasources(String datasources)
           
 void setJmxService(JmxService jmxService)
           
 void setRegistryService(RegistryService registry)
           
 void setTransactionService(TransactionService txService)
           
 void unbindDataSources()
          Unbind dataSource names from the registry, unregister MBeans.
 void unloadDataSource(String name)
          MBean method.
 
Methods inherited from class org.ow2.jonas.lib.service.AbsServiceImpl
convertToList, doInit, getDomainName, getJonasServerName, getName, getServerProperties, init, isStarted, setName, setServerProperties, start, stop, throwRequirementException, toString
 
Methods inherited from class org.ow2.jonas.lib.reconfig.ReconfigEmitter
initLogger, sendReconfigNotification, sendSaveNotification
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ow2.jonas.service.Service
getName, init, isStarted, setName, start, stop
 

Field Detail

JDBC_RESOURCE_NAME

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

See Also:
Constant Field Values
Constructor Detail

JOnASDataBaseManagerService

public JOnASDataBaseManagerService()
Method Detail

setDatasources

public void setDatasources(String datasources)
Parameters:
datasources - datasources to deploy at startup.

doStart

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

Specified by:
doStart in class AbsServiceImpl
Throws:
ServiceException - exception

doStop

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

Specified by:
doStop in class AbsServiceImpl
Throws:
ServiceException - exception

createDataSource

public void createDataSource(String datasourceName,
                             Properties dsd)
                      throws Exception
Creates a ConnectionManager (implementation of DataSource).

Specified by:
createDataSource in interface DataBaseService
Parameters:
datasourceName - datasource name
dsd - a set of properties that describes a dataSource and the ConnectionPool
Throws:
Exception

unbindDataSources

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

Specified by:
unbindDataSources in interface DataBaseService
Throws:
NamingException

getConnectionManager

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


getDSList

public Collection<ConnectionManager> getDSList()
return the list of the datasources.

Returns:

getDataSourcePropertiesFiles

public List getDataSourcePropertiesFiles()
                                  throws Exception
MBean method.

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

getCurrentNumberOfDataSource

public Integer getCurrentNumberOfDataSource()
MBean method.

Specified by:
getCurrentNumberOfDataSource in interface JOnASDataBaseManagerServiceMBean
Returns:
Integer Total Number of Datasource available in JOnAS

getTotalCurrentNumberOfJDBCConnectionOpen

public Integer getTotalCurrentNumberOfJDBCConnectionOpen()
MBean method.

Specified by:
getTotalCurrentNumberOfJDBCConnectionOpen in interface JOnASDataBaseManagerServiceMBean
Returns:
Integer Total Number of JDBC connection open

isLoadedDataSource

public boolean isLoadedDataSource(String dsName)
MBean method.

Specified by:
isLoadedDataSource in interface JOnASDataBaseManagerServiceMBean
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(String name)
MBean method. Allows undeploy datasource.

Specified by:
unloadDataSource in interface JOnASDataBaseManagerServiceMBean
Parameters:
name - of the data source to unload

getDataSourcePropertiesFile

public Properties getDataSourcePropertiesFile(String dsFile)
                                       throws Exception
MBean method. Return a datasource properties from a local file.

Specified by:
getDataSourcePropertiesFile in interface JOnASDataBaseManagerServiceMBean
Parameters:
dsFile - file name
Returns:
datasource properties
Throws:
Exception - could not read properties file

loadDataSource

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

Specified by:
loadDataSource in interface JOnASDataBaseManagerServiceMBean
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 String getDatasourceName(String jndiName)
MBean method allowing to determine the datasource name from its jndi name.

Specified by:
getDatasourceName in interface JOnASDataBaseManagerServiceMBean
Parameters:
jndiName - The jndi name of a datasource
Returns:
The datasource name

setTransactionService

public void setTransactionService(TransactionService txService)
Parameters:
txService - the TransactionService to set

setJmxService

public void setJmxService(JmxService jmxService)
Parameters:
jmxService - the jmxService to set

setRegistryService

public void setRegistryService(RegistryService registry)
Parameters:
registry - the registry servic to set


Copyright © 2010 OW2 Consortium. All Rights Reserved.