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, ResourceService, Service

public class JOnASResourceService
extends AbsServiceImpl
implements 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 String JONAS_BASE
          The name of the JONAS_BASE 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 constructor for ResourceService.
 
Method Summary
 String createResourceAdapter(Context ctx)
          Create a new resource adapter.
 String deployRar(String fileName)
          Deploy the resource adapter
 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.
 Object getConfigObject(String jndiName)
          get the ConfigObj object matching the jndiName.
 ConnectorDesc getConnectorDesc(String jndiName)
          get the RAR ConnectorDesc object matching the JNDI name.
 Integer getCurrentNumberOfRars()
           
 Integer getCurrentNumberOfResource()
           
 List<String> getDeployedRars()
           
 String getJDBCResourceAdapater(String jndiName)
          Return the JDBC ResourceAdapter MBean OBJECT_NAME deployed in the current server having the 'jndiName' attribute value equal to the given jndiName.
 ObjectName[] getJDBCResourceAdapaters()
          Return the JDBC ResourceAdapter MBean ObjectNames deployed in the current server.
 JonasConnectorDesc getJonasConnectorDesc(String jndiName)
          get the RAR JonasConnectorDesc object matching the JNDI name.
 Rar getRar(String jndiName)
          get the Rar matching the jndiNname will be used in EJB container to deploy an MDB
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 setDeployerManager(org.ow2.util.ee.deploy.api.deployer.IDeployerManager deployerManager)
           
 void setDeploymentPlanDeployer(DeploymentPlanDeployer deploymentPlanDeployer)
          Sets the JOnAS deployment plan deployer service.
 void setJmxService(JmxService jmxService)
           
 void setParsingwithvalidation(boolean validate)
           
 void setRegistryService(RegistryService registry)
           
 void setTransactionService(TransactionService transactionService)
           
 void setWorkManagerService(WorkManagerService workManagerService)
           
 void unDeployRar(String filename)
          Undeploy the resource adapter.
 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, 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

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.

Constructor Detail

JOnASResourceService

public JOnASResourceService()
Default constructor for ResourceService.

Method Detail

setParsingwithvalidation

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

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 String createResourceAdapter(Context ctx)
                             throws 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 ResourceService
Parameters:
ctx - Context to use for deploying an RAR
Returns:
Sting resource objectName
Throws:
MalformedURLException
ResourceServiceException
NamingException

deployRars

public void deployRars(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(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 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' attribute 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 having the 'jndiName' attribute 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()
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<String> getDeployedRars()
Specified by:
getDeployedRars in interface JOnASResourceServiceMBean
Returns:
the list of RAR files deployed

deployRar

public String deployRar(String fileName)
                 throws ResourceServiceException
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:
Exception - if unable to deploy the rar
ResourceServiceException

isRarDeployed

public Boolean isRarDeployed(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(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.

unDeployRar

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

Specified by:
unDeployRar in interface 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 ResourceService
Parameters:
fileName - the name of the rar file.
Returns:
true if the rar is deployed, else false.

setTransactionService

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

setJmxService

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

setWorkManagerService

public void setWorkManagerService(WorkManagerService workManagerService)
Parameters:
workManagerService - the workManagerService to set

setDeployerManager

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

setDeploymentPlanDeployer

public void setDeploymentPlanDeployer(DeploymentPlanDeployer deploymentPlanDeployer)
Sets the JOnAS deployment plan deployer service.

Parameters:
deploymentPlanDeployer - the JOnAS deployment plan deployer service.

setRegistryService

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

getRar

public 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 ResourceService
Parameters:
jndiName - jndi name to lookup
Returns:
Rar Rar object for the specified jndi name

getConnectorDesc

public ConnectorDesc getConnectorDesc(String jndiName)
get the RAR ConnectorDesc object matching the JNDI name.

Parameters:
jndiName - the JNDI name to lookup
Returns:
ConnectorDesc matching ConnectorDesc

getJonasConnectorDesc

public JonasConnectorDesc getJonasConnectorDesc(String jndiName)
get the RAR JonasConnectorDesc object matching the JNDI name.

Parameters:
jndiName - the JNDI name 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 © 2010 OW2 Consortium. All Rights Reserved.