convert jetty-servlet to annotated jmx

This commit is contained in:
Jesse McConnell 2012-08-15 08:41:16 -05:00
parent b7407000cb
commit a06d5e96b6
12 changed files with 38 additions and 26 deletions

View File

@ -21,10 +21,12 @@ import javax.servlet.DispatcherType;
import org.eclipse.jetty.http.PathMap;
import org.eclipse.jetty.server.Handler;
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.Dumpable;
@ManagedObject("Filter Mappings")
public class FilterMapping implements Dumpable
{
/** Dispatch types */
@ -126,6 +128,7 @@ public class FilterMapping implements Dumpable
/**
* @return Returns the filterName.
*/
@ManagedAttribute(value="filter name", readonly=true)
public String getFilterName()
{
return _filterName;
@ -144,6 +147,7 @@ public class FilterMapping implements Dumpable
/**
* @return Returns the pathSpec.
*/
@ManagedAttribute(value="url patterns", readonly=true)
public String[] getPathSpecs()
{
return _pathSpecs;
@ -223,6 +227,7 @@ public class FilterMapping implements Dumpable
/**
* @return Returns the servletName.
*/
@ManagedAttribute(value="servlet names", readonly=true)
public String[] getServletNames()
{
return _servletNames;

View File

@ -27,6 +27,8 @@ import javax.servlet.UnavailableException;
import org.eclipse.jetty.server.handler.ContextHandler;
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.AggregateLifeCycle;
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 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()
{
return _className;
@ -123,6 +127,7 @@ public class Holder<T> extends AbstractLifeCycle implements Dumpable
}
/* ------------------------------------------------------------ */
@ManagedAttribute(value="Display Name", readonly=true)
public String getDisplayName()
{
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()
{
return _initParams;
}
/* ------------------------------------------------------------ */
@ManagedAttribute(value="Name", readonly=true)
public String getName()
{
return _name;

View File

@ -53,6 +53,8 @@ import org.eclipse.jetty.server.handler.ErrorHandler;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.server.handler.HandlerWrapper;
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
* cause confusion with {@link ServletContext}.
*/
@ManagedObject("Servlet Context Handler")
public class ServletContextHandler extends ContextHandler
{
public final static int SESSIONS=1;
@ -262,6 +265,7 @@ public class ServletContextHandler extends ContextHandler
/**
* @return Returns the securityHandler.
*/
@ManagedAttribute(value="context security handler", readonly=true)
public SecurityHandler getSecurityHandler()
{
if (_securityHandler==null && (_options&SECURITY)!=0 && !isStarted())
@ -274,6 +278,7 @@ public class ServletContextHandler extends ContextHandler
/**
* @return Returns the servletHandler.
*/
@ManagedAttribute(value="context servlet handler", readonly=true)
public ServletHandler getServletHandler()
{
if (_servletHandler==null && !isStarted())
@ -285,6 +290,7 @@ public class ServletContextHandler extends ContextHandler
/**
* @return Returns the sessionHandler.
*/
@ManagedAttribute(value="context session handler", readonly=true)
public SessionHandler getSessionHandler()
{
if (_sessionHandler==null && (_options&SESSIONS)!=0 && !isStarted())

View File

@ -62,6 +62,8 @@ import org.eclipse.jetty.util.MultiException;
import org.eclipse.jetty.util.MultiMap;
import org.eclipse.jetty.util.TypeUtil;
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.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()}
* method must be called manually after start().
*/
@ManagedObject("Servlet Handler")
public class ServletHandler extends ScopedHandler
{
private static final Logger LOG = Log.getLogger(ServletHandler.class);
@ -230,6 +233,7 @@ public class ServletHandler extends ScopedHandler
/**
* @return Returns the filterMappings.
*/
@ManagedAttribute(value="filters", readonly=true)
public FilterMapping[] getFilterMappings()
{
return _filterMappings;
@ -239,6 +243,7 @@ public class ServletHandler extends ScopedHandler
/** Get Filters.
* @return Array of defined servlets
*/
@ManagedAttribute(value="filters", readonly=true)
public FilterHolder[] getFilters()
{
return _filters;
@ -266,6 +271,7 @@ public class ServletHandler extends ScopedHandler
/**
* @return Returns the servletMappings.
*/
@ManagedAttribute(value="mappings of servlets", readonly=true)
public ServletMapping[] getServletMappings()
{
return _servletMappings;
@ -300,6 +306,7 @@ public class ServletHandler extends ScopedHandler
/** Get Servlets.
* @return Array of defined servlets
*/
@ManagedAttribute(value="servlets", readonly=true)
public ServletHolder[] getServlets()
{
return _servlets;

View File

@ -43,6 +43,8 @@ import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.UserIdentity;
import org.eclipse.jetty.server.handler.ContextHandler;
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.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
{
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()
{
return _initOrder;
@ -254,6 +258,7 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
/**
* @return Returns the forcedPath.
*/
@ManagedAttribute(value="forced servlet path", readonly=true)
public String getForcedPath()
{
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()
{
return _runAsRole;

View File

@ -16,7 +16,10 @@ package org.eclipse.jetty.servlet;
import java.io.IOException;
import java.util.Arrays;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
@ManagedObject("Servlet Mapping")
public class ServletMapping
{
private String[] _pathSpecs;
@ -33,6 +36,7 @@ public class ServletMapping
/**
* @return Returns the pathSpecs.
*/
@ManagedAttribute(value="url patterns", readonly=true)
public String[] getPathSpecs()
{
return _pathSpecs;
@ -42,6 +46,7 @@ public class ServletMapping
/**
* @return Returns the servletName.
*/
@ManagedAttribute(value="servlet name", readonly=true)
public String getServletName()
{
return _servletName;
@ -79,6 +84,7 @@ public class ServletMapping
/**
* @return
*/
@ManagedAttribute(value="default", readonly=true)
public boolean isDefault()
{
return _default;

View File

@ -1,4 +0,0 @@
FilterMapping: Filter Mapping
filterName: RO:Filter Name
pathSpecs: RO:URL patterns
servletNames: RO:Servlet Names

View File

@ -1,5 +0,0 @@
Holder: Holder
name: RO:Name
displayName: RO:Display Name
className: RO:Class Name
initParameters: RO:Initial parameters

View File

@ -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

View File

@ -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

View File

@ -1,4 +0,0 @@
ServletHolder: Servlet Holder
initOrder: Initialization order
runAsRole: Role to run servlet as
forcedPath: Forced servlet path

View File

@ -1,3 +0,0 @@
ServletMapping: Servlet Mapping
servletName: RO:Servlet Name
pathSpecs: RO:URL patterns