Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse McConnell2012-08-14 21:52:17 +0000
committerJesse McConnell2012-08-14 21:52:17 +0000
commit5c3a1cfe8ce08f2629243ff07d2779246ccc177e (patch)
treed91cc2c9fd9a1b5c4c663da7a9e7eb541b7d1fc3 /jetty-deploy
parent447b9ecee58c012be600dd32976930671f34663f (diff)
downloadorg.eclipse.jetty.project-5c3a1cfe8ce08f2629243ff07d2779246ccc177e.tar.gz
org.eclipse.jetty.project-5c3a1cfe8ce08f2629243ff07d2779246ccc177e.tar.xz
org.eclipse.jetty.project-5c3a1cfe8ce08f2629243ff07d2779246ccc177e.zip
removed the wrapper element from the ManagedObject annotation, rejiggered object mbean to not need wrapper, also smoking the convert concept in objectMbean in favor of dynamically discovering it where needed since its easy with annotations
Diffstat (limited to 'jetty-deploy')
-rw-r--r--jetty-deploy/src/main/java/org/eclipse/jetty/deploy/ContextDeployer.java468
-rw-r--r--jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java15
-rw-r--r--jetty-deploy/src/main/java/org/eclipse/jetty/deploy/WebAppDeployer.java322
-rw-r--r--jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java2
-rw-r--r--jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java5
-rw-r--r--jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/WebAppProvider.java9
6 files changed, 29 insertions, 792 deletions
diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/ContextDeployer.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/ContextDeployer.java
deleted file mode 100644
index 4e0305142a..0000000000
--- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/ContextDeployer.java
+++ /dev/null
@@ -1,468 +0,0 @@
-// ========================================================================
-// Copyright (c) 2006-2009 Mort Bay Consulting Pty. Ltd.
-// ------------------------------------------------------------------------
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// and Apache License v2.0 which accompanies this distribution.
-// The Eclipse Public License is available at
-// http://www.eclipse.org/legal/epl-v10.html
-// The Apache License v2.0 is available at
-// http://www.opensource.org/licenses/apache2.0.php
-// You may elect to redistribute this code under either of these licenses.
-// ========================================================================
-
-package org.eclipse.jetty.deploy;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jetty.deploy.providers.ContextProvider;
-import org.eclipse.jetty.deploy.providers.ScanningAppProvider;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.handler.ContextHandler;
-import org.eclipse.jetty.server.handler.ContextHandlerCollection;
-import org.eclipse.jetty.util.AttributesMap;
-import org.eclipse.jetty.util.Scanner;
-import org.eclipse.jetty.util.component.AbstractLifeCycle;
-import org.eclipse.jetty.util.log.Log;
-import org.eclipse.jetty.util.log.Logger;
-import org.eclipse.jetty.util.resource.Resource;
-import org.eclipse.jetty.xml.XmlConfiguration;
-
-/**
- * Legacy Context Deployer.
- *
- * <p>
- * Note: The WebAppDeployer is being phased out of Jetty in favor of the {@link DeploymentManager} and
- * {@link org.eclipse.jetty.deploy.providers.ContextProvider} implementation.
- *
- * <p>
- * This deployer scans a designated directory by {@link #setConfigurationDir(String)} for the appearance/disappearance
- * or changes to xml configuration files. The scan is performed at startup and at an optional hot deployment frequency
- * specified by {@link #setScanInterval(int)}. By default, the scanning is NOT recursive, but can be made so by
- * {@link #setRecursive(boolean)}.
- *
- * <p>
- * Each configuration file is in {@link XmlConfiguration} format and represents the configuration of a instance of
- * {@link ContextHandler} (or a subclass specified by the XML <code>Configure</code> element).
- *
- * <p>
- * The xml should configure the context and the instance is deployed to the {@link ContextHandlerCollection} specified
- * by {@link Server#setHandler(org.eclipse.jetty.server.Handler)}.
- *
- * <p>
- * Similarly, when one of these existing files is removed, the corresponding context is undeployed; when one of these
- * files is changed, the corresponding context is undeployed, the (changed) xml config file reapplied to it, and then
- * (re)deployed.
- *
- * <p>
- * Note that the context itself is NOT copied into the hot deploy directory. The webapp directory or war file can exist
- * anywhere. It is the xml config file that points to it's location and deploys it from there.
- *
- * <p>
- * It means, for example, that you can keep a "read-only" copy of your webapp somewhere, and apply different
- * configurations to it simply by dropping different xml configuration files into the configuration directory.
- *
- * @see DeploymentManager
- * @see ScanningAppProvider
- *
- * @org.apache.xbean.XBean element="hotDeployer" description="Creates a hot deployer to watch a directory for changes at
- * a configurable interval."
- * @deprecated replaced with {@link ContextProvider} from the {@link DeploymentManager}
- */
-@SuppressWarnings("unchecked")
-@Deprecated
-public class ContextDeployer extends AbstractLifeCycle
-{
- private static final Logger LOG = Log.getLogger(ContextDeployer.class);
-
- private int _scanInterval=10;
- private Scanner _scanner;
- private ScannerListener _scannerListener;
- private Resource _contextsDir;
- private Map _currentDeployments = new HashMap();
- private ContextHandlerCollection _contexts;
- private ConfigurationManager _configMgr;
- private boolean _recursive = false;
- private AttributesMap _contextAttributes = new AttributesMap();
-
-
- /* ------------------------------------------------------------ */
- protected class ScannerListener implements Scanner.DiscreteListener
- {
- /**
- * Handle a new deployment
- *
- * @see org.eclipse.jetty.util.Scanner.DiscreteListener#fileAdded(java.lang.String)
- */
- public void fileAdded(String filename) throws Exception
- {
- deploy(filename);
- }
-
- /**
- * Handle a change to an existing deployment. Undeploy then redeploy.
- *
- * @see org.eclipse.jetty.util.Scanner.DiscreteListener#fileChanged(java.lang.String)
- */
- public void fileChanged(String filename) throws Exception
- {
- redeploy(filename);
- }
-
- /**
- * Handle an undeploy.
- *
- * @see org.eclipse.jetty.util.Scanner.DiscreteListener#fileRemoved(java.lang.String)
- */
- public void fileRemoved(String filename) throws Exception
- {
- undeploy(filename);
- }
- @Override
- public String toString()
- {
- return "ContextDeployer$Scanner";
- }
- }
-
- /**
- * Constructor
- */
- public ContextDeployer()
- {
- LOG.warn("ContextDeployer is deprecated. Use ContextProvider");
- _scanner=new Scanner();
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @return the ContextHandlerColletion to which to deploy the contexts
- */
- public ContextHandlerCollection getContexts()
- {
- return _contexts;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * Associate with a {@link ContextHandlerCollection}.
- *
- * @param contexts
- * the ContextHandlerColletion to which to deploy the contexts
- */
- public void setContexts(ContextHandlerCollection contexts)
- {
- if (isStarted()||isStarting())
- throw new IllegalStateException("Cannot set Contexts after deployer start");
- _contexts=contexts;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @param seconds
- * The period in second between scans for changed configuration
- * files. A zero or negative interval disables hot deployment
- */
- public void setScanInterval(int seconds)
- {
- if (isStarted()||isStarting())
- throw new IllegalStateException("Cannot change scan interval after deployer start");
- _scanInterval=seconds;
- }
-
- /* ------------------------------------------------------------ */
- public int getScanInterval()
- {
- return _scanInterval;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @param dir Directory to scan for context descriptors
- */
- public void setContextsDir(String dir)
- {
- try
- {
- _contextsDir=Resource.newResource(dir);
- }
- catch(Exception e)
- {
- throw new IllegalArgumentException(e);
- }
- }
-
- /* ------------------------------------------------------------ */
- public String getContextsDir()
- {
- return _contextsDir==null?null:_contextsDir.toString();
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @param dir
- * @throws Exception
- * @deprecated use {@link #setContextsDir(String)}
- */
- @Deprecated
- public void setConfigurationDir(String dir) throws Exception
- {
- setConfigurationDir(Resource.newResource(dir));
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @param file
- * @throws Exception
- * @deprecated use {@link #setContextsDir(String)}
- */
- @Deprecated
- public void setConfigurationDir(File file) throws Exception
- {
- setConfigurationDir(Resource.newResource(Resource.toURL(file)));
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @param resource
- * @deprecated use {@link #setContextsDir(String)}
- */
- @Deprecated
- public void setConfigurationDir(Resource resource)
- {
- if (isStarted()||isStarting())
- throw new IllegalStateException("Cannot change hot deploy dir after deployer start");
- _contextsDir=resource;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @param directory
- * @deprecated use {@link #setContextsDir(String)}
- */
- @Deprecated
- public void setDirectory(String directory) throws Exception
- {
- setConfigurationDir(directory);
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @return the directory
- * @deprecated use {@link #setContextsDir(String)}
- */
- @Deprecated
- public String getDirectory()
- {
- return getConfigurationDir().getName();
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @return the configuration directory
- * @deprecated use {@link #setContextsDir(String)}
- */
- @Deprecated
- public Resource getConfigurationDir()
- {
- return _contextsDir;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @param configMgr
- */
- public void setConfigurationManager(ConfigurationManager configMgr)
- {
- _configMgr=configMgr;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @return the configuration manager
- */
- public ConfigurationManager getConfigurationManager()
- {
- return _configMgr;
- }
-
-
- /* ------------------------------------------------------------ */
- public void setRecursive (boolean recursive)
- {
- _recursive=recursive;
- }
-
- /* ------------------------------------------------------------ */
- public boolean getRecursive ()
- {
- return _recursive;
- }
-
- /* ------------------------------------------------------------ */
- public boolean isRecursive()
- {
- return _recursive;
- }
-
-
- /* ------------------------------------------------------------ */
- /**
- * Set a contextAttribute that will be set for every Context deployed by this deployer.
- * @param name
- * @param value
- */
- public void setAttribute (String name, Object value)
- {
- _contextAttributes.setAttribute(name,value);
- }
-
-
- /* ------------------------------------------------------------ */
- /**
- * Get a contextAttribute that will be set for every Context deployed by this deployer.
- * @param name
- * @return the attribute value
- */
- public Object getAttribute (String name)
- {
- return _contextAttributes.getAttribute(name);
- }
-
-
- /* ------------------------------------------------------------ */
- /**
- * Remove a contextAttribute that will be set for every Context deployed by this deployer.
- * @param name
- */
- public void removeAttribute(String name)
- {
- _contextAttributes.removeAttribute(name);
- }
-
- /* ------------------------------------------------------------ */
- private void deploy(String filename) throws Exception
- {
- ContextHandler context=createContext(filename);
- LOG.info("Deploy "+filename+" -> "+ context);
- _contexts.addHandler(context);
- _currentDeployments.put(filename,context);
- if (_contexts.isStarted())
- context.start();
- }
-
- /* ------------------------------------------------------------ */
- private void undeploy(String filename) throws Exception
- {
- ContextHandler context=(ContextHandler)_currentDeployments.get(filename);
- LOG.info("Undeploy "+filename+" -> "+context);
- if (context==null)
- return;
- context.stop();
- _contexts.removeHandler(context);
- _currentDeployments.remove(filename);
- }
-
- /* ------------------------------------------------------------ */
- private void redeploy(String filename) throws Exception
- {
- undeploy(filename);
- deploy(filename);
- }
-
- /* ------------------------------------------------------------ */
- /**
- * Start the hot deployer looking for webapps to deploy/undeploy
- *
- * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart()
- */
- @SuppressWarnings("deprecation")
- @Override
- protected void doStart() throws Exception
- {
- if (_contextsDir==null)
- throw new IllegalStateException("No configuration dir specified");
-
- if (_contexts==null)
- throw new IllegalStateException("No context handler collection specified for deployer");
-
- _scanner.setScanDir(_contextsDir.getFile());
- _scanner.setScanInterval(getScanInterval());
- _scanner.setRecursive(_recursive); //only look in the top level for deployment files?
- // Accept changes only in files that could be a deployment descriptor
- _scanner.setFilenameFilter(new FilenameFilter()
- {
- public boolean accept(File dir, String name)
- {
- try
- {
- if (name.endsWith(".xml"))
- return true;
- return false;
- }
- catch (Exception e)
- {
- LOG.warn(e);
- return false;
- }
- }
- });
- _scannerListener=new ScannerListener();
- _scanner.addListener(_scannerListener);
- _scanner.scan();
- _scanner.start();
- _contexts.getServer().getContainer().addBean(_scanner);
- }
-
- /* ------------------------------------------------------------ */
- /**
- * Stop the hot deployer.
- *
- * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStop()
- */
- @Override
- protected void doStop() throws Exception
- {
- _scanner.removeListener(_scannerListener);
- _scanner.stop();
- }
-
- /* ------------------------------------------------------------ */
- /**
- * Create a WebAppContext for the webapp being hot deployed, then apply the
- * xml config file to it to configure it.
- *
- * @param filename
- * the config file found in the hot deploy directory
- * @return
- * @throws Exception
- */
- private ContextHandler createContext(String filename) throws Exception
- {
- // The config file can call any method on WebAppContext to configure
- // the webapp being deployed.
- Resource resource = Resource.newResource(filename);
- if (!resource.exists())
- return null;
-
- XmlConfiguration xmlConfiguration=new XmlConfiguration(resource.getURL());
- xmlConfiguration.getIdMap().put("Server", _contexts.getServer());
- if (_configMgr!=null)
- xmlConfiguration.getProperties().putAll(_configMgr.getProperties());
-
- ContextHandler context=(ContextHandler)xmlConfiguration.configure();
-
- // merge attributes
- if (_contextAttributes!=null && _contextAttributes.size()>0)
- {
- AttributesMap attributes = new AttributesMap(_contextAttributes);
- attributes.addAll(context.getAttributes());
- context.setAttributes(attributes);
- }
- return context;
- }
-
-}
diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java
index afe06a80e1..9e5b68f8c0 100644
--- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java
+++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java
@@ -35,6 +35,10 @@ import org.eclipse.jetty.deploy.graph.Path;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.util.AttributesMap;
+import org.eclipse.jetty.util.annotation.ManagedAttribute;
+import org.eclipse.jetty.util.annotation.ManagedObject;
+import org.eclipse.jetty.util.annotation.ManagedOperation;
+import org.eclipse.jetty.util.annotation.Name;
import org.eclipse.jetty.util.component.AggregateLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@@ -53,6 +57,7 @@ import org.eclipse.jetty.util.log.Logger;
* <p>
* <img src="doc-files/DeploymentManager.png">
*/
+@ManagedObject("Deployment Manager")
public class DeploymentManager extends AggregateLifeCycle
{
private static final Logger LOG = Log.getLogger(DeploymentManager.class);
@@ -157,6 +162,7 @@ public class DeploymentManager extends AggregateLifeCycle
addBean(provider);
}
+ @ManagedAttribute("Application Providers")
public Collection<AppProvider> getAppProviders()
{
return Collections.unmodifiableList(_providers);
@@ -279,6 +285,7 @@ public class DeploymentManager extends AggregateLifeCycle
return _apps;
}
+ @ManagedAttribute("Deployed Apps")
public Collection<App> getApps()
{
List<App> ret = new ArrayList<App>();
@@ -357,6 +364,7 @@ public class DeploymentManager extends AggregateLifeCycle
return _contextAttributes;
}
+ @ManagedAttribute("Deployed Contexts")
public ContextHandlerCollection getContexts()
{
return _contexts;
@@ -508,7 +516,8 @@ public class DeploymentManager extends AggregateLifeCycle
* @param nodeName
* the name of the node to attain
*/
- public void requestAppGoal(String appId, String nodeName)
+ @ManagedOperation(value="request the app to be moved to the specified lifecycle node", impact="ACTION")
+ public void requestAppGoal(@Name("appId") String appId, @Name("nodeName") String nodeName)
{
AppEntry appentry = findAppByOriginId(appId);
if (appentry == null)
@@ -576,12 +585,14 @@ public class DeploymentManager extends AggregateLifeCycle
this._useStandardBindings = useStandardBindings;
}
+ @ManagedAttribute("App LifeCycle Nodes")
public Collection<Node> getNodes()
{
return _lifecycle.getNodes();
}
- public Collection<App> getApps(String nodeName)
+ @ManagedOperation(value="list apps that are located at specified App LifeCycle nodes", impact="ACTION")
+ public Collection<App> getApps(@Name("nodeName") String nodeName)
{
return getApps(_lifecycle.getNodeByName(nodeName));
}
diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/WebAppDeployer.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/WebAppDeployer.java
deleted file mode 100644
index 6cbb2d6fc3..0000000000
--- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/WebAppDeployer.java
+++ /dev/null
@@ -1,322 +0,0 @@
-// ========================================================================
-// Copyright (c) 2006-2009 Mort Bay Consulting Pty. Ltd.
-// ------------------------------------------------------------------------
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// and Apache License v2.0 which accompanies this distribution.
-// The Eclipse Public License is available at
-// http://www.eclipse.org/legal/epl-v10.html
-// The Apache License v2.0 is available at
-// http://www.opensource.org/licenses/apache2.0.php
-// You may elect to redistribute this code under either of these licenses.
-// ========================================================================
-
-package org.eclipse.jetty.deploy;
-
-import java.util.ArrayList;
-
-import org.eclipse.jetty.deploy.providers.ScanningAppProvider;
-import org.eclipse.jetty.server.Handler;
-import org.eclipse.jetty.server.handler.ContextHandler;
-import org.eclipse.jetty.server.handler.ContextHandlerCollection;
-import org.eclipse.jetty.server.handler.HandlerCollection;
-import org.eclipse.jetty.util.AttributesMap;
-import org.eclipse.jetty.util.URIUtil;
-import org.eclipse.jetty.util.component.AbstractLifeCycle;
-import org.eclipse.jetty.util.log.Log;
-import org.eclipse.jetty.util.log.Logger;
-import org.eclipse.jetty.util.resource.Resource;
-import org.eclipse.jetty.webapp.WebAppContext;
-
-/**
- * Legacy Web Application Deployer.
- *
- * <p>
- * Note: The WebAppDeployer is being phased out of Jetty in favor of the {@link DeploymentManager} and
- * {@link org.eclipse.jetty.deploy.providers.WebAppProvider} implementation.
- *
- * <p>
- * The class searches a directory for and deploys standard web application. At startup, the directory specified by
- * {@link #setWebAppDir(String)} is searched for subdirectories (excluding hidden and CVS) or files ending with ".zip"
- * or "*.war". For each webapp discovered is passed to a new instance of {@link WebAppContext} (or a subclass specified
- * by {@link #getContexts()}. {@link ContextHandlerCollection#getContextClass()}
- *
- * <p>
- * This deployer does not do hot deployment or undeployment. Nor does it support per web application configuration. For
- * these features see {@link ContextDeployer}.
- *
- * @deprecated
- * @see DeploymentManager
- * @see ScanningAppProvider
- * @see ContextDeployer
- */
-@SuppressWarnings("unchecked")
-public class WebAppDeployer extends AbstractLifeCycle
-{
- private static final Logger LOG = Log.getLogger(WebAppDeployer.class);
-
- private HandlerCollection _contexts;
- private String _webAppDir;
- private String _defaultsDescriptor;
- private String[] _configurationClasses;
- private boolean _extract;
- private boolean _parentLoaderPriority;
- private boolean _allowDuplicates;
- private ArrayList _deployed;
- private AttributesMap _contextAttributes = new AttributesMap();
-
-
- public WebAppDeployer()
- {
- LOG.warn("WebAppDeployer is deprecated. Use WebAppProvider");
- }
-
- public String[] getConfigurationClasses()
- {
- return _configurationClasses;
- }
-
- public void setConfigurationClasses(String[] configurationClasses)
- {
- _configurationClasses=configurationClasses;
- }
-
- public HandlerCollection getContexts()
- {
- return _contexts;
- }
-
- public void setContexts(HandlerCollection contexts)
- {
- _contexts=contexts;
- }
-
- public String getDefaultsDescriptor()
- {
- return _defaultsDescriptor;
- }
-
- public void setDefaultsDescriptor(String defaultsDescriptor)
- {
- _defaultsDescriptor=defaultsDescriptor;
- }
-
- public boolean isExtract()
- {
- return _extract;
- }
-
- public void setExtract(boolean extract)
- {
- _extract=extract;
- }
-
- public boolean isParentLoaderPriority()
- {
- return _parentLoaderPriority;
- }
-
- public void setParentLoaderPriority(boolean parentPriorityClassLoading)
- {
- _parentLoaderPriority=parentPriorityClassLoading;
- }
-
- public String getWebAppDir()
- {
- return _webAppDir;
- }
-
- public void setWebAppDir(String dir)
- {
- _webAppDir=dir;
- }
-
- public boolean getAllowDuplicates()
- {
- return _allowDuplicates;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @param allowDuplicates If false, do not deploy webapps that have already been deployed or duplicate context path
- */
- public void setAllowDuplicates(boolean allowDuplicates)
- {
- _allowDuplicates=allowDuplicates;
- }
-
-
- /**
- * Set a contextAttribute that will be set for every Context deployed by this deployer.
- * @param name
- * @param value
- */
- public void setAttribute (String name, Object value)
- {
- _contextAttributes.setAttribute(name,value);
- }
-
-
- /**
- * Get a contextAttribute that will be set for every Context deployed by this deployer.
- * @param name
- * @return the attribute value
- */
- public Object getAttribute (String name)
- {
- return _contextAttributes.getAttribute(name);
- }
-
-
- /**
- * Remove a contextAttribute that will be set for every Context deployed by this deployer.
- * @param name
- */
- public void removeAttribute(String name)
- {
- _contextAttributes.removeAttribute(name);
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @throws Exception
- */
- @Override
- public void doStart() throws Exception
- {
- _deployed=new ArrayList();
-
- scan();
-
- }
-
- /* ------------------------------------------------------------ */
- /** Scan for webapplications.
- *
- * @throws Exception
- */
- public void scan() throws Exception
- {
- if (_contexts==null)
- throw new IllegalArgumentException("No HandlerContainer");
-
- Resource r=Resource.newResource(_webAppDir);
- if (!r.exists())
- throw new IllegalArgumentException("No such webapps resource "+r);
-
- if (!r.isDirectory())
- throw new IllegalArgumentException("Not directory webapps resource "+r);
-
- String[] files=r.list();
-
- files: for (int f=0; files!=null&&f<files.length; f++)
- {
- String context=files[f];
-
- if (context.equalsIgnoreCase("CVS/")||context.equalsIgnoreCase("CVS")||context.startsWith("."))
- continue;
-
- Resource app=r.addPath(r.encode(context));
-
- if (context.toLowerCase().endsWith(".war")||context.toLowerCase().endsWith(".jar"))
- {
- context=context.substring(0,context.length()-4);
- Resource unpacked=r.addPath(context);
- if (unpacked!=null&&unpacked.exists()&&unpacked.isDirectory())
- continue;
- }
- else if (!app.isDirectory())
- continue;
-
- if (context.equalsIgnoreCase("root")||context.equalsIgnoreCase("root/"))
- context=URIUtil.SLASH;
- else
- context="/"+context;
- if (context.endsWith("/")&&context.length()>0)
- context=context.substring(0,context.length()-1);
-
- // Check the context path has not already been added or the webapp itself is not already deployed
- if (!_allowDuplicates)
- {
- Handler[] installed=_contexts.getChildHandlersByClass(ContextHandler.class);
- for (int i=0; i<installed.length; i++)
- {
- ContextHandler c = (ContextHandler)installed[i];
-
- if (context.equals(c.getContextPath()))
- continue files;
-
-
- try
- {
- String path = null;
- if (c instanceof WebAppContext)
- path = Resource.newResource(((WebAppContext)c).getWar()).getFile().getCanonicalPath();
- else if (c.getBaseResource() != null)
- path = c.getBaseResource().getFile().getCanonicalPath();
-
- if (path != null && path.equals(app.getFile().getCanonicalPath()))
- {
- LOG.debug("Already deployed: {}",path);
- continue files;
- }
- }
- catch (Exception e)
- {
- LOG.ignore(e);
- }
-
- }
- }
-
- // create a webapp
- WebAppContext wah=null;
- if (_contexts instanceof ContextHandlerCollection &&
- WebAppContext.class.isAssignableFrom(((ContextHandlerCollection)_contexts).getContextClass()))
- {
- try
- {
- wah=(WebAppContext)((ContextHandlerCollection)_contexts).getContextClass().newInstance();
- }
- catch (Exception e)
- {
- throw new Error(e);
- }
- }
- else
- {
- wah=new WebAppContext();
- }
-
- // configure it
- wah.setContextPath(context);
- if (_configurationClasses!=null)
- wah.setConfigurationClasses(_configurationClasses);
- if (_defaultsDescriptor!=null)
- wah.setDefaultsDescriptor(_defaultsDescriptor);
- wah.setExtractWAR(_extract);
- wah.setWar(app.toString());
- wah.setParentLoaderPriority(_parentLoaderPriority);
-
- //set up any contextAttributes
- wah.setAttributes(new AttributesMap(_contextAttributes));
-
- // add it
- _contexts.addHandler(wah);
- _deployed.add(wah);
-
- if (_contexts.isStarted())
- wah.start(); // TODO Multi exception
- }
- }
-
- @Override
- public void doStop() throws Exception
- {
- for (int i=_deployed.size();i-->0;)
- {
- ContextHandler wac = (ContextHandler)_deployed.get(i);
- wac.stop();// TODO Multi exception
- }
- }
-}
diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java
index 2685b82fdc..7ae9193ec2 100644
--- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java
+++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java
@@ -19,6 +19,7 @@ import org.eclipse.jetty.deploy.App;
import org.eclipse.jetty.deploy.ConfigurationManager;
import org.eclipse.jetty.deploy.util.FileID;
import org.eclipse.jetty.server.handler.ContextHandler;
+import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.xml.XmlConfiguration;
@@ -27,6 +28,7 @@ import org.eclipse.jetty.xml.XmlConfiguration;
* replacement for the old (and deprecated) <code>org.eclipse.jetty.deploy.ContextDeployer</code> and it will scan a directory
* only for context.xml files.
*/
+@ManagedObject("Provider for starting webapps originating from context.xml files")
public class ContextProvider extends ScanningAppProvider
{
private ConfigurationManager _configurationManager;
diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java
index 8bf03f30a1..d59ab14561 100644
--- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java
+++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java
@@ -25,6 +25,8 @@ import org.eclipse.jetty.deploy.App;
import org.eclipse.jetty.deploy.AppProvider;
import org.eclipse.jetty.deploy.DeploymentManager;
import org.eclipse.jetty.util.Scanner;
+import org.eclipse.jetty.util.annotation.ManagedAttribute;
+import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@@ -32,6 +34,7 @@ import org.eclipse.jetty.util.resource.Resource;
/**
*/
+@ManagedObject("Abstract Provider for loading webapps")
public abstract class ScanningAppProvider extends AbstractLifeCycle implements AppProvider
{
private static final Logger LOG = Log.getLogger(ScanningAppProvider.class);
@@ -196,12 +199,14 @@ public abstract class ScanningAppProvider extends AbstractLifeCycle implements A
}
/* ------------------------------------------------------------ */
+ @ManagedAttribute("scanning interval to detect changes which need reloaded")
public int getScanInterval()
{
return _scanInterval;
}
/* ------------------------------------------------------------ */
+ @ManagedAttribute("recursive scanning supported")
public boolean isRecursive()
{
return _recursive;
diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/WebAppProvider.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/WebAppProvider.java
index 557edc0de9..62e7e33be4 100644
--- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/WebAppProvider.java
+++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/WebAppProvider.java
@@ -21,6 +21,8 @@ import org.eclipse.jetty.deploy.App;
import org.eclipse.jetty.deploy.util.FileID;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.util.URIUtil;
+import org.eclipse.jetty.util.annotation.ManagedAttribute;
+import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.WebAppContext;
@@ -34,6 +36,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
* If the name is in the format root-hostname, then the webapp is deployed
* at / in the virtual host hostname.
*/
+@ManagedObject("Provider for start-up deployement of webapps based on presence in directory")
public class WebAppProvider extends ScanningAppProvider
{
private boolean _extractWars = false;
@@ -110,6 +113,7 @@ public class WebAppProvider extends ScanningAppProvider
/** Get the extractWars.
* @return the extractWars
*/
+ @ManagedAttribute("extract war files")
public boolean isExtractWars()
{
return _extractWars;
@@ -128,6 +132,7 @@ public class WebAppProvider extends ScanningAppProvider
/** Get the parentLoaderPriority.
* @return the parentLoaderPriority
*/
+ @ManagedAttribute("parent classloader has priority")
public boolean isParentLoaderPriority()
{
return _parentLoaderPriority;
@@ -146,6 +151,7 @@ public class WebAppProvider extends ScanningAppProvider
/** Get the defaultsDescriptor.
* @return the defaultsDescriptor
*/
+ @ManagedAttribute("default descriptor for webapps")
public String getDefaultsDescriptor()
{
return _defaultsDescriptor;
@@ -161,6 +167,7 @@ public class WebAppProvider extends ScanningAppProvider
}
/* ------------------------------------------------------------ */
+ @ManagedAttribute("directory to scan for context.xml files")
public String getContextXmlDir()
{
return _filter._contexts==null?null:_filter._contexts.toString();
@@ -207,6 +214,7 @@ public class WebAppProvider extends ScanningAppProvider
/**
*
*/
+ @ManagedAttribute("configuration classes for webapps to be processed through")
public String[] getConfigurationClasses()
{
return _configurationClasses;
@@ -229,6 +237,7 @@ public class WebAppProvider extends ScanningAppProvider
*
* @return the user supplied work directory (null if user has not set Temp Directory yet)
*/
+ @ManagedAttribute("temp directory for use, null if no user set temp directory")
public File getTempDir()
{
return _tempDirectory;

Back to the top