332907 Add context property to ObjectName of JMX MBeans
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@3101 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
835cf031bf
commit
6e197c7ba2
|
@ -1,4 +1,5 @@
|
|||
jetty-7.4.1-SNAPSHOT
|
||||
+ 332907 Add context property to ObjectName of JMX MBeans
|
||||
+ 340040 Support for a total timeout
|
||||
+ 343083 Set nested dispatch type and connection
|
||||
+ 343172 Check package implementor for version
|
||||
|
|
|
@ -15,11 +15,15 @@ package org.eclipse.jetty.embedded;
|
|||
|
||||
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
|
||||
import org.eclipse.jetty.jmx.MBeanContainer;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.servlet.DefaultServlet;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
||||
public class ManyServletContexts
|
||||
{
|
||||
|
@ -27,6 +31,12 @@ public class ManyServletContexts
|
|||
{
|
||||
Server server = new Server(8080);
|
||||
|
||||
// Setup JMX
|
||||
MBeanContainer mbContainer=new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
|
||||
server.getContainer().addEventListener(mbContainer);
|
||||
server.addBean(mbContainer);
|
||||
mbContainer.addBean(Log.getLog());
|
||||
|
||||
ContextHandlerCollection contexts = new ContextHandlerCollection();
|
||||
server.setHandler(contexts);
|
||||
|
||||
|
|
|
@ -232,29 +232,32 @@ public class MBeanContainer extends AbstractLifeCycle implements Container.Liste
|
|||
if (dot >= 0)
|
||||
type = type.substring(dot + 1);
|
||||
|
||||
String context = null;
|
||||
if (mbean instanceof ObjectMBean)
|
||||
{
|
||||
context = makeName(((ObjectMBean)mbean).getObjectContextBasis());
|
||||
}
|
||||
|
||||
String name = null;
|
||||
if (mbean instanceof ObjectMBean)
|
||||
{
|
||||
name = ((ObjectMBean)mbean).getObjectNameBasis();
|
||||
if (name != null)
|
||||
{
|
||||
name = name.replace('\\', '/');
|
||||
if (name.endsWith("/"))
|
||||
name = name.substring(0, name.length() - 1);
|
||||
|
||||
int slash = name.lastIndexOf('/', name.length() - 1);
|
||||
if (slash > 0)
|
||||
name = name.substring(slash + 1);
|
||||
dot = name.lastIndexOf('.');
|
||||
if (dot > 0)
|
||||
name = name.substring(0, dot);
|
||||
|
||||
name = name.replace(':', '_').replace('*', '_').replace('?', '_').replace('=', '_').replace(',', '_').replace(' ', '_');
|
||||
}
|
||||
name = makeName(((ObjectMBean)mbean).getObjectNameBasis());
|
||||
}
|
||||
|
||||
String basis = (name != null && name.length() > 1) ? ("type=" + type + ",name=" + name) : ("type=" + type);
|
||||
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("type=").append(type);
|
||||
if (context != null && context.length()>1)
|
||||
{
|
||||
buf.append(buf.length()>0 ? ",":"");
|
||||
buf.append("context=").append(context);
|
||||
}
|
||||
if (name != null && name.length()>1)
|
||||
{
|
||||
buf.append(buf.length()>0 ? ",":"");
|
||||
buf.append("name=").append(name);
|
||||
}
|
||||
|
||||
String basis = buf.toString();
|
||||
Integer count = _unique.get(basis);
|
||||
count = count == null ? 0 : 1 + count;
|
||||
_unique.put(basis, count);
|
||||
|
@ -278,6 +281,28 @@ public class MBeanContainer extends AbstractLifeCycle implements Container.Liste
|
|||
}
|
||||
}
|
||||
|
||||
public String makeName(String basis)
|
||||
{
|
||||
String name = basis;
|
||||
if (name != null)
|
||||
{
|
||||
name = name.replace('\\', '/');
|
||||
if (name.endsWith("/"))
|
||||
name = name.substring(0, name.length() - 1);
|
||||
|
||||
int slash = name.lastIndexOf('/', name.length() - 1);
|
||||
if (slash > 0)
|
||||
name = name.substring(slash + 1);
|
||||
int dot = name.lastIndexOf('.');
|
||||
if (dot > 0)
|
||||
name = name.substring(0, dot);
|
||||
|
||||
name = name.replace(':', '_').replace('*', '_').replace('?', '_').replace('=', '_').replace(',', '_').replace(' ', '_');
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform actions needed to start lifecycle
|
||||
*
|
||||
|
|
|
@ -182,6 +182,11 @@ public class ObjectMBean implements DynamicMBean
|
|||
return null;
|
||||
}
|
||||
|
||||
public String getObjectContextBasis()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getObjectNameBasis()
|
||||
{
|
||||
return null;
|
||||
|
|
|
@ -61,6 +61,9 @@ public interface Handler extends LifeCycle, Destroyable
|
|||
public void setServer(Server server);
|
||||
public Server getServer();
|
||||
|
||||
public void setContextBasis(String basis);
|
||||
public String getContextBasis();
|
||||
|
||||
public void destroy();
|
||||
|
||||
}
|
||||
|
|
|
@ -340,5 +340,18 @@ public interface SessionManager extends LifeCycle
|
|||
* @param remote True if absolute URLs are check for remoteness before being session encoded.
|
||||
*/
|
||||
public void setCheckingRemoteSessionIdEncoding(boolean remote);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the context basis.
|
||||
*
|
||||
* @param basis the new context basis
|
||||
*/
|
||||
public void setContextBasis(String basis);
|
||||
|
||||
/**
|
||||
* Gets the context basis.
|
||||
*
|
||||
* @return the context basis
|
||||
*/
|
||||
public String getContextBasis();
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.eclipse.jetty.util.log.Log;
|
|||
public abstract class AbstractHandler extends AggregateLifeCycle implements Handler
|
||||
{
|
||||
private Server _server;
|
||||
private String _contextBasis;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
|
@ -93,5 +94,14 @@ public abstract class AbstractHandler extends AggregateLifeCycle implements Hand
|
|||
{
|
||||
out.append(toString()).append(' ').append(getState()).append('\n');
|
||||
}
|
||||
|
||||
public void setContextBasis(String basis)
|
||||
{
|
||||
_contextBasis = basis;
|
||||
}
|
||||
|
||||
public String getContextBasis()
|
||||
{
|
||||
return _contextBasis;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ import javax.servlet.ServletRequestEvent;
|
|||
import javax.servlet.ServletRequestListener;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.swing.plaf.metal.MetalIconFactory.FileIcon16;
|
||||
|
||||
import org.eclipse.jetty.http.HttpException;
|
||||
import org.eclipse.jetty.http.MimeTypes;
|
||||
|
@ -435,6 +436,27 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
|||
{
|
||||
return _displayName;
|
||||
}
|
||||
|
||||
public String getContextBasis()
|
||||
{
|
||||
if (_displayName != null)
|
||||
return _displayName;
|
||||
|
||||
if (_baseResource != null && _baseResource.getName().length() > 1)
|
||||
return _baseResource.getName();
|
||||
|
||||
if (_contextPath != null && _contextPath.length() > 0)
|
||||
{
|
||||
int idx = _contextPath.lastIndexOf(File.separator);
|
||||
String name = idx < 0 ? _contextPath : _contextPath.substring(++idx);
|
||||
if (name.isEmpty())
|
||||
return "[root]";
|
||||
else
|
||||
return name;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public EventListener[] getEventListeners()
|
||||
|
|
|
@ -77,6 +77,7 @@ public class HandlerWrapper extends AbstractHandlerContainer
|
|||
if (handler!=null)
|
||||
{
|
||||
handler.setServer(getServer());
|
||||
handler.setContextBasis(getContextBasis());
|
||||
}
|
||||
|
||||
_handler = handler;
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
//========================================================================
|
||||
//Copyright (c) Webtide LLC
|
||||
//------------------------------------------------------------------------
|
||||
//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.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.server.handler.jmx;
|
||||
|
||||
import org.eclipse.jetty.jmx.ObjectMBean;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
|
||||
public class AbstractHandlerMBean extends ObjectMBean
|
||||
{
|
||||
public AbstractHandlerMBean(Object managedObject)
|
||||
{
|
||||
super(managedObject);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public String getObjectContextBasis()
|
||||
{
|
||||
if (_managed != null && _managed instanceof AbstractHandler)
|
||||
{
|
||||
AbstractHandler handler = (AbstractHandler)_managed;
|
||||
String name = handler.getContextBasis();
|
||||
if (name != null)
|
||||
return name;
|
||||
}
|
||||
return super.getObjectContextBasis();
|
||||
}
|
||||
}
|
|
@ -17,33 +17,16 @@ import java.util.Enumeration;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.jetty.jmx.ObjectMBean;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.util.Attributes;
|
||||
|
||||
public class ContextHandlerMBean extends ObjectMBean
|
||||
public class ContextHandlerMBean extends AbstractHandlerMBean
|
||||
{
|
||||
public ContextHandlerMBean(Object managedObject)
|
||||
{
|
||||
super(managedObject);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public String getObjectNameBasis()
|
||||
{
|
||||
if (_managed!=null && _managed instanceof ContextHandler)
|
||||
{
|
||||
ContextHandler context = (ContextHandler)_managed;
|
||||
String name = context.getDisplayName();
|
||||
if (name!=null)
|
||||
return name;
|
||||
|
||||
if (context.getBaseResource()!=null && context.getBaseResource().getName().length()>1)
|
||||
return context.getBaseResource().getName();
|
||||
}
|
||||
return super.getObjectNameBasis();
|
||||
}
|
||||
|
||||
public Map getContextAttributes()
|
||||
{
|
||||
Map map = new HashMap();
|
||||
|
|
|
@ -70,6 +70,7 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
|
|||
private static final HttpSessionContext __nullSessionContext=new NullSessionContext();
|
||||
|
||||
private boolean _usingCookies=true;
|
||||
private String _contextBasis;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
// Setting of max inactive interval for new sessions
|
||||
|
@ -96,6 +97,7 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
|
|||
|
||||
protected final CounterStatistic _sessionsStats = new CounterStatistic();
|
||||
protected final SampleStatistic _sessionTimeStats = new SampleStatistic();
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public AbstractSessionManager()
|
||||
|
@ -754,6 +756,24 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
|
|||
{
|
||||
_checkingRemoteSessionIdEncoding=remote;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.SessionManager#setContextBasis(java.lang.String)
|
||||
*/
|
||||
public void setContextBasis(String basis)
|
||||
{
|
||||
_contextBasis = basis;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.SessionManager#getContextBasis()
|
||||
*/
|
||||
public String getContextBasis()
|
||||
{
|
||||
return _contextBasis;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
|
|
|
@ -80,7 +80,10 @@ public class SessionHandler extends ScopedHandler
|
|||
getServer().getContainer().update(this, old_session_manager, sessionManager, "sessionManager",true);
|
||||
|
||||
if (sessionManager!=null)
|
||||
{
|
||||
sessionManager.setSessionHandler(this);
|
||||
sessionManager.setContextBasis(getContextBasis());
|
||||
}
|
||||
|
||||
_sessionManager = sessionManager;
|
||||
|
||||
|
@ -320,4 +323,15 @@ public class SessionHandler extends ScopedHandler
|
|||
if(_sessionManager!=null)
|
||||
_sessionManager.clearEventListeners();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void setContextBasis(String name)
|
||||
{
|
||||
if (_sessionManager != null)
|
||||
{
|
||||
_sessionManager.setContextBasis(name);
|
||||
}
|
||||
|
||||
super.setContextBasis(name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
//========================================================================
|
||||
//Copyright (c) Webtide LLC
|
||||
//------------------------------------------------------------------------
|
||||
//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.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.server.session.jmx;
|
||||
|
||||
import org.eclipse.jetty.jmx.ObjectMBean;
|
||||
import org.eclipse.jetty.server.session.AbstractSessionManager;
|
||||
|
||||
public class AbstractSessionManagerMBean extends ObjectMBean
|
||||
{
|
||||
public AbstractSessionManagerMBean(Object managedObject)
|
||||
{
|
||||
super(managedObject);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public String getObjectContextBasis()
|
||||
{
|
||||
if (_managed != null && _managed instanceof AbstractSessionManager)
|
||||
{
|
||||
AbstractSessionManager manager = (AbstractSessionManager)_managed;
|
||||
String name = manager.getContextBasis();
|
||||
if (name != null)
|
||||
return name;
|
||||
}
|
||||
return super.getObjectContextBasis();
|
||||
}
|
||||
}
|
|
@ -589,5 +589,14 @@ public class SessionHandlerTest
|
|||
public void changeSessionIdOnAuthentication(HttpServletRequest request, HttpServletResponse response)
|
||||
{
|
||||
}
|
||||
|
||||
public void setContextBasis(String basis)
|
||||
{
|
||||
}
|
||||
|
||||
public String getContextBasis()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,116 @@
|
|||
//========================================================================
|
||||
//Copyright (c) Webtide LLC
|
||||
//------------------------------------------------------------------------
|
||||
//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.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
||||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
*/
|
||||
public abstract class AbstractMapping implements Mapping, Dumpable
|
||||
{
|
||||
private String _entityName;
|
||||
private String[] _pathSpecs;
|
||||
private String _contextBasis;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.servlet.Mapping#setEntityName(java.lang.String)
|
||||
*/
|
||||
public void setEntityName(String name)
|
||||
{
|
||||
_entityName = name;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.servlet.Mapping#getEntityName()
|
||||
*/
|
||||
public String getEntityName()
|
||||
{
|
||||
return _entityName;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.servlet.Mapping#setPathSpecs(java.lang.String[])
|
||||
*/
|
||||
public void setPathSpecs(String[] pathSpecs)
|
||||
{
|
||||
_pathSpecs = pathSpecs;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.servlet.Mapping#setPathSpec(java.lang.String)
|
||||
*/
|
||||
public void setPathSpec(String pathSpec)
|
||||
{
|
||||
_pathSpecs = new String[]{pathSpec};
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.servlet.Mapping#getPathSpecs()
|
||||
*/
|
||||
public String[] getPathSpecs()
|
||||
{
|
||||
return _pathSpecs;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.servlet.Mapping#getContextBasis()
|
||||
*/
|
||||
public String getContextBasis()
|
||||
{
|
||||
return _contextBasis;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.servlet.Mapping#setContextBasis(java.lang.String)
|
||||
*/
|
||||
public void setContextBasis(String basis)
|
||||
{
|
||||
_contextBasis = basis;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return TypeUtil.asList(getPathSpecs())+"=>"+getEntityName();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void dump(Appendable out, String indent) throws IOException
|
||||
{
|
||||
out.append(String.valueOf(this)).append("\n");
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public String dump()
|
||||
{
|
||||
return AggregateLifeCycle.dump(this);
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@ import org.eclipse.jetty.util.component.Dumpable;
|
|||
import org.eclipse.jetty.util.log.Log;
|
||||
|
||||
|
||||
public class FilterMapping implements Dumpable
|
||||
public class FilterMapping extends AbstractMapping
|
||||
{
|
||||
/** Dispatch types */
|
||||
public static final int DEFAULT=0;
|
||||
|
@ -84,9 +84,7 @@ public class FilterMapping implements Dumpable
|
|||
|
||||
|
||||
private int _dispatches=DEFAULT;
|
||||
private String _filterName;
|
||||
private transient FilterHolder _holder;
|
||||
private String[] _pathSpecs;
|
||||
private String[] _servletNames;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -103,8 +101,9 @@ public class FilterMapping implements Dumpable
|
|||
{
|
||||
if (appliesTo(type))
|
||||
{
|
||||
for (int i=0;i<_pathSpecs.length;i++)
|
||||
if (_pathSpecs[i]!=null && PathMap.match(_pathSpecs[i], path,true))
|
||||
String[] pathSpecs = getPathSpecs();
|
||||
for (int i=0;i<pathSpecs.length;i++)
|
||||
if (pathSpecs[i]!=null && PathMap.match(pathSpecs[i], path,true))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -130,7 +129,7 @@ public class FilterMapping implements Dumpable
|
|||
*/
|
||||
public String getFilterName()
|
||||
{
|
||||
return _filterName;
|
||||
return getEntityName();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -142,15 +141,6 @@ public class FilterMapping implements Dumpable
|
|||
return _holder;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Returns the pathSpec.
|
||||
*/
|
||||
public String[] getPathSpecs()
|
||||
{
|
||||
return _pathSpecs;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void setDispatcherTypes(EnumSet<DispatcherType> dispatcherTypes)
|
||||
{
|
||||
|
@ -192,7 +182,7 @@ public class FilterMapping implements Dumpable
|
|||
*/
|
||||
public void setFilterName(String filterName)
|
||||
{
|
||||
_filterName = filterName;
|
||||
setEntityName(filterName);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -205,24 +195,6 @@ public class FilterMapping implements Dumpable
|
|||
setFilterName(holder.getName());
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param pathSpecs The Path specifications to which this filter should be mapped.
|
||||
*/
|
||||
public void setPathSpecs(String[] pathSpecs)
|
||||
{
|
||||
_pathSpecs = pathSpecs;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param pathSpec The pathSpec to set.
|
||||
*/
|
||||
public void setPathSpec(String pathSpec)
|
||||
{
|
||||
_pathSpecs = new String[]{pathSpec};
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Returns the servletName.
|
||||
|
@ -253,24 +225,13 @@ public class FilterMapping implements Dumpable
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return
|
||||
TypeUtil.asList(_pathSpecs)+"/"+
|
||||
TypeUtil.asList(getPathSpecs())+"/"+
|
||||
TypeUtil.asList(_servletNames)+"=="+
|
||||
_dispatches+"=>"+
|
||||
_filterName;
|
||||
getEntityName();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void dump(Appendable out, String indent) throws IOException
|
||||
{
|
||||
out.append(String.valueOf(this)).append("\n");
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public String dump()
|
||||
{
|
||||
return AggregateLifeCycle.dump(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,8 @@ public class Holder<T> extends AbstractLifeCycle implements Dumpable
|
|||
/* ---------------------------------------------------------------- */
|
||||
protected String _name;
|
||||
protected ServletHandler _servletHandler;
|
||||
|
||||
private String _contextBasis;
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
protected Holder()
|
||||
|
@ -266,6 +268,16 @@ public class Holder<T> extends AbstractLifeCycle implements Dumpable
|
|||
return AggregateLifeCycle.dump(this);
|
||||
}
|
||||
|
||||
public void setContextBasis(String basis)
|
||||
{
|
||||
_contextBasis = basis;
|
||||
}
|
||||
|
||||
public String getContextBasis()
|
||||
{
|
||||
return _contextBasis;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
//========================================================================
|
||||
//Copyright (c) Webtide LLC
|
||||
//------------------------------------------------------------------------
|
||||
//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.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.servlet;
|
||||
|
||||
public interface Mapping
|
||||
{
|
||||
/**
|
||||
* Sets the entity name.
|
||||
*
|
||||
* @param name the new entity name
|
||||
*/
|
||||
public void setEntityName(String name);
|
||||
|
||||
/**
|
||||
* Gets the entity name.
|
||||
*
|
||||
* @return the entity name
|
||||
*/
|
||||
public String getEntityName();
|
||||
|
||||
/**
|
||||
* Sets the path specs.
|
||||
*
|
||||
* @param pathSpecs the new path specs
|
||||
*/
|
||||
public void setPathSpecs(String[] pathSpecs);
|
||||
|
||||
/**
|
||||
* Sets the path spec.
|
||||
*
|
||||
* @param pathSpec the new path spec
|
||||
*/
|
||||
public void setPathSpec(String pathSpec);
|
||||
|
||||
/**
|
||||
* Gets the path specs.
|
||||
*
|
||||
* @return the path specs
|
||||
*/
|
||||
public String[] getPathSpecs();
|
||||
|
||||
/**
|
||||
* Gets the context basis.
|
||||
*
|
||||
* @return the context basis
|
||||
*/
|
||||
public String getContextBasis();
|
||||
|
||||
/**
|
||||
* Sets the context basis.
|
||||
*
|
||||
* @param basis the new context basis
|
||||
*/
|
||||
public void setContextBasis(String basis);
|
||||
}
|
|
@ -116,10 +116,12 @@ public class ServletContextHandler extends ContextHandler
|
|||
public ServletContextHandler(HandlerContainer parent, String contextPath, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler)
|
||||
{
|
||||
super((ContextHandler.Context)null);
|
||||
|
||||
_scontext = new Context();
|
||||
_sessionHandler = sessionHandler;
|
||||
_securityHandler = securityHandler;
|
||||
_servletHandler = servletHandler;
|
||||
|
||||
setSessionHandler(sessionHandler);
|
||||
setSecurityHandler(securityHandler);
|
||||
setServletHandler(servletHandler);
|
||||
|
||||
if (errorHandler!=null)
|
||||
setErrorHandler(errorHandler);
|
||||
|
@ -253,7 +255,7 @@ public class ServletContextHandler extends ContextHandler
|
|||
public SecurityHandler getSecurityHandler()
|
||||
{
|
||||
if (_securityHandler==null && (_options&SECURITY)!=0 && !isStarted())
|
||||
_securityHandler=newSecurityHandler();
|
||||
setSecurityHandler(newSecurityHandler());
|
||||
|
||||
return _securityHandler;
|
||||
}
|
||||
|
@ -265,7 +267,8 @@ public class ServletContextHandler extends ContextHandler
|
|||
public ServletHandler getServletHandler()
|
||||
{
|
||||
if (_servletHandler==null && !isStarted())
|
||||
_servletHandler=newServletHandler();
|
||||
setServletHandler(newServletHandler());
|
||||
|
||||
return _servletHandler;
|
||||
}
|
||||
|
||||
|
@ -276,7 +279,7 @@ public class ServletContextHandler extends ContextHandler
|
|||
public SessionHandler getSessionHandler()
|
||||
{
|
||||
if (_sessionHandler==null && (_options&SESSIONS)!=0 && !isStarted())
|
||||
_sessionHandler=newSessionHandler();
|
||||
setSessionHandler(newSessionHandler());
|
||||
return _sessionHandler;
|
||||
}
|
||||
|
||||
|
@ -377,6 +380,11 @@ public class ServletContextHandler extends ContextHandler
|
|||
if (isStarted())
|
||||
throw new IllegalStateException("STARTED");
|
||||
|
||||
if (sessionHandler != null)
|
||||
{
|
||||
sessionHandler.setContextBasis(getContextBasis());
|
||||
}
|
||||
|
||||
_sessionHandler = sessionHandler;
|
||||
}
|
||||
|
||||
|
@ -389,6 +397,11 @@ public class ServletContextHandler extends ContextHandler
|
|||
if (isStarted())
|
||||
throw new IllegalStateException("STARTED");
|
||||
|
||||
if (securityHandler != null)
|
||||
{
|
||||
securityHandler.setContextBasis(getContextBasis());
|
||||
}
|
||||
|
||||
_securityHandler = securityHandler;
|
||||
}
|
||||
|
||||
|
@ -401,6 +414,11 @@ public class ServletContextHandler extends ContextHandler
|
|||
if (isStarted())
|
||||
throw new IllegalStateException("STARTED");
|
||||
|
||||
if (servletHandler != null)
|
||||
{
|
||||
servletHandler.setContextBasis(getContextBasis());
|
||||
}
|
||||
|
||||
_servletHandler = servletHandler;
|
||||
}
|
||||
|
||||
|
@ -445,7 +463,7 @@ public class ServletContextHandler extends ContextHandler
|
|||
for (Decorator decorator : _decorators)
|
||||
decorator.destroyFilterInstance(filter);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public class Context extends ContextHandler.Context
|
||||
{
|
||||
|
|
|
@ -1110,6 +1110,7 @@ public class ServletHandler extends ScopedHandler
|
|||
{
|
||||
_filterNameMap.put(_filters[i].getName(),_filters[i]);
|
||||
_filters[i].setServletHandler(this);
|
||||
_filters[i].setContextBasis(getContextBasis());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1122,6 +1123,7 @@ public class ServletHandler extends ScopedHandler
|
|||
{
|
||||
_servletNameMap.put(_servlets[i].getName(),_servlets[i]);
|
||||
_servlets[i].setServletHandler(this);
|
||||
_servlets[i].setContextBasis(getContextBasis());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1141,6 +1143,8 @@ public class ServletHandler extends ScopedHandler
|
|||
_filterNameMappings=new MultiMap();
|
||||
for (int i=0;i<_filterMappings.length;i++)
|
||||
{
|
||||
_filterMappings[i].setContextBasis(getContextBasis());
|
||||
|
||||
FilterHolder filter_holder = (FilterHolder)_filterNameMap.get(_filterMappings[i].getFilterName());
|
||||
if (filter_holder==null)
|
||||
throw new IllegalStateException("No filter named "+_filterMappings[i].getFilterName());
|
||||
|
@ -1172,6 +1176,8 @@ public class ServletHandler extends ScopedHandler
|
|||
// update the maps
|
||||
for (int i=0;i<_servletMappings.length;i++)
|
||||
{
|
||||
_servletMappings[i].setContextBasis(getContextBasis());
|
||||
|
||||
ServletHolder servlet_holder = (ServletHolder)_servletNameMap.get(_servletMappings[i].getServletName());
|
||||
if (servlet_holder==null)
|
||||
throw new IllegalStateException("No such servlet: "+_servletMappings[i].getServletName());
|
||||
|
@ -1181,6 +1187,7 @@ public class ServletHandler extends ScopedHandler
|
|||
for (int j=0;j<pathSpecs.length;j++)
|
||||
if (pathSpecs[j]!=null)
|
||||
pm.put(pathSpecs[j],servlet_holder);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,51 +16,25 @@ package org.eclipse.jetty.servlet;
|
|||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
|
||||
public class ServletMapping
|
||||
|
||||
public class ServletMapping extends AbstractMapping
|
||||
{
|
||||
private String[] _pathSpecs;
|
||||
private String _servletName;
|
||||
private String _contextName;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public ServletMapping()
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Returns the pathSpecs.
|
||||
*/
|
||||
public String[] getPathSpecs()
|
||||
{
|
||||
return _pathSpecs;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Returns the servletName.
|
||||
*/
|
||||
public String getServletName()
|
||||
{
|
||||
return _servletName;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param pathSpecs The pathSpecs to set.
|
||||
*/
|
||||
public void setPathSpecs(String[] pathSpecs)
|
||||
{
|
||||
_pathSpecs = pathSpecs;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param pathSpec The pathSpec to set.
|
||||
*/
|
||||
public void setPathSpec(String pathSpec)
|
||||
{
|
||||
_pathSpecs = new String[]{pathSpec};
|
||||
return getEntityName();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -69,19 +43,6 @@ public class ServletMapping
|
|||
*/
|
||||
public void setServletName(String servletName)
|
||||
{
|
||||
_servletName = servletName;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public String toString()
|
||||
{
|
||||
return (_pathSpecs==null?"[]":Arrays.asList(_pathSpecs).toString())+"=>"+_servletName;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void dump(Appendable out, String indent) throws IOException
|
||||
{
|
||||
out.append(String.valueOf(this)).append("\n");
|
||||
setEntityName(servletName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
//========================================================================
|
||||
//Copyright (c) Webtide LLC
|
||||
//------------------------------------------------------------------------
|
||||
//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.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.servlet.jmx;
|
||||
|
||||
import org.eclipse.jetty.jmx.ObjectMBean;
|
||||
import org.eclipse.jetty.servlet.AbstractMapping;
|
||||
|
||||
public class AbstractMappingMBean extends ObjectMBean
|
||||
{
|
||||
|
||||
public AbstractMappingMBean(Object managedObject)
|
||||
{
|
||||
super(managedObject);
|
||||
}
|
||||
|
||||
public String getObjectContextBasis()
|
||||
{
|
||||
if (_managed != null && _managed instanceof AbstractMapping)
|
||||
{
|
||||
AbstractMapping mapping = (AbstractMapping)_managed;
|
||||
String name = mapping.getContextBasis();
|
||||
if (name != null)
|
||||
return name;
|
||||
}
|
||||
|
||||
return super.getObjectContextBasis();
|
||||
}
|
||||
|
||||
public String getObjectNameBasis()
|
||||
{
|
||||
if (_managed != null && _managed instanceof AbstractMapping)
|
||||
{
|
||||
AbstractMapping mapping = (AbstractMapping)_managed;
|
||||
String name = mapping.getEntityName();
|
||||
if (name != null)
|
||||
return name;
|
||||
}
|
||||
|
||||
return super.getObjectNameBasis();
|
||||
}
|
||||
}
|
|
@ -23,6 +23,20 @@ public class HolderMBean extends ObjectMBean
|
|||
super(managedObject);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public String getObjectContextBasis()
|
||||
{
|
||||
if (_managed != null && _managed instanceof Holder)
|
||||
{
|
||||
Holder holder = (Holder)_managed;
|
||||
String name = holder.getContextBasis();
|
||||
if (name != null)
|
||||
return name;
|
||||
}
|
||||
|
||||
return super.getObjectContextBasis();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public String getObjectNameBasis()
|
||||
{
|
||||
|
|
|
@ -1198,6 +1198,19 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
super.startContext();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public MetaData getMetaData()
|
||||
{
|
||||
return _metadata;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public String getContextBasis()
|
||||
{
|
||||
return getWar();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public class Context extends ServletContextHandler.Context
|
||||
{
|
||||
|
@ -1247,11 +1260,4 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public MetaData getMetaData()
|
||||
{
|
||||
return _metadata;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2004-2009 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.
|
||||
// ========================================================================
|
||||
|
||||
package org.eclipse.jetty.webapp.jmx;
|
||||
|
||||
import org.eclipse.jetty.server.handler.jmx.ContextHandlerMBean;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
public class WebAppContextMBean extends ContextHandlerMBean
|
||||
{
|
||||
|
||||
public WebAppContextMBean(Object managedObject)
|
||||
{
|
||||
super(managedObject);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public String getObjectNameBasis()
|
||||
{
|
||||
String basis = super.getObjectNameBasis();
|
||||
if (basis!=null)
|
||||
return basis;
|
||||
|
||||
if (_managed!=null && _managed instanceof WebAppContext)
|
||||
{
|
||||
WebAppContext context = (WebAppContext)_managed;
|
||||
String name = context.getWar();
|
||||
if (name!=null)
|
||||
return name;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue