more mbean -> annotation conversion

This commit is contained in:
Jesse McConnell 2012-08-13 11:56:25 -05:00
parent 9f4375d1e5
commit 51eac5ddf7
13 changed files with 49 additions and 62 deletions

View File

@ -18,6 +18,7 @@ import java.io.IOException;
import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
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.log.Log; import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.log.Logger;
@ -28,6 +29,7 @@ import org.eclipse.jetty.util.log.Logger;
* *
* *
*/ */
@ManagedObject("Jetty Handler")
public abstract class AbstractHandler extends AggregateLifeCycle implements Handler public abstract class AbstractHandler extends AggregateLifeCycle implements Handler
{ {
private static final Logger LOG = Log.getLogger(AbstractHandler.class); private static final Logger LOG = Log.getLogger(AbstractHandler.class);

View File

@ -624,7 +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") @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)
@ -1360,6 +1360,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
/** /**
* @return True if aliases are allowed * @return True if aliases are allowed
*/ */
@ManagedAttribute("true if alias checking is performed on resource")
public boolean isAliases() public boolean isAliases()
{ {
return _aliases; return _aliases;

View File

@ -27,6 +27,8 @@ import org.eclipse.jetty.server.HandlerContainer;
import org.eclipse.jetty.server.HttpChannelState; import org.eclipse.jetty.server.HttpChannelState;
import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.util.LazyList; import org.eclipse.jetty.util.LazyList;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.annotation.ManagedOperation;
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;
@ -40,8 +42,8 @@ import org.eclipse.jetty.util.log.Logger;
* Multiple contexts may have the same context path and they are called in order until one * Multiple contexts may have the same context path and they are called in order until one
* handles the request. * handles the request.
* *
* @org.apache.xbean.XBean element="contexts"
*/ */
@ManagedObject("Context Handler Collection")
public class ContextHandlerCollection extends HandlerCollection public class ContextHandlerCollection extends HandlerCollection
{ {
private static final Logger LOG = Log.getLogger(ContextHandlerCollection.class); private static final Logger LOG = Log.getLogger(ContextHandlerCollection.class);
@ -60,6 +62,7 @@ public class ContextHandlerCollection extends HandlerCollection
/** /**
* Remap the context paths. * Remap the context paths.
*/ */
@ManagedOperation("update the mapping of context path to context")
public void mapContexts() public void mapContexts()
{ {
PathMap<Object> contextMap = new PathMap<Object>(); PathMap<Object> contextMap = new PathMap<Object>();

View File

@ -26,6 +26,8 @@ import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.ArrayUtil; import org.eclipse.jetty.util.ArrayUtil;
import org.eclipse.jetty.util.MultiException; import org.eclipse.jetty.util.MultiException;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/** A collection of handlers. /** A collection of handlers.
@ -36,8 +38,8 @@ import org.eclipse.jetty.util.MultiException;
* handlers. * handlers.
* <p> * <p>
* *
* @org.apache.xbean.XBean
*/ */
@ManagedObject("Handler of multiple handlers")
public class HandlerCollection extends AbstractHandlerContainer public class HandlerCollection extends AbstractHandlerContainer
{ {
private final boolean _mutableWhenRunning; private final boolean _mutableWhenRunning;
@ -61,6 +63,7 @@ public class HandlerCollection extends AbstractHandlerContainer
* @return Returns the handlers. * @return Returns the handlers.
*/ */
@Override @Override
@ManagedAttribute(value="Wrapped handlers", managed=true)
public Handler[] getHandlers() public Handler[] getHandlers()
{ {
return _handlers; return _handlers;

View File

@ -23,6 +23,8 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.LifeCycle; import org.eclipse.jetty.util.component.LifeCycle;
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@ -30,6 +32,7 @@ import org.eclipse.jetty.util.component.LifeCycle;
* {@link LifeCycle life cycle} events to a delegate. This is primarily used to implement the <i>Decorator</i> pattern. * {@link LifeCycle life cycle} events to a delegate. This is primarily used to implement the <i>Decorator</i> pattern.
* *
*/ */
@ManagedObject("Handler wrapping another Handler")
public class HandlerWrapper extends AbstractHandlerContainer public class HandlerWrapper extends AbstractHandlerContainer
{ {
protected Handler _handler; protected Handler _handler;
@ -46,6 +49,7 @@ public class HandlerWrapper extends AbstractHandlerContainer
/** /**
* @return Returns the handlers. * @return Returns the handlers.
*/ */
@ManagedAttribute(value="Wrapped Handler", managed=true)
public Handler getHandler() public Handler getHandler()
{ {
return _handler; return _handler;

View File

@ -26,9 +26,13 @@ import org.eclipse.jetty.continuation.ContinuationListener;
import org.eclipse.jetty.server.HttpChannelState; import org.eclipse.jetty.server.HttpChannelState;
import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Response; import org.eclipse.jetty.server.Response;
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.statistic.CounterStatistic; import org.eclipse.jetty.util.statistic.CounterStatistic;
import org.eclipse.jetty.util.statistic.SampleStatistic; import org.eclipse.jetty.util.statistic.SampleStatistic;
@ManagedObject("Request Statistics Gathering")
public class StatisticsHandler extends HandlerWrapper public class StatisticsHandler extends HandlerWrapper
{ {
private final AtomicLong _statsStartedAt = new AtomicLong(); private final AtomicLong _statsStartedAt = new AtomicLong();
@ -74,6 +78,7 @@ public class StatisticsHandler extends HandlerWrapper
/** /**
* Resets the current request statistics. * Resets the current request statistics.
*/ */
@ManagedOperation(value="resets statistics", impact="ACTION")
public void statsReset() public void statsReset()
{ {
_statsStartedAt.set(System.currentTimeMillis()); _statsStartedAt.set(System.currentTimeMillis());
@ -189,6 +194,7 @@ public class StatisticsHandler extends HandlerWrapper
* active requests * active requests
* @see #getResumes() * @see #getResumes()
*/ */
@ManagedAttribute("number of requests")
public int getRequests() public int getRequests()
{ {
return (int)_requestStats.getTotal(); return (int)_requestStats.getTotal();
@ -198,6 +204,7 @@ public class StatisticsHandler extends HandlerWrapper
* @return the number of requests currently active. * @return the number of requests currently active.
* since {@link #statsReset()} was last called. * since {@link #statsReset()} was last called.
*/ */
@ManagedAttribute("number of requests currently active")
public int getRequestsActive() public int getRequestsActive()
{ {
return (int)_requestStats.getCurrent(); return (int)_requestStats.getCurrent();
@ -207,6 +214,7 @@ public class StatisticsHandler extends HandlerWrapper
* @return the maximum number of active requests * @return the maximum number of active requests
* since {@link #statsReset()} was last called. * since {@link #statsReset()} was last called.
*/ */
@ManagedAttribute("maximum number of active requests")
public int getRequestsActiveMax() public int getRequestsActiveMax()
{ {
return (int)_requestStats.getMax(); return (int)_requestStats.getMax();
@ -216,6 +224,7 @@ public class StatisticsHandler extends HandlerWrapper
* @return the maximum time (in milliseconds) of request handling * @return the maximum time (in milliseconds) of request handling
* since {@link #statsReset()} was last called. * since {@link #statsReset()} was last called.
*/ */
@ManagedAttribute("maximum time spend handling requests (in ms)")
public long getRequestTimeMax() public long getRequestTimeMax()
{ {
return _requestTimeStats.getMax(); return _requestTimeStats.getMax();
@ -225,6 +234,7 @@ public class StatisticsHandler extends HandlerWrapper
* @return the total time (in milliseconds) of requests handling * @return the total time (in milliseconds) of requests handling
* since {@link #statsReset()} was last called. * since {@link #statsReset()} was last called.
*/ */
@ManagedAttribute("total time spend in all request handling (in ms)")
public long getRequestTimeTotal() public long getRequestTimeTotal()
{ {
return _requestTimeStats.getTotal(); return _requestTimeStats.getTotal();
@ -236,6 +246,7 @@ public class StatisticsHandler extends HandlerWrapper
* @see #getRequestTimeTotal() * @see #getRequestTimeTotal()
* @see #getRequests() * @see #getRequests()
*/ */
@ManagedAttribute("mean time spent handling requests (in ms)")
public double getRequestTimeMean() public double getRequestTimeMean()
{ {
return _requestTimeStats.getMean(); return _requestTimeStats.getMean();
@ -247,6 +258,7 @@ public class StatisticsHandler extends HandlerWrapper
* @see #getRequestTimeTotal() * @see #getRequestTimeTotal()
* @see #getRequests() * @see #getRequests()
*/ */
@ManagedAttribute("standard deviation for request handling (in ms)")
public double getRequestTimeStdDev() public double getRequestTimeStdDev()
{ {
return _requestTimeStats.getStdDev(); return _requestTimeStats.getStdDev();
@ -257,6 +269,7 @@ public class StatisticsHandler extends HandlerWrapper
* since {@link #statsReset()} was last called, excluding * since {@link #statsReset()} was last called, excluding
* active dispatches * active dispatches
*/ */
@ManagedAttribute("number of dispatches")
public int getDispatched() public int getDispatched()
{ {
return (int)_dispatchedStats.getTotal(); return (int)_dispatchedStats.getTotal();
@ -267,6 +280,7 @@ public class StatisticsHandler extends HandlerWrapper
* since {@link #statsReset()} was last called, including * since {@link #statsReset()} was last called, including
* resumed requests * resumed requests
*/ */
@ManagedAttribute("number of dispatches currently active")
public int getDispatchedActive() public int getDispatchedActive()
{ {
return (int)_dispatchedStats.getCurrent(); return (int)_dispatchedStats.getCurrent();
@ -277,6 +291,7 @@ public class StatisticsHandler extends HandlerWrapper
* since {@link #statsReset()} was last called, including * since {@link #statsReset()} was last called, including
* resumed requests * resumed requests
*/ */
@ManagedAttribute("maximum number of active dispatches being handled")
public int getDispatchedActiveMax() public int getDispatchedActiveMax()
{ {
return (int)_dispatchedStats.getMax(); return (int)_dispatchedStats.getMax();
@ -286,6 +301,7 @@ public class StatisticsHandler extends HandlerWrapper
* @return the maximum time (in milliseconds) of request dispatch * @return the maximum time (in milliseconds) of request dispatch
* since {@link #statsReset()} was last called. * since {@link #statsReset()} was last called.
*/ */
@ManagedAttribute("maximum time spend in dispatch handling")
public long getDispatchedTimeMax() public long getDispatchedTimeMax()
{ {
return _dispatchedTimeStats.getMax(); return _dispatchedTimeStats.getMax();
@ -295,6 +311,7 @@ public class StatisticsHandler extends HandlerWrapper
* @return the total time (in milliseconds) of requests handling * @return the total time (in milliseconds) of requests handling
* since {@link #statsReset()} was last called. * since {@link #statsReset()} was last called.
*/ */
@ManagedAttribute("total time spent in dispatch handling (in ms)")
public long getDispatchedTimeTotal() public long getDispatchedTimeTotal()
{ {
return _dispatchedTimeStats.getTotal(); return _dispatchedTimeStats.getTotal();
@ -306,6 +323,7 @@ public class StatisticsHandler extends HandlerWrapper
* @see #getRequestTimeTotal() * @see #getRequestTimeTotal()
* @see #getRequests() * @see #getRequests()
*/ */
@ManagedAttribute("mean time spent in dispatch handling (in ms)")
public double getDispatchedTimeMean() public double getDispatchedTimeMean()
{ {
return _dispatchedTimeStats.getMean(); return _dispatchedTimeStats.getMean();
@ -317,6 +335,7 @@ public class StatisticsHandler extends HandlerWrapper
* @see #getRequestTimeTotal() * @see #getRequestTimeTotal()
* @see #getRequests() * @see #getRequests()
*/ */
@ManagedAttribute("standard deviation for dispatch handling (in ms)")
public double getDispatchedTimeStdDev() public double getDispatchedTimeStdDev()
{ {
return _dispatchedTimeStats.getStdDev(); return _dispatchedTimeStats.getStdDev();
@ -328,6 +347,7 @@ public class StatisticsHandler extends HandlerWrapper
* resumed requests * resumed requests
* @see #getResumes() * @see #getResumes()
*/ */
@ManagedAttribute("number of requests suspended")
public int getSuspends() public int getSuspends()
{ {
return (int)_suspendStats.getTotal(); return (int)_suspendStats.getTotal();
@ -337,6 +357,7 @@ public class StatisticsHandler extends HandlerWrapper
* @return the number of requests currently suspended. * @return the number of requests currently suspended.
* since {@link #statsReset()} was last called. * since {@link #statsReset()} was last called.
*/ */
@ManagedAttribute("number of currently suspended requests")
public int getSuspendsActive() public int getSuspendsActive()
{ {
return (int)_suspendStats.getCurrent(); return (int)_suspendStats.getCurrent();
@ -346,6 +367,7 @@ public class StatisticsHandler extends HandlerWrapper
* @return the maximum number of current suspended requests * @return the maximum number of current suspended requests
* since {@link #statsReset()} was last called. * since {@link #statsReset()} was last called.
*/ */
@ManagedAttribute("maximum number of suspended requests")
public int getSuspendsActiveMax() public int getSuspendsActiveMax()
{ {
return (int)_suspendStats.getMax(); return (int)_suspendStats.getMax();
@ -355,6 +377,7 @@ public class StatisticsHandler extends HandlerWrapper
* @return the number of requests that have been resumed * @return the number of requests that have been resumed
* @see #getExpires() * @see #getExpires()
*/ */
@ManagedAttribute("number of requested that have been resumed")
public int getResumes() public int getResumes()
{ {
return _resumes.get(); return _resumes.get();
@ -364,6 +387,7 @@ public class StatisticsHandler extends HandlerWrapper
* @return the number of requests that expired while suspended. * @return the number of requests that expired while suspended.
* @see #getResumes() * @see #getResumes()
*/ */
@ManagedAttribute("number of requests have have expired")
public int getExpires() public int getExpires()
{ {
return _expires.get(); return _expires.get();
@ -373,6 +397,7 @@ public class StatisticsHandler extends HandlerWrapper
* @return the number of responses with a 1xx status returned by this context * @return the number of responses with a 1xx status returned by this context
* since {@link #statsReset()} was last called. * since {@link #statsReset()} was last called.
*/ */
@ManagedAttribute("number of requests with 1xx response status")
public int getResponses1xx() public int getResponses1xx()
{ {
return _responses1xx.get(); return _responses1xx.get();
@ -382,6 +407,7 @@ public class StatisticsHandler extends HandlerWrapper
* @return the number of responses with a 2xx status returned by this context * @return the number of responses with a 2xx status returned by this context
* since {@link #statsReset()} was last called. * since {@link #statsReset()} was last called.
*/ */
@ManagedAttribute("number of requests with 2xx response status")
public int getResponses2xx() public int getResponses2xx()
{ {
return _responses2xx.get(); return _responses2xx.get();
@ -391,6 +417,7 @@ public class StatisticsHandler extends HandlerWrapper
* @return the number of responses with a 3xx status returned by this context * @return the number of responses with a 3xx status returned by this context
* since {@link #statsReset()} was last called. * since {@link #statsReset()} was last called.
*/ */
@ManagedAttribute("number of requests with 3xx response status")
public int getResponses3xx() public int getResponses3xx()
{ {
return _responses3xx.get(); return _responses3xx.get();
@ -400,6 +427,7 @@ public class StatisticsHandler extends HandlerWrapper
* @return the number of responses with a 4xx status returned by this context * @return the number of responses with a 4xx status returned by this context
* since {@link #statsReset()} was last called. * since {@link #statsReset()} was last called.
*/ */
@ManagedAttribute("number of requests with 4xx response status")
public int getResponses4xx() public int getResponses4xx()
{ {
return _responses4xx.get(); return _responses4xx.get();
@ -409,6 +437,7 @@ public class StatisticsHandler extends HandlerWrapper
* @return the number of responses with a 5xx status returned by this context * @return the number of responses with a 5xx status returned by this context
* since {@link #statsReset()} was last called. * since {@link #statsReset()} was last called.
*/ */
@ManagedAttribute("number of requests with 5xx response status")
public int getResponses5xx() public int getResponses5xx()
{ {
return _responses5xx.get(); return _responses5xx.get();
@ -417,6 +446,7 @@ public class StatisticsHandler extends HandlerWrapper
/** /**
* @return the milliseconds since the statistics were started with {@link #statsReset()}. * @return the milliseconds since the statistics were started with {@link #statsReset()}.
*/ */
@ManagedAttribute("time in milliseconds stats have been collected for")
public long getStatsOnMs() public long getStatsOnMs()
{ {
return System.currentTimeMillis() - _statsStartedAt.get(); return System.currentTimeMillis() - _statsStartedAt.get();
@ -425,6 +455,7 @@ public class StatisticsHandler extends HandlerWrapper
/** /**
* @return the total bytes of content sent in responses * @return the total bytes of content sent in responses
*/ */
@ManagedAttribute("total number of bytes across all responses")
public long getResponsesBytesTotal() public long getResponsesBytesTotal()
{ {
return _responsesTotalBytes.get(); return _responsesTotalBytes.get();

View File

@ -20,9 +20,11 @@ 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.ManagedAttribute; 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.ManagedOperation;
import org.eclipse.jetty.util.annotation.Name; import org.eclipse.jetty.util.annotation.Name;
@ManagedObject("ContextHandler mbean wrapper")
public class ContextHandlerMBean extends AbstractHandlerMBean public class ContextHandlerMBean extends AbstractHandlerMBean
{ {
public ContextHandlerMBean(Object managedObject) public ContextHandlerMBean(Object managedObject)

View File

@ -1,24 +0,0 @@
ContextHandler: URI Context
aliases: True if alias checking is performed on resource
allowNullPathInfo: Checks if the /context is not redirected to /context/
classPath: RO: The file classpath
compactPath: True if URLs are compacted to replace the multiple '/'s with a single '/'
connectorNames: Names and ports of accepted connectors
contextAttributes: RO:MBean: Map of context attributes
contextPath: URI prefix of context
displayName: RO: Display name of the Context
errorHandler: MObject: The error handler to use for the context
initParams: Initial Parameter map for the context
maxFormContentSize: The maximum content size
removeContextAttribute(java.lang.String): MBean:ACTION: remove context attribute
removeContextAttribute(java.lang.String)[0]: name: The attribute name
resourceBase: Document root for the context
setContextAttribute(java.lang.String,java.lang.Object): MBean:ACTION: Set context attribute
setContextAttribute(java.lang.String,java.lang.Object)[0]: name: The attribute name
setContextAttribute(java.lang.String,java.lang.Object)[1]: value: The attribute value
setContextAttribute(java.lang.String,java.lang.String): MBean:ACTION: Set context attribute
setContextAttribute(java.lang.String,java.lang.String)[0]: name: The attribute name
setContextAttribute(java.lang.String,java.lang.String)[1]: value: The attribute value
shutdown: False if this context is accepting new requests. True for graceful shutdown, which allows existing requests to complete
virtualHosts: Virtual hosts accepted by the context
welcomeFiles: Partial URIs of directory welcome files

View File

@ -1,2 +0,0 @@
ContextHandlerCollection: Context Handler Collection
mapContexts(): Update the mapping of context path to context

View File

@ -1,2 +0,0 @@
HandlerCollection: Handler of multiple Handlers
handlers: MObject:Wrapped handlers

View File

@ -1,2 +0,0 @@
HandlerWrapper: Handler wrapping another Handler
handler: MObject:Wrapped handler

View File

@ -1,28 +0,0 @@
StatisticsHandler: Request Statistics gathering
statsOnMs: Time in milliseconds stats have been collected for.
statsReset(): Resets statistics.
requests: Number of requests since statsReset() called.
requestsActive: Number of requests currently active since statsReset() called.
requestsActiveMax: Maximum number of active requests since statsReset() called.
requestTimeMax: Maximum time in milliseconds of request handling since statsReset() called.
requestTimeTotal: Total time in milliseconds of all request handling since statsReset() called.
requestTimeMean: Mean of time in milliseconds of request handling since statsReset() called.
requestTimeStdDev: Standard deviation of time in milliseconds of request handling since statsReset() called.
dispatched: Number of dispatches since statsReset() called.
dispatchedActive: Number of dispatches currently active since statsReset() called.
dispatchedActiveMax: Maximum number of active dispatches since statsReset() called.
dispatchedTimeMax: Maximum time in milliseconds of dispatched handling since statsReset() called.
dispatchedTimeTotal: Total time in milliseconds of all dispatched handling since statsReset() called.
dispatchedTimeMean: Mean of time in milliseconds of dispatch handling since statsReset() called.
dispatchedTimeStdDev: Standard deviation of time in milliseconds of dispatch handling since statsReset() called.
suspends: Number of requests suspended since statsReset() called.
suspendsActive: Number of dispatches currently active since statsReset() called.
suspendsActiveMax: Maximum number of active dispatches since statsReset() called.
resumes: Number of requests resumed since statsReset() called.
expires: Number of requests expired since statsReset() called.
responses1xx: Number of responses with a 1xx status since statsReset() called.
responses2xx: Number of responses with a 2xx status since statsReset() called.
responses3xx: Number of responses with a 3xx status since statsReset() called.
responses4xx: Number of responses with a 4xx status since statsReset() called.
responses5xx: Number of responses with a 5xx status since statsReset() called.
responsesBytesTotal: Total number of bytes of all responses since statsReset() called.