org.objectweb.jonas.resource
Class ResourceServiceImpl

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by org.objectweb.jonas.management.reconfig.emitter.ReconfigEmitter
          extended by org.objectweb.jonas.service.AbsServiceImpl
              extended by org.objectweb.jonas.resource.ResourceServiceImpl
All Implemented Interfaces:
NotificationBroadcaster, NotificationEmitter, 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 String AUTOLOADDIR
          Autoload directory property name
static String CLASS
          Service class property name
static String JONAS_BASE
          The name of the JONAS_BASE directory
static String PARSINGWITHVALIDATION
          Parsing validation property name
static String RARSDIR
          The name of the rars directory
static String RESOURCE_LIST
          Resources list property name
static String WORK_RARS_DIR
          The name of the working apps directory.
 
Fields inherited from class org.objectweb.jonas.management.reconfig.emitter.ReconfigEmitter
RECONFIG_TYPE, SAVE_RECONFIG_TYPE
 
Constructor Summary
ResourceServiceImpl()
          Default construtor for ResourceService
 
Method Summary
 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 doInit(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.
 List getAutoloadDirectories()
          Return the list of "autoload" directories for RAR containers.
 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.
 Set getRarNames()
          This method is added temporarily.
 String getRarsDirectory()
          Return the Rars directory.
 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 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.objectweb.jonas.service.AbsServiceImpl
getDomainName, getJonasServerName, getName, init, isStarted, setName, start, stop
 
Methods inherited from class org.objectweb.jonas.management.reconfig.emitter.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, 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 String AUTOLOADDIR
Autoload directory property name

See Also:
Constant Field Values

CLASS

public static final String CLASS
Service class property name

See Also:
Constant Field Values

PARSINGWITHVALIDATION

public static final String PARSINGWITHVALIDATION
Parsing validation property name

See Also:
Constant Field Values

RESOURCE_LIST

public static final String RESOURCE_LIST
Resources list property name

See Also:
Constant Field Values

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

ResourceServiceImpl

public ResourceServiceImpl()
Default construtor for ResourceService

Method Detail

doInit

public void doInit(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 String createResourceAdapter(Context ctx)
                             throws 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:
Exception - error encountered

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' 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 ResourceServiceImplMBean
Returns:
Integer Total Number of Resources available in JOnAS

getCurrentNumberOfRars

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

getDeployedRars

public List getDeployedRars()
Specified by:
getDeployedRars in interface ResourceServiceImplMBean
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 ResourceServiceImplMBean
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 ResourceServiceImplMBean
Returns:
the names of the rars currently deployed in the JOnAS server

deployRarMBean

public String deployRarMBean(String fileName)
                      throws 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:
RemoteException - if rmi call failed.
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 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 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.

unDeployRarMBean

public void unDeployRarMBean(String fileName)
                      throws 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:
RemoteException - if rmi call failed.
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 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.

getDeployableRars

public List getDeployableRars()
                       throws 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:
Exception - if error retrieving the list

getAutoloadDirectories

public 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 String getRarsDirectory()
Return the Rars directory.

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


Copyright © 2007 OW2 Consortium. All Rights Reserved.