org.jboss.web.deployers
Class AbstractWarDeployment

java.lang.Object
  extended by org.jboss.web.deployers.AbstractWarDeployment

public abstract class AbstractWarDeployment
extends Object

An abstract web app deployment bean. Subclasses implement: - init(Object) to initialize from the deployment configuration java bean passed in from the AbstractWarDeployer instance. - performDeploy(WebApplication webApp, String warUrl) to translate the WebApplication data into a running web application. This is called when the AbstractWarDeployment is started. - performUndeploy(WebApplication webApp, String warUrl) to remove the application corresponding to the WebApplication data. This is called when the AbstractWarDeployment is stopped. The one thing to be aware of is the relationship between the thread context class loader and the JNDI ENC context. Any method that attempts to access the JNDI ENC context must have the ClassLoader in the WebApplication returned from the performDeploy as its thread context ClassLoader or else the lookup for java:comp/env will fail with a name not found exception, or worse, it will receive some other web application ENC context. TODO: the enc should be managed outside of the container without relying on the TCL behavior.

Version:
$Revision: 85945 $
Author:
Scott.Stark@jboss.org, Anil.Saldhana@redhat.com, adrian@jboss.org

Field Summary
protected  String defaultSecurityDomain
          The default security-domain name to use
static String ERROR
           
protected  boolean java2ClassLoadingCompliance
          The parent class loader first model flag
protected  org.jboss.kernel.Kernel kernel
           
protected  boolean lenientEjbLink
          If true, ejb-links that don't resolve don't cause an error (fallback to jndi-name)
protected  org.jboss.logging.Logger log
           
protected  org.jboss.deployers.structure.spi.main.MainDeployerStructure mainDeployer
           
protected  org.jboss.security.authorization.PolicyRegistration policyRegistration
          The Security PolicyRegistration
protected  String policyRegistrationName
          The Security PolicyRegistration Name
protected  ISecurityManagement securityManagement
          The security management
protected  String securityManagementName
          The security management name
protected  MBeanServer server
           
protected  org.jboss.deployers.structure.spi.DeploymentUnit unit
           
protected  boolean unpackWars
          A flag indicating if war archives should be unpacked
 
Constructor Summary
AbstractWarDeployment()
           
 
Method Summary
protected  void addEnvEntries(org.jboss.metadata.javaee.spec.EnvironmentEntriesMetaData envEntries, Context envCtx)
           
static void bindEnvEntry(Context ctx, org.jboss.metadata.javaee.spec.EnvironmentEntryMetaData entry)
           
 String[] getCompileClasspath(ClassLoader loader)
          A utility method that walks up the ClassLoader chain starting at the given loader and queries each ClassLoader for a 'URL[] getURLs()' method from which a complete classpath of URL strings is built.
 String getDefaultSecurityDomain()
          Get the default security domain implementation to use if a war does not declare a security-domain.
 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  org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver getPersistenceUnitDependencyResolver()
           
 org.jboss.security.authorization.PolicyRegistration getPolicyRegistration()
          Get the PolicyRegistration Bean
 String getPolicyRegistrationName()
          Get the Policy Registration Name
 ISecurityManagement getSecurityManagement()
          Get the securityManagement.
 String getSecurityManagementName()
          Get the securityManagement.
 MBeanServer getServer()
           
 String[] getStandardCompileClasspath(ClassLoader loader)
          A utility method that searches the given loader for the resources: "javax/servlet/resources/web-app_2_3.dtd", "org/apache/jasper/resources/jsp12.dtd", and "javax/ejb/EJBHome.class" and returns an array of URL strings.
 boolean getUnpackWars()
          Get the flag indicating if war archives should be unpacked.
abstract  void init(Object containerConfig)
          Initialize the deployment using an instance specific configuration object.
protected  void linkEjbLocalRefs(org.jboss.deployers.structure.spi.DeploymentUnit unit, org.jboss.metadata.javaee.spec.EJBLocalReferencesMetaData ejbLocalRefs, Context envCtx)
           
protected  void linkEjbRefs(org.jboss.deployers.structure.spi.DeploymentUnit unit, org.jboss.metadata.javaee.spec.EJBReferencesMetaData ejbRefs, Context envCtx)
           
protected  void linkMessageDestinationRefs(org.jboss.deployers.structure.spi.DeploymentUnit unit, org.jboss.metadata.javaee.spec.MessageDestinationReferencesMetaData msgRefs, Context envCtx)
           
protected  void linkResourceEnvRefs(org.jboss.metadata.javaee.spec.ResourceEnvironmentReferencesMetaData resourceEnvRefs, Context envCtx)
           
protected  void linkResourceRefs(org.jboss.metadata.javaee.spec.ResourceReferencesMetaData resourceRefs, Context envCtx)
           
protected  void linkSecurityDomain(String securityDomain, Context envCtx)
          This creates a java:comp/env/security context that contains a securityMgr binding pointing to an AuthenticationManager implementation and a realmMapping binding pointing to a RealmMapping implementation.
protected abstract  void performDeploy(WebApplication webApp, String warUrlStr)
          This method is called by the start() method template and must be overriden by subclasses to perform the web container specific deployment steps.
protected abstract  void performUndeploy(WebApplication webApp, String warUrlStr)
          Called as part of the stop() method template to ask the subclass for perform the web container specific undeployment steps.
protected  void processEnc(ClassLoader loader, WebApplication webApp)
          This method is invoked from within subclass performDeploy() method implementations when they invoke WebDescriptorParser.parseWebAppDescriptors().
protected  void processEncReferences(WebApplication webApp, Context envCtx)
           
 void setDefaultSecurityDomain(String defaultSecurityDomain)
          Set the default security domain implementation to use if a war does not declare a security-domain.
 void setDeploymentUnit(org.jboss.deployers.structure.spi.DeploymentUnit unit)
           
 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 setKernel(org.jboss.kernel.Kernel kernel)
           
 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 setPolicyRegistration(org.jboss.security.authorization.PolicyRegistration policyRegistration)
          Set the PolicyRegistration Bean
 void setPolicyRegistrationName(String policyRegistrationName)
          Set the Policy Registration Name
 void setSecurityManagement(ISecurityManagement securityManagement)
          Set the securityManagement.
 void setSecurityManagementName(String securityManagement)
          Set the securityManagement.
 void setServer(MBeanServer server)
           
 void setUnpackWars(boolean flag)
          Get the flag indicating if war archives should be unpacked.
static String shortWarUrlFromServerHome(String warUrl)
          Utility method that builds a string url based on the ServerConfig.SERVER_HOME_URL system property and the input url.
 WebApplication start(org.jboss.deployers.structure.spi.DeploymentUnit unit, org.jboss.metadata.web.jboss.JBossWebMetaData metaData)
          A template pattern implementation of the deploy() method.
 void stop(org.jboss.deployers.structure.spi.DeploymentUnit di, WebApplication webApp)
          A template pattern implementation of the undeploy() method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR

public static final String ERROR
See Also:
Constant Field Values

log

protected org.jboss.logging.Logger log

server

protected MBeanServer server

mainDeployer

protected org.jboss.deployers.structure.spi.main.MainDeployerStructure mainDeployer

kernel

protected org.jboss.kernel.Kernel kernel

unit

protected org.jboss.deployers.structure.spi.DeploymentUnit unit

java2ClassLoadingCompliance

protected boolean java2ClassLoadingCompliance
The parent class loader first model flag


unpackWars

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


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


policyRegistrationName

protected String policyRegistrationName
The Security PolicyRegistration Name


policyRegistration

protected org.jboss.security.authorization.PolicyRegistration policyRegistration
The Security PolicyRegistration


securityManagementName

protected String securityManagementName
The security management name


securityManagement

protected ISecurityManagement securityManagement
The security management

Constructor Detail

AbstractWarDeployment

public AbstractWarDeployment()
Method Detail

setKernel

public void setKernel(org.jboss.kernel.Kernel kernel)

setDeploymentUnit

public void setDeploymentUnit(org.jboss.deployers.structure.spi.DeploymentUnit unit)

shortWarUrlFromServerHome

public static String shortWarUrlFromServerHome(String warUrl)
Utility method that builds a string url based on the ServerConfig.SERVER_HOME_URL system property and the input url. If the input url is under the SERVER_HOME_URL, the SERVER_HOME_URL prefix is replaced with ".../".

Parameters:
warUrl -
Returns:
the possibly shorted war url string.

init

public abstract void init(Object containerConfig)
                   throws Exception
Initialize the deployment using an instance specific configuration object.

Parameters:
containerConfig -
Throws:
Exception

getServer

public MBeanServer getServer()

setServer

public void setServer(MBeanServer server)

getMainDeployer

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

setMainDeployer

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

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()
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.

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

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:
a boolean value

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.

getPersistenceUnitDependencyResolver

protected org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver getPersistenceUnitDependencyResolver()

setPersistenceUnitDependencyResolver

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

getPolicyRegistrationName

public String getPolicyRegistrationName()
Get the Policy Registration Name

Returns:

setPolicyRegistrationName

public void setPolicyRegistrationName(String policyRegistrationName)
Set the Policy Registration Name

Parameters:
policyRegistrationName -

getPolicyRegistration

public org.jboss.security.authorization.PolicyRegistration getPolicyRegistration()
Get the PolicyRegistration Bean

Returns:

setPolicyRegistration

public void setPolicyRegistration(org.jboss.security.authorization.PolicyRegistration policyRegistration)
Set the PolicyRegistration Bean

Parameters:
policyRegistration -

getSecurityManagementName

public String getSecurityManagementName()
Get the securityManagement.

Returns:
the securityManagement.

setSecurityManagementName

public void setSecurityManagementName(String securityManagement)
Set the securityManagement.

Parameters:
securityManagement - the securityManagement.

getSecurityManagement

public ISecurityManagement getSecurityManagement()
Get the securityManagement.

Returns:
the securityManagement.

setSecurityManagement

public void setSecurityManagement(ISecurityManagement securityManagement)
Set the securityManagement.

Parameters:
securityManagement - the securityManagement.

start

public WebApplication start(org.jboss.deployers.structure.spi.DeploymentUnit unit,
                            org.jboss.metadata.web.jboss.JBossWebMetaData metaData)
                     throws Exception
A template pattern implementation of the deploy() method. This method calls the performDeploy() method to perform the container specific deployment steps and registers the returned WebApplication in the deployment map. The steps performed are: ClassLoader appClassLoader = thread.getContextClassLoader(); URLClassLoader warLoader = URLClassLoader.newInstance(empty, appClassLoader); thread.setContextClassLoader(warLoader); WebDescriptorParser webAppParser = ...; WebMetaData metaData = di.metaData; // Create JACC permissions, contextID, etc. ... WebApplication warInfo = new WebApplication(metaData); performDeploy(warInfo, warUrl, webAppParser); deploymentMap.put(warUrl, warInfo); thread.setContextClassLoader(appClassLoader); The subclass performDeploy() implementation needs to invoke processEnc(loader, warInfo) to have the JNDI java:comp/env namespace setup before any web app component can access this namespace. Also, an MBean for each servlet deployed should be created and its JMX ObjectName placed into the DeploymentInfo.mbeans list so that the JSR77 layer can create the approriate model view. The servlet MBean needs to provide access to the min, max and total time in milliseconds. Expose this information via MinServiceTime, MaxServiceTime and TotalServiceTime attributes to integrate seemlessly with the JSR77 factory layer.

Parameters:
unit - The deployment info that contains the context-root element value from the J2EE application/module/web application.xml descriptor. This may be null if war was is not being deployed as part of an enterprise application. It also contains the URL of the web application war.
Throws:
Exception

stop

public void stop(org.jboss.deployers.structure.spi.DeploymentUnit di,
                 WebApplication webApp)
          throws Exception
A template pattern implementation of the undeploy() method. This method calls the performUndeploy() method to perform the container specific undeployment steps and unregisters the the warUrl from the deployment map.

Throws:
Exception

performDeploy

protected abstract void performDeploy(WebApplication webApp,
                                      String warUrlStr)
                               throws Exception
This method is called by the start() method template and must be overriden by subclasses to perform the web container specific deployment steps.

Parameters:
webApp - The web application information context. This contains the metadata such as the context-root element value from the J2EE application/module/web application.xml descriptor and virtual-host.
warUrlStr - The string for the URL of the web application war.
Throws:
Exception

performUndeploy

protected abstract void performUndeploy(WebApplication webApp,
                                        String warUrlStr)
                                 throws Exception
Called as part of the stop() method template to ask the subclass for perform the web container specific undeployment steps.

Parameters:
webApp - The web application information context. This contains the metadata such as the context-root element value from the J2EE application/module/web application.xml descriptor and virtual-host.
warUrlStr - The string for the URL of the web application war.
Throws:
Exception

processEnc

protected void processEnc(ClassLoader loader,
                          WebApplication webApp)
                   throws Exception
This method is invoked from within subclass performDeploy() method implementations when they invoke WebDescriptorParser.parseWebAppDescriptors().

Parameters:
loader - the ClassLoader for the web application. May not be null.
metaData - the WebMetaData from the WebApplication object passed to the performDeploy method.
Throws:
Exception

processEncReferences

protected void processEncReferences(WebApplication webApp,
                                    Context envCtx)
                             throws ClassNotFoundException,
                                    NamingException
Throws:
ClassNotFoundException
NamingException

addEnvEntries

protected void addEnvEntries(org.jboss.metadata.javaee.spec.EnvironmentEntriesMetaData envEntries,
                             Context envCtx)
                      throws ClassNotFoundException,
                             NamingException
Throws:
ClassNotFoundException
NamingException

linkResourceEnvRefs

protected void linkResourceEnvRefs(org.jboss.metadata.javaee.spec.ResourceEnvironmentReferencesMetaData resourceEnvRefs,
                                   Context envCtx)
                            throws NamingException
Throws:
NamingException

linkResourceRefs

protected void linkResourceRefs(org.jboss.metadata.javaee.spec.ResourceReferencesMetaData resourceRefs,
                                Context envCtx)
                         throws NamingException
Throws:
NamingException

linkMessageDestinationRefs

protected void linkMessageDestinationRefs(org.jboss.deployers.structure.spi.DeploymentUnit unit,
                                          org.jboss.metadata.javaee.spec.MessageDestinationReferencesMetaData msgRefs,
                                          Context envCtx)
                                   throws NamingException
Throws:
NamingException

linkEjbRefs

protected void linkEjbRefs(org.jboss.deployers.structure.spi.DeploymentUnit unit,
                           org.jboss.metadata.javaee.spec.EJBReferencesMetaData ejbRefs,
                           Context envCtx)
                    throws NamingException
Throws:
NamingException

linkEjbLocalRefs

protected void linkEjbLocalRefs(org.jboss.deployers.structure.spi.DeploymentUnit unit,
                                org.jboss.metadata.javaee.spec.EJBLocalReferencesMetaData ejbLocalRefs,
                                Context envCtx)
                         throws NamingException
Throws:
NamingException

linkSecurityDomain

protected void linkSecurityDomain(String securityDomain,
                                  Context envCtx)
                           throws NamingException
This creates a java:comp/env/security context that contains a securityMgr binding pointing to an AuthenticationManager implementation and a realmMapping binding pointing to a RealmMapping implementation. If the jboss-web.xml descriptor contained a security-domain element then the bindings are LinkRefs to the jndi name specified by the security-domain element. If there was no security-domain element then the bindings are to NullSecurityManager instance which simply allows all access.

Throws:
NamingException

getStandardCompileClasspath

public String[] getStandardCompileClasspath(ClassLoader loader)
A utility method that searches the given loader for the resources: "javax/servlet/resources/web-app_2_3.dtd", "org/apache/jasper/resources/jsp12.dtd", and "javax/ejb/EJBHome.class" and returns an array of URL strings. Any jar: urls are reduced to the underlying portion of the 'jar:!/{entry}' construct.


getCompileClasspath

public String[] getCompileClasspath(ClassLoader loader)
A utility method that walks up the ClassLoader chain starting at the given loader and queries each ClassLoader for a 'URL[] getURLs()' method from which a complete classpath of URL strings is built.


bindEnvEntry

public static void bindEnvEntry(Context ctx,
                                org.jboss.metadata.javaee.spec.EnvironmentEntryMetaData entry)
                         throws ClassNotFoundException,
                                NamingException
Throws:
ClassNotFoundException
NamingException


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