more mbean -> annotation conversion

This commit is contained in:
Jesse McConnell 2012-08-13 12:41:02 -05:00
parent 51eac5ddf7
commit efce7e8421
15 changed files with 69 additions and 42 deletions

View File

@ -30,6 +30,8 @@ import javax.print.attribute.standard.MediaSize.ISO;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.StandardByteBufferPool;
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;
import org.eclipse.jetty.util.log.Log;
@ -39,6 +41,7 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
/**
* <p>Partial implementation of {@link Connector}</p>
*/
@ManagedObject("Abstract implementation of the Connector Interface")
public abstract class AbstractConnector extends AggregateLifeCycle implements Connector, Dumpable
{
protected final Logger LOG = Log.getLogger(getClass());
@ -157,6 +160,7 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
/**
* @return Returns the number of acceptor threads.
*/
@ManagedAttribute("number of acceptor threads")
public int getAcceptors()
{
return _acceptors.length;
@ -328,6 +332,7 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
}
@Override
@ManagedAttribute("name of the connector")
public String getName()
{
return _name;

View File

@ -17,6 +17,8 @@ import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService;
import org.eclipse.jetty.io.ByteBufferPool;
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.ssl.SslContextFactory;
@ -25,6 +27,7 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
* and allows applications to send data to remote peers, by setting up
* the machinery needed to handle such tasks.</p>
*/
@ManagedObject("Connector Interface")
public interface Connector extends LifeCycle
{
/**
@ -60,6 +63,7 @@ public interface Connector extends LifeCycle
/**
* @return the dle timeout for connections in milliseconds
*/
@ManagedAttribute("maximum time a connection can be idle before being closed (in ms)")
public long getIdleTimeout();
/**

View File

@ -21,6 +21,9 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.server.handler.HandlerWrapper;
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.component.Destroyable;
import org.eclipse.jetty.util.component.LifeCycle;
@ -40,6 +43,7 @@ import org.eclipse.jetty.util.component.LifeCycle;
* before passing it to the next stage of handling.
*
*/
@ManagedObject("Jetty Handler")
public interface Handler extends LifeCycle, Destroyable
{
/* ------------------------------------------------------------ */
@ -59,8 +63,11 @@ public interface Handler extends LifeCycle, Destroyable
throws IOException, ServletException;
public void setServer(Server server);
@ManagedAttribute(value="the jetty server for this handler", readonly=true)
public Server getServer();
@ManagedOperation(value="destroy associated resources", impact="ACTION")
public void destroy();
}

View File

@ -13,6 +13,8 @@
package org.eclipse.jetty.server;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.LifeCycle;
/**
@ -22,18 +24,21 @@ import org.eclipse.jetty.util.component.LifeCycle;
* or many (see {@link org.eclipse.jetty.server.handler.HandlerList} or {@link org.eclipse.jetty.server.handler.HandlerCollection}.
*
*/
@ManagedObject("Handler of Multiple Handlers")
public interface HandlerContainer extends LifeCycle
{
/* ------------------------------------------------------------ */
/**
* @return array of handlers directly contained by this handler.
*/
@ManagedAttribute(value="handlers in this container", managed=true)
public Handler[] getHandlers();
/* ------------------------------------------------------------ */
/**
* @return array of all handlers contained by this handler and it's children
*/
@ManagedAttribute(value="all contained handlers", managed=true)
public Handler[] getChildHandlers();
/* ------------------------------------------------------------ */

View File

@ -27,6 +27,8 @@ import org.eclipse.jetty.http.PathMap;
import org.eclipse.jetty.util.DateCache;
import org.eclipse.jetty.util.RolloverFileOutputStream;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -39,12 +41,12 @@ import org.eclipse.jetty.util.log.Logger;
* servers, and almost all web log analysis software can understand these
* formats.
*
* @org.apache.xbean.XBean element="ncsaLog"
*/
/* ------------------------------------------------------------ */
/**
*/
@ManagedObject("NCSA standard format request log")
public class NCSARequestLog extends AbstractLifeCycle implements RequestLog
{
private static final Logger LOG = Log.getLogger(NCSARequestLog.class);
@ -124,6 +126,7 @@ public class NCSARequestLog extends AbstractLifeCycle implements RequestLog
*
* @return file name of the request log
*/
@ManagedAttribute("file of log")
public String getFilename()
{
return _filename;
@ -206,6 +209,7 @@ public class NCSARequestLog extends AbstractLifeCycle implements RequestLog
*
* @return timezone string
*/
@ManagedAttribute("the timezone")
public String getLogTimeZone()
{
return _logTimeZone;
@ -228,6 +232,7 @@ public class NCSARequestLog extends AbstractLifeCycle implements RequestLog
*
* @return number of days to keep a log file
*/
@ManagedAttribute("number of days that log files are kept")
public int getRetainDays()
{
return _retainDays;
@ -251,6 +256,7 @@ public class NCSARequestLog extends AbstractLifeCycle implements RequestLog
*
* @return value of the flag
*/
@ManagedAttribute("use extended NCSA format")
public boolean isExtended()
{
return _extended;
@ -274,6 +280,7 @@ public class NCSARequestLog extends AbstractLifeCycle implements RequestLog
*
* @return value of the flag
*/
@ManagedAttribute("existing log files are appends to the new one")
public boolean isAppend()
{
return _append;

View File

@ -31,12 +31,14 @@ import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.SelectChannelEndPoint;
import org.eclipse.jetty.io.SelectorManager;
import org.eclipse.jetty.io.SelectorManager.ManagedSelector;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.annotation.Name;
import org.eclipse.jetty.util.ssl.SslContextFactory;
/**
* <p>Implementation of {@link NetworkConnector} based on NIO classes.</p>
*/
@ManagedObject("HTTP connector using NIO ByteChannels and Selectors")
public class SelectChannelConnector extends AbstractNetworkConnector
{
private final SelectorManager _manager;

View File

@ -33,6 +33,8 @@ import org.eclipse.jetty.util.AttributesMap;
import org.eclipse.jetty.util.MultiException;
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.component.Container;
import org.eclipse.jetty.util.component.Destroyable;
import org.eclipse.jetty.util.component.Dumpable;
@ -50,6 +52,7 @@ import org.eclipse.jetty.util.thread.ThreadPool;
* The server is itself a handler and a ThreadPool. Connectors use the ThreadPool methods
* to run jobs that will eventually call the handle method.
*/
@ManagedObject(value="Jetty HTTP Servlet server", wrapper="org.eclipse.jetty.server.ServerMBean")
public class Server extends HandlerWrapper implements Attributes
{
private static final Logger LOG = Log.getLogger(Server.class);
@ -120,6 +123,7 @@ public class Server extends HandlerWrapper implements Attributes
/* ------------------------------------------------------------ */
@ManagedAttribute("version of this server")
public static String getVersion()
{
return __version;
@ -164,6 +168,7 @@ public class Server extends HandlerWrapper implements Attributes
/**
* @return Returns the connectors.
*/
@ManagedAttribute(value="connectors for this server", managed=true)
public Connector[] getConnectors()
{
List<Connector> connectors = new ArrayList<>(_connectors);
@ -217,6 +222,7 @@ public class Server extends HandlerWrapper implements Attributes
/**
* @return Returns the threadPool.
*/
@ManagedAttribute(value="the server thread pool", managed=true)
public ThreadPool getThreadPool()
{
return _threadPool;
@ -225,6 +231,7 @@ public class Server extends HandlerWrapper implements Attributes
/**
* @return true if {@link #dumpStdErr()} is called after starting
*/
@ManagedAttribute("dump state to stderr after start")
public boolean isDumpAfterStart()
{
return _dumpAfterStart;
@ -241,6 +248,7 @@ public class Server extends HandlerWrapper implements Attributes
/**
* @return true if {@link #dumpStdErr()} is called before stopping
*/
@ManagedAttribute("dump state to stderr before stop")
public boolean isDumpBeforeStop()
{
return _dumpBeforeStop;
@ -478,6 +486,7 @@ public class Server extends HandlerWrapper implements Attributes
}
/* ------------------------------------------------------------ */
@ManagedAttribute("if true, include the server version in HTTP headers")
public boolean getSendServerVersion()
{
return _sendServerVersion;
@ -490,6 +499,7 @@ public class Server extends HandlerWrapper implements Attributes
}
/* ------------------------------------------------------------ */
@ManagedAttribute("if true, include the date in HTTP headers")
public boolean getSendDateHeader()
{
return _sendDateHeader;

View File

@ -17,10 +17,13 @@ import org.eclipse.jetty.jmx.ObjectMBean;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
/**
*
*/
@ManagedObject("MBean Wrapper for Server")
public class ServerMBean extends ObjectMBean
{
private final long startupTime;
@ -33,11 +36,13 @@ public class ServerMBean extends ObjectMBean
server = (Server)managedObject;
}
@ManagedAttribute(value="contexts on this server", managed=true)
public Handler[] getContexts()
{
return server.getChildHandlersByClass(ContextHandler.class);
}
@ManagedAttribute("the startup time since January 1st, 1970 (in ms)")
public long getStartupTime()
{
return startupTime;

View File

@ -40,6 +40,9 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.SessionIdManager;
import org.eclipse.jetty.server.SessionManager;
import org.eclipse.jetty.server.handler.ContextHandler;
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.component.AbstractLifeCycle;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.statistic.CounterStatistic;
@ -56,6 +59,7 @@ import org.eclipse.jetty.util.statistic.SampleStatistic;
* <p>
*/
@SuppressWarnings("deprecation")
@ManagedObject("Abstract Session Manager")
public abstract class AbstractSessionManager extends AbstractLifeCycle implements SessionManager
{
final static Logger __log = SessionHandler.LOG;
@ -135,11 +139,13 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
return _context.getContextHandler();
}
@ManagedAttribute("path of the session cookie, or null for default")
public String getSessionPath()
{
return _sessionPath;
}
@ManagedAttribute("if greater the zero, the time in seconds a session cookie will last for")
public int getMaxCookieAge()
{
return _maxCookieAge;
@ -266,6 +272,7 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
/**
* @return Returns the httpOnly.
*/
@ManagedAttribute("true if cookies use the http only flag")
public boolean getHttpOnly()
{
return _httpOnly;
@ -296,6 +303,7 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
/**
* @return Returns the SessionIdManager used for cross context session management
*/
@ManagedAttribute("Session ID Manager")
public SessionIdManager getSessionIdManager()
{
return _sessionIdManager;
@ -307,6 +315,7 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
* @return seconds
*/
@Override
@ManagedAttribute("defailt maximum time a session may be idle for (in s)")
public int getMaxInactiveInterval()
{
return _dftMaxIdleSecs;
@ -326,6 +335,7 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
/**
* @return maximum number of sessions
*/
@ManagedAttribute("maximum number of simultaneous sessions")
public int getSessionsMax()
{
return (int)_sessionsStats.getMax();
@ -335,6 +345,7 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
/**
* @return total number of sessions
*/
@ManagedAttribute("total number of sessions")
public int getSessionsTotal()
{
return (int)_sessionsStats.getTotal();
@ -361,6 +372,7 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
}
/* ------------------------------------------------------------ */
@ManagedAttribute("time before a session cookie is re-set (in s)")
public int getRefreshCookieAge()
{
return _refreshCookieAge;
@ -373,6 +385,7 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
* cookies are ALWAYS marked as secure. If false, a session cookie is
* ONLY marked as secure if _secureRequestOnly == true and it is a HTTPS request.
*/
@ManagedAttribute("if true, secure cookie flag is set on session cookies")
public boolean getSecureCookies()
{
return _secureCookies;
@ -402,6 +415,7 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
/* ------------------------------------------------------------ */
@ManagedAttribute("the set session cookie")
public String getSessionCookie()
{
return _sessionCookie;
@ -471,6 +485,7 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
return null;
}
@ManagedAttribute("domain of the session cookie, or null for the default")
public String getSessionDomain()
{
return _sessionDomain;
@ -498,12 +513,14 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
/* ------------------------------------------------------------ */
@ManagedAttribute("number of currently active sessions")
public int getSessions()
{
return (int)_sessionsStats.getCurrent();
}
/* ------------------------------------------------------------ */
@ManagedAttribute("name of use for URL session tracking")
public String getSessionIdPathParameterName()
{
return _sessionIdPathParameterName;
@ -580,6 +597,7 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
/**
* Reset statistics values
*/
@ManagedOperation(value="reset statistics", impact="ACTION")
public void statsReset()
{
_sessionsStats.reset(getSessions());
@ -784,6 +802,7 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
/**
* @return maximum amount of time session remained valid
*/
@ManagedAttribute("maximum amount of time sessions have remained active (in s)")
public long getSessionTimeMax()
{
return _sessionTimeStats.getMax();
@ -919,6 +938,7 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
/**
* @return total amount of time all sessions remained valid
*/
@ManagedAttribute("total time sessions have remained valid")
public long getSessionTimeTotal()
{
return _sessionTimeStats.getTotal();
@ -928,6 +948,7 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
/**
* @return mean amount of time session remained valid
*/
@ManagedAttribute("mean time sessions remain valid (in s)")
public double getSessionTimeMean()
{
return _sessionTimeStats.getMean();
@ -937,6 +958,7 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
/**
* @return standard deviation of amount of time session remained valid
*/
@ManagedAttribute("standard deviation a session remained valid (in s)")
public double getSessionTimeStdDev()
{
return _sessionTimeStats.getStdDev();
@ -946,6 +968,7 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
/**
* @see org.eclipse.jetty.server.SessionManager#isCheckingRemoteSessionIdEncoding()
*/
@ManagedAttribute("check remote session id encoding")
public boolean isCheckingRemoteSessionIdEncoding()
{
return _checkingRemoteSessionIdEncoding;

View File

@ -1,3 +0,0 @@
Handler: Jetty Handler.
server: MObject:RO:The Jetty server for this handler
destroy(): destroy associated resources (eg MBean)

View File

@ -1,3 +0,0 @@
HandlerContainer: Handler of multiple Handlers
handlers: MObject:RO:Handlers in this container
childHandlers: MObject:RO:All contained handlers

View File

@ -1,6 +0,0 @@
NCSARequestLog : NCSA standard format request log
filename : Filename of log
retainDays : Number of days that the log files are kept
append : Existing log files are appended to the new one
extended : Use the extended NCSA format
LogTimeZone : The timezone

View File

@ -1 +0,0 @@
SelectChannelConnector: HTTP connector using NIO ByteChannels and Selectors

View File

@ -1,9 +0,0 @@
Server: Jetty HTTP Servlet server
connectors: MObject:HTTP Connectors for this server
version: RO: The version of this server
sendServerVersion: If true include the server version in HTTP headers
threadPool: MObject:The server Thread Pool
contexts: MMBean:RO:The contexts of this server
startupTime: MBean:RO:The startup time, in milliseconds, since January 1st 1970
dumpAfterStart: RW:Dump state to stderr after start
dumpBeforeStop: RW:Dump state to stderr before stop

View File

@ -1,19 +0,0 @@
AbstractSessionManager: Abstract Session Manager
httpOnly: True if cookies use the http only flag
idManager: MObject:RO:The ID Manager instance
maxCookieAge: if greater than zero, the time in seconds a session cookie will last for
maxInactiveInterval: default maximum time in seconds a session may be idle
refreshCookieAge: The time in seconds after which a session cookie is re-set
secureCookies: If true, the secure cookie flag is set on session cookies
sessionCookie: The set session cookie
sessionDomain: The domain of the session cookie or null for the default
sessionPath: The path of the session cookie or null for the default
sessionsTotal: The total number of sessions
sessionIdPathParameterName: The name to use for URL session tracking
statsReset(): Reset statistics
sessions: Current instantaneous number of sessions
sessionsMax: Maximum number of simultaneous sessions since statsReset() was called
sessionTimeMax: Maximum amount of time in seconds session remained valid since statsReset() was called
sessionTimeTotal: Total amount of time in seconds sessions remained valid since statsReset() was called
sessionTimeMean: Mean amount of time in seconds a session remained valid since statsReset() was called
sessionTimeStdDev: Standard deviation of amount of time in seconds a session remained valid since statsReset() was called