org.eclipse.jetty.overlays
Class OverlayedAppProvider

java.lang.Object
  extended by org.eclipse.jetty.util.component.AbstractLifeCycle
      extended by org.eclipse.jetty.overlays.OverlayedAppProvider
All Implemented Interfaces:
AppProvider, LifeCycle

public class OverlayedAppProvider
extends AbstractLifeCycle
implements AppProvider

Overlayed AppProvider

This AppProvider implementation can deploy either WebAppContexts or plain ContextHandlers that are assembled from a series of overlays:

webapp
The webapp overlay is a WAR file or docroot directory. The intent is that the WAR should be deployed to this AppProvider unchanged from how it was delivered. All configuration and extension should be able to be done in an overlay.
template
A template overlay is applied to a WAR file to configure it for all instances of the webapp to be deployed in the server(s)
node
A node overlay is applied to a template to configure it all instances of the template with node specific information (eg IP address, DB servers etc.).
instance
An instance overlay is applied to a node and/or template to configure it for a specific instance of the template (eg per tenant configuration).

Each overlays may provide the following files and subdirectories:

lib
The lib directory can contain jars that are applied to a URLClassLoader that is available before any context.xml files are executed, so that classes from these jars may be used by the context.xml.
context.xml
This XmlConfiguration formatted file may exist in a template, node or instance overlay and is applied to the ContextHandler or WebAppContext so that it may be configured. The context.xml from the template overlay can be used to create the ContextHandler instance, so a derived class maybe used.
template.xml
This XmlConfiguration formatted file if it exists in a template or node overlay, is applied to a shared instance of TemplateContext. Any ID's created in a template are available as ID's in context.xml for an instance.
webdefaul.xml
If present in an overlay, then the most specific version is passed to WebAppContext.setDefaultsDescriptor(String). Typically this is set in the template overlay.
web.xml
The web.xml file of an overlay is applied to a web application as with WebAppContext.addOverrideDescriptor(String). This allows incremental changes to web.xml without totally replacing it (see webapp). Typically this is used to set init parameters.
webapp
This directory contains static content that overlays the static content of the webapp or earlier overlays. Using this directory, files like index.html or logo.png can be added or replaced. It can also be used to replace files within WEB-INF including web.xml classes and libs.

The OverlayedAppProvider will scan the "webapps", "templates", "nodes" and "instances" subdirectories of the directory configured with setScanDir(File). New webapps and overlays and modified files within the overlays will trigger hot deployment, redeployment or undeployment. The scan for modified files is restricted to only top level files (eg context.xml) and the files matching WEB-INF/*.xml WEB-INF/lib/* and WEB-INF/classes/*. The webapps/overlays may be directory structures or war/jar archives.

The filenames of the templates and instances are used to match them together and with a webapplication. A webapp may be named anyway, but it is good practise to include a version number (eg webapps/foo-1.2.3.war or webapps/foo-1.2.3/). A template for that webapplication must have a name that includes the template name and the war name separated by '=' (eg templates/myFoo=foo-1.2.3.jar or templates/myFoo=foo-1.2.3/). An instance overlay is named with the template name and an arbitrary instance name separated by '=' (eg instances/myFoo=instance1.jar instances/myFoo=instance2/ etc.).

If a template name does not include a webapp name, then the template is created as a ContextHandler instead of a WebAppContext (with the exact type being determined by context.xml).


Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
 
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
 
Field Summary
static List<Pattern> __scanPatterns
           
static String CLOUDTIDE_DIR
          Property set for context.xml and template.xml files that gives the root cloudtide directory as a canoncial file name.
static String CLOUDTIDE_INSTANCE
          Property set for context.xml and template.xml files that gives the current instance name, Instance#getName().
static String CLOUDTIDE_NODE
          Property set for context.xml and template.xml files that gives the current node name, as Node#getName().
static String CLOUDTIDE_TEMPLATE
          Property set for context.xml and template.xml files that gives the current template name, as Template#getTemplateName().
static String CLOUDTIDE_WEBAPP
          Property set for context.xml and template.xml files that gives the current webapp name, as Webapp#getName().
static String INSTANCES
           
static String NODES
           
static String TEMPLATES
           
static String WEBAPPS
           
 
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
 
Constructor Summary
OverlayedAppProvider()
           
 
Method Summary
 ContextHandler createContextHandler(App app)
          Create Context Handler.
protected  void doStart()
           
protected  void doStop()
           
 ConfigurationManager getConfigurationManager()
           
 DeploymentManager getDeploymentManager()
           
 String getNodeName()
           
 File getScanDir()
          Get the scanDir.
 int getScanInterval()
           
 String getServerID()
           
 File getTmpDir()
          Get the temporary directory.
protected  org.eclipse.jetty.overlays.OverlayedAppProvider.Instance loadInstance(String name, File origin)
           
protected  org.eclipse.jetty.overlays.OverlayedAppProvider.Node loadNode(File origin)
           
protected  org.eclipse.jetty.overlays.OverlayedAppProvider.Template loadTemplate(String name, File origin)
           
protected  org.eclipse.jetty.overlays.OverlayedAppProvider.Webapp loadWebapp(String name, File origin)
           
protected  void redeploy()
          Walks the defined webapps, templates, nodes and instances to determine what should be deployed, then adjust reality to match.
protected  void removeInstance(String name)
           
protected  void removeNode()
           
protected  void removeTemplate(String name)
           
protected  void removeWebapp(String name)
           
 void scan()
           
 void setConfigurationManager(ConfigurationManager configurationManager)
          Set the configurationManager.
 void setDeploymentManager(DeploymentManager deploymentManager)
          Set the Deployment Manager
 void setNodeName(String nodeName)
           
 void setScanDir(File scanDir)
          Set the scanDir.
 void setScanInterval(int scanInterval)
           
 void setServerID(String serverID)
           
 void setTmpDir(File tmpDir)
          Set the temporary directory.
protected  File tmpdir(String name, String suffix)
           
protected  void updateLayers(Set<String> layerURIs)
           
 
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 

Field Detail

CLOUDTIDE_DIR

public static final String CLOUDTIDE_DIR
Property set for context.xml and template.xml files that gives the root cloudtide directory as a canoncial file name.

See Also:
Constant Field Values

CLOUDTIDE_WEBAPP

public static final String CLOUDTIDE_WEBAPP
Property set for context.xml and template.xml files that gives the current webapp name, as Webapp#getName().

See Also:
Constant Field Values

CLOUDTIDE_TEMPLATE

public static final String CLOUDTIDE_TEMPLATE
Property set for context.xml and template.xml files that gives the current template name, as Template#getTemplateName().

See Also:
Constant Field Values

CLOUDTIDE_NODE

public static final String CLOUDTIDE_NODE
Property set for context.xml and template.xml files that gives the current node name, as Node#getName().

See Also:
Constant Field Values

CLOUDTIDE_INSTANCE

public static final String CLOUDTIDE_INSTANCE
Property set for context.xml and template.xml files that gives the current instance name, Instance#getName().

See Also:
Constant Field Values

WEBAPPS

public static final String WEBAPPS
See Also:
Constant Field Values

TEMPLATES

public static final String TEMPLATES
See Also:
Constant Field Values

NODES

public static final String NODES
See Also:
Constant Field Values

INSTANCES

public static final String INSTANCES
See Also:
Constant Field Values

__scanPatterns

public static final List<Pattern> __scanPatterns
Constructor Detail

OverlayedAppProvider

public OverlayedAppProvider()
Method Detail

setDeploymentManager

public void setDeploymentManager(DeploymentManager deploymentManager)
Description copied from interface: AppProvider
Set the Deployment Manager

Specified by:
setDeploymentManager in interface AppProvider

getDeploymentManager

public DeploymentManager getDeploymentManager()

getConfigurationManager

public ConfigurationManager getConfigurationManager()

setConfigurationManager

public void setConfigurationManager(ConfigurationManager configurationManager)
Set the configurationManager.

Parameters:
configurationManager - the configurationManager to set

getServerID

public String getServerID()
Returns:
The name in XmlConfiguration.getIdMap() of the Server instance. Default "Server".

setServerID

public void setServerID(String serverID)
Parameters:
serverID - The name in XmlConfiguration.getIdMap() of the Server instance.

createContextHandler

public ContextHandler createContextHandler(App app)
                                    throws Exception
Create Context Handler.

Callback from the deployment manager to create a context handler instance.

Specified by:
createContextHandler in interface AppProvider
Parameters:
app - The App
Returns:
A ContextHandler
Throws:
IOException
Exception
See Also:
AppProvider.createContextHandler(org.eclipse.jetty.deploy.App)

getNodeName

public String getNodeName()
Returns:
The node name (defaults to hostname)

setNodeName

public void setNodeName(String nodeName)
Parameters:
nodeName - Set the node name

getScanDir

public File getScanDir()
Get the scanDir.

Returns:
the scanDir

setScanDir

public void setScanDir(File scanDir)
Set the scanDir.

Parameters:
scanDir - the scanDir to set

setTmpDir

public void setTmpDir(File tmpDir)
Set the temporary directory.

Parameters:
tmpDir - the directory for temporary files. If null, then getScanDir()+"/tmp" is used if it exists, else the system default is used.

getTmpDir

public File getTmpDir()
Get the temporary directory. return the tmpDir. If null, then getScanDir()+"/tmp" is used if it exists, else the system default is used.


getScanInterval

public int getScanInterval()
Returns:
The scan interval
See Also:
Scanner.getScanInterval()

setScanInterval

public void setScanInterval(int scanInterval)
Parameters:
scanInterval - The scan interval
See Also:
Scanner.setScanInterval(int)

scan

public void scan()
See Also:
Scanner.scan()

doStart

protected void doStart()
                throws Exception
Overrides:
doStart in class AbstractLifeCycle
Throws:
Exception
See Also:
AbstractLifeCycle.doStart()

doStop

protected void doStop()
               throws Exception
Overrides:
doStop in class AbstractLifeCycle
Throws:
Exception
See Also:
AbstractLifeCycle.doStop()

updateLayers

protected void updateLayers(Set<String> layerURIs)

tmpdir

protected File tmpdir(String name,
                      String suffix)
               throws IOException
Throws:
IOException

redeploy

protected void redeploy()
Walks the defined webapps, templates, nodes and instances to determine what should be deployed, then adjust reality to match.


removeInstance

protected void removeInstance(String name)

loadInstance

protected org.eclipse.jetty.overlays.OverlayedAppProvider.Instance loadInstance(String name,
                                                                                File origin)
                                                                         throws IOException
Throws:
IOException

removeNode

protected void removeNode()

loadNode

protected org.eclipse.jetty.overlays.OverlayedAppProvider.Node loadNode(File origin)
                                                                 throws IOException
Throws:
IOException

removeTemplate

protected void removeTemplate(String name)

loadTemplate

protected org.eclipse.jetty.overlays.OverlayedAppProvider.Template loadTemplate(String name,
                                                                                File origin)
                                                                         throws IOException
Throws:
IOException

removeWebapp

protected void removeWebapp(String name)

loadWebapp

protected org.eclipse.jetty.overlays.OverlayedAppProvider.Webapp loadWebapp(String name,
                                                                            File origin)
                                                                     throws IOException
Throws:
IOException


Copyright © 1995-2011 Mort Bay Consulting. All Rights Reserved.