org.objectweb.jonas.resource
Class ResourceServiceImpl

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.resource.ResourceServiceImpl
All Implemented Interfaces:
javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, ReconfigDispatcherMBean, ResourceService, ResourceServiceImplMBean, Service

public class ResourceServiceImpl
extends AbsServiceImpl
implements ResourceService, ResourceServiceImplMBean

JCA resource service implmentation

Author:
Philippe Coq Contributor(s): JOnAS 2.4 Sebastien Chassande-Barrioz (sebastien.chassande@inrialpes.fr) JOnAS 3.0 Eric Hardesty (Eric.Hardesty@bull.com) JOnAS 4.0 Adriana Danes (JSR 77 + use of Jakarta Modeler Component : http://jakarta.apache.org/commons/modeler) Eric Hardesty (J2CA 1.5)

Field Summary
static java.lang.String AUTOLOADDIR
          Autoload directory property name
static java.lang.String CLASS
          Service class property name
static int DEF_EXEC_TIME
          Maximum work execution timeout (0 is unlimited)
static int DEF_MAX_WRK_THREADS
          Default max number of work threads
static int DEF_WRK_THREADS
          Default number of work threads
static int DEF_WRK_THREADWAITTIMEOUT
          Default work thread timeout
static java.lang.String EXECTIMEOUT
          Work max execution timeout property name
static java.lang.String FACTORY_OFFSET
          Factory offset property name
static java.lang.String FACTORY_TYPE
          Factory type property name
static java.lang.String JNDI_NAME
          Jndiname property name
static java.lang.String JONAS_BASE
          The name of the JONAS_BASE directory
static java.lang.String JONAS_RA_XML
          Jonas ra.xml property name
static java.lang.String LNK_JNDI_NAME
          Jndiname link property name
static java.lang.String LNK_RAR_FILENAME
          Link Rar filename property name
static java.lang.String MAXWORKTHREADS
          Maximum number of work threads property name
static java.lang.String MINWORKTHREADS
          Minimum number of work threads property name
static java.lang.String PARSINGWITHVALIDATION
          Parsing validation property name
static java.lang.String RA_XML
          ra.xml property name
static java.lang.String RAR_FILENAME
          Rar filename property name
static java.lang.String RAR_OBJNAME
          Rar object property name
static java.lang.String RARSDIR
          The name of the rars directory
static java.lang.String RESOURCE_LIST
          Resources list property name
static java.lang.String THREADWAITTIMEOUT
          Thread timeout
static java.lang.String WORK_RARS_DIR
          The name of the working apps directory.
 
Fields inherited from class org.objectweb.jonas.management.ReconfigDispatcher
RECONFIG_TYPE, SAVE_RECONFIG_TYPE
 
Constructor Summary
ResourceServiceImpl()
          Default construtor for ResourceService
 
Method Summary
 java.lang.String createResourceAdapter(javax.naming.Context ctx)
          Create a new resource adapter.
 java.lang.String deployRar(java.lang.String fileName)
          Deploy the resource adapter
 java.lang.String deployRarMBean(java.lang.String fileName)
          Deploy an RAR by delegating the operation to the createResourceAdapter method.
 void deployRars(javax.naming.Context ctx)
          Deploy the given rars of an ear file with the specified parent classloader (ear classloader).
 void doInit(javax.naming.Context ctx)
          - Get the loggers - Get the global jndi context - Get the list of the resource adapters.
 void doStart()
          Start the Resource service.
 void doStop()
          Stop the Resource service.
 java.util.List getAutoloadDirectories()
          Return the list of "autoload" directories for RAR containers.
 java.lang.Integer getCurrentNumberOfRars()
           
 java.lang.Integer getCurrentNumberOfResource()
           
 java.util.List getDeployableRars()
          Return the list of installed RAR container ready to deploy.
 java.util.List getDeployedRars()
           
 java.util.List getInstalledRars()
          Return the list of installed RAR containers.
 java.lang.String getJDBCResourceAdapater(java.lang.String jndiName)
          Return the JDBC ResourceAdapter MBean OBJECT_NAME deployed in the current server haveing the 'jndiName' attribue value equal to the given jndiName
 javax.management.ObjectName[] getJDBCResourceAdapaters()
          Return the JDBC ResourceAdapter MBean ObjectNames deployed in the current server.
 java.util.Set getRarNames()
          This method is added temporarily.
 java.lang.String getRarsDirectory()
          Return the Rars directory.
 java.lang.Boolean isRarDeployed(java.lang.String fileName)
          Test if the specified filename is already deployed or not.
 boolean isRarDeployedByUnpackName(java.lang.String unpackName)
          Test if the specified unpack name is already deployed or not.
 boolean isRarLoaded(java.lang.String fileName)
          Test if the specified filename is already deployed or not
 void unDeployRar(java.lang.String fileName)
          Undeploy the resource adapter
 void unDeployRarMBean(java.lang.String fileName)
          Undeploy an RAR by delegating the operation to the unRegisterRar() method.
 void unDeployRars(java.net.URL[] urls, java.net.URL earUrl)
          Undeploy the given rars of an ear file.
 void unRegisterRar(javax.naming.Context ctx)
          Unregister the resource adapter.
 
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

AUTOLOADDIR

public static final java.lang.String AUTOLOADDIR
Autoload directory property name

See Also:
Constant Field Values

CLASS

public static final java.lang.String CLASS
Service class property name

See Also:
Constant Field Values

JNDI_NAME

public static final java.lang.String JNDI_NAME
Jndiname property name

See Also:
Constant Field Values

RAR_OBJNAME

public static final java.lang.String RAR_OBJNAME
Rar object property name

See Also:
Constant Field Values

FACTORY_OFFSET

public static final java.lang.String FACTORY_OFFSET
Factory offset property name

See Also:
Constant Field Values

FACTORY_TYPE

public static final java.lang.String FACTORY_TYPE
Factory type property name

See Also:
Constant Field Values

RAR_FILENAME

public static final java.lang.String RAR_FILENAME
Rar filename property name

See Also:
Constant Field Values

LNK_JNDI_NAME

public static final java.lang.String LNK_JNDI_NAME
Jndiname link property name

See Also:
Constant Field Values

LNK_RAR_FILENAME

public static final java.lang.String LNK_RAR_FILENAME
Link Rar filename property name

See Also:
Constant Field Values

JONAS_RA_XML

public static final java.lang.String JONAS_RA_XML
Jonas ra.xml property name

See Also:
Constant Field Values

RA_XML

public static final java.lang.String RA_XML
ra.xml property name

See Also:
Constant Field Values

PARSINGWITHVALIDATION

public static final java.lang.String PARSINGWITHVALIDATION
Parsing validation property name

See Also:
Constant Field Values

RESOURCE_LIST

public static final java.lang.String RESOURCE_LIST
Resources list property name

See Also:
Constant Field Values

THREADWAITTIMEOUT

public static final java.lang.String THREADWAITTIMEOUT
Thread timeout

See Also:
Constant Field Values

MINWORKTHREADS

public static final java.lang.String MINWORKTHREADS
Minimum number of work threads property name

See Also:
Constant Field Values

MAXWORKTHREADS

public static final java.lang.String MAXWORKTHREADS
Maximum number of work threads property name

See Also:
Constant Field Values

EXECTIMEOUT

public static final java.lang.String EXECTIMEOUT
Work max execution timeout property name

See Also:
Constant Field Values

DEF_WRK_THREADWAITTIMEOUT

public static final int DEF_WRK_THREADWAITTIMEOUT
Default work thread timeout

See Also:
Constant Field Values

DEF_WRK_THREADS

public static final int DEF_WRK_THREADS
Default number of work threads

See Also:
Constant Field Values

DEF_MAX_WRK_THREADS

public static final int DEF_MAX_WRK_THREADS
Default max number of work threads

See Also:
Constant Field Values

DEF_EXEC_TIME

public static final int DEF_EXEC_TIME
Maximum work execution timeout (0 is unlimited)

See Also:
Constant Field Values

JONAS_BASE

public static final java.lang.String JONAS_BASE
The name of the JONAS_BASE directory


WORK_RARS_DIR

public static final java.lang.String WORK_RARS_DIR
The name of the working apps directory.


RARSDIR

public static final java.lang.String RARSDIR
The name of the rars directory

Constructor Detail

ResourceServiceImpl

public ResourceServiceImpl()
Default construtor for ResourceService

Method Detail

doInit

public void doInit(javax.naming.Context ctx)
- Get the loggers - Get the global jndi context - Get the list of the resource adapters. The list is reachable in the - context parameter under the name RESOURCE_LIST. - Get the transaction manager into the jndi - Set the XML validation property

Specified by:
doInit in class AbsServiceImpl
Parameters:
ctx - Context

doStart

public void doStart()
             throws ServiceException
Start the Resource service.

Specified by:
doStart in class AbsServiceImpl
Throws:
ServiceException - if the startup failed.

doStop

public void doStop()
            throws ServiceException
Stop the Resource service.

Specified by:
doStop in class AbsServiceImpl
Throws:
ServiceException - if the stop failed.

createResourceAdapter

public java.lang.String createResourceAdapter(javax.naming.Context ctx)
                                       throws java.lang.Exception
Create a new resource adapter. This Resource Adapter is configured via xml files in the rar file

Specified by:
createResourceAdapter in interface ResourceService
Parameters:
ctx - Context to use for deploying an RAR
Returns:
Sting resource objectName
Throws:
java.lang.Exception - error encountered

deployRars

public void deployRars(javax.naming.Context ctx)
                throws ResourceServiceException
Deploy the given rars of an ear file with the specified parent classloader (ear classloader). (This method is only used for for ear applications).

Specified by:
deployRars in interface ResourceService
Parameters:
ctx - the context containing the configuration to deploy the rars.
This context contains the following parameters :
- urls the list of the urls of the rars to deploy.
- earRootURL the URL of the ear application file.
- earClassLoader the ear classLoader of the j2ee app.
- altDDs the optional URI of deployment descriptor.
Throws:
ResourceServiceException - if an error occurs during the deployment.

unDeployRars

public void unDeployRars(java.net.URL[] urls,
                         java.net.URL earUrl)
Undeploy the given rars of an ear file. (This method is only used for the ear applications).

Specified by:
unDeployRars in interface ResourceService
Parameters:
urls - the list of the urls of the rars to undeploy.
earUrl - the URL of the associated EAR file

unRegisterRar

public void unRegisterRar(javax.naming.Context ctx)
                   throws java.lang.Exception
Unregister the resource adapter.

Parameters:
ctx - Context to use for unregistering an RAR
Throws:
java.lang.Exception - error encountered

getJDBCResourceAdapaters

public javax.management.ObjectName[] getJDBCResourceAdapaters()
                                                       throws java.lang.Exception
Return the JDBC ResourceAdapter MBean ObjectNames deployed in the current server. The JDBC ResourceAdapters have a 'properties' attribue containing the following properties set (not null and not empty): 'dsClass', 'URL'.

Returns:
The found MBean ObjectNames or null if no JDBC ResourceAdapter MBean registered for the current server in the current domain.
Throws:
java.lang.Exception - The ResourceAdapter MBeans checking failed.

getJDBCResourceAdapater

public java.lang.String getJDBCResourceAdapater(java.lang.String jndiName)
                                         throws java.lang.Exception
Return the JDBC ResourceAdapter MBean OBJECT_NAME deployed in the current server haveing the 'jndiName' attribue value equal to the given jndiName

Parameters:
jndiName - A DataSource jndi name we are looking for.
Returns:
The found MBean OBJECT_NAME or null if none of the JDBC ResourceAdapter MBean have the given jndi name.
Throws:
java.lang.Exception - The ResourceAdapter MBeans checking failed.

getCurrentNumberOfResource

public java.lang.Integer getCurrentNumberOfResource()
Specified by:
getCurrentNumberOfResource in interface ResourceServiceImplMBean
Returns:
Integer Total Number of Resources available in JOnAS

getCurrentNumberOfRars

public java.lang.Integer getCurrentNumberOfRars()
Specified by:
getCurrentNumberOfRars in interface ResourceServiceImplMBean
Returns:
Integer Total Number of Rars available in JOnAS

getDeployedRars

public java.util.List getDeployedRars()
Specified by:
getDeployedRars in interface ResourceServiceImplMBean
Returns:
the list of RAR files deployed

getInstalledRars

public java.util.List getInstalledRars()
                                throws java.lang.Exception
Return the list of installed RAR containers. The RAR files or the directories with expanded RAR container are searched in JONAS_BASE/rars and all rar directories 'autoload'.

Specified by:
getInstalledRars in interface ResourceServiceImplMBean
Returns:
The list of RAR files or the directories with expanded RAR container found
Throws:
java.lang.Exception - if the list can't be retrieved

getRarNames

public java.util.Set getRarNames()
This method is added temporarily. It will disapear when Rars will have their associated MBeans (when Rars will become manageable)

Specified by:
getRarNames in interface ResourceServiceImplMBean
Returns:
the names of the rars currently deployed in the JOnAS server

deployRarMBean

public java.lang.String deployRarMBean(java.lang.String fileName)
                                throws java.rmi.RemoteException,
                                       ResourceServiceException
Deploy an RAR by delegating the operation to the createResourceAdapter method. This is used for JMX management.

Specified by:
deployRarMBean in interface ResourceServiceImplMBean
Parameters:
fileName - the fileName of the rar which must be be deployed.
Returns:
The ObjectName of the MBean associated to the deployed J2EE Application
Throws:
java.rmi.RemoteException - if rmi call failed.
ResourceServiceException - if the deployment of the RAR failed.

deployRar

public java.lang.String deployRar(java.lang.String fileName)
                           throws java.lang.Exception
Deploy the resource adapter

Specified by:
deployRar in interface ResourceService
Parameters:
fileName - the name of the rar file.
Returns:
String ObjectName of the deployed rar
Throws:
java.lang.Exception - if unable to deploy the rar

isRarDeployed

public java.lang.Boolean isRarDeployed(java.lang.String fileName)
Test if the specified filename is already deployed or not.

Specified by:
isRarDeployed in interface ResourceService
Parameters:
fileName - the name of the rar file.
Returns:
true if the rar is deployed, else false.

isRarDeployedByUnpackName

public boolean isRarDeployedByUnpackName(java.lang.String unpackName)
Test if the specified unpack name is already deployed or not. This method is defined in the ResourceService interface.

Specified by:
isRarDeployedByUnpackName in interface ResourceService
Parameters:
unpackName - the name of the rar file.
Returns:
true if the rar is deployed, else false.

unDeployRarMBean

public void unDeployRarMBean(java.lang.String fileName)
                      throws java.rmi.RemoteException,
                             ResourceServiceException
Undeploy an RAR by delegating the operation to the unRegisterRar() method. This is used for JMX management.

Specified by:
unDeployRarMBean in interface ResourceServiceImplMBean
Parameters:
fileName - the fileName of the rar which must be be undeployed.
Throws:
java.rmi.RemoteException - if rmi call failed.
ResourceServiceException - if the undeployment of the RAR failed.

unDeployRar

public void unDeployRar(java.lang.String fileName)
                 throws java.lang.Exception
Undeploy the resource adapter

Specified by:
unDeployRar in interface ResourceService
Parameters:
fileName - the name of the rar file.
Throws:
java.lang.Exception - if not able to undeploy the rar

isRarLoaded

public boolean isRarLoaded(java.lang.String fileName)
Test if the specified filename is already deployed or not

Specified by:
isRarLoaded in interface ResourceServiceImplMBean
Parameters:
fileName - the name of the rar file.
Returns:
true if the rar is deployed, else false.

getDeployableRars

public java.util.List getDeployableRars()
                                 throws java.lang.Exception
Return the list of installed RAR container ready to deploy.

Specified by:
getDeployableRars in interface ResourceServiceImplMBean
Returns:
The list of deployable RAR container
Throws:
java.lang.Exception - if error retrieving the list

getAutoloadDirectories

public java.util.List getAutoloadDirectories()
Return the list of "autoload" directories for RAR containers.

Specified by:
getAutoloadDirectories in interface ResourceServiceImplMBean
Returns:
The list of all "autoload" directories

getRarsDirectory

public java.lang.String getRarsDirectory()
Return the Rars directory.

Specified by:
getRarsDirectory in interface ResourceService
Specified by:
getRarsDirectory in interface ResourceServiceImplMBean
Returns:
The Rars directory