org.eclipse.jetty.overlays
public class OverlayedAppProvider extends AbstractLifeCycle implements AppProvider
This AppProvider
implementation can deploy either WebAppContext
s or plain
ContextHandler
s that are assembled from a series of overlays:
Each overlays may provide the following files and subdirectories:
URLClassLoader
that is
available before any overlay.xml files are executed, so that classes from these jars may be used by the
overlay.xml.XmlConfiguration
formatted file must exist in the WEB-INF directory of an overlay and is
used to configure a ContextHandler
or WebAppContext
. The overlay.xml from the template
overlay can be used to instantiate the ContextHandler instance, so a derived class maybe used.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 overlay.xml for an instance.WebAppContext.setDefaultsDescriptor(String)
. Typically this is set in the template overlay.WebAppContext.addOverrideDescriptor(String)
. This allows incremental changes to web.xml without
totally replacing it (see webapp). Typically this is used to set init parameters.Any init parameters set on the context, filters or servlets may have parameterized values, with the parameters including:
Webapp#getName()
.Template#getName()
.Template#getTemplateName()
.Template#getClassifier()()
.Node#getName()
.Instance#getName()
.Instance#getClassifier()()
.getConfigurationManager()
.ConfigurationManager.getProperties()
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 overlay.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 overlay.xml).
AbstractLifeCycle.AbstractLifeCycleListener
LifeCycle.Listener
Modifier and Type | Field and Description |
---|---|
static java.util.List<java.util.regex.Pattern> |
__scanPatterns |
static java.lang.String |
INSTANCES |
static java.lang.String |
LIB |
static java.lang.String |
NODES |
static java.lang.String |
OVERLAY_INSTANCE
Property set for overlay.xml and template.xml files that gives the current instance name,
Instance#getName() . |
static java.lang.String |
OVERLAY_INSTANCE_CLASSIFIER
Property set for overlay.xml and template.xml files that gives the current instance clasifier,
Instance#getClassifier() . |
static java.lang.String |
OVERLAY_NODE
Property set for overlay.xml and template.xml files that gives the current node name, as
Node#getName() . |
static java.lang.String |
OVERLAY_TEMPLATE
Property set for overlay.xml and template.xml files that gives the current template full name, as
Template#getName() . |
static java.lang.String |
OVERLAY_TEMPLATE_CLASSIFIER
Property set for overlay.xml and template.xml files that gives the current template classifier, as
Template#getClassifier() . |
static java.lang.String |
OVERLAY_TEMPLATE_NAME
Property set for overlay.xml and template.xml files that gives the current template name, as
Template#getTemplateName() . |
static java.lang.String |
OVERLAY_WEBAPP
Property set for overlay.xml and template.xml files that gives the current webapp name, as
Webapp#getName() . |
static java.lang.String |
OVERLAY_XML |
static java.lang.String |
OVERLAYS_DIR
Property set for overlay.xml and template.xml files that gives the root overlay scan directory as a canonical file name.
|
static java.lang.String |
TEMPLATE_XML |
static java.lang.String |
TEMPLATES |
static java.lang.String |
WEB_DEFAULT_XML |
static java.lang.String |
WEB_FRAGMENT_XML |
static java.lang.String |
WEBAPP |
static java.lang.String |
WEBAPPS |
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
Constructor and Description |
---|
OverlayedAppProvider() |
Modifier and Type | Method and Description |
---|---|
ContextHandler |
createContextHandler(App app)
Create Context Handler.
|
protected void |
doStart() |
protected void |
doStop() |
ConfigurationManager |
getConfigurationManager() |
DeploymentManager |
getDeploymentManager() |
java.lang.String |
getNodeName() |
java.io.File |
getScanDir()
Get the scanDir.
|
int |
getScanInterval() |
java.lang.String |
getServerID() |
java.io.File |
getTmpDir()
Get the temporary directory.
|
protected org.eclipse.jetty.overlays.OverlayedAppProvider.Instance |
loadInstance(java.lang.String name,
java.io.File origin) |
protected org.eclipse.jetty.overlays.OverlayedAppProvider.Node |
loadNode(java.io.File origin) |
protected org.eclipse.jetty.overlays.OverlayedAppProvider.Template |
loadTemplate(java.lang.String name,
java.io.File origin) |
protected org.eclipse.jetty.overlays.OverlayedAppProvider.Webapp |
loadWebapp(java.lang.String name,
java.io.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(java.lang.String name) |
protected void |
removeNode() |
protected void |
removeTemplate(java.lang.String name) |
protected void |
removeWebapp(java.lang.String name) |
void |
scan() |
void |
setConfigurationManager(ConfigurationManager configurationManager)
Set the configurationManager.
|
void |
setDeploymentManager(DeploymentManager deploymentManager)
Set the Deployment Manager
|
void |
setNodeName(java.lang.String nodeName) |
void |
setScanDir(java.io.File scanDir)
Set the scanDir.
|
void |
setScanInterval(int scanInterval) |
void |
setServerID(java.lang.String serverID) |
void |
setTmpDir(java.io.File tmpDir)
Set the temporary directory.
|
protected java.io.File |
tmpdir(java.lang.String name,
java.lang.String suffix) |
protected void |
updateLayers(java.util.Set<java.lang.String> layerURIs) |
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
public static final java.lang.String OVERLAYS_DIR
public static final java.lang.String OVERLAY_WEBAPP
Webapp#getName()
.public static final java.lang.String OVERLAY_TEMPLATE
Template#getName()
.public static final java.lang.String OVERLAY_TEMPLATE_NAME
Template#getTemplateName()
.public static final java.lang.String OVERLAY_TEMPLATE_CLASSIFIER
Template#getClassifier()
.public static final java.lang.String OVERLAY_NODE
Node#getName()
.public static final java.lang.String OVERLAY_INSTANCE
Instance#getName()
.public static final java.lang.String OVERLAY_INSTANCE_CLASSIFIER
Instance#getClassifier()
.public static final java.lang.String WEBAPPS
public static final java.lang.String TEMPLATES
public static final java.lang.String NODES
public static final java.lang.String INSTANCES
public static final java.lang.String LIB
public static final java.lang.String WEBAPP
public static final java.lang.String OVERLAY_XML
public static final java.lang.String TEMPLATE_XML
public static final java.lang.String WEB_DEFAULT_XML
public static final java.lang.String WEB_FRAGMENT_XML
public static final java.util.List<java.util.regex.Pattern> __scanPatterns
public void setDeploymentManager(DeploymentManager deploymentManager)
AppProvider
setDeploymentManager
in interface AppProvider
public DeploymentManager getDeploymentManager()
public ConfigurationManager getConfigurationManager()
public void setConfigurationManager(ConfigurationManager configurationManager)
configurationManager
- the configurationManager to setpublic java.lang.String getServerID()
XmlConfiguration.getIdMap()
of the Server
instance. Default "Server".public void setServerID(java.lang.String serverID)
serverID
- The name in XmlConfiguration.getIdMap()
of the Server
instance.public ContextHandler createContextHandler(App app) throws java.lang.Exception
Callback from the deployment manager to create a context handler instance.
createContextHandler
in interface AppProvider
app
- The Appjava.io.IOException
java.lang.Exception
AppProvider.createContextHandler(org.eclipse.jetty.deploy.App)
public java.lang.String getNodeName()
public void setNodeName(java.lang.String nodeName)
nodeName
- Set the node namepublic java.io.File getScanDir()
public void setScanDir(java.io.File scanDir)
scanDir
- the scanDir to setpublic void setTmpDir(java.io.File tmpDir)
tmpDir
- the directory for temporary files. If null, then getScanDir()+"/tmp" is used if it exists, else the system default is used.public java.io.File getTmpDir()
public int getScanInterval()
Scanner.getScanInterval()
public void setScanInterval(int scanInterval)
scanInterval
- The scan intervalScanner.setScanInterval(int)
public void scan()
Scanner.scan()
protected void doStart() throws java.lang.Exception
doStart
in class AbstractLifeCycle
java.lang.Exception
AbstractLifeCycle.doStart()
protected void doStop() throws java.lang.Exception
doStop
in class AbstractLifeCycle
java.lang.Exception
AbstractLifeCycle.doStop()
protected void updateLayers(java.util.Set<java.lang.String> layerURIs)
protected java.io.File tmpdir(java.lang.String name, java.lang.String suffix) throws java.io.IOException
java.io.IOException
protected void redeploy()
protected void removeInstance(java.lang.String name)
protected org.eclipse.jetty.overlays.OverlayedAppProvider.Instance loadInstance(java.lang.String name, java.io.File origin) throws java.io.IOException
java.io.IOException
protected void removeNode()
protected org.eclipse.jetty.overlays.OverlayedAppProvider.Node loadNode(java.io.File origin) throws java.io.IOException
java.io.IOException
protected void removeTemplate(java.lang.String name)
protected org.eclipse.jetty.overlays.OverlayedAppProvider.Template loadTemplate(java.lang.String name, java.io.File origin) throws java.io.IOException
java.io.IOException
protected void removeWebapp(java.lang.String name)
protected org.eclipse.jetty.overlays.OverlayedAppProvider.Webapp loadWebapp(java.lang.String name, java.io.File origin) throws java.io.IOException
java.io.IOException
Copyright © 2014. All Rights Reserved.