changeset 988:13beba0c127f

remove ContextHandler._attributes
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 17 Oct 2016 05:22:25 -0600
parents af8742d31bca
children 900e5b8ccd19
files src/org/eclipse/jetty/server/Request.java src/org/eclipse/jetty/server/handler/ContextHandler.java
diffstat 2 files changed, 5 insertions(+), 108 deletions(-) [+]
line wrap: on
line diff
diff -r af8742d31bca -r 13beba0c127f src/org/eclipse/jetty/server/Request.java
--- a/src/org/eclipse/jetty/server/Request.java	Mon Oct 17 04:59:15 2016 -0600
+++ b/src/org/eclipse/jetty/server/Request.java	Mon Oct 17 05:22:25 2016 -0600
@@ -1071,7 +1071,6 @@
 		return _port;
 	}
 
-	/* ------------------------------------------------------------ */
 	public ServletContext getServletContext()
 	{
 		return _context;
diff -r af8742d31bca -r 13beba0c127f src/org/eclipse/jetty/server/handler/ContextHandler.java
--- a/src/org/eclipse/jetty/server/handler/ContextHandler.java	Mon Oct 17 04:59:15 2016 -0600
+++ b/src/org/eclipse/jetty/server/handler/ContextHandler.java	Mon Oct 17 05:22:25 2016 -0600
@@ -69,7 +69,6 @@
 import org.eclipse.jetty.server.HandlerContainer;
 import org.eclipse.jetty.server.Request;
 import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.util.Attributes;
 import org.eclipse.jetty.util.AttributesMap;
 import org.eclipse.jetty.util.LazyList;
 import org.eclipse.jetty.util.StringUtil;
@@ -96,7 +95,7 @@
  * 
  * @org.apache.xbean.XBean description="Creates a basic HTTP context"
  */
-public class ContextHandler extends ScopedHandler implements Attributes, Server.Graceful
+public final class ContextHandler extends ScopedHandler implements Server.Graceful
 {
 	private static final Logger LOG = LoggerFactory.getLogger(ContextHandler.class);
 
@@ -122,7 +121,6 @@
 
 	protected Context _scontext;
 
-	private final AttributesMap _attributes;
 	private final AttributesMap _contextAttributes;
 	private final Map<String, String> _initParams;
 	private ClassLoader _classLoader;
@@ -164,21 +162,6 @@
 	{
 		super();
 		_scontext = new Context();
-		_attributes = new AttributesMap();
-		_contextAttributes = new AttributesMap();
-		_initParams = new HashMap<String, String>();
-		addAliasCheck(new ApproveNonExistentDirectoryAliases());
-	}
-
-	/* ------------------------------------------------------------ */
-	/**
-	 *
-	 */
-	protected ContextHandler(Context context)
-	{
-		super();
-		_scontext = context;
-		_attributes = new AttributesMap();
 		_contextAttributes = new AttributesMap();
 		_initParams = new HashMap<String, String>();
 		addAliasCheck(new ApproveNonExistentDirectoryAliases());
@@ -214,7 +197,7 @@
 	{
 		dumpThis(out);
 		dump(out,indent,Collections.singletonList(new CLDump(getClassLoader())),TypeUtil.asList(getHandlers()),getBeans(),_initParams.entrySet(),
-				_attributes.getAttributeEntrySet(),_contextAttributes.getAttributeEntrySet());
+				_contextAttributes.getAttributeEntrySet());
 	}
 
 	/* ------------------------------------------------------------ */
@@ -360,34 +343,6 @@
 	}
 
 	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletContext#getAttribute(java.lang.String)
-	 */
-	public Object getAttribute(String name)
-	{
-		return _attributes.getAttribute(name);
-	}
-
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletContext#getAttributeNames()
-	 */
-	@SuppressWarnings("unchecked")
-	public Enumeration getAttributeNames()
-	{
-		return AttributesMap.getAttributeNamesCopy(_attributes);
-	}
-
-	/* ------------------------------------------------------------ */
-	/**
-	 * @return Returns the attributes.
-	 */
-	public Attributes getAttributes()
-	{
-		return _attributes;
-	}
-
-	/* ------------------------------------------------------------ */
 	/**
 	 * @return Returns the classLoader.
 	 */
@@ -1132,58 +1087,6 @@
 	
 
 	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletContext#removeAttribute(java.lang.String)
-	 */
-	public void removeAttribute(String name)
-	{
-		checkManagedAttribute(name,null);
-		_attributes.removeAttribute(name);
-	}
-
-	/* ------------------------------------------------------------ */
-	/*
-	 * Set a context attribute. Attributes set via this API cannot be overriden by the ServletContext.setAttribute API. Their lifecycle spans the stop/start of
-	 * a context. No attribute listener events are triggered by this API.
-	 *
-	 * @see javax.servlet.ServletContext#setAttribute(java.lang.String, java.lang.Object)
-	 */
-	public void setAttribute(String name, Object value)
-	{
-		checkManagedAttribute(name,value);
-		_attributes.setAttribute(name,value);
-	}
-
-	/* ------------------------------------------------------------ */
-	/**
-	 * @param attributes
-	 *            The attributes to set.
-	 */
-	public void setAttributes(Attributes attributes)
-	{
-		_attributes.clearAttributes();
-		_attributes.addAll(attributes);
-		Enumeration e = _attributes.getAttributeNames();
-		while (e.hasMoreElements())
-		{
-			String name = (String)e.nextElement();
-			checkManagedAttribute(name,attributes.getAttribute(name));
-		}
-	}
-
-	/* ------------------------------------------------------------ */
-	public void clearAttributes()
-	{
-		Enumeration e = _attributes.getAttributeNames();
-		while (e.hasMoreElements())
-		{
-			String name = (String)e.nextElement();
-			checkManagedAttribute(name,null);
-		}
-		_attributes.clearAttributes();
-	}
-
-	/* ------------------------------------------------------------ */
 	public void checkManagedAttribute(String name, Object value)
 	{
 		if (_managedAttributes != null && _managedAttributes.containsKey(name))
@@ -1941,10 +1844,9 @@
 		@Override
 		public synchronized Object getAttribute(String name)
 		{
-			Object o = ContextHandler.this.getAttribute(name);
-			if (o == null && _contextAttributes != null)
-				o = _contextAttributes.getAttribute(name);
-			return o;
+			if (_contextAttributes != null)
+				return _contextAttributes.getAttribute(name);
+			return null;
 		}
 
 		/* ------------------------------------------------------------ */
@@ -1962,9 +1864,6 @@
 				while (e.hasMoreElements())
 					set.add(e.nextElement());
 			}
-			Enumeration<String> e = _attributes.getAttributeNames();
-			while (e.hasMoreElements())
-				set.add(e.nextElement());
 
 			return Collections.enumeration(set);
 		}
@@ -2014,7 +1913,6 @@
 			if (_contextAttributes == null)
 			{
 				// Set it on the handler
-				_attributes.removeAttribute(name);
 				return;
 			}