User: olegnitz
Date: 02/02/10 09:57:43
Added: jetty/src/main/org/mortbay/http/jmx HttpContextMBean.java
HttpListenerMBean.java HttpServerMBean.java
NCSARequestLogMBean.java SocketListenerMBean.java
mbean_en.properties
Log:
Fresh version of Jetty and patches to Jetty plugin by Jan Bartel
Revision Changes Path
1.1
contrib/jetty/src/main/org/mortbay/http/jmx/HttpContextMBean.java
Index: HttpContextMBean.java
===================================================================
// ========================================================================
// Copyright (c) 1999 Mort Bay Consulting (Australia) Pty. Ltd.
// $Id: HttpContextMBean.java,v 1.1 2002/02/10 17:57:43 olegnitz Exp $
// ========================================================================
package org.mortbay.http.jmx;
import javax.management.AttributeNotFoundException;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanServer;
import javax.management.MBeanException;
import javax.management.MBeanOperationInfo;
import javax.management.ObjectName;
import javax.management.ReflectionException;
import javax.management.modelmbean.InvalidTargetObjectTypeException;
import javax.management.modelmbean.ModelMBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanOperationInfo;
import org.mortbay.http.HttpServer;
import org.mortbay.http.HttpContext;
import org.mortbay.util.Code;
import org.mortbay.util.Log;
import org.mortbay.util.LifeCycle;
import org.mortbay.util.LogSink;
import org.mortbay.util.jmx.LifeCycleMBean;
import org.mortbay.util.jmx.LifeCycleMBean;
import java.beans.beancontext.BeanContextMembershipListener;
import java.beans.beancontext.BeanContextMembershipEvent;
import java.util.Iterator;
/* ------------------------------------------------------------ */
/**
*
* @version $Revision: 1.1 $
* @author Greg Wilkins (gregw)
*/
public class HttpContextMBean extends LifeCycleMBean
{
private HttpContext _httpContext;
/* ------------------------------------------------------------ */
/** Constructor.
* @exception MBeanException
* @exception InstanceNotFoundException
*/
public HttpContextMBean()
throws MBeanException
{}
/* ------------------------------------------------------------ */
protected void defineManagedResource()
{
super.defineManagedResource();
defineAttribute("logSink");
defineAttribute("contextPath");
defineAttribute("classPath");
defineAttribute("classLoader");
defineAttribute("realm");
defineAttribute("redirectNullPath");
defineAttribute("resourceBase");
defineAttribute("servingResources");
defineAttribute("hosts");
defineAttribute("handlers");
defineAttribute("statsOn");
defineOperation("statsReset",IMPACT_ACTION);
defineAttribute("requests");
defineAttribute("responses1xx");
defineAttribute("responses2xx");
defineAttribute("responses3xx");
defineAttribute("responses4xx");
defineAttribute("responses5xx");
defineOperation("destroy",
IMPACT_ACTION);
defineOperation("setInitParameter",
new String[] {STRING,STRING},
IMPACT_ACTION);
defineOperation("getInitParameter",
new String[] {STRING},
IMPACT_INFO);
defineOperation("getInitParameterNames",
NO_PARAMS,
IMPACT_INFO);
defineOperation("setAttribute",
new String[] {STRING,OBJECT},
IMPACT_ACTION);
defineOperation("getAttribute",
new String[] {STRING},
IMPACT_INFO);
defineOperation("getAttributeNames",
NO_PARAMS,
IMPACT_INFO);
defineOperation("removeAttribute",
new String[] {STRING},
IMPACT_ACTION);
defineOperation("addHttpHandler",
new String[] {INT, "org.mortbay.http.HttpHandler"},
IMPACT_ACTION);
defineOperation("getHttpHandler",
new String[] {INT},
IMPACT_INFO);
defineOperation("removeHttpHandler",
new String[] {INT},
IMPACT_ACTION);
defineOperation("setMimeMapping",
new String[] {STRING,STRING},
IMPACT_ACTION);
_httpContext=(HttpContext)getManagedResource();
}
/* ------------------------------------------------------------ */
protected ObjectName newObjectName(MBeanServer server)
{
ObjectName oName=super.newObjectName(server);
String context=_httpContext.getContextPath();
if (context.length()==0)
context="/";
try{oName=new ObjectName(oName+",context="+context);}
catch(Exception e){Code.warning(e);}
return oName;
}
/* ------------------------------------------------------------ */
public void postDeregister()
{
_httpContext=null;
super.postDeregister();
}
}
1.1
contrib/jetty/src/main/org/mortbay/http/jmx/HttpListenerMBean.java
Index: HttpListenerMBean.java
===================================================================
// ========================================================================
// Copyright (c) 1999 Mort Bay Consulting (Australia) Pty. Ltd.
// $Id: HttpListenerMBean.java,v 1.1 2002/02/10 17:57:43 olegnitz Exp $
// ========================================================================
package org.mortbay.http.jmx;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanException;
import javax.management.MBeanServer;
import javax.management.MBeanOperationInfo;
import javax.management.ObjectName;
import javax.management.modelmbean.InvalidTargetObjectTypeException;
import javax.management.modelmbean.ModelMBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanOperationInfo;
import org.mortbay.http.HttpServer;
import org.mortbay.http.HttpListener;
import org.mortbay.util.Code;
import org.mortbay.util.Log;
import org.mortbay.util.LifeCycle;
import org.mortbay.util.jmx.ThreadedServerMBean;
import java.util.Iterator;
import org.mortbay.util.ThreadPool;
/* ------------------------------------------------------------ */
/**
*
* @version $Revision: 1.1 $
* @author Greg Wilkins (gregw)
*/
public class HttpListenerMBean
extends ThreadedServerMBean
{
/* ------------------------------------------------------------ */
/** Constructor.
* @exception MBeanException
*/
public HttpListenerMBean()
throws MBeanException
{}
/* ------------------------------------------------------------ */
protected void defineManagedResource()
{
super.defineManagedResource();
defineAttribute("defaultScheme");
}
}
1.1 contrib/jetty/src/main/org/mortbay/http/jmx/HttpServerMBean.java
Index: HttpServerMBean.java
===================================================================
// ========================================================================
// Copyright (c) 1999 Mort Bay Consulting (Australia) Pty. Ltd.
// $Id: HttpServerMBean.java,v 1.1 2002/02/10 17:57:43 olegnitz Exp $
// ========================================================================
package org.mortbay.http.jmx;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanServer;
import javax.management.MBeanException;
import javax.management.ObjectName;
import javax.management.MBeanOperationInfo;
import javax.management.modelmbean.InvalidTargetObjectTypeException;
import javax.management.modelmbean.ModelMBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanOperationInfo;
import javax.management.modelmbean.ModelMBean;
import org.mortbay.http.HttpServer;
import org.mortbay.http.HttpServer.ComponentEvent;
import org.mortbay.http.HttpServer.ComponentEventListener;
import org.mortbay.http.HttpListener;
import org.mortbay.http.SocketListener;
import org.mortbay.http.HttpContext;
import org.mortbay.util.Code;
import org.mortbay.util.Log;
import org.mortbay.util.LogSink;
import org.mortbay.util.LifeCycle;
import org.mortbay.util.OutputStreamLogSink;
import org.mortbay.util.jmx.LifeCycleMBean;
import org.mortbay.util.jmx.ModelMBeanImpl;
import java.util.Iterator;
import java.util.HashMap;
import java.io.IOException;
/* ------------------------------------------------------------ */
/** HttpServer MBean.
* This Model MBean class provides the mapping for HttpServer
* management methods. It also registers itself as a membership
* listener of the HttpServer, so it can create and destroy MBean
* wrappers for listeners and contexts.
*
* @version $Revision: 1.1 $
* @author Greg Wilkins (gregw)
*/
public class HttpServerMBean extends LifeCycleMBean
implements HttpServer.ComponentEventListener
{
private HttpServer _httpServer;
private HashMap _mbeanMap = new HashMap();
private String _configuration;
/* ------------------------------------------------------------ */
/** Constructor.
* @exception MBeanException
* @exception InstanceNotFoundException
*/
protected HttpServerMBean(HttpServer httpServer)
throws MBeanException, InstanceNotFoundException
{
_httpServer=httpServer;
_httpServer.addEventListener(this);
try{super.setManagedResource(_httpServer,"objectReference");}
catch(InvalidTargetObjectTypeException e){Code.warning(e);}
}
/* ------------------------------------------------------------ */
/** Constructor.
* @exception MBeanException
* @exception InstanceNotFoundException
*/
public HttpServerMBean()
throws MBeanException, InstanceNotFoundException
{
this(new HttpServer());
}
/* ------------------------------------------------------------ */
public void setManagedResource(Object o,String s)
throws MBeanException, InstanceNotFoundException,
InvalidTargetObjectTypeException
{
if (o!=null)
((HttpServer)o).addEventListener(this);
super.setManagedResource(o,s);
}
/* ------------------------------------------------------------ */
protected void defineManagedResource()
{
super.defineManagedResource();
defineAttribute("requestLog");
defineOperation("addListener",
new String[]{"java.lang.String"},
IMPACT_ACTION);
defineOperation("addListener",
new String[]{"org.mortbay.http.HttpListener"},
IMPACT_ACTION);
defineOperation("addContext",
new String[]{"java.lang.String","java.lang.String"},
IMPACT_ACTION);
defineOperation("addHostAlias",
new String[]{"java.lang.String","java.lang.String"},
IMPACT_ACTION);
defineAttribute("statsOn");
defineOperation("statsReset",IMPACT_ACTION);
defineAttribute("connections");
defineAttribute("connectionsOpen");
defineAttribute("connectionsOpenMax");
defineAttribute("connectionsDurationAve");
defineAttribute("connectionsDurationMax");
defineAttribute("connectionsRequestsAve");
defineAttribute("connectionsRequestsMax");
defineAttribute("errors");
defineAttribute("requests");
defineAttribute("requestsActive");
defineAttribute("requestsActiveMax");
defineAttribute("requestsDurationAve");
defineAttribute("requestsDurationMax");
defineOperation("destroy",IMPACT_ACTION);
}
/* ------------------------------------------------------------ */
public synchronized void addComponent(ComponentEvent event)
{
try
{
Code.debug("Component added ",event);
Object o=event.getComponent();
ModelMBean mbean=ModelMBeanImpl.mbeanFor(o);
if (mbean==null)
Code.warning("No MBean for "+o);
else
{
if (mbean instanceof ModelMBeanImpl)
((ModelMBeanImpl)mbean).setBaseObjectName(getObjectName().toString());
ObjectName oName=
getMBeanServer().registerMBean(mbean,null).getObjectName();
Holder holder = new Holder(oName,mbean);
_mbeanMap.put(o,holder);
}
}
catch(Exception e)
{
Code.warning(e);
}
}
/* ------------------------------------------------------------ */
public synchronized void removeComponent(ComponentEvent event)
{
Code.debug("Component removed ",event);
try
{
Object o=event.getComponent();
Holder holder=(Holder)_mbeanMap.remove(o);
if (holder!=null)
getMBeanServer().unregisterMBean(holder.oName);
else if (o==_httpServer)
getMBeanServer().unregisterMBean(this.getObjectName());
}
catch(Exception e)
{
Code.warning(e);
}
}
/* ------------------------------------------------------------ */
/**
* @param ok
*/
public void postRegister(Boolean ok)
{
super.postRegister(ok);
}
/* ------------------------------------------------------------ */
public void postDeregister()
{
_httpServer.removeEventListener(this);
_httpServer=null;
if (_mbeanMap!=null)
_mbeanMap.clear();
_mbeanMap=null;
super.postDeregister();
}
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
private static class Holder
{
Holder(ObjectName oName,Object mbean){ this.oName=oName; this.mbean=mbean;}
ObjectName oName;
Object mbean;
}
}
1.1
contrib/jetty/src/main/org/mortbay/http/jmx/NCSARequestLogMBean.java
Index: NCSARequestLogMBean.java
===================================================================
// ========================================================================
// Copyright (c) 1999 Mort Bay Consulting (Australia) Pty. Ltd.
// $Id: NCSARequestLogMBean.java,v 1.1 2002/02/10 17:57:43 olegnitz Exp $
// ========================================================================
package org.mortbay.http.jmx;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanException;
import javax.management.MBeanServer;
import javax.management.MBeanOperationInfo;
import javax.management.modelmbean.InvalidTargetObjectTypeException;
import javax.management.modelmbean.ModelMBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanOperationInfo;
import org.mortbay.util.Code;
import org.mortbay.util.Log;
import org.mortbay.util.LogSink;
import org.mortbay.util.LifeCycle;
import org.mortbay.util.jmx.LifeCycleMBean;
/* ------------------------------------------------------------ */
/**
*
* @version $Revision: 1.1 $
* @author Greg Wilkins (gregw)
*/
public class NCSARequestLogMBean extends LifeCycleMBean
{
/* ------------------------------------------------------------ */
/** Constructor.
* @param sink
* @exception MBeanException
* @exception InstanceNotFoundException
*/
public NCSARequestLogMBean()
throws MBeanException
{}
/* ------------------------------------------------------------ */
protected void defineManagedResource()
{
super.defineManagedResource();
defineAttribute("filename");
defineAttribute("datedFilename");
defineAttribute("logDateFormat");
defineAttribute("logTimeZone");
defineAttribute("retainDays");
defineAttribute("extended");
defineAttribute("append");
}
}
1.1
contrib/jetty/src/main/org/mortbay/http/jmx/SocketListenerMBean.java
Index: SocketListenerMBean.java
===================================================================
// ========================================================================
// Copyright (c) 1999 Mort Bay Consulting (Australia) Pty. Ltd.
// $Id: SocketListenerMBean.java,v 1.1 2002/02/10 17:57:43 olegnitz Exp $
// ========================================================================
package org.mortbay.http.jmx;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanException;
import javax.management.MBeanServer;
import javax.management.MBeanOperationInfo;
import javax.management.modelmbean.InvalidTargetObjectTypeException;
import javax.management.modelmbean.ModelMBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanOperationInfo;
import org.mortbay.http.HttpServer;
import org.mortbay.http.HttpListener;
import org.mortbay.http.SocketListener;
import org.mortbay.util.Code;
import org.mortbay.util.Log;
import org.mortbay.util.LifeCycle;
import java.beans.beancontext.BeanContextMembershipListener;
import java.beans.beancontext.BeanContextMembershipEvent;
import java.util.Iterator;
import org.mortbay.util.ThreadPool;
/* ------------------------------------------------------------ */
/**
*
* @version $Revision: 1.1 $
* @author Greg Wilkins (gregw)
*/
public class SocketListenerMBean extends HttpListenerMBean
{
/* ------------------------------------------------------------ */
/** Constructor.
* @exception MBeanException
* @exception InstanceNotFoundException
*/
public SocketListenerMBean()
throws MBeanException
{
super();
}
/* ------------------------------------------------------------ */
protected void defineManagedResource()
{
super.defineManagedResource();
defineAttribute("lowResourcePersistTimeMs");
defineAttribute("lowOnResources");
defineAttribute("outOfResources");
}
}
1.1 contrib/jetty/src/main/org/mortbay/http/jmx/mbean_en.properties
Index: mbean_en.properties
===================================================================
HttpServer = \
Jetty core HTTP Server.
HttpServer.started = True if any of the components of Jetty Server have been
started and are still running.
HttpServer.start() = Start the Jetty Server and all registered listeners, contexts
and logs.
HttpServer.stop() = Stop the Jetty Server and all registered listeners, contexts
and logs.
HttpServer.destroy() = Destroy the Jetty Server and all registered listeners,
contexts and logs.
HttpServer.addListener(java.lang.String) = Create and add a new HttpListener.
HttpServer.addListener(java.lang.String)[0] = listenerClass:The Listener classname
or null for the default HttpListener class.
HttpServer.addHostAlias(java.lang.String,java.lang.String) = Define a virtual
host alias
HttpServer.addHostAlias(java.lang.String,java.lang.String)[0] = virtualHost:Known
host name or IP
HttpServer.addHostAlias(java.lang.String,java.lang.String)[1] = alias:Alias host
name or IP
HttpServer.addContext(java.lang.String,java.lang.String) = Create and add a new
context.
HttpServer.addContext(java.lang.String,java.lang.String)[0] = virtualHost:Virtual
host name. null for all hosts.
HttpServer.addContext(java.lang.String,java.lang.String)[1] = contextPath:The path
specification for the context.
HttpServer.requestlog = The RequestLog.
HttpServer.statsOn = True if statistics collection is turned on.
HttpServer.statsReset() = Reset statistics.
HttpServer.connections = Number of connections accepted by the server since
statsReset() called. Undefined if setStatsOn(false).
HttpServer.connectionsOpen = Number of connections currently open that were opened
since statsReset() called. Undefined if setStatsOn(false).
HttpServer.connectionsOpenMax = Maximum number of connections opened simultaneously
since statsReset() called. Undefined if setStatsOn(false).
HttpServer.connectionsDurationAve = Sliding average duration in milliseconds of open
connections since statsReset() called. Undefined if setStatsOn(false).
HttpServer.connectionsDurationMax = Maximum duration in milliseconds of an open
connection since statsReset() called. Undefined if setStatsOn(false).
HttpServer.connectionsRequestsAve = Sliding average number of requests per
connection since statsReset() called. Undefined if setStatsOn(false).
HttpServer.connectionsRequestsMax = Maximum number of requests per connection since
statsReset() called. Undefined if setStatsOn(false).
HttpServer.errors = Number of errors since statsReset() called. Undefined if
setStatsOn(false). An error is a request that resulted in an exception being thrown by
the handler.
HttpServer.requests = Number of requests since statsReset() called. Undefined if
setStatsOn(false).
HttpServer.requestsActive = Number of requests currently active. Undefined if
setStatsOn(false).
HttpServer.requestsActiveMax = Maximum number of active requests since statsReset()
called. Undefined if setStatsOn(false).
HttpServer.requestsDurationAve = Average duration of request handling in
milliseconds since statsReset() called. Undefined if setStatsOn(false).
HttpServer.requestsDurationMax = Get maximum duration in milliseconds of request
handling since statsReset() called. Undefined if setStatsOn(false).
HttpListener.host = The host or IP interface to listen on. Null or 0.0.0.0 is
interpreted as all known interfaces.
HttpListener.port = The port to listen on. 0 is interpreted as any free port.
SocketListener.lowResourcePersistTimeMs = Time in ms to persist idle connections if
low on resources.
SocketListener.lowOnResources = True if listener is low on resources.
SocketListener.outOfResources = True if listener is out of resources.
HttpContext=A HTTP Context, which is a collection of HttpHandlers with their
resources and configurations. Changes made to this MBean are not persisted.
HttpContext.contextPath = The URL prefix of this context.
HttpContext.classPath = The path to load classes for this context from.
HttpContext.classLoader = The classloader for this context. If both the
class path and the class loader are set, \
then the classloader is used as the parent
loader for a context loader initialized on the classpath. \
This attribute always returns the actual
classloader used for the context.
HttpContext.realm = The name of the security realm for the context.
HttpContext.redirectNullPath = If true, requests to /contextpath are
redirected to /contextpath/
HttpContext.resourceBase = The file or URL to use as a prefix to all
resource lookups within the context.
HttpContext.servingResources = If true, a ResourceHandler is serving static
resources from the context resource base.
HttpContext.hosts = A list of virtual host aliases that this
context is registered against.
HttpContext.handlers = A list of handlers in this context.
HttpContext.logSink = The LogSink for the requestLog.
HttpContext.statsOn = True if statistics collection is turned on.
HttpContext.destroy() = Destroy a stopped HttpContext and remove it from the
HttpServer.
HttpContext.statsReset() = Reset statistics.
HttpContext.requests = Number of requests since statsReset() called. Undefined if
setStatsOn(false).
HttpContext.responses1xx = Number of responses with 1xx status (Informal) since
statsReset() called. Undefined if setStatsOn(false).
HttpContext.responses2xx = Number of responses with 2xx status (Success) since
statsReset() called. Undefined if setStatsOn(false).
HttpContext.responses3xx = Number of responses with 3xx status (Redirection) since
statsReset() called. Undefined if setStatsOn(false).
HttpContext.responses4xx = Number of responses with 4xx status (Client Error) since
statsReset() called. Undefined if setStatsOn(false).
HttpContext.responses5xx = Number of responses with 5xx status (Server Error) since
statsReset() called. Undefined if setStatsOn(false).
HttpContext.setInitParameter(java.lang.String,java.lang.String) =Set an context
initialization parameter.
HttpContext.setInitParameter(java.lang.String,java.lang.String)[0]=name:The name of
the parameter.
HttpContext.setInitParameter(java.lang.String,java.lang.String)[1]=value:The value
of the parameter.
HttpContext.getInitParameter(java.lang.String) =Get a context initialization
parameter.
HttpContext.getInitParameter(java.lang.String)[0]=name:The name of the parameter.
HttpContext.getInitParameterNames()=Get a list of initialization parameter names.
HttpContext.setAttribute(java.lang.String,java.lang.String) =Set a context
attribute.
HttpContext.setAttribute(java.lang.String,java.lang.String)[0]=name:The attribute
name.
HttpContext.setAttribute(java.lang.String,java.lang.String)[1]=value:The attribute
value.
HttpContext.getAttribute(java.lang.String) =Get a context attribute
HttpContext.getAttribute(java.lang.String)[0]=name:The attribute name.
HttpContext.getAttributeNames()=Get a list of attribute names.
HttpContext.removeAttribute(java.lang.String) =Remove a context attribute.
HttpContext.removeAttribute(java.lang.String)[0]=name:The attribute name.
HttpContext.addHttpHandler(int,org.mortbay.http.HttpHandler) = Add a HttpHandler
instance to the context. When a request is serviced by the context, \
each handler is
called in order until it is handled.
HttpContext.addHttpHandler(int,org.mortbay.http.HttpHandler)[0] = index:The index
within the context to insert the handler at.
HttpContext.addHttpHandler(int,org.mortbay.http.HttpHandler)[1] = handler:The
HttpHandler instance to add.
HttpContext.getHttpHandler(int) = Get a context HttpHandler.
HttpContext.getHttpHandler(int)[0] = index:The index of the handler within the
context.
HttpContext.removeHttpHandler(int) = Remove a context HttpHandler.
HttpContext.removeHttpHandler(int)[0] = index:The index of the handler within the
context.
HttpContext.setMimeMapping(java.lang.String,java.lang.String) = Set a mime mapping
by name extension.
HttpContext.setMimeMapping(java.lang.String,java.lang.String)[0]= extension:The name
extension to map.
HttpContext.setMimeMapping(java.lang.String,java.lang.String)[1]= mimetype:The MIME
type of resources with the extension.
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development