org.jboss.deployment
Class SubDeployerSupport

java.lang.Object
  extended by org.jboss.mx.util.JBossNotificationBroadcasterSupport
      extended by org.jboss.system.ServiceMBeanSupport
          extended by org.jboss.deployment.SubDeployerSupport
All Implemented Interfaces:
javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, SubDeployer, SubDeployerExt, SubDeployerExtMBean, SubDeployerMBean, Service, ServiceMBean
Direct Known Subclasses:
JARDeployer, SARDeployer, SimpleSubDeployerSupport, XSLSubDeployer

public abstract class SubDeployerSupport
extends ServiceMBeanSupport
implements SubDeployerExt, SubDeployerExtMBean

An abstract SubDeployer. Provides registration with MainDeployer as well as implementations of init, create, start, stop and destroy that generate JMX notifications on completion of the method.

Version:
$Revision: 1.25.2.8 $
Author:
Jason Dillon, Scott Stark, Dimitris Andreadis

Nested Class Summary
protected static class SubDeployerSupport.ClassConfiguration
          Static configuration properties for this class.
 
Field Summary
protected static SubDeployerSupport.ClassConfiguration CONFIGURATION
          The singleton class configuration object for this class.
protected  String[] enhancedSuffixes
          The list of enhancedSuffixes for this subdeployer
protected  MainDeployerMBean mainDeployer
          A proxy to the MainDeployer.
protected static String nativePrefix
          Holds the native library prefix for this system.
protected static String nativeSuffix
          Holds the native library suffix for this system.
protected  int relativeOrder
          The relative order of this subdeployer - not really used
protected  String[] suffixes
          The suffixes of interest to this subdeployer
protected  File tempDeployDir
          The temporary directory into which deployments are unpacked
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.deployment.SubDeployer
CREATE_NOTIFICATION, DESTROY_NOTIFICATION, INIT_NOTIFICATION, RELATIVE_ORDER_100, RELATIVE_ORDER_200, RELATIVE_ORDER_300, RELATIVE_ORDER_400, RELATIVE_ORDER_500, RELATIVE_ORDER_600, RELATIVE_ORDER_700, RELATIVE_ORDER_800, RELATIVE_ORDER_900, START_NOTIFICATION, STOP_NOTIFICATION
 
Fields inherited from interface org.jboss.system.ServiceMBean
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
SubDeployerSupport()
           
 
Method Summary
 boolean accepts(DeploymentInfo sdi)
          A default implementation that uses the suffixes registered through either setSuffixes() or setEnhancedSuffixes(), to decide if a module is deployable by this deployer.
protected  void addDeployableFiles(DeploymentInfo di, File dir)
          This method recursively searches the directory structure for any files that are deployable (@see isDeployable).
protected  void addDeployableJar(DeploymentInfo di, JarFile jarFile)
          This method searches the entire jar file for any deployable files (@see isDeployable).
 void create(DeploymentInfo di)
          Sub-classes should override this method to provide custom 'create' logic.
protected  void createService()
          The createService method is one of the ServiceMBean lifecyle operations.
protected  void deployUrl(DeploymentInfo di, URL url, String name)
           
 void destroy(DeploymentInfo di)
          Sub-classes should override this method to provide custom 'destroy' logic.
protected  void destroyService()
          Clean up.
protected  void emitNotification(String type, DeploymentInfo di)
          Simple helper to emit a subdeployer notification containing DeploymentInfo
 String[] getEnhancedSuffixes()
          Get an array of enhancedSuffixes
 int getRelativeOrder()
          Get the relative order of the specified suffixes
 String[] getSuffixes()
          Get an array of suffixes of interest to this subdeployer
 void init(DeploymentInfo di)
          Sub-classes should override this method to provide custom 'init' logic.
protected  boolean isDeployable(String name, URL url)
          This method returns true if the name is a recognized archive file.
protected  void processNestedDeployments(DeploymentInfo di)
          The processNestedDeployments method searches for any nested and deployable elements.
 void setEnhancedSuffixes(String[] enhancedSuffixes)
          Set the enhanced suffixes list for this deployer, causing also the supported suffixes list to be updated.
protected  void setRelativeOrder(int relativeOrder)
          Set the relative order of the specified suffixes all to the same value.
protected  void setSuffixes(String[] suffixes)
          Set an array of suffixes of interest to this subdeployer.
 void start(DeploymentInfo di)
          Sub-classes should override this method to provide custom 'start' logic.
protected  void startService()
          Performs SubDeployer registration.
 void stop(DeploymentInfo di)
          Sub-classes should override this method to provide custom 'stop' logic.
protected  void stopService()
          Performs SubDeployer deregistration.
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport
create, destroy, getDeploymentInfo, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, nextNotificationSequenceNumber, 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.jboss.deployment.SubDeployer
getServiceName
 
Methods inherited from interface org.jboss.deployment.SubDeployerMBean
getServiceName
 
Methods inherited from interface org.jboss.system.ServiceMBean
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service
create, destroy, start, stop
 

Field Detail

nativeSuffix

protected static final String nativeSuffix
Holds the native library suffix for this system. Determined by examining the result of System.mapLibraryName(specialToken). The special token defaults to "XxX", but can be changed by setting the system property: org.jboss.deployment.SubDeployerSupport.nativeLibToken.


nativePrefix

protected static final String nativePrefix
Holds the native library prefix for this system.

See Also:
nativeSuffix

mainDeployer

protected MainDeployerMBean mainDeployer
A proxy to the MainDeployer.


tempDeployDir

protected File tempDeployDir
The temporary directory into which deployments are unpacked


enhancedSuffixes

protected String[] enhancedSuffixes
The list of enhancedSuffixes for this subdeployer


suffixes

protected String[] suffixes
The suffixes of interest to this subdeployer


relativeOrder

protected int relativeOrder
The relative order of this subdeployer - not really used


CONFIGURATION

protected static final SubDeployerSupport.ClassConfiguration CONFIGURATION
The singleton class configuration object for this class.

Constructor Detail

SubDeployerSupport

public SubDeployerSupport()
Method Detail

createService

protected void createService()
                      throws Exception
The createService method is one of the ServiceMBean lifecyle operations. (no jmx tag needed from superinterface)

Overrides:
createService in class ServiceMBeanSupport
Throws:
Exception - if an error occurs

startService

protected void startService()
                     throws Exception
Performs SubDeployer registration.

Overrides:
startService in class ServiceMBeanSupport
Throws:
Exception

stopService

protected void stopService()
                    throws Exception
Performs SubDeployer deregistration.

Overrides:
stopService in class ServiceMBeanSupport
Throws:
Exception

destroyService

protected void destroyService()
                       throws Exception
Clean up.

Overrides:
destroyService in class ServiceMBeanSupport
Throws:
Exception

setSuffixes

protected void setSuffixes(String[] suffixes)
Set an array of suffixes of interest to this subdeployer. No need to register twice suffixes that may refer to unpacked deployments (e.g. .sar, .sar/).

Parameters:
suffixes - array of suffix strings

setRelativeOrder

protected void setRelativeOrder(int relativeOrder)
Set the relative order of the specified suffixes all to the same value.

Parameters:
relativeOrder - the relative order of the specified suffixes

setEnhancedSuffixes

public void setEnhancedSuffixes(String[] enhancedSuffixes)
Set the enhanced suffixes list for this deployer, causing also the supported suffixes list to be updated. Each enhanced suffix entries has the form: [order:]suffix No need to register twice suffixes that may refer to unpacked deployments (e.g. .sar, .sar/).

Specified by:
setEnhancedSuffixes in interface SubDeployerExt
Specified by:
setEnhancedSuffixes in interface SubDeployerExtMBean
Parameters:
enhancedSuffixes -

getEnhancedSuffixes

public String[] getEnhancedSuffixes()
Get an array of enhancedSuffixes

Specified by:
getEnhancedSuffixes in interface SubDeployerExt
Specified by:
getEnhancedSuffixes in interface SubDeployerExtMBean
Returns:
array of enhanced suffix strings

getSuffixes

public String[] getSuffixes()
Get an array of suffixes of interest to this subdeployer

Specified by:
getSuffixes in interface SubDeployer
Specified by:
getSuffixes in interface SubDeployerMBean
Returns:
array of suffix strings

getRelativeOrder

public int getRelativeOrder()
Get the relative order of the specified suffixes

Specified by:
getRelativeOrder in interface SubDeployer
Specified by:
getRelativeOrder in interface SubDeployerMBean
Returns:
the relative order of the specified suffixes

accepts

public boolean accepts(DeploymentInfo sdi)
A default implementation that uses the suffixes registered through either setSuffixes() or setEnhancedSuffixes(), to decide if a module is deployable by this deployer. If (according to DeploymentInfo) the deployment refers to a directory, but not an xml or script deployment, then the deployment suffix will be checked also against the registered suffixes + "/".

Specified by:
accepts in interface SubDeployer
Specified by:
accepts in interface SubDeployerMBean
Parameters:
sdi - the DeploymentInfo to check
Returns:
whether the deployer can handle the deployment

init

public void init(DeploymentInfo di)
          throws DeploymentException
Sub-classes should override this method to provide custom 'init' logic.

This method calls the processNestedDeployments(di) method and then issues a JMX notification of type SubDeployer.INIT_NOTIFICATION. This behaviour can overridden by concrete sub-classes. If further initialization needs to be done, and you wish to preserve the functionality, be sure to call super.init(di) at the end of your implementation.

Specified by:
init in interface SubDeployer
Specified by:
init in interface SubDeployerMBean
Parameters:
di - a DeploymentInfo value
Throws:
DeploymentException - if an error occurs

create

public void create(DeploymentInfo di)
            throws DeploymentException
Sub-classes should override this method to provide custom 'create' logic. This method issues a JMX notification of type SubDeployer.CREATE_NOTIFICATION.

Specified by:
create in interface SubDeployer
Specified by:
create in interface SubDeployerMBean
Parameters:
di - a DeploymentInfo value
Throws:
DeploymentException - if an error occurs

start

public void start(DeploymentInfo di)
           throws DeploymentException
Sub-classes should override this method to provide custom 'start' logic. This method issues a JMX notification of type SubDeployer.START_NOTIFICATION.

Specified by:
start in interface SubDeployer
Specified by:
start in interface SubDeployerMBean
Parameters:
di - a DeploymentInfo value
Throws:
DeploymentException - if an error occurs

stop

public void stop(DeploymentInfo di)
          throws DeploymentException
Sub-classes should override this method to provide custom 'stop' logic. This method issues a JMX notification of type SubDeployer.START_NOTIFICATION.

Specified by:
stop in interface SubDeployer
Specified by:
stop in interface SubDeployerMBean
Parameters:
di - a DeploymentInfo value
Throws:
DeploymentException - if an error occurs

destroy

public void destroy(DeploymentInfo di)
             throws DeploymentException
Sub-classes should override this method to provide custom 'destroy' logic. This method issues a JMX notification of type SubDeployer.DESTROY_NOTIFICATION.

Specified by:
destroy in interface SubDeployer
Specified by:
destroy in interface SubDeployerMBean
Parameters:
di - a DeploymentInfo value
Throws:
DeploymentException - if an error occurs

emitNotification

protected void emitNotification(String type,
                                DeploymentInfo di)
Simple helper to emit a subdeployer notification containing DeploymentInfo


processNestedDeployments

protected void processNestedDeployments(DeploymentInfo di)
                                 throws DeploymentException
The processNestedDeployments method searches for any nested and deployable elements. Only Directories and Zipped archives are processed, and those are delegated to the addDeployableFiles and addDeployableJar methods respectively. This method can be overridden for alternate behaviour.

Throws:
DeploymentException

isDeployable

protected boolean isDeployable(String name,
                               URL url)
This method returns true if the name is a recognized archive file. It will query the MainDeployer that keeps a dynamically updated list of known archive extensions.

Parameters:
name - The "short-name" of the URL. It will have any trailing '/' characters removed, and any directory structure has been removed.
url - The full url.
Returns:
true iff the name ends in a known archive extension: .jar, .sar, .ear, .rar, .zip, .wsr, .war, or if the name matches the native library conventions.

addDeployableFiles

protected void addDeployableFiles(DeploymentInfo di,
                                  File dir)
                           throws DeploymentException
This method recursively searches the directory structure for any files that are deployable (@see isDeployable). If a directory is found to be deployable, then its subfiles and subdirectories are not searched.

Parameters:
di - the DeploymentInfo
dir - The root directory to start searching.
Throws:
DeploymentException

addDeployableJar

protected void addDeployableJar(DeploymentInfo di,
                                JarFile jarFile)
                         throws DeploymentException
This method searches the entire jar file for any deployable files (@see isDeployable).

Parameters:
di - the DeploymentInfo
jarFile - the jar file to process.
Throws:
DeploymentException

deployUrl

protected void deployUrl(DeploymentInfo di,
                         URL url,
                         String name)
                  throws DeploymentException
Throws:
DeploymentException


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.