Merge branch 'jetty-9' of ssh://git.eclipse.org/gitroot/jetty/org.eclipse.jetty.project into jetty-9
This commit is contained in:
commit
ffd86fd21b
|
@ -17,6 +17,9 @@ package org.eclipse.jetty.embedded;
|
||||||
|
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.deploy.DeploymentManager;
|
||||||
|
import org.eclipse.jetty.deploy.providers.ContextProvider;
|
||||||
|
import org.eclipse.jetty.deploy.providers.WebAppProvider;
|
||||||
import org.eclipse.jetty.jmx.MBeanContainer;
|
import org.eclipse.jetty.jmx.MBeanContainer;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||||
|
@ -48,6 +51,16 @@ public class ManyServletContexts
|
||||||
other.addServlet(DefaultServlet.class.getCanonicalName(),"/");
|
other.addServlet(DefaultServlet.class.getCanonicalName(),"/");
|
||||||
other.addServlet(new ServletHolder(new HelloServlet("YO!")),"*.yo");
|
other.addServlet(new ServletHolder(new HelloServlet("YO!")),"*.yo");
|
||||||
|
|
||||||
|
DeploymentManager dm = new DeploymentManager();
|
||||||
|
WebAppProvider wp = new WebAppProvider();
|
||||||
|
dm.addAppProvider(wp);
|
||||||
|
ContextProvider cp = new ContextProvider();
|
||||||
|
dm.addAppProvider(cp);
|
||||||
|
|
||||||
|
server.addBean(dm);
|
||||||
|
server.addBean(wp);
|
||||||
|
server.addBean(cp);
|
||||||
|
|
||||||
server.start();
|
server.start();
|
||||||
System.err.println(server.dump());
|
System.err.println(server.dump());
|
||||||
server.join();
|
server.join();
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -35,6 +35,10 @@ import org.eclipse.jetty.deploy.graph.Path;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||||
import org.eclipse.jetty.util.AttributesMap;
|
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.component.AggregateLifeCycle;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
|
@ -53,6 +57,7 @@ import org.eclipse.jetty.util.log.Logger;
|
||||||
* <p>
|
* <p>
|
||||||
* <img src="doc-files/DeploymentManager.png">
|
* <img src="doc-files/DeploymentManager.png">
|
||||||
*/
|
*/
|
||||||
|
@ManagedObject("Deployment Manager")
|
||||||
public class DeploymentManager extends AggregateLifeCycle
|
public class DeploymentManager extends AggregateLifeCycle
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(DeploymentManager.class);
|
private static final Logger LOG = Log.getLogger(DeploymentManager.class);
|
||||||
|
@ -157,6 +162,7 @@ public class DeploymentManager extends AggregateLifeCycle
|
||||||
addBean(provider);
|
addBean(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ManagedAttribute("Application Providers")
|
||||||
public Collection<AppProvider> getAppProviders()
|
public Collection<AppProvider> getAppProviders()
|
||||||
{
|
{
|
||||||
return Collections.unmodifiableList(_providers);
|
return Collections.unmodifiableList(_providers);
|
||||||
|
@ -279,6 +285,7 @@ public class DeploymentManager extends AggregateLifeCycle
|
||||||
return _apps;
|
return _apps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ManagedAttribute("Deployed Apps")
|
||||||
public Collection<App> getApps()
|
public Collection<App> getApps()
|
||||||
{
|
{
|
||||||
List<App> ret = new ArrayList<App>();
|
List<App> ret = new ArrayList<App>();
|
||||||
|
@ -357,6 +364,7 @@ public class DeploymentManager extends AggregateLifeCycle
|
||||||
return _contextAttributes;
|
return _contextAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ManagedAttribute("Deployed Contexts")
|
||||||
public ContextHandlerCollection getContexts()
|
public ContextHandlerCollection getContexts()
|
||||||
{
|
{
|
||||||
return _contexts;
|
return _contexts;
|
||||||
|
@ -508,7 +516,8 @@ public class DeploymentManager extends AggregateLifeCycle
|
||||||
* @param nodeName
|
* @param nodeName
|
||||||
* the name of the node to attain
|
* 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);
|
AppEntry appentry = findAppByOriginId(appId);
|
||||||
if (appentry == null)
|
if (appentry == null)
|
||||||
|
@ -581,7 +590,8 @@ public class DeploymentManager extends AggregateLifeCycle
|
||||||
return _lifecycle.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));
|
return getApps(_lifecycle.getNodeByName(nodeName));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.jetty.deploy.App;
|
||||||
import org.eclipse.jetty.deploy.ConfigurationManager;
|
import org.eclipse.jetty.deploy.ConfigurationManager;
|
||||||
import org.eclipse.jetty.deploy.util.FileID;
|
import org.eclipse.jetty.deploy.util.FileID;
|
||||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
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.util.resource.Resource;
|
||||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
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
|
* replacement for the old (and deprecated) <code>org.eclipse.jetty.deploy.ContextDeployer</code> and it will scan a directory
|
||||||
* only for context.xml files.
|
* only for context.xml files.
|
||||||
*/
|
*/
|
||||||
|
@ManagedObject("Provider for starting webapps originating from context.xml files")
|
||||||
public class ContextProvider extends ScanningAppProvider
|
public class ContextProvider extends ScanningAppProvider
|
||||||
{
|
{
|
||||||
private ConfigurationManager _configurationManager;
|
private ConfigurationManager _configurationManager;
|
||||||
|
|
|
@ -25,6 +25,8 @@ import org.eclipse.jetty.deploy.App;
|
||||||
import org.eclipse.jetty.deploy.AppProvider;
|
import org.eclipse.jetty.deploy.AppProvider;
|
||||||
import org.eclipse.jetty.deploy.DeploymentManager;
|
import org.eclipse.jetty.deploy.DeploymentManager;
|
||||||
import org.eclipse.jetty.util.Scanner;
|
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.component.AbstractLifeCycle;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
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
|
public abstract class ScanningAppProvider extends AbstractLifeCycle implements AppProvider
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(ScanningAppProvider.class);
|
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()
|
public int getScanInterval()
|
||||||
{
|
{
|
||||||
return _scanInterval;
|
return _scanInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ManagedAttribute("recursive scanning supported")
|
||||||
public boolean isRecursive()
|
public boolean isRecursive()
|
||||||
{
|
{
|
||||||
return _recursive;
|
return _recursive;
|
||||||
|
|
|
@ -21,6 +21,8 @@ import org.eclipse.jetty.deploy.App;
|
||||||
import org.eclipse.jetty.deploy.util.FileID;
|
import org.eclipse.jetty.deploy.util.FileID;
|
||||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||||
import org.eclipse.jetty.util.URIUtil;
|
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.util.resource.Resource;
|
||||||
import org.eclipse.jetty.webapp.WebAppContext;
|
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
|
* If the name is in the format root-hostname, then the webapp is deployed
|
||||||
* at / in the virtual host hostname.
|
* at / in the virtual host hostname.
|
||||||
*/
|
*/
|
||||||
|
@ManagedObject("Provider for start-up deployement of webapps based on presence in directory")
|
||||||
public class WebAppProvider extends ScanningAppProvider
|
public class WebAppProvider extends ScanningAppProvider
|
||||||
{
|
{
|
||||||
private boolean _extractWars = false;
|
private boolean _extractWars = false;
|
||||||
|
@ -110,6 +113,7 @@ public class WebAppProvider extends ScanningAppProvider
|
||||||
/** Get the extractWars.
|
/** Get the extractWars.
|
||||||
* @return the extractWars
|
* @return the extractWars
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute("extract war files")
|
||||||
public boolean isExtractWars()
|
public boolean isExtractWars()
|
||||||
{
|
{
|
||||||
return _extractWars;
|
return _extractWars;
|
||||||
|
@ -128,6 +132,7 @@ public class WebAppProvider extends ScanningAppProvider
|
||||||
/** Get the parentLoaderPriority.
|
/** Get the parentLoaderPriority.
|
||||||
* @return the parentLoaderPriority
|
* @return the parentLoaderPriority
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute("parent classloader has priority")
|
||||||
public boolean isParentLoaderPriority()
|
public boolean isParentLoaderPriority()
|
||||||
{
|
{
|
||||||
return _parentLoaderPriority;
|
return _parentLoaderPriority;
|
||||||
|
@ -146,6 +151,7 @@ public class WebAppProvider extends ScanningAppProvider
|
||||||
/** Get the defaultsDescriptor.
|
/** Get the defaultsDescriptor.
|
||||||
* @return the defaultsDescriptor
|
* @return the defaultsDescriptor
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute("default descriptor for webapps")
|
||||||
public String getDefaultsDescriptor()
|
public String getDefaultsDescriptor()
|
||||||
{
|
{
|
||||||
return _defaultsDescriptor;
|
return _defaultsDescriptor;
|
||||||
|
@ -161,6 +167,7 @@ public class WebAppProvider extends ScanningAppProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ManagedAttribute("directory to scan for context.xml files")
|
||||||
public String getContextXmlDir()
|
public String getContextXmlDir()
|
||||||
{
|
{
|
||||||
return _filter._contexts==null?null:_filter._contexts.toString();
|
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()
|
public String[] getConfigurationClasses()
|
||||||
{
|
{
|
||||||
return _configurationClasses;
|
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)
|
* @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()
|
public File getTempDir()
|
||||||
{
|
{
|
||||||
return _tempDirectory;
|
return _tempDirectory;
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
ContextDeployer: Deployer for runtime deploy/undeploy of webapps
|
|
||||||
contexts: MObject: The ContextHandlerCollection to which the deployer deploys
|
|
||||||
scanInterval: Object: The interval in seconds between scans of the deploy directory
|
|
||||||
configurationDir: Object:RO: The deploy directory
|
|
||||||
setConfigurationDir(java.lang.String):ACTION:Set the deploy directory
|
|
||||||
setConfigurationDir(java.lang.String)[0]:dir:The directory
|
|
||||||
setConfigurationDir(java.io.File):ACTION:Set the deploy directory
|
|
||||||
setConfigurationDir(java.io.File)[0]:file:The directory
|
|
||||||
configurationManager: MObject:Source of property values for property name resolution in deployed config file
|
|
|
@ -1,10 +0,0 @@
|
||||||
DeploymentManager: Deployment Manager
|
|
||||||
nodes:MBean: App LifeCycle Nodes
|
|
||||||
apps:MBean: Deployed Apps
|
|
||||||
contexts:MMBean: Deployed Contexts
|
|
||||||
appProviders:MMBean: Application Providers
|
|
||||||
getApps(java.lang.String):MBean:ACTION: List apps that are located at specified App LifeCycle node
|
|
||||||
getApps(java.lang.String)[0]:nodeName: Name of the App LifeCycle node
|
|
||||||
requestAppGoal(java.lang.String,java.lang.String):ACTION: Request the app to be moved to the specified App LifeCycle node
|
|
||||||
requestAppGoal(java.lang.String,java.lang.String)[0]:appId:App identifier
|
|
||||||
requestAppGoal(java.lang.String,java.lang.String)[1]:nodeName:Name of the App LifeCycle node
|
|
|
@ -1,14 +0,0 @@
|
||||||
WebAppDeployer: Deployer for startup deployment of webapps
|
|
||||||
contexts: MObject: The ContextHandlerCollection to which the deployer deploys
|
|
||||||
allowDuplicates: Object:RO: Whether or not duplicate deployments are allowed
|
|
||||||
setAllowDuplicates(boolean):ACTION: Whether or not duplicate deployments are allowed
|
|
||||||
setAllowDuplicates(boolean)[0]:allowDuplicates: True allows duplicate webapps to be deployed while false does not
|
|
||||||
defaultsDescriptor: Object: The webdefault.xml descriptor to use for all webapps deployed by the deployer
|
|
||||||
configurationClasses: Object: The set of configuration classes to apply to the deployment of each webapp
|
|
||||||
webAppDir: Object: The directory where the webapps are to be found to deploy
|
|
||||||
extract: Object:RO: Whether or not to extract war files on deployment
|
|
||||||
setExtract(boolean):ACTION:Set whether or not to extract war files
|
|
||||||
setExtract(boolean)[0]:extract: True will extract war files while false will not
|
|
||||||
parentLoaderPriority: Object:RO: Whether to use j2se classloading order or servlet spec classloading order
|
|
||||||
setParentLoaderPriority(boolean):ACTION: Set which classloading paradigm to use
|
|
||||||
setParentLoaderPriority(boolean)[0]:parentPriorityClassLoading: True uses j2se classloading order while false uses servlet spec order
|
|
|
@ -1 +0,0 @@
|
||||||
ContextProvider: Context AppProvider for Deployment manager
|
|
|
@ -1,4 +0,0 @@
|
||||||
ScanningAppProvider: Scanning AppProvider for Deployment manager
|
|
||||||
monitoredDirName: The directory to monitor for new Apps
|
|
||||||
scanInterval: The scan interval in seconds
|
|
||||||
recursive: Look in subdirectories
|
|
|
@ -1,7 +0,0 @@
|
||||||
WebAppProvider: Web application AppProvider for Deployment manager
|
|
||||||
extractWars: Extract WAR files to temporary directory
|
|
||||||
parentLoaderPriority: ClassLoaders give priority to classes from parent loader
|
|
||||||
defaultsDescriptor: The default descriptor applied before any web.xml
|
|
||||||
contextXmlDir: The directory of context.xml files
|
|
||||||
configurationClasses: The configuration classes to apply
|
|
||||||
tempDir: The temporary directory to use
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
|
||||||
|
org.eclipse.jetty.deploy.LEVEL=WARN
|
||||||
|
|
|
@ -43,7 +43,6 @@ import javax.management.MBeanParameterInfo;
|
||||||
import javax.management.ObjectName;
|
import javax.management.ObjectName;
|
||||||
import javax.management.ReflectionException;
|
import javax.management.ReflectionException;
|
||||||
import javax.management.modelmbean.ModelMBean;
|
import javax.management.modelmbean.ModelMBean;
|
||||||
import javax.xml.crypto.dsig.keyinfo.RetrievalMethod;
|
|
||||||
|
|
||||||
import org.eclipse.jetty.util.Loader;
|
import org.eclipse.jetty.util.Loader;
|
||||||
import org.eclipse.jetty.util.TypeUtil;
|
import org.eclipse.jetty.util.TypeUtil;
|
||||||
|
@ -117,15 +116,12 @@ public class ObjectMBean implements DynamicMBean
|
||||||
Class<?> oClass = o.getClass();
|
Class<?> oClass = o.getClass();
|
||||||
Object mbean = null;
|
Object mbean = null;
|
||||||
|
|
||||||
while (mbean == null && oClass != null)
|
while ( mbean == null && oClass != null )
|
||||||
{
|
{
|
||||||
ManagedObject mo = oClass.getAnnotation(ManagedObject.class);
|
String pName = oClass.getPackage().getName();
|
||||||
String mName = "";
|
String cName = oClass.getName().substring(pName.length() + 1);
|
||||||
if ( mo != null )
|
String mName = pName + ".jmx." + cName + "MBean";
|
||||||
{
|
|
||||||
mName = mo.wrapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Class<?> mClass = (Object.class.equals(oClass))?oClass=ObjectMBean.class:Loader.loadClass(oClass,mName,true);
|
Class<?> mClass = (Object.class.equals(oClass))?oClass=ObjectMBean.class:Loader.loadClass(oClass,mName,true);
|
||||||
|
@ -180,6 +176,7 @@ public class ObjectMBean implements DynamicMBean
|
||||||
{
|
{
|
||||||
LOG.ignore(e);
|
LOG.ignore(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +235,7 @@ public class ObjectMBean implements DynamicMBean
|
||||||
Class<?> o_class=_managed.getClass();
|
Class<?> o_class=_managed.getClass();
|
||||||
List<Class<?>> influences = findInfluences(new ArrayList<Class<?>>(), _managed.getClass());
|
List<Class<?>> influences = findInfluences(new ArrayList<Class<?>>(), _managed.getClass());
|
||||||
|
|
||||||
LOG.debug("Influence Count: " + influences.size() );
|
LOG.debug("Influence Count: {}", influences.size() );
|
||||||
|
|
||||||
// Process Type Annotations
|
// Process Type Annotations
|
||||||
ManagedObject primary = o_class.getAnnotation( ManagedObject.class);
|
ManagedObject primary = o_class.getAnnotation( ManagedObject.class);
|
||||||
|
@ -258,12 +255,12 @@ public class ObjectMBean implements DynamicMBean
|
||||||
{
|
{
|
||||||
Class<?> oClass = influences.get(i);
|
Class<?> oClass = influences.get(i);
|
||||||
|
|
||||||
ManagedObject typeAnnotation = oClass.getAnnotation( ManagedObject.class);
|
ManagedObject typeAnnotation = oClass.getAnnotation( ManagedObject.class );
|
||||||
|
|
||||||
LOG.debug("Influenced by: " + oClass.getCanonicalName() );
|
LOG.debug("Influenced by: " + oClass.getCanonicalName() );
|
||||||
if ( typeAnnotation == null )
|
if ( typeAnnotation == null )
|
||||||
{
|
{
|
||||||
LOG.debug("Annotations not found for: " + oClass.getCanonicalName() );
|
LOG.debug("Annotations not found for: {}", oClass.getCanonicalName() );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +273,7 @@ public class ObjectMBean implements DynamicMBean
|
||||||
if (methodAttributeAnnotation != null)
|
if (methodAttributeAnnotation != null)
|
||||||
{
|
{
|
||||||
// TODO sort out how a proper name could get here, its a method name as an attribute at this point.
|
// TODO sort out how a proper name could get here, its a method name as an attribute at this point.
|
||||||
LOG.debug("Attribute Annotation found for: " + method.getName());
|
LOG.debug("Attribute Annotation found for: {}", method.getName());
|
||||||
MBeanAttributeInfo mai = defineAttribute(method,methodAttributeAnnotation);
|
MBeanAttributeInfo mai = defineAttribute(method,methodAttributeAnnotation);
|
||||||
if ( mai != null )
|
if ( mai != null )
|
||||||
{
|
{
|
||||||
|
@ -288,7 +285,7 @@ public class ObjectMBean implements DynamicMBean
|
||||||
|
|
||||||
if (methodOperationAnnotation != null)
|
if (methodOperationAnnotation != null)
|
||||||
{
|
{
|
||||||
LOG.debug("Method Annotation found for: " + method.getName());
|
LOG.debug("Method Annotation found for: {}", method.getName());
|
||||||
MBeanOperationInfo oi = defineOperation(method,methodOperationAnnotation);
|
MBeanOperationInfo oi = defineOperation(method,methodOperationAnnotation);
|
||||||
|
|
||||||
if (oi != null)
|
if (oi != null)
|
||||||
|
@ -335,34 +332,51 @@ public class ObjectMBean implements DynamicMBean
|
||||||
// get the attribute
|
// get the attribute
|
||||||
Object r=getter.invoke(o, (java.lang.Object[]) null);
|
Object r=getter.invoke(o, (java.lang.Object[]) null);
|
||||||
|
|
||||||
// convert to ObjectName if need be.
|
// convert to ObjectName if the type has the @ManagedObject annotation
|
||||||
if (r!=null && _convert.contains(name))
|
if (r!=null )
|
||||||
{
|
{
|
||||||
if (r.getClass().isArray())
|
if (r.getClass().isArray())
|
||||||
{
|
{
|
||||||
ObjectName[] on = new ObjectName[Array.getLength(r)];
|
if (r.getClass().getComponentType().isAnnotationPresent(ManagedObject.class))
|
||||||
for (int i=0;i<on.length;i++)
|
{
|
||||||
on[i]=_mbeanContainer.findMBean(Array.get(r, i));
|
ObjectName[] on = new ObjectName[Array.getLength(r)];
|
||||||
r=on;
|
for (int i = 0; i < on.length; i++)
|
||||||
|
{
|
||||||
|
on[i] = _mbeanContainer.findMBean(Array.get(r,i));
|
||||||
|
}
|
||||||
|
r = on;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (r instanceof Collection<?>)
|
else if (r instanceof Collection<?>)
|
||||||
{
|
{
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Collection<Object> c = (Collection<Object>)r;
|
Collection<Object> c = (Collection<Object>)r;
|
||||||
ObjectName[] on = new ObjectName[c.size()];
|
|
||||||
int i=0;
|
if (!c.isEmpty() && c.iterator().next().getClass().isAnnotationPresent(ManagedObject.class))
|
||||||
for (Object obj :c)
|
{
|
||||||
on[i++]=_mbeanContainer.findMBean(obj);
|
// check the first thing out
|
||||||
r=on;
|
|
||||||
|
ObjectName[] on = new ObjectName[c.size()];
|
||||||
|
int i = 0;
|
||||||
|
for (Object obj : c)
|
||||||
|
{
|
||||||
|
on[i++] = _mbeanContainer.findMBean(obj);
|
||||||
|
}
|
||||||
|
r = on;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ObjectName mbean = _mbeanContainer.findMBean(r);
|
if ( r.getClass().isAnnotationPresent(ManagedObject.class))
|
||||||
|
{
|
||||||
if (mbean==null)
|
ObjectName mbean = _mbeanContainer.findMBean(r);
|
||||||
return null;
|
|
||||||
r=mbean;
|
if (mbean == null)
|
||||||
|
return null;
|
||||||
|
r = mbean;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
|
@ -525,24 +539,19 @@ public class ObjectMBean implements DynamicMBean
|
||||||
// This class is an influence
|
// This class is an influence
|
||||||
influences.add(aClass);
|
influences.add(aClass);
|
||||||
|
|
||||||
// check for mbean influence
|
String pName = aClass.getPackage().getName();
|
||||||
ManagedObject mo = aClass.getAnnotation(ManagedObject.class);
|
String cName = aClass.getName().substring(pName.length() + 1);
|
||||||
|
String mName = pName + ".jmx." + cName + "MBean";
|
||||||
|
|
||||||
if ( mo != null && !"".equals(mo.wrapper()))
|
try
|
||||||
{
|
{
|
||||||
String clazz = mo.wrapper();
|
Class<?> mbeanClazz = Class.forName(mName);
|
||||||
|
LOG.debug("MBean Influence found for " + aClass.getSimpleName());
|
||||||
try
|
influences.add(mbeanClazz);
|
||||||
{
|
}
|
||||||
Class<?> mbean = Class.forName(clazz);
|
catch (ClassNotFoundException cnfe)
|
||||||
|
{
|
||||||
LOG.debug("MBean Influence found for " + aClass.getSimpleName() );
|
LOG.debug("No MBean Influence for " + aClass.getSimpleName());
|
||||||
influences.add(mbean);
|
|
||||||
}
|
|
||||||
catch ( ClassNotFoundException cnfe )
|
|
||||||
{
|
|
||||||
LOG.debug("No MBean Influence for " + aClass.getSimpleName() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// So are the super classes
|
// So are the super classes
|
||||||
|
@ -625,7 +634,7 @@ public class ObjectMBean implements DynamicMBean
|
||||||
{
|
{
|
||||||
String declaredSetter = attributeAnnotation.setter();
|
String declaredSetter = attributeAnnotation.setter();
|
||||||
|
|
||||||
LOG.debug("DeclaredSetter:" + declaredSetter);
|
LOG.debug("DeclaredSetter: {}", declaredSetter);
|
||||||
Method[] methods = oClass.getMethods();
|
Method[] methods = oClass.getMethods();
|
||||||
for (int m = 0; m < methods.length; m++)
|
for (int m = 0; m < methods.length; m++)
|
||||||
{
|
{
|
||||||
|
@ -640,13 +649,13 @@ public class ObjectMBean implements DynamicMBean
|
||||||
{
|
{
|
||||||
if (setter != null)
|
if (setter != null)
|
||||||
{
|
{
|
||||||
LOG.warn("Multiple setters for mbean attr " + name + " in " + oClass);
|
LOG.warn("Multiple setters for mbean attr {} in {}", name, oClass);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
setter = methods[m];
|
setter = methods[m];
|
||||||
if ( !type.equals(methods[m].getParameterTypes()[0]))
|
if ( !type.equals(methods[m].getParameterTypes()[0]))
|
||||||
{
|
{
|
||||||
LOG.warn("Type conflict for mbean attr " + name + " in " + oClass);
|
LOG.warn("Type conflict for mbean attr {} in {}", name, oClass);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
LOG.debug("Declared Setter: " + declaredSetter);
|
LOG.debug("Declared Setter: " + declaredSetter);
|
||||||
|
@ -658,13 +667,13 @@ public class ObjectMBean implements DynamicMBean
|
||||||
{
|
{
|
||||||
if (setter != null)
|
if (setter != null)
|
||||||
{
|
{
|
||||||
LOG.warn("Multiple setters for mbean attr " + name + " in " + oClass);
|
LOG.warn("Multiple setters for mbean attr {} in {}", name, oClass);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
setter = methods[m];
|
setter = methods[m];
|
||||||
if ( !type.equals(methods[m].getParameterTypes()[0]))
|
if ( !type.equals(methods[m].getParameterTypes()[0]))
|
||||||
{
|
{
|
||||||
LOG.warn("Type conflict for mbean attr " + name + " in " + oClass);
|
LOG.warn("Type conflict for mbean attr {} in {}", name, oClass);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -751,6 +760,7 @@ public class ObjectMBean implements DynamicMBean
|
||||||
|
|
||||||
if ( returnType.isArray() )
|
if ( returnType.isArray() )
|
||||||
{
|
{
|
||||||
|
LOG.debug("returnType is array, get component type");
|
||||||
returnType = returnType.getComponentType();
|
returnType = returnType.getComponentType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -758,11 +768,11 @@ public class ObjectMBean implements DynamicMBean
|
||||||
{
|
{
|
||||||
convert = true;
|
convert = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String impactName = methodAnnotation.impact();
|
String impactName = methodAnnotation.impact();
|
||||||
|
|
||||||
|
|
||||||
LOG.debug("defineOperation "+method.getName()+" "+onMBean+":"+impactName+":"+description);
|
LOG.debug("defineOperation {} {}:{}:{}", method.getName(), onMBean, impactName, description);
|
||||||
|
|
||||||
String signature = method.getName();
|
String signature = method.getName();
|
||||||
|
|
||||||
|
@ -833,8 +843,7 @@ public class ObjectMBean implements DynamicMBean
|
||||||
throw new IllegalArgumentException(e.toString());
|
throw new IllegalArgumentException(e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected String toVariableName( String methodName )
|
protected String toVariableName( String methodName )
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,7 +18,7 @@ import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||||
import org.eclipse.jetty.util.annotation.ManagedOperation;
|
import org.eclipse.jetty.util.annotation.ManagedOperation;
|
||||||
import org.eclipse.jetty.util.annotation.Name;
|
import org.eclipse.jetty.util.annotation.Name;
|
||||||
|
|
||||||
@ManagedObject(value="Test the mbean stuff", wrapper="com.acme.jmx.DerivedMBean")
|
@ManagedObject(value="Test the mbean stuff")
|
||||||
public class Derived extends Base implements Signature
|
public class Derived extends Base implements Signature
|
||||||
{
|
{
|
||||||
String fname="Full Name";
|
String fname="Full Name";
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.acme;
|
||||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||||
|
|
||||||
@ManagedObject(value="Managed Object", wrapper="com.acme.jmx.ManagedMBean")
|
@ManagedObject(value="Managed Object")
|
||||||
public class Managed
|
public class Managed
|
||||||
{
|
{
|
||||||
String managed = "foo";
|
String managed = "foo";
|
||||||
|
|
|
@ -52,7 +52,7 @@ import org.eclipse.jetty.util.thread.ThreadPool;
|
||||||
* The server is itself a handler and a ThreadPool. Connectors use the ThreadPool methods
|
* The server is itself a handler and a ThreadPool. Connectors use the ThreadPool methods
|
||||||
* to run jobs that will eventually call the handle method.
|
* to run jobs that will eventually call the handle method.
|
||||||
*/
|
*/
|
||||||
@ManagedObject(value="Jetty HTTP Servlet server", wrapper="org.eclipse.jetty.server.ServerMBean")
|
@ManagedObject(value="Jetty HTTP Servlet server")
|
||||||
public class Server extends HandlerWrapper implements Attributes
|
public class Server extends HandlerWrapper implements Attributes
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(Server.class);
|
private static final Logger LOG = Log.getLogger(Server.class);
|
||||||
|
|
|
@ -21,10 +21,12 @@ import javax.servlet.DispatcherType;
|
||||||
import org.eclipse.jetty.http.PathMap;
|
import org.eclipse.jetty.http.PathMap;
|
||||||
import org.eclipse.jetty.server.Handler;
|
import org.eclipse.jetty.server.Handler;
|
||||||
import org.eclipse.jetty.util.TypeUtil;
|
import org.eclipse.jetty.util.TypeUtil;
|
||||||
|
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||||
|
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||||
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
||||||
import org.eclipse.jetty.util.component.Dumpable;
|
import org.eclipse.jetty.util.component.Dumpable;
|
||||||
|
|
||||||
|
@ManagedObject("Filter Mappings")
|
||||||
public class FilterMapping implements Dumpable
|
public class FilterMapping implements Dumpable
|
||||||
{
|
{
|
||||||
/** Dispatch types */
|
/** Dispatch types */
|
||||||
|
@ -126,6 +128,7 @@ public class FilterMapping implements Dumpable
|
||||||
/**
|
/**
|
||||||
* @return Returns the filterName.
|
* @return Returns the filterName.
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute(value="filter name", readonly=true)
|
||||||
public String getFilterName()
|
public String getFilterName()
|
||||||
{
|
{
|
||||||
return _filterName;
|
return _filterName;
|
||||||
|
@ -144,6 +147,7 @@ public class FilterMapping implements Dumpable
|
||||||
/**
|
/**
|
||||||
* @return Returns the pathSpec.
|
* @return Returns the pathSpec.
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute(value="url patterns", readonly=true)
|
||||||
public String[] getPathSpecs()
|
public String[] getPathSpecs()
|
||||||
{
|
{
|
||||||
return _pathSpecs;
|
return _pathSpecs;
|
||||||
|
@ -223,6 +227,7 @@ public class FilterMapping implements Dumpable
|
||||||
/**
|
/**
|
||||||
* @return Returns the servletName.
|
* @return Returns the servletName.
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute(value="servlet names", readonly=true)
|
||||||
public String[] getServletNames()
|
public String[] getServletNames()
|
||||||
{
|
{
|
||||||
return _servletNames;
|
return _servletNames;
|
||||||
|
|
|
@ -27,6 +27,8 @@ import javax.servlet.UnavailableException;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||||
import org.eclipse.jetty.util.Loader;
|
import org.eclipse.jetty.util.Loader;
|
||||||
|
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.component.AbstractLifeCycle;
|
||||||
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
||||||
import org.eclipse.jetty.util.component.Dumpable;
|
import org.eclipse.jetty.util.component.Dumpable;
|
||||||
|
@ -38,6 +40,7 @@ import org.eclipse.jetty.util.log.Logger;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ManagedObject("Holder - a container for servlets and the like")
|
||||||
public class Holder<T> extends AbstractLifeCycle implements Dumpable
|
public class Holder<T> extends AbstractLifeCycle implements Dumpable
|
||||||
{
|
{
|
||||||
public enum Source { EMBEDDED, JAVAX_API, DESCRIPTOR, ANNOTATION };
|
public enum Source { EMBEDDED, JAVAX_API, DESCRIPTOR, ANNOTATION };
|
||||||
|
@ -111,6 +114,7 @@ public class Holder<T> extends AbstractLifeCycle implements Dumpable
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ManagedAttribute(value="Class Name", readonly=true)
|
||||||
public String getClassName()
|
public String getClassName()
|
||||||
{
|
{
|
||||||
return _className;
|
return _className;
|
||||||
|
@ -123,6 +127,7 @@ public class Holder<T> extends AbstractLifeCycle implements Dumpable
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ManagedAttribute(value="Display Name", readonly=true)
|
||||||
public String getDisplayName()
|
public String getDisplayName()
|
||||||
{
|
{
|
||||||
return _displayName;
|
return _displayName;
|
||||||
|
@ -145,12 +150,14 @@ public class Holder<T> extends AbstractLifeCycle implements Dumpable
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
|
@ManagedAttribute(value="Initial Parameters", readonly=true)
|
||||||
public Map<String,String> getInitParameters()
|
public Map<String,String> getInitParameters()
|
||||||
{
|
{
|
||||||
return _initParams;
|
return _initParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ManagedAttribute(value="Name", readonly=true)
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return _name;
|
return _name;
|
||||||
|
|
|
@ -53,6 +53,8 @@ import org.eclipse.jetty.server.handler.ErrorHandler;
|
||||||
import org.eclipse.jetty.server.handler.HandlerCollection;
|
import org.eclipse.jetty.server.handler.HandlerCollection;
|
||||||
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
||||||
import org.eclipse.jetty.server.session.SessionHandler;
|
import org.eclipse.jetty.server.session.SessionHandler;
|
||||||
|
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||||
|
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -66,6 +68,7 @@ import org.eclipse.jetty.server.session.SessionHandler;
|
||||||
* This class should have been called ServletContext, but this would have
|
* This class should have been called ServletContext, but this would have
|
||||||
* cause confusion with {@link ServletContext}.
|
* cause confusion with {@link ServletContext}.
|
||||||
*/
|
*/
|
||||||
|
@ManagedObject("Servlet Context Handler")
|
||||||
public class ServletContextHandler extends ContextHandler
|
public class ServletContextHandler extends ContextHandler
|
||||||
{
|
{
|
||||||
public final static int SESSIONS=1;
|
public final static int SESSIONS=1;
|
||||||
|
@ -262,6 +265,7 @@ public class ServletContextHandler extends ContextHandler
|
||||||
/**
|
/**
|
||||||
* @return Returns the securityHandler.
|
* @return Returns the securityHandler.
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute(value="context security handler", readonly=true)
|
||||||
public SecurityHandler getSecurityHandler()
|
public SecurityHandler getSecurityHandler()
|
||||||
{
|
{
|
||||||
if (_securityHandler==null && (_options&SECURITY)!=0 && !isStarted())
|
if (_securityHandler==null && (_options&SECURITY)!=0 && !isStarted())
|
||||||
|
@ -274,6 +278,7 @@ public class ServletContextHandler extends ContextHandler
|
||||||
/**
|
/**
|
||||||
* @return Returns the servletHandler.
|
* @return Returns the servletHandler.
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute(value="context servlet handler", readonly=true)
|
||||||
public ServletHandler getServletHandler()
|
public ServletHandler getServletHandler()
|
||||||
{
|
{
|
||||||
if (_servletHandler==null && !isStarted())
|
if (_servletHandler==null && !isStarted())
|
||||||
|
@ -285,6 +290,7 @@ public class ServletContextHandler extends ContextHandler
|
||||||
/**
|
/**
|
||||||
* @return Returns the sessionHandler.
|
* @return Returns the sessionHandler.
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute(value="context session handler", readonly=true)
|
||||||
public SessionHandler getSessionHandler()
|
public SessionHandler getSessionHandler()
|
||||||
{
|
{
|
||||||
if (_sessionHandler==null && (_options&SESSIONS)!=0 && !isStarted())
|
if (_sessionHandler==null && (_options&SESSIONS)!=0 && !isStarted())
|
||||||
|
|
|
@ -62,6 +62,8 @@ import org.eclipse.jetty.util.MultiException;
|
||||||
import org.eclipse.jetty.util.MultiMap;
|
import org.eclipse.jetty.util.MultiMap;
|
||||||
import org.eclipse.jetty.util.TypeUtil;
|
import org.eclipse.jetty.util.TypeUtil;
|
||||||
import org.eclipse.jetty.util.URIUtil;
|
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.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
|
|
||||||
|
@ -77,6 +79,7 @@ import org.eclipse.jetty.util.log.Logger;
|
||||||
* Unless run as part of a {@link ServletContextHandler} or derivative, the {@link #initialize()}
|
* Unless run as part of a {@link ServletContextHandler} or derivative, the {@link #initialize()}
|
||||||
* method must be called manually after start().
|
* method must be called manually after start().
|
||||||
*/
|
*/
|
||||||
|
@ManagedObject("Servlet Handler")
|
||||||
public class ServletHandler extends ScopedHandler
|
public class ServletHandler extends ScopedHandler
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(ServletHandler.class);
|
private static final Logger LOG = Log.getLogger(ServletHandler.class);
|
||||||
|
@ -230,6 +233,7 @@ public class ServletHandler extends ScopedHandler
|
||||||
/**
|
/**
|
||||||
* @return Returns the filterMappings.
|
* @return Returns the filterMappings.
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute(value="filters", readonly=true)
|
||||||
public FilterMapping[] getFilterMappings()
|
public FilterMapping[] getFilterMappings()
|
||||||
{
|
{
|
||||||
return _filterMappings;
|
return _filterMappings;
|
||||||
|
@ -239,6 +243,7 @@ public class ServletHandler extends ScopedHandler
|
||||||
/** Get Filters.
|
/** Get Filters.
|
||||||
* @return Array of defined servlets
|
* @return Array of defined servlets
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute(value="filters", readonly=true)
|
||||||
public FilterHolder[] getFilters()
|
public FilterHolder[] getFilters()
|
||||||
{
|
{
|
||||||
return _filters;
|
return _filters;
|
||||||
|
@ -266,6 +271,7 @@ public class ServletHandler extends ScopedHandler
|
||||||
/**
|
/**
|
||||||
* @return Returns the servletMappings.
|
* @return Returns the servletMappings.
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute(value="mappings of servlets", readonly=true)
|
||||||
public ServletMapping[] getServletMappings()
|
public ServletMapping[] getServletMappings()
|
||||||
{
|
{
|
||||||
return _servletMappings;
|
return _servletMappings;
|
||||||
|
@ -300,6 +306,7 @@ public class ServletHandler extends ScopedHandler
|
||||||
/** Get Servlets.
|
/** Get Servlets.
|
||||||
* @return Array of defined servlets
|
* @return Array of defined servlets
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute(value="servlets", readonly=true)
|
||||||
public ServletHolder[] getServlets()
|
public ServletHolder[] getServlets()
|
||||||
{
|
{
|
||||||
return _servlets;
|
return _servlets;
|
||||||
|
|
|
@ -43,6 +43,8 @@ import org.eclipse.jetty.server.Request;
|
||||||
import org.eclipse.jetty.server.UserIdentity;
|
import org.eclipse.jetty.server.UserIdentity;
|
||||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||||
import org.eclipse.jetty.util.Loader;
|
import org.eclipse.jetty.util.Loader;
|
||||||
|
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||||
|
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
|
|
||||||
|
@ -58,6 +60,7 @@ import org.eclipse.jetty.util.log.Logger;
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ManagedObject("Servlet Holder")
|
||||||
public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope, Comparable
|
public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope, Comparable
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(ServletHolder.class);
|
private static final Logger LOG = Log.getLogger(ServletHolder.class);
|
||||||
|
@ -157,6 +160,7 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ManagedAttribute(value="initialization order", readonly=true)
|
||||||
public int getInitOrder()
|
public int getInitOrder()
|
||||||
{
|
{
|
||||||
return _initOrder;
|
return _initOrder;
|
||||||
|
@ -254,6 +258,7 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
|
||||||
/**
|
/**
|
||||||
* @return Returns the forcedPath.
|
* @return Returns the forcedPath.
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute(value="forced servlet path", readonly=true)
|
||||||
public String getForcedPath()
|
public String getForcedPath()
|
||||||
{
|
{
|
||||||
return _forcedPath;
|
return _forcedPath;
|
||||||
|
@ -585,6 +590,7 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ManagedAttribute(value="role to run servlet as", readonly=true)
|
||||||
public String getRunAsRole()
|
public String getRunAsRole()
|
||||||
{
|
{
|
||||||
return _runAsRole;
|
return _runAsRole;
|
||||||
|
|
|
@ -16,7 +16,10 @@ package org.eclipse.jetty.servlet;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||||
|
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||||
|
|
||||||
|
@ManagedObject("Servlet Mapping")
|
||||||
public class ServletMapping
|
public class ServletMapping
|
||||||
{
|
{
|
||||||
private String[] _pathSpecs;
|
private String[] _pathSpecs;
|
||||||
|
@ -33,6 +36,7 @@ public class ServletMapping
|
||||||
/**
|
/**
|
||||||
* @return Returns the pathSpecs.
|
* @return Returns the pathSpecs.
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute(value="url patterns", readonly=true)
|
||||||
public String[] getPathSpecs()
|
public String[] getPathSpecs()
|
||||||
{
|
{
|
||||||
return _pathSpecs;
|
return _pathSpecs;
|
||||||
|
@ -42,6 +46,7 @@ public class ServletMapping
|
||||||
/**
|
/**
|
||||||
* @return Returns the servletName.
|
* @return Returns the servletName.
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute(value="servlet name", readonly=true)
|
||||||
public String getServletName()
|
public String getServletName()
|
||||||
{
|
{
|
||||||
return _servletName;
|
return _servletName;
|
||||||
|
@ -79,6 +84,7 @@ public class ServletMapping
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute(value="default", readonly=true)
|
||||||
public boolean isDefault()
|
public boolean isDefault()
|
||||||
{
|
{
|
||||||
return _default;
|
return _default;
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
FilterMapping: Filter Mapping
|
|
||||||
filterName: RO:Filter Name
|
|
||||||
pathSpecs: RO:URL patterns
|
|
||||||
servletNames: RO:Servlet Names
|
|
|
@ -1,5 +0,0 @@
|
||||||
Holder: Holder
|
|
||||||
name: RO:Name
|
|
||||||
displayName: RO:Display Name
|
|
||||||
className: RO:Class Name
|
|
||||||
initParameters: RO:Initial parameters
|
|
|
@ -1,4 +0,0 @@
|
||||||
ServletContextHandler: Servlet Context Handler
|
|
||||||
securityHandler: MObject: The context's security handler
|
|
||||||
servletHandler: MObject: The context's servlet handler
|
|
||||||
sessionHandler: MObject: The context's session handler
|
|
|
@ -1,5 +0,0 @@
|
||||||
ServletHandler: Servlet Handler
|
|
||||||
servlets: MObject:RO:Servlets
|
|
||||||
servletMappings: MObject:RO:Mappings of servlets
|
|
||||||
filters: MObject:RO:Filters
|
|
||||||
filterMappings: MObject:RO:Mappings of filters
|
|
|
@ -1,4 +0,0 @@
|
||||||
ServletHolder: Servlet Holder
|
|
||||||
initOrder: Initialization order
|
|
||||||
runAsRole: Role to run servlet as
|
|
||||||
forcedPath: Forced servlet path
|
|
|
@ -1,3 +0,0 @@
|
||||||
ServletMapping: Servlet Mapping
|
|
||||||
servletName: RO:Servlet Name
|
|
||||||
pathSpecs: RO:URL patterns
|
|
|
@ -29,6 +29,4 @@ public @interface ManagedObject
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String value() default "Not Specified";
|
String value() default "Not Specified";
|
||||||
|
|
||||||
String wrapper() default "";
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public @interface ManagedOperation
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String value() default "Not Specified";
|
String value() default "Not Specified";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The impact of an operation.
|
* The impact of an operation.
|
||||||
|
|
Loading…
Reference in New Issue