org.jboss.web.deployers
Class AbstractWarDeployer

java.lang.Object
  extended by org.jboss.deployers.spi.deployer.helpers.AbstractDeployer
      extended by org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer
          extended by org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer<org.jboss.metadata.web.jboss.JBossWebMetaData>
              extended by org.jboss.web.deployers.AbstractWarDeployer
All Implemented Interfaces:
org.jboss.deployers.spi.deployer.Deployer, org.jboss.deployers.spi.deployer.managed.ManagedObjectCreator, org.jboss.deployers.spi.Ordered

public abstract class AbstractWarDeployer
extends org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer<org.jboss.metadata.web.jboss.JBossWebMetaData>
implements org.jboss.deployers.spi.deployer.managed.ManagedObjectCreator

A template pattern class for web container integration into JBoss. This class should be subclassed by web container providers wishing to integrate their container into a JBoss server. The sole method to implement is: #getDeployment(DeploymentUnit, WebMetaData). This is called from within #deploy(DeploymentUnit, WebMetaData) to translate the WebMetaData into a AbstractWarDeployment bean that will be passed to the ServiceDeployer by creating ServiceMetaData for the AbstractWarDeployment in #deployWebModule(DeploymentUnit, WebMetaData, AbstractWarDeployment) The output of this deployer is a ServiceMetaData attachment. When this is translated into a service instance by the ServiceDeployer, the AbstractWarDeployment start/stop trigger the actual deployment/undeployment of the web application.

Version:
$Revision: 88848 $
Author:
Scott.Stark@jboss.org, Christoph.Jung@infor.de, Thomas.Diesler@arcor.de, adrian@jboss.org
See Also:
AbstractWarDeployment

Nested Class Summary
static class AbstractWarDeployer.ContextMO
           
 
Nested classes/interfaces inherited from interface org.jboss.deployers.spi.Ordered
org.jboss.deployers.spi.Ordered.OrderedComparator
 
Field Summary
protected  boolean acceptNonWarDirs
          A flag indicating if local dirs with WEB-INF/web.xml should be treated as wars
protected  String defaultSecurityDomain
          The default security-domain name to use
static String DEPLOYER
           
protected  HashMap deploymentMap
          A mapping of deployed warUrl strings to the WebApplication object
static String ERROR
           
protected  boolean java2ClassLoadingCompliance
          The parent class loader first model flag
protected  boolean lenientEjbLink
          If true, ejb-links that don't resolve don't cause an error (fallback to jndi-name)
protected  boolean unpackWars
          A flag indicating if war archives should be unpacked
static String WEB_APP
           
static String WEB_MODULE
           
 
Fields inherited from class org.jboss.deployers.spi.deployer.helpers.AbstractDeployer
log
 
Fields inherited from interface org.jboss.deployers.spi.Ordered
COMPARATOR
 
Constructor Summary
AbstractWarDeployer()
          Create a new AbstractWarDeployer.
 
Method Summary
 void addDeployedApp(String warURL, WebApplication webApp)
           
 void build(org.jboss.deployers.structure.spi.DeploymentUnit unit, Set<String> outputs, Map<String,org.jboss.managed.api.ManagedObject> managedObjects)
           
protected  String buildWebContext(String ctxPath, String warName, org.jboss.metadata.web.jboss.JBossWebMetaData metaData, org.jboss.deployers.structure.spi.DeploymentUnit unit)
          This method creates a context-root string from either the WEB-INF/jboss-web.xml context-root element is one exists, or the filename portion of the warURL.
 void deploy(org.jboss.deployers.structure.spi.DeploymentUnit unit, org.jboss.metadata.web.jboss.JBossWebMetaData metaData)
          Deploy a web app based on the WebMetaData.
protected  void deployWebModule(org.jboss.deployers.structure.spi.DeploymentUnit unit, org.jboss.metadata.web.jboss.JBossWebMetaData metaData, AbstractWarDeployment deployment)
          Called by deploy first to create a ServiceMetaData instance that wraps the AbstractWarDeployment bean and then attach it to the deployment unit.
 boolean getAcceptNonWarDirs()
          Get the flag indicating if local dirs with WEB-INF/web.xml should be treated as wars
static URL[] getClassLoaderURLs(ClassLoader cl)
          A utility method that uses reflection to access a URL[] getURLs method so that non-URLClassLoader class loaders that support this method can provide info.
 String getDefaultSecurityDomain()
          Get the default security domain implementation to use if a war does not declare a security-domain.
 WebApplication getDeployedApp(String warUrl)
          Get the WebApplication object for a deployed war.
 Iterator getDeployedApplications()
          Returns the applications deployed by the web container subclasses.
abstract  AbstractWarDeployment getDeployment(org.jboss.deployers.structure.spi.DeploymentUnit unit, org.jboss.metadata.web.jboss.JBossWebMetaData metaData)
          Get the AbstractWarDeployment bean for the deployment metadata.
 boolean getJava2ClassLoadingCompliance()
          Get the flag indicating if the normal Java2 parent first class loading model should be used over the servlet 2.3 web container first model.
 boolean getLenientEjbLink()
          Get the flag indicating if ejb-link errors should be ignored in favour of trying the jndi-name in jboss-web.xml
 org.jboss.deployers.structure.spi.main.MainDeployerStructure getMainDeployer()
           
protected  String getObjectName(org.jboss.metadata.web.jboss.JBossWebMetaData metaData)
          Get the object name of the ServiceMetaData instance associated with the WebMetaData.
protected  MBeanServer getServer()
          Deprecated. 
 String getSubjectAttributeName()
          Get the session attribute number under which the caller Subject is stored
 boolean getUnpackWars()
          Set the flag indicating if war archives should be unpacked.
 WebApplication removeDeployedApp(String warURL)
           
 void setAcceptNonWarDirs(boolean flag)
          Set the flag indicating if local dirs with WEB-INF/web.xml should be treated as wars
 void setDefaultSecurityDomain(String defaultSecurityDomain)
          Set the default security domain implementation to use if a war does not declare a security-domain.
 void setJava2ClassLoadingCompliance(boolean flag)
          Set the flag indicating if the normal Java2 parent first class loading model should be used over the servlet 2.3 web container first model.
 void setLenientEjbLink(boolean flag)
          Set the flag indicating if ejb-link errors should be ignored in favour of trying the jndi-name in jboss-web.xml
 void setMainDeployer(org.jboss.deployers.structure.spi.main.MainDeployerStructure mainDeployer)
           
 void setPersistenceUnitDependencyResolver(org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver resolver)
           
 void setSubjectAttributeName(String subjectAttributeName)
          Set the session attribute number under which the caller Subject is stored
 void setUnpackWars(boolean flag)
          Get the flag indicating if war archives should be unpacked.
 void start()
           
 void stop()
           
 void undeploy(org.jboss.deployers.structure.spi.DeploymentUnit unit, org.jboss.metadata.web.jboss.JBossWebMetaData metaData)
          Cleanup war deployer specifics.
 
Methods inherited from class org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer
getInput, internalDeploy, internalUndeploy
 
Methods inherited from class org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer
addControllerContextName, deploy, isControllerContextNameCandidate, isUseUnitName, removeControllerContextName, setUseUnitName, undeploy
 
Methods inherited from class org.jboss.deployers.spi.deployer.helpers.AbstractDeployer
addInput, addInput, addOutput, addOutput, getInputs, getOutput, getOutputs, getRelativeOrder, getStage, isAllInputs, isComponentsOnly, isParentFirst, isTopLevelOnly, isWantComponents, setAllInputs, setComponentsOnly, setInput, setInputs, setInputs, setInputs, setOutput, setOutputs, setOutputs, setOutputs, setParentFirst, setRelativeOrder, setStage, setTopLevelOnly, setWantComponents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEPLOYER

public static final String DEPLOYER
See Also:
Constant Field Values

WEB_APP

public static final String WEB_APP
See Also:
Constant Field Values

WEB_MODULE

public static final String WEB_MODULE
See Also:
Constant Field Values

ERROR

public static final String ERROR
See Also:
Constant Field Values

deploymentMap

protected HashMap deploymentMap
A mapping of deployed warUrl strings to the WebApplication object


java2ClassLoadingCompliance

protected boolean java2ClassLoadingCompliance
The parent class loader first model flag


unpackWars

protected boolean unpackWars
A flag indicating if war archives should be unpacked


acceptNonWarDirs

protected boolean acceptNonWarDirs
A flag indicating if local dirs with WEB-INF/web.xml should be treated as wars


lenientEjbLink

protected boolean lenientEjbLink
If true, ejb-links that don't resolve don't cause an error (fallback to jndi-name)


defaultSecurityDomain

protected String defaultSecurityDomain
The default security-domain name to use

Constructor Detail

AbstractWarDeployer

public AbstractWarDeployer()
Create a new AbstractWarDeployer.

Method Detail

getJava2ClassLoadingCompliance

public boolean getJava2ClassLoadingCompliance()
Get the flag indicating if the normal Java2 parent first class loading model should be used over the servlet 2.3 web container first model.

Returns:
true for parent first, false for the servlet 2.3 model

setJava2ClassLoadingCompliance

public void setJava2ClassLoadingCompliance(boolean flag)
Set the flag indicating if the normal Java2 parent first class loading model should be used over the servlet 2.3 web container first model.

Parameters:
flag - true for parent first, false for the servlet 2.3 model

getUnpackWars

public boolean getUnpackWars()
Set the flag indicating if war archives should be unpacked. This may need to be set to false as long extraction paths under deploy can show up as deployment failures on some platforms.

Returns:
true is war archives should be unpacked

setUnpackWars

public void setUnpackWars(boolean flag)
Get the flag indicating if war archives should be unpacked. This may need to be set to false as long extraction paths under deploy can show up as deployment failures on some platforms.

Parameters:
flag - , true is war archives should be unpacked

getAcceptNonWarDirs

public boolean getAcceptNonWarDirs()
Get the flag indicating if local dirs with WEB-INF/web.xml should be treated as wars

Returns:
true if local dirs with WEB-INF/web.xml should be treated as wars

setAcceptNonWarDirs

public void setAcceptNonWarDirs(boolean flag)
Set the flag indicating if local dirs with WEB-INF/web.xml should be treated as wars

Parameters:
flag - - true if local dirs with WEB-INF/web.xml should be treated as wars

getLenientEjbLink

public boolean getLenientEjbLink()
Get the flag indicating if ejb-link errors should be ignored in favour of trying the jndi-name in jboss-web.xml

Returns:
the LenientEjbLink flag

setLenientEjbLink

public void setLenientEjbLink(boolean flag)
Set the flag indicating if ejb-link errors should be ignored in favour of trying the jndi-name in jboss-web.xml


getDefaultSecurityDomain

public String getDefaultSecurityDomain()
Get the default security domain implementation to use if a war does not declare a security-domain.

Returns:
jndi name of the security domain binding to use.

setDefaultSecurityDomain

public void setDefaultSecurityDomain(String defaultSecurityDomain)
Set the default security domain implementation to use if a war does not declare a security-domain.

Parameters:
defaultSecurityDomain - - jndi name of the security domain binding to use.

setPersistenceUnitDependencyResolver

public void setPersistenceUnitDependencyResolver(org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver resolver)

getSubjectAttributeName

public String getSubjectAttributeName()
Get the session attribute number under which the caller Subject is stored


setSubjectAttributeName

public void setSubjectAttributeName(String subjectAttributeName)
Set the session attribute number under which the caller Subject is stored


start

public void start()
           throws Exception
Throws:
Exception

stop

public void stop()
          throws Exception
Throws:
Exception

getDeployment

public abstract AbstractWarDeployment getDeployment(org.jboss.deployers.structure.spi.DeploymentUnit unit,
                                                    org.jboss.metadata.web.jboss.JBossWebMetaData metaData)
                                             throws Exception
Get the AbstractWarDeployment bean for the deployment metadata. Subclasses override this method to provide a AbstractWarDeployment bean whose start/stop will control the deployment/undeployment of the web application.

Parameters:
unit - - the deployment unit
metaData - - the input web application metadata
Returns:
the AbstractWarDeployment for the input WebMetaData
Throws:
Exception - - thrown on any failure

deploy

public void deploy(org.jboss.deployers.structure.spi.DeploymentUnit unit,
                   org.jboss.metadata.web.jboss.JBossWebMetaData metaData)
            throws org.jboss.deployers.spi.DeploymentException
Deploy a web app based on the WebMetaData. This calls #getDeployment(DeploymentUnit, WebMetaData) to obtain an AbstractWarDeployment bean that is wrapped in a ServiceMetaData by deployWebModule. This will set the WebMetaData.contextRoot if it has not been set based on the war deployment name.

Specified by:
deploy in class org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer<org.jboss.metadata.web.jboss.JBossWebMetaData>
Parameters:
unit - - the war for the deployment
metaData - - the metadata for the deployment
Throws:
org.jboss.deployers.spi.DeploymentException
See Also:
#deployWebModule(DeploymentUnit, WebMetaData, AbstractWarDeployment), #buildWebContext(DeploymentUnit, String, String, WebMetaData)

undeploy

public void undeploy(org.jboss.deployers.structure.spi.DeploymentUnit unit,
                     org.jboss.metadata.web.jboss.JBossWebMetaData metaData)
Cleanup war deployer specifics.

Overrides:
undeploy in class org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer<org.jboss.metadata.web.jboss.JBossWebMetaData>

addDeployedApp

public void addDeployedApp(String warURL,
                           WebApplication webApp)

getDeployedApp

public WebApplication getDeployedApp(String warUrl)
Get the WebApplication object for a deployed war.

Parameters:
warUrl - the war url string as originally passed to deploy().
Returns:
The WebApplication created during the deploy step if the warUrl is valid, null if no such deployment exists.

removeDeployedApp

public WebApplication removeDeployedApp(String warURL)

getDeployedApplications

public Iterator getDeployedApplications()
Returns the applications deployed by the web container subclasses.

Returns:
An Iterator of WebApplication objects for the deployed wars.

getClassLoaderURLs

public static URL[] getClassLoaderURLs(ClassLoader cl)
A utility method that uses reflection to access a URL[] getURLs method so that non-URLClassLoader class loaders that support this method can provide info.


buildWebContext

protected String buildWebContext(String ctxPath,
                                 String warName,
                                 org.jboss.metadata.web.jboss.JBossWebMetaData metaData,
                                 org.jboss.deployers.structure.spi.DeploymentUnit unit)
This method creates a context-root string from either the WEB-INF/jboss-web.xml context-root element is one exists, or the filename portion of the warURL. It is called if the deployment webContext value is null which indicates a standalone war deployment. A war name of ROOT.war is handled as a special case of a war that should be installed as the default web context.

Parameters:
ctxPath - - war level context-root
warName - -

getServer

@Deprecated
protected MBeanServer getServer()
Deprecated. 

TODO: The use of an MBeanServer needs to be removed

Returns:

getMainDeployer

public org.jboss.deployers.structure.spi.main.MainDeployerStructure getMainDeployer()

setMainDeployer

public void setMainDeployer(org.jboss.deployers.structure.spi.main.MainDeployerStructure mainDeployer)

getObjectName

protected String getObjectName(org.jboss.metadata.web.jboss.JBossWebMetaData metaData)
Get the object name of the ServiceMetaData instance associated with the WebMetaData. This uses the pattern: "jboss.web.deployment:war="+metaData.getContextRoot() if there are no virtual hosts, otherwise "jboss.web.deployment:war="+metaData.getVirtualHosts()[0]+metaData.getContextRoot()

Parameters:
metaData - - the web app metaData
Returns:
the war object name

deployWebModule

protected void deployWebModule(org.jboss.deployers.structure.spi.DeploymentUnit unit,
                               org.jboss.metadata.web.jboss.JBossWebMetaData metaData,
                               AbstractWarDeployment deployment)
                        throws Exception
Called by deploy first to create a ServiceMetaData instance that wraps the AbstractWarDeployment bean and then attach it to the deployment unit. The presence of the ServiceMetaData attachment makes the deployment unit "relevant" to the deployers that handle mbean services.

Parameters:
unit - - the deployment unit
metaData - - the web app metadata passed to deploy
deployment - - the web app deployment bean created by getDeployment
Throws:
Exception

build

public void build(org.jboss.deployers.structure.spi.DeploymentUnit unit,
                  Set<String> outputs,
                  Map<String,org.jboss.managed.api.ManagedObject> managedObjects)
           throws org.jboss.deployers.spi.DeploymentException
Specified by:
build in interface org.jboss.deployers.spi.deployer.managed.ManagedObjectCreator
Throws:
org.jboss.deployers.spi.DeploymentException


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.