org.ow2.jonas.resource.internal
Class JOnASResourceService

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.resource.internal.JOnASResourceService
All Implemented Interfaces:
NotificationBroadcaster, NotificationEmitter, JOnASResourceServiceMBean, org.ow2.jonas.resource.ResourceService, org.ow2.jonas.service.Service

public class JOnASResourceService
extends org.ow2.jonas.lib.service.AbsServiceImpl
implements org.ow2.jonas.resource.ResourceService, JOnASResourceServiceMBean

JCA resource service implementation.

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 Hashtable fileName2RA
          Hashtable mapping a filename to an RAR object
static Hashtable jndiName2RA
          Associate a Rar with its jndi name
static String JONAS_BASE
          The name of the JONAS_BASE directory
static String RARSDIR
          The name of the rars directory
static String WORK_RARS_DIR
          The name of the working apps directory.
 
Fields inherited from class org.ow2.jonas.lib.reconfig.ReconfigEmitter
RECONFIG_TYPE, SAVE_RECONFIG_TYPE
 
Constructor Summary
JOnASResourceService()
          Default construtor for ResourceService.
 
Method Summary
 void checkRequirements()
          
 String createResourceAdapter(Context ctx)
          Create a new resource adapter.
 String deployRar(String fileName)
          Deploy the resource adapter
 String deployRarMBean(String fileName)
          Deploy an RAR by delegating the operation to the createResourceAdapter method.
 void deployRars(Context ctx)
          Deploy the given rars of an ear file with the specified parent classloader (ear classloader).
 void doStart()
          Start the Resource service.
 void doStop()
          Stop the Resource service.
 List getAutoloadDirectories()
          Return the list of "autoload" directories for RAR containers.
 Object getConfigObject(String jndiName)
          get the ConfigObj object matching the jndiName
 org.ow2.jonas.deployment.rar.ConnectorDesc getConnectorDesc(String jndiName)
          get the RAR ConnectorDesc object matching the jndiname
 Integer getCurrentNumberOfRars()
           
 Integer getCurrentNumberOfResource()
           
 List getDeployableRars()
          Return the list of installed RAR container ready to deploy.
 List getDeployedRars()
           
 List getInstalledRars()
          Return the list of installed RAR containers.
 String getJDBCResourceAdapater(String jndiName)
          Return the JDBC ResourceAdapter MBean OBJECT_NAME deployed in the current server haveing the 'jndiName' attribue value equal to the given jndiName
 ObjectName[] getJDBCResourceAdapaters()
          Return the JDBC ResourceAdapter MBean ObjectNames deployed in the current server.
 org.ow2.jonas.deployment.rar.JonasConnectorDesc getJonasConnectorDesc(String jndiName)
          get the RAR JonasConnectorDesc object matching the jndiname
 org.ow2.jonas.resource.Rar getRar(String jndiName)
          get the Rar matching the jndiNname will be used in EJB container to deploy an MDB
 Set getRarNames()
          This method is added temporarily.
 String getRarsDirectory()
          Return the Rars directory.
static Object getResourceObject(String jndiName)
          get the ResourceAdapter matching the jndiName will be used in ResourceObjectJNDIHandler class at lookup time
 String getXmlContent(String jndiName)
          get the ResourceAdapter Connector object matching the jndiName
 Boolean isRarDeployed(String fileName)
          Test if the specified filename is already deployed or not.
 boolean isRarDeployedByUnpackName(String unpackName)
          Test if the specified unpack name is already deployed or not.
 boolean isRarLoaded(String fileName)
          Test if the specified filename is already deployed or not
 void setAutoloaddir(String directories)
           
 void setDeployerManager(org.ow2.util.ee.deploy.api.deployer.IDeployerManager deployerManager)
           
 void setJmxService(org.ow2.jonas.jmx.JmxService jmxService)
           
 void setParsingwithvalidation(boolean validate)
           
 void setRegistryService(org.ow2.jonas.registry.RegistryService registry)
           
 void setResources(String resources)
           
 void setTransactionService(org.ow2.jonas.tm.TransactionService transactionService)
           
 void setWorkManagerService(org.ow2.jonas.workmanager.WorkManagerService workManagerService)
           
 void unDeployRar(String fileName)
          Undeploy the resource adapter
 void unDeployRarMBean(String fileName)
          Undeploy an RAR by delegating the operation to the unRegisterRar() method.
 void unDeployRars(URL[] urls, URL earUrl)
          Undeploy the given rars of an ear file.
 void unRegisterRar(Context ctx)
          Unregister the resource adapter.
 
Methods inherited from class org.ow2.jonas.lib.service.AbsServiceImpl
convertToList, doInit, getDomainName, getJonasServerName, getName, getServerProperties, init, isOSGi, 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

jndiName2RA

public static Hashtable jndiName2RA
Associate a Rar with its jndi name


fileName2RA

public static Hashtable fileName2RA
Hashtable mapping a filename to an RAR object


JONAS_BASE

public static final String JONAS_BASE
The name of the JONAS_BASE directory


WORK_RARS_DIR

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


RARSDIR

public static final String RARSDIR
The name of the rars directory

Constructor Detail

JOnASResourceService

public JOnASResourceService()
Default construtor for ResourceService.

Method Detail

checkRequirements

public void checkRequirements()
                       throws org.ow2.jonas.service.ServiceException

Specified by:
checkRequirements in interface org.ow2.jonas.service.Service
Overrides:
checkRequirements in class org.ow2.jonas.lib.service.AbsServiceImpl
Throws:
org.ow2.jonas.service.ServiceException
See Also:
AbsServiceImpl.checkRequirements()

setAutoloaddir

public void setAutoloaddir(String directories)
Parameters:
directories - Autoloaded directories.

setResources

public void setResources(String resources)
Parameters:
resources - initial set of resources to be deployed.

setParsingwithvalidation

public void setParsingwithvalidation(boolean validate)
Parameters:
validate - Use a validating XML parser ?

doStart

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

Specified by:
doStart in class org.ow2.jonas.lib.service.AbsServiceImpl
Throws:
org.ow2.jonas.service.ServiceException - if the startup failed.

doStop

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

Specified by:
doStop in class org.ow2.jonas.lib.service.AbsServiceImpl
Throws:
org.ow2.jonas.service.ServiceException - if the stop failed.

createResourceAdapter

public String createResourceAdapter(Context ctx)
                             throws org.ow2.jonas.resource.ResourceServiceException,
                                    NamingException,
                                    MalformedURLException
Create a new resource adapter. This Resource Adapter is configured via xml files in the rar file

Specified by:
createResourceAdapter in interface org.ow2.jonas.resource.ResourceService
Parameters:
ctx - Context to use for deploying an RAR
Returns:
Sting resource objectName
Throws:
MalformedURLException
Exception - error encountered
org.ow2.jonas.resource.ResourceServiceException
NamingException

deployRars

public void deployRars(Context ctx)
                throws org.ow2.jonas.resource.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 org.ow2.jonas.resource.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:
org.ow2.jonas.resource.ResourceServiceException - if an error occurs during the deployment.

unDeployRars

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

Specified by:
unDeployRars in interface org.ow2.jonas.resource.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(Context ctx)
                   throws Exception
Unregister the resource adapter.

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

getJDBCResourceAdapaters

public ObjectName[] getJDBCResourceAdapaters()
                                      throws 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:
Exception - The ResourceAdapter MBeans checking failed.

getJDBCResourceAdapater

public String getJDBCResourceAdapater(String jndiName)
                               throws 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:
Exception - The ResourceAdapter MBeans checking failed.

getCurrentNumberOfResource

public Integer getCurrentNumberOfResource()
Specified by:
getCurrentNumberOfResource in interface JOnASResourceServiceMBean
Returns:
Integer Total Number of Resources available in JOnAS

getCurrentNumberOfRars

public Integer getCurrentNumberOfRars()
Specified by:
getCurrentNumberOfRars in interface JOnASResourceServiceMBean
Returns:
Integer Total Number of Rars available in JOnAS

getDeployedRars

public List getDeployedRars()
Specified by:
getDeployedRars in interface JOnASResourceServiceMBean
Returns:
the list of RAR files deployed

getInstalledRars

public List getInstalledRars()
                      throws 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 JOnASResourceServiceMBean
Returns:
The list of RAR files or the directories with expanded RAR container found
Throws:
Exception - if the list can't be retrieved

getRarNames

public 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 JOnASResourceServiceMBean
Returns:
the names of the rars currently deployed in the JOnAS server

deployRarMBean

public String deployRarMBean(String fileName)
                      throws RemoteException,
                             org.ow2.jonas.resource.ResourceServiceException
Deploy an RAR by delegating the operation to the createResourceAdapter method. This is used for JMX management.

Specified by:
deployRarMBean in interface JOnASResourceServiceMBean
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:
RemoteException - if rmi call failed.
org.ow2.jonas.resource.ResourceServiceException - if the deployment of the RAR failed.

deployRar

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

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

isRarDeployed

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

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

isRarDeployedByUnpackName

public boolean isRarDeployedByUnpackName(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 org.ow2.jonas.resource.ResourceService
Parameters:
unpackName - the name of the rar file.
Returns:
true if the rar is deployed, else false.

unDeployRarMBean

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

Specified by:
unDeployRarMBean in interface JOnASResourceServiceMBean
Parameters:
fileName - the fileName of the rar which must be be undeployed.
Throws:
RemoteException - if rmi call failed.
org.ow2.jonas.resource.ResourceServiceException - if the undeployment of the RAR failed.

unDeployRar

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

Specified by:
unDeployRar in interface org.ow2.jonas.resource.ResourceService
Parameters:
fileName - the name of the rar file.
Throws:
Exception - if not able to undeploy the rar

isRarLoaded

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

Specified by:
isRarLoaded in interface org.ow2.jonas.resource.ResourceService
Parameters:
fileName - the name of the rar file.
Returns:
true if the rar is deployed, else false.

getDeployableRars

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

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

getAutoloadDirectories

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

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

getRarsDirectory

public String getRarsDirectory()
Return the Rars directory.

Specified by:
getRarsDirectory in interface JOnASResourceServiceMBean
Returns:
The Rars directory

setTransactionService

public void setTransactionService(org.ow2.jonas.tm.TransactionService transactionService)
Parameters:
transactionService - the transactionService to set

setJmxService

public void setJmxService(org.ow2.jonas.jmx.JmxService jmxService)
Parameters:
jmxService - the jmxService to set

setWorkManagerService

public void setWorkManagerService(org.ow2.jonas.workmanager.WorkManagerService workManagerService)
Parameters:
workManagerService - the workManagerService to set

setDeployerManager

public void setDeployerManager(org.ow2.util.ee.deploy.api.deployer.IDeployerManager deployerManager)
Parameters:
deployerManagerService - the deployerManagerService to set

setRegistryService

public void setRegistryService(org.ow2.jonas.registry.RegistryService registry)
Parameters:
registry - the registry service to set

getRar

public org.ow2.jonas.resource.Rar getRar(String jndiName)
get the Rar matching the jndiNname will be used in EJB container to deploy an MDB

Specified by:
getRar in interface org.ow2.jonas.resource.ResourceService
Parameters:
jndiName - jndi name to lookup
Returns:
Rar Rar object for the specified jndi name

getConnectorDesc

public org.ow2.jonas.deployment.rar.ConnectorDesc getConnectorDesc(String jndiName)
get the RAR ConnectorDesc object matching the jndiname

Parameters:
jndiName - the jndiname to lookup
Returns:
ConnectorDesc matching ConnectorDesc

getJonasConnectorDesc

public org.ow2.jonas.deployment.rar.JonasConnectorDesc getJonasConnectorDesc(String jndiName)
get the RAR JonasConnectorDesc object matching the jndiname

Parameters:
jndiName - the jndiname to lookup
Returns:
JonasConnectorDesc matching JonasConnectorDesc

getResourceObject

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

Parameters:
jndiName - to lookup ResourceObject
Returns:
Object resourceObject corresponding to jndiName

getXmlContent

public String getXmlContent(String jndiName)
get the ResourceAdapter Connector object matching the jndiName

Parameters:
jndiName - String of jndi name
Returns:
String for the jndiName

getConfigObject

public Object getConfigObject(String jndiName)
get the ConfigObj object matching the jndiName

Parameters:
jndiName - String of jndi name
Returns:
Object for the jndiName


Copyright © 2007 OW2 Consortium. All Rights Reserved.