Remove Managed annotation and convert the context handler over to the new usage
This commit is contained in:
parent
608e74b9bf
commit
86daeab0ca
|
@ -68,7 +68,8 @@ import org.eclipse.jetty.util.Loader;
|
||||||
import org.eclipse.jetty.util.StringUtil;
|
import org.eclipse.jetty.util.StringUtil;
|
||||||
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.Managed;
|
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;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
|
@ -90,7 +91,7 @@ import org.eclipse.jetty.util.resource.Resource;
|
||||||
*
|
*
|
||||||
* @org.apache.xbean.XBean description="Creates a basic HTTP context"
|
* @org.apache.xbean.XBean description="Creates a basic HTTP context"
|
||||||
*/
|
*/
|
||||||
@Managed("URI Context")
|
@ManagedObject("URI Context")
|
||||||
public class ContextHandler extends ScopedHandler implements Attributes, Server.Graceful
|
public class ContextHandler extends ScopedHandler implements Attributes, Server.Graceful
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -121,41 +122,33 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
||||||
private final AttributesMap _attributes;
|
private final AttributesMap _attributes;
|
||||||
private final AttributesMap _contextAttributes;
|
private final AttributesMap _contextAttributes;
|
||||||
|
|
||||||
@Managed("Initial Parameter map for the context")
|
|
||||||
private final Map<String, String> _initParams;
|
private final Map<String, String> _initParams;
|
||||||
|
|
||||||
private ClassLoader _classLoader;
|
private ClassLoader _classLoader;
|
||||||
private String _contextPath = "/";
|
private String _contextPath = "/";
|
||||||
|
|
||||||
@Managed(value="Display name of the Context", readonly=true)
|
|
||||||
private String _displayName;
|
private String _displayName;
|
||||||
|
|
||||||
private Resource _baseResource;
|
private Resource _baseResource;
|
||||||
private MimeTypes _mimeTypes;
|
private MimeTypes _mimeTypes;
|
||||||
private Map<String, String> _localeEncodingMap;
|
private Map<String, String> _localeEncodingMap;
|
||||||
|
|
||||||
@Managed("Partial URIs of directory welcome files")
|
|
||||||
private String[] _welcomeFiles;
|
private String[] _welcomeFiles;
|
||||||
|
|
||||||
@Managed(value="The error handler to use for the context", managed=true)
|
|
||||||
private ErrorHandler _errorHandler;
|
private ErrorHandler _errorHandler;
|
||||||
|
|
||||||
@Managed("Virtual hosts accepted by the context")
|
|
||||||
private String[] _vhosts;
|
private String[] _vhosts;
|
||||||
|
|
||||||
private Set<String> _connectors;
|
private Set<String> _connectors;
|
||||||
private EventListener[] _eventListeners;
|
private EventListener[] _eventListeners;
|
||||||
private Logger _logger;
|
private Logger _logger;
|
||||||
|
|
||||||
@Managed("Checks if the /context is not redirected to /context/")
|
|
||||||
private boolean _allowNullPathInfo;
|
private boolean _allowNullPathInfo;
|
||||||
|
|
||||||
private int _maxFormKeys = Integer.getInteger("org.eclipse.jetty.server.Request.maxFormKeys",1000).intValue();
|
private int _maxFormKeys = Integer.getInteger("org.eclipse.jetty.server.Request.maxFormKeys",1000).intValue();
|
||||||
|
|
||||||
@Managed("The maximum content size")
|
|
||||||
private int _maxFormContentSize = Integer.getInteger("org.eclipse.jetty.server.Request.maxFormContentSize",200000).intValue();
|
private int _maxFormContentSize = Integer.getInteger("org.eclipse.jetty.server.Request.maxFormContentSize",200000).intValue();
|
||||||
|
|
||||||
@Managed("True if URLs are compacted to replace the multiple '/'s with a single '/'")
|
|
||||||
private boolean _compactPath = false;
|
private boolean _compactPath = false;
|
||||||
|
|
||||||
private boolean _aliases = false;
|
private boolean _aliases = false;
|
||||||
|
@ -167,7 +160,6 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
||||||
private Map<String, Object> _managedAttributes;
|
private Map<String, Object> _managedAttributes;
|
||||||
private String[] _protectedTargets;
|
private String[] _protectedTargets;
|
||||||
|
|
||||||
@Managed("False if this context is accepting new requests. True for graceful shutdown, which allows existing requests to complete")
|
|
||||||
private boolean _shutdown = false;
|
private boolean _shutdown = false;
|
||||||
|
|
||||||
private boolean _available = true;
|
private boolean _available = true;
|
||||||
|
@ -244,6 +236,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
||||||
/**
|
/**
|
||||||
* @return the allowNullPathInfo true if /context is not redirected to /context/
|
* @return the allowNullPathInfo true if /context is not redirected to /context/
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute("Checks if the /context is not redirected to /context/")
|
||||||
public boolean getAllowNullPathInfo()
|
public boolean getAllowNullPathInfo()
|
||||||
{
|
{
|
||||||
return _allowNullPathInfo;
|
return _allowNullPathInfo;
|
||||||
|
@ -389,6 +382,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
||||||
* @return Array of virtual hosts that this context responds to. A null host name or empty array means any hostname is acceptable. Host names may be String
|
* @return Array of virtual hosts that this context responds to. A null host name or empty array means any hostname is acceptable. Host names may be String
|
||||||
* representation of IP addresses. Host names may start with '*.' to wildcard one level of names.
|
* representation of IP addresses. Host names may start with '*.' to wildcard one level of names.
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute("Virtual hosts accepted by the context")
|
||||||
public String[] getVirtualHosts()
|
public String[] getVirtualHosts()
|
||||||
{
|
{
|
||||||
return _vhosts;
|
return _vhosts;
|
||||||
|
@ -398,6 +392,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
||||||
/**
|
/**
|
||||||
* @return an array of connector names that this context will accept a request from.
|
* @return an array of connector names that this context will accept a request from.
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute("Names and ports of accepted connectors")
|
||||||
public String[] getConnectorNames()
|
public String[] getConnectorNames()
|
||||||
{
|
{
|
||||||
if (_connectors == null || _connectors.size() == 0)
|
if (_connectors == null || _connectors.size() == 0)
|
||||||
|
@ -466,6 +461,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
||||||
*
|
*
|
||||||
* @return Returns the classLoader.
|
* @return Returns the classLoader.
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute("The file classpath")
|
||||||
public String getClassPath()
|
public String getClassPath()
|
||||||
{
|
{
|
||||||
if (_classLoader == null || !(_classLoader instanceof URLClassLoader))
|
if (_classLoader == null || !(_classLoader instanceof URLClassLoader))
|
||||||
|
@ -500,6 +496,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
||||||
/**
|
/**
|
||||||
* @return Returns the _contextPath.
|
* @return Returns the _contextPath.
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute("True if URLs are compacted to replace the multiple '/'s with a single '/'")
|
||||||
public String getContextPath()
|
public String getContextPath()
|
||||||
{
|
{
|
||||||
return _contextPath;
|
return _contextPath;
|
||||||
|
@ -536,6 +533,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
||||||
/**
|
/**
|
||||||
* @return Returns the initParams.
|
* @return Returns the initParams.
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute("Initial Parameter map for the context")
|
||||||
public Map<String, String> getInitParams()
|
public Map<String, String> getInitParams()
|
||||||
{
|
{
|
||||||
return _initParams;
|
return _initParams;
|
||||||
|
@ -545,6 +543,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
||||||
/*
|
/*
|
||||||
* @see javax.servlet.ServletContext#getServletContextName()
|
* @see javax.servlet.ServletContext#getServletContextName()
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute(value="Display name of the Context", readonly=true)
|
||||||
public String getDisplayName()
|
public String getDisplayName()
|
||||||
{
|
{
|
||||||
return _displayName;
|
return _displayName;
|
||||||
|
@ -625,6 +624,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
||||||
/**
|
/**
|
||||||
* @return true if this context is accepting new requests
|
* @return true if this context is accepting new requests
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute("False if this context is accepting new requests. True for graceful shutdown, which allows existing requests to complete")
|
||||||
public boolean isShutdown()
|
public boolean isShutdown()
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
|
@ -1319,6 +1319,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
||||||
/**
|
/**
|
||||||
* @return Returns the base resource as a string.
|
* @return Returns the base resource as a string.
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute("document root for context")
|
||||||
public String getResourceBase()
|
public String getResourceBase()
|
||||||
{
|
{
|
||||||
if (_baseResource == null)
|
if (_baseResource == null)
|
||||||
|
@ -1409,6 +1410,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
||||||
* @see <a href="http://jcp.org/aboutJava/communityprocess/final/jsr154/index.html">The Servlet Specification</a>
|
* @see <a href="http://jcp.org/aboutJava/communityprocess/final/jsr154/index.html">The Servlet Specification</a>
|
||||||
* @see #setWelcomeFiles
|
* @see #setWelcomeFiles
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute("Partial URIs of directory welcome files")
|
||||||
public String[] getWelcomeFiles()
|
public String[] getWelcomeFiles()
|
||||||
{
|
{
|
||||||
return _welcomeFiles;
|
return _welcomeFiles;
|
||||||
|
@ -1418,6 +1420,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
||||||
/**
|
/**
|
||||||
* @return Returns the errorHandler.
|
* @return Returns the errorHandler.
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute(value="The error handler to use for the context", managed=true)
|
||||||
public ErrorHandler getErrorHandler()
|
public ErrorHandler getErrorHandler()
|
||||||
{
|
{
|
||||||
return _errorHandler;
|
return _errorHandler;
|
||||||
|
@ -1438,6 +1441,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ManagedAttribute("The maximum content size")
|
||||||
public int getMaxFormContentSize()
|
public int getMaxFormContentSize()
|
||||||
{
|
{
|
||||||
return _maxFormContentSize;
|
return _maxFormContentSize;
|
||||||
|
|
|
@ -19,7 +19,8 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||||
import org.eclipse.jetty.util.Attributes;
|
import org.eclipse.jetty.util.Attributes;
|
||||||
import org.eclipse.jetty.util.annotation.Managed;
|
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||||
|
import org.eclipse.jetty.util.annotation.ManagedOperation;
|
||||||
import org.eclipse.jetty.util.annotation.Name;
|
import org.eclipse.jetty.util.annotation.Name;
|
||||||
|
|
||||||
public class ContextHandlerMBean extends AbstractHandlerMBean
|
public class ContextHandlerMBean extends AbstractHandlerMBean
|
||||||
|
@ -29,7 +30,7 @@ public class ContextHandlerMBean extends AbstractHandlerMBean
|
||||||
super(managedObject);
|
super(managedObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Managed(value="Map of context attributes", readonly=true, attribute=true)
|
@ManagedAttribute("Map of context attributes")
|
||||||
public Map getContextAttributes()
|
public Map getContextAttributes()
|
||||||
{
|
{
|
||||||
Map map = new HashMap();
|
Map map = new HashMap();
|
||||||
|
@ -44,21 +45,21 @@ public class ContextHandlerMBean extends AbstractHandlerMBean
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Managed(value="Set context attribute", impact="ACTION")
|
@ManagedOperation(value="Set context attribute", impact="ACTION")
|
||||||
public void setContextAttribute(@Name(value = "name", description="attribute name") String name, @Name(value = "value", description="attribute value") Object value)
|
public void setContextAttribute(@Name(value = "name", description="attribute name") String name, @Name(value = "value", description="attribute value") Object value)
|
||||||
{
|
{
|
||||||
Attributes attrs = ((ContextHandler)_managed).getAttributes();
|
Attributes attrs = ((ContextHandler)_managed).getAttributes();
|
||||||
attrs.setAttribute(name,value);
|
attrs.setAttribute(name,value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Managed(value="Set context attribute", impact="ACTION")
|
@ManagedOperation(value="Set context attribute", impact="ACTION")
|
||||||
public void setContextAttribute(@Name(value = "name", description="attribute name") String name, @Name(value = "value", description="attribute value") String value)
|
public void setContextAttribute(@Name(value = "name", description="attribute name") String name, @Name(value = "value", description="attribute value") String value)
|
||||||
{
|
{
|
||||||
Attributes attrs = ((ContextHandler)_managed).getAttributes();
|
Attributes attrs = ((ContextHandler)_managed).getAttributes();
|
||||||
attrs.setAttribute(name,value);
|
attrs.setAttribute(name,value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Managed(value="Remove context attribute", impact="ACTION")
|
@ManagedOperation(value="Remove context attribute", impact="ACTION")
|
||||||
public void removeContextAttribute(@Name(value = "name", description="attribute name") String name)
|
public void removeContextAttribute(@Name(value = "name", description="attribute name") String name)
|
||||||
{
|
{
|
||||||
Attributes attrs = ((ContextHandler)_managed).getAttributes();
|
Attributes attrs = ((ContextHandler)_managed).getAttributes();
|
||||||
|
|
|
@ -1,100 +0,0 @@
|
||||||
package org.eclipse.jetty.util.annotation;
|
|
||||||
//========================================================================
|
|
||||||
//Copyright 2011-2012 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.
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Documented
|
|
||||||
@Target( { ElementType.TYPE, ElementType.METHOD, ElementType.FIELD } )
|
|
||||||
public @interface Managed
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Description of the Managed Object
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
String value() default "Not Specified";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is the managed field read-only?
|
|
||||||
*
|
|
||||||
* NOTE: applies to FIELD
|
|
||||||
*
|
|
||||||
* @return true if readonly
|
|
||||||
*/
|
|
||||||
boolean readonly() default false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is the managed field itself a Managed Object?
|
|
||||||
*
|
|
||||||
* NOTE: applies to FIELD
|
|
||||||
*
|
|
||||||
* @return true if the target is a Managed Object
|
|
||||||
*/
|
|
||||||
boolean managed() default false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Does the managed field or method exist on a proxy object?
|
|
||||||
*
|
|
||||||
* NOTE: applies to FIELD and METHOD
|
|
||||||
*
|
|
||||||
* @return true if a proxy object is involved
|
|
||||||
*/
|
|
||||||
boolean proxied() default false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The impact of an operation.
|
|
||||||
*
|
|
||||||
* NOTE: Valid values are UNKNOWN, ACTION, INFO, ACTION_INFO
|
|
||||||
*
|
|
||||||
* NOTE: applies to METHOD
|
|
||||||
*
|
|
||||||
* @return String representing the impact of the operation
|
|
||||||
*/
|
|
||||||
String impact() default "UNKNOWN";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If is a field references a getter that doesn't conform to standards for discovery
|
|
||||||
* it can be set here.
|
|
||||||
*
|
|
||||||
* NOTE: applies to FIELD
|
|
||||||
*
|
|
||||||
* @return the full name of the getter in question
|
|
||||||
*/
|
|
||||||
String getter() default "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If is a field references a setter that doesn't conform to standards for discovery
|
|
||||||
* it can be set here.
|
|
||||||
*
|
|
||||||
* NOTE: applies to FIELD
|
|
||||||
*
|
|
||||||
* @return the full name of the setter in question
|
|
||||||
*/
|
|
||||||
String setter() default "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Treat method as an attribute and not an operation
|
|
||||||
*
|
|
||||||
* NOTE: applies to METHOD
|
|
||||||
*
|
|
||||||
* @return true of the method should be treating as an attribute
|
|
||||||
*/
|
|
||||||
boolean attribute() default false;
|
|
||||||
}
|
|
Loading…
Reference in New Issue