org.objectweb.jonas.resource
Class ResourceServiceImpl

java.lang.Object
  extended byjavax.management.NotificationBroadcasterSupport
      extended byorg.objectweb.jonas.management.ReconfigDispatcher
          extended byorg.objectweb.jonas.service.AbsServiceImpl
              extended byorg.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
           
static java.lang.String CLASS
           
static int DEF_EXEC_TIME
           
static int DEF_WRK_THREADS
           
static java.lang.String EXECTIMEOUT
           
static java.lang.String JNDI_NAME
           
static java.lang.String JONAS_RA_XML
           
static java.lang.String LNK_JNDI_NAME
           
static java.lang.String LNK_RAR_FILENAME
           
 java.lang.String MANAGED_CONNECTION_FACTORY_CLASS
           
static java.lang.String PARSINGWITHVALIDATION
           
static java.lang.String RA_XML
           
static java.lang.String RAR_FILENAME
           
static java.lang.String RESOURCE_LIST
           
static java.lang.String WORKTHREADS
           
 
Fields inherited from class org.objectweb.jonas.management.ReconfigDispatcher
RECONFIG_TYPE, SAVE_RECONFIG_TYPE
 
Constructor Summary
ResourceServiceImpl()
           
ResourceServiceImpl(boolean client)
           
 
Method Summary
static void addDefaultAS(java.lang.String jndiName)
          add a default AS to the list, the first one deployed is the default if others are added then they will become default if this one is undeployed
 java.lang.String createClientResourceAdapter(javax.naming.Context ctx, ConnectorDesc conn, JonasConnectorDesc jConn)
           
 java.lang.String createResourceAdapter(javax.naming.Context ctx)
          Create a Resource Adapter
 java.lang.Object createResourceObject(java.lang.String jndiName, java.lang.String rarFileName, ConnectorDesc conn, JonasConnectorDesc jConn)
          create the ResourceAdapter the jndiname will be used to return the factory
 java.lang.Object createResourceObject(java.lang.String jndiName, java.lang.String rarFileName, java.lang.String lnkJndiName, java.lang.String lnkRarFileName)
          create the ResourceAdapter the jndiname will be used to return the factory
 java.lang.String deployRar(java.lang.String fileName)
          Deploy an RAR, used by management applications via J2EEServer managed object
 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()
          Abstract start-up method to be implemented by sub-classes
 void doStop()
          Abstract method for service stopping to be implemented by sub-classes
static java.lang.Object getActivationSpec(java.lang.String jndiName)
          get the ActivationSpec matching the jndiNname will be used in EJB container to get an ActivationSpec
static java.lang.Object getAdminObject(java.lang.String jndiName)
          get the AdminObject matching the jndiNname will be used in EJB container to get an AdminObject
 java.util.List getAutoloadDirectories()
          Return the list of "autoload" directories for RAR containers.
static java.lang.Object getConfigObj(java.lang.String jndiName)
          get the ConfigObj matching the jndiName
static ConnectorDesc getConnectorDesc(java.lang.String jndiName)
          get the RAR ConnectorDesc object matching the jndiname
 java.lang.Integer getCurrentNumberOfRars()
           
 java.lang.Integer getCurrentNumberOfResource()
           
static java.lang.String getDefaultAS()
          return the current default ActivationSpec
 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.
static ResourceServiceImpl getInstance()
           
static JonasConnectorDesc getJonasConnectorDesc(java.lang.String jndiName)
          get the RAR JonasConnectorDesc object matching the jndiname
static Rar getRar(java.lang.String jndiName)
          get the Rar matching the jndiNname will be used in EJB container to deploy an MDB
 java.util.Set getRarNames()
          This method is added temporarily.
 java.lang.String getRarsDirectory()
          Return the Rars directory.
static java.lang.Object getResourceObject(java.lang.String jndiName)
          get the ResourceAdapter matching the jndiName will be used in ResourceObjectJNDIHandler class at lookup time
static java.lang.String getXmlContent(java.lang.String jndiName)
          get the RAR XmlContent for the jndiname
 java.lang.Boolean isRarDeployed(java.lang.String fileName)
          Test if the specified filename is already deployed or not.
 boolean isRarLoaded(java.lang.String fileName)
          Test if the specified filename is already deployed or not
static void removeDefaultAS(java.lang.String jndiName)
          remove the specified jndiName from the default AS list
 void unDeployRar(java.lang.String fileName)
          Undeploy an RAR, used by management applications via J2EEServer managed object
 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)
           
 
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
See Also:
Constant Field Values

CLASS

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

JNDI_NAME

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

RAR_FILENAME

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

LNK_JNDI_NAME

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

LNK_RAR_FILENAME

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

JONAS_RA_XML

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

RA_XML

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

PARSINGWITHVALIDATION

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

RESOURCE_LIST

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

WORKTHREADS

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

EXECTIMEOUT

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

MANAGED_CONNECTION_FACTORY_CLASS

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

DEF_WRK_THREADS

public static final int DEF_WRK_THREADS
See Also:
Constant Field Values

DEF_EXEC_TIME

public static final int DEF_EXEC_TIME
See Also:
Constant Field Values
Constructor Detail

ResourceServiceImpl

public ResourceServiceImpl()

ResourceServiceImpl

public ResourceServiceImpl(boolean client)
Method Detail

getInstance

public static ResourceServiceImpl getInstance()

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 - configuration of the service

doStart

public void doStart()
             throws ServiceException
Description copied from class: AbsServiceImpl
Abstract start-up method to be implemented by sub-classes

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

doStop

public void doStop()
            throws ServiceException
Description copied from class: AbsServiceImpl
Abstract method for service stopping to be implemented by sub-classes

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

createResourceAdapter

public java.lang.String createResourceAdapter(javax.naming.Context ctx)
                                       throws java.lang.Exception
Description copied from interface: ResourceService
Create a Resource Adapter

Specified by:
createResourceAdapter in interface ResourceService
Throws:
java.lang.Exception

createClientResourceAdapter

public java.lang.String createClientResourceAdapter(javax.naming.Context ctx,
                                                    ConnectorDesc conn,
                                                    JonasConnectorDesc jConn)
                                             throws java.lang.Exception
Throws:
java.lang.Exception

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

getResourceObject

public static java.lang.Object getResourceObject(java.lang.String jndiName)
get the ResourceAdapter matching the jndiName will be used in ResourceObjectJNDIHandler class at lookup time


createResourceObject

public java.lang.Object createResourceObject(java.lang.String jndiName,
                                             java.lang.String rarFileName,
                                             ConnectorDesc conn,
                                             JonasConnectorDesc jConn)
create the ResourceAdapter the jndiname will be used to return the factory


createResourceObject

public java.lang.Object createResourceObject(java.lang.String jndiName,
                                             java.lang.String rarFileName,
                                             java.lang.String lnkJndiName,
                                             java.lang.String lnkRarFileName)
create the ResourceAdapter the jndiname will be used to return the factory


getAdminObject

public static java.lang.Object getAdminObject(java.lang.String jndiName)
get the AdminObject matching the jndiNname will be used in EJB container to get an AdminObject


getActivationSpec

public static java.lang.Object getActivationSpec(java.lang.String jndiName)
get the ActivationSpec matching the jndiNname will be used in EJB container to get an ActivationSpec


getRar

public static Rar getRar(java.lang.String jndiName)
get the Rar matching the jndiNname will be used in EJB container to deploy an MDB


addDefaultAS

public static void addDefaultAS(java.lang.String jndiName)
add a default AS to the list, the first one deployed is the default if others are added then they will become default if this one is undeployed


getDefaultAS

public static java.lang.String getDefaultAS()
return the current default ActivationSpec


removeDefaultAS

public static void removeDefaultAS(java.lang.String jndiName)
remove the specified jndiName from the default AS list


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
Description copied from interface: ResourceService
Deploy an RAR, used by management applications via J2EEServer managed object

Specified by:
deployRar in interface ResourceService
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.lang.Exception - if the deployment of the RAR failed.

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.

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
Description copied from interface: ResourceService
Undeploy an RAR, used by management applications via J2EEServer managed object

Specified by:
unDeployRar in interface ResourceService
Parameters:
fileName - the fileName of the rar which must be be undeployed.
Throws:
java.lang.Exception - if the undeployment of the RAR failed.

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

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
Returns:
The Rars directory

getConnectorDesc

public static ConnectorDesc getConnectorDesc(java.lang.String jndiName)
get the RAR ConnectorDesc object matching the jndiname


getJonasConnectorDesc

public static JonasConnectorDesc getJonasConnectorDesc(java.lang.String jndiName)
get the RAR JonasConnectorDesc object matching the jndiname


getConfigObj

public static java.lang.Object getConfigObj(java.lang.String jndiName)
get the ConfigObj matching the jndiName


getXmlContent

public static java.lang.String getXmlContent(java.lang.String jndiName)
get the RAR XmlContent for the jndiname