org.springframework.osgi.web.extender.deployer.support
Class AbstractWarDeployer

java.lang.Object
  extended by org.springframework.osgi.web.extender.deployer.support.AbstractWarDeployer
All Implemented Interfaces:
InitializingBean, BundleContextAware, WarDeployer
Direct Known Subclasses:
JettyWarDeployer, TomcatWarDeployer

public abstract class AbstractWarDeployer
extends Object
implements WarDeployer, InitializingBean, BundleContextAware

Convenient base class offering common functionality for war deployers such as logging. Additionally, subclasses can associate a context with each bundle deployed which will used at undeployment time.

Author:
Costin Leau

Field Summary
protected  Log log
          logger
 
Constructor Summary
AbstractWarDeployer()
           
 
Method Summary
 void afterPropertiesSet()
           
protected abstract  Object createDeployment(Bundle bundle, String contextPath)
          Creates and configures (but does not start) the web deployment for the given bundle.
 void deploy(Bundle bundle, String contextPath)
          Deploys the given bundle as a WAR using the given context path. Logs bundle deployment and associates it with a context object.
protected  BundleContext getBundleContext()
          Returns the bundle context used by this deployer.
protected abstract  String getServerInfo()
          Returns a nice String representation of the underlying server for logging messages.
 void setBundleContext(BundleContext bundleContext)
          Set the BundleContext that this bean runs in.
protected abstract  void startDeployment(Object deployment)
          Starts the deployment artifact.
protected abstract  void stopDeployment(Bundle bundle, Object deployment)
          Stops the deployment artifact.
 void undeploy(Bundle bundle, String contextPath)
          Un-deploys the given bundle from the given context path. Logs bundle undeployment and clears the context object associated with the bundle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final Log log
logger

Constructor Detail

AbstractWarDeployer

public AbstractWarDeployer()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

setBundleContext

public void setBundleContext(BundleContext bundleContext)
Description copied from interface: BundleContextAware
Set the BundleContext that this bean runs in. Normally this can be used to initialize an object.

Specified by:
setBundleContext in interface BundleContextAware
Parameters:
bundleContext - the BundleContext object to be used by this object

getBundleContext

protected BundleContext getBundleContext()
Returns the bundle context used by this deployer.

Returns:
the OSGi bundle context used by this deployer.

deploy

public void deploy(Bundle bundle,
                   String contextPath)
            throws Exception
Deploys the given bundle as a WAR using the given context path. Traditionally, a WAR means the given bundle contains a WEB-INF/web.xml file in its bundle space. However, implementations can chose to create a synthetic WAR or use other configuration files instead. Logs bundle deployment and associates it with a context object. It's up to the subclass to define this object as it usually contains container specific information.

Specified by:
deploy in interface WarDeployer
Parameters:
bundle - war bundle
contextPath - the war context path
Throws:
Exception - if something went wrong during deployment

undeploy

public void undeploy(Bundle bundle,
                     String contextPath)
              throws Exception
Un-deploys the given bundle from the given context path. Undeploying a WAR makes sense only if it has been previously deployed. Logs bundle undeployment and clears the context object associated with the bundle.

Specified by:
undeploy in interface WarDeployer
Parameters:
bundle - war bundle
contextPath - the war context path
Throws:
Exception - if something went wrong during undeployment

createDeployment

protected abstract Object createDeployment(Bundle bundle,
                                           String contextPath)
                                    throws Exception
Creates and configures (but does not start) the web deployment for the given bundle. The returned object is used during the deploy/undeploy stages; implementations are free to use whatever appeals to the target environment. The returned object will be given as argument to startDeployment(Object) and stopDeployment(Bundle, Object).

Parameters:
bundle - OSGi bundle deployed as war
contextPath - WAR context path
Returns:
web deployment artifact
Throws:
Exception - if something goes wrong

startDeployment

protected abstract void startDeployment(Object deployment)
                                 throws Exception
Starts the deployment artifact.

Parameters:
deployment - web deployment artifact
Throws:
Exception - if something goes wrong

stopDeployment

protected abstract void stopDeployment(Bundle bundle,
                                       Object deployment)
                                throws Exception
Stops the deployment artifact.

Parameters:
bundle - OSGi bundle backing the OSGi deployment
deployment - web deployment artifact
Throws:
Exception - if something goes wrong

getServerInfo

protected abstract String getServerInfo()
Returns a nice String representation of the underlying server for logging messages.

Returns:
toString for the running environment


Copyright © 2006-2008 Spring Framework. All Rights Reserved.