332703 Cleanup context scope JNDI at stop

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2610 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2010-12-16 10:35:07 +00:00
parent b8bb6c8ccb
commit 796f444914
10 changed files with 71 additions and 71 deletions

View File

@ -2,6 +2,7 @@
jetty-7.2.3-SNAPSHOT
+ 332432 Scanner.java now always scanning the canonical form of File
+ 332179 Fixed formatting of negative dates
+ 332703 Cleanup context scope JNDI at stop
jetty-7.2.2.v20101205 5 December 2010
+ JETTY-1308 327109 (re)fixed AJP handling of empty packets

View File

@ -136,6 +136,9 @@ public class LikeJettyXml
server.setSendServerVersion(true);
server.start();
System.err.println(server.dump());
server.join();
}

View File

@ -15,8 +15,12 @@ package org.eclipse.jetty.jndi;
import java.io.IOException;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
@ -62,27 +66,15 @@ import org.eclipse.jetty.util.log.Logger;
public class NamingContext implements Context, Cloneable
{
private final static Logger __log=NamingUtil.__log;
private final static List<Binding> __empty = Collections.emptyList();
public static final String LOCK_PROPERTY = "org.eclipse.jndi.lock";
public static final String UNLOCK_PROPERTY = "org.eclipse.jndi.unlock";
public static final Enumeration EMPTY_ENUM = new Enumeration ()
{
public boolean hasMoreElements()
{
return false;
}
public Object nextElement ()
{
throw new NoSuchElementException();
}
};
protected final Hashtable<String,Object> _env = new Hashtable<String,Object>();
protected Map<String,Binding> _bindings = new HashMap<String,Binding>();
protected Context _parent = null;
protected String _name = null;
protected Hashtable _env = null;
protected Hashtable _bindings = new Hashtable();
protected NameParser _parser = null;
@ -103,11 +95,11 @@ public class NamingContext implements Context, Cloneable
* @see
*
*/
public class NameEnumeration implements NamingEnumeration
public class NameEnumeration implements NamingEnumeration<NameClassPair>
{
Enumeration _delegate;
Iterator<Binding> _delegate;
public NameEnumeration (Enumeration e)
public NameEnumeration (Iterator<Binding> e)
{
_delegate = e;
}
@ -120,24 +112,24 @@ public class NamingContext implements Context, Cloneable
public boolean hasMore ()
throws NamingException
{
return _delegate.hasMoreElements();
return _delegate.hasNext();
}
public Object next()
public NameClassPair next()
throws NamingException
{
Binding b = (Binding)_delegate.nextElement();
Binding b = _delegate.next();
return new NameClassPair(b.getName(),b.getClassName(),true);
}
public boolean hasMoreElements()
{
return _delegate.hasMoreElements();
return _delegate.hasNext();
}
public Object nextElement()
public NameClassPair nextElement()
{
Binding b = (Binding)_delegate.nextElement();
Binding b = _delegate.next();
return new NameClassPair(b.getName(),b.getClassName(),true);
}
}
@ -163,11 +155,11 @@ public class NamingContext implements Context, Cloneable
* @see
*
*/
public class BindingEnumeration implements NamingEnumeration
public class BindingEnumeration implements NamingEnumeration<Binding>
{
Enumeration _delegate;
Iterator<Binding> _delegate;
public BindingEnumeration (Enumeration e)
public BindingEnumeration (Iterator<Binding> e)
{
_delegate = e;
}
@ -180,24 +172,24 @@ public class NamingContext implements Context, Cloneable
public boolean hasMore ()
throws NamingException
{
return _delegate.hasMoreElements();
return _delegate.hasNext();
}
public Object next()
public Binding next()
throws NamingException
{
Binding b = (Binding)_delegate.nextElement();
Binding b = (Binding)_delegate.next();
return new Binding (b.getName(), b.getClassName(), b.getObject(), true);
}
public boolean hasMoreElements()
{
return _delegate.hasMoreElements();
return _delegate.hasNext();
}
public Object nextElement()
public Binding nextElement()
{
Binding b = (Binding)_delegate.nextElement();
Binding b = (Binding)_delegate.next();
return new Binding (b.getName(), b.getClassName(), b.getObject(),true);
}
}
@ -213,39 +205,31 @@ public class NamingContext implements Context, Cloneable
* @param parent immediate ancestor Context (can be null)
* @param parser NameParser for this Context
*/
public NamingContext(Hashtable env,
public NamingContext(Hashtable<String,Object> env,
String name,
Context parent,
NameParser parser)
{
if (env == null)
_env = new Hashtable();
else
_env = new Hashtable(env);
if (env != null)
_env.putAll(env);
_name = name;
_parent = parent;
_parser = parser;
}
/*------------------------------------------------*/
/**
* Creates a new <code>NamingContext</code> instance.
*
* @param env a <code>Hashtable</code> value
*/
public NamingContext (Hashtable env)
public NamingContext (Hashtable<String,Object> env)
{
if (env == null)
_env = new Hashtable();
else
_env = new Hashtable(env);
if (env != null)
_env.putAll(env);
}
/*------------------------------------------------*/
/**
* Constructor
@ -253,7 +237,6 @@ public class NamingContext implements Context, Cloneable
*/
public NamingContext ()
{
_env = new Hashtable();
}
@ -268,8 +251,8 @@ public class NamingContext implements Context, Cloneable
throws CloneNotSupportedException
{
NamingContext ctx = (NamingContext)super.clone();
ctx._env = (Hashtable)_env.clone();
ctx._bindings = (Hashtable)_bindings.clone();
ctx._env.putAll(_env);
ctx._bindings.putAll(_bindings);
return ctx;
}
@ -812,13 +795,13 @@ public class NamingContext implements Context, Cloneable
if (cname == null)
{
return new NameEnumeration(EMPTY_ENUM);
return new NameEnumeration(__empty.iterator());
}
if (cname.size() == 0)
{
return new NameEnumeration (_bindings.elements());
return new NameEnumeration (_bindings.values().iterator());
}
@ -895,12 +878,12 @@ public class NamingContext implements Context, Cloneable
if (cname == null)
{
return new BindingEnumeration(EMPTY_ENUM);
return new BindingEnumeration(__empty.iterator());
}
if (cname.size() == 0)
{
return new BindingEnumeration (_bindings.elements());
return new BindingEnumeration (_bindings.values().iterator());
}

View File

@ -36,8 +36,7 @@ import org.eclipse.jetty.jndi.NamingContext;
public class localContextRoot implements Context
{
private static final NamingContext __root = new NamingContext();
private final Hashtable _env;
private final Hashtable<String,Object> _env;
// make a root for the static namespace local:
static

View File

@ -185,7 +185,6 @@ public class NamingEntryUtil
public static Context getContextForScope(Object scope)
throws NamingException
{
InitialContext ic = new InitialContext();
NameParser parser = ic.getNameParser("");
Name name = parser.parse("");
@ -240,7 +239,7 @@ public class NamingEntryUtil
if (scope==null)
return "";
String str = scope.getClass().getName()+"@"+scope.hashCode();
String str = scope.getClass().getName()+"@"+Long.toHexString(scope.hashCode());
str=str.replace('/', '_').replace(' ', '_');
return str;
}

View File

@ -23,7 +23,9 @@ import javax.naming.Name;
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
import org.eclipse.jetty.jndi.NamingContext;
import org.eclipse.jetty.jndi.NamingUtil;
import org.eclipse.jetty.jndi.local.localContextRoot;
import org.eclipse.jetty.plus.jndi.EnvEntry;
import org.eclipse.jetty.plus.jndi.NamingEntry;
import org.eclipse.jetty.plus.jndi.NamingEntryUtil;
@ -128,8 +130,8 @@ public class EnvConfiguration extends AbstractConfiguration
//unbind any NamingEntries that were configured in this webapp's name space
try
{
Context scopeContext = NamingEntryUtil.getContextForScope(context);
scopeContext.destroySubcontext(NamingEntry.__contextName);
NamingContext scopeContext = (NamingContext)NamingEntryUtil.getContextForScope(context);
scopeContext.getParent().destroySubcontext(scopeContext.getName());
}
catch (NameNotFoundException e)
{

View File

@ -42,7 +42,7 @@ public class TestNamingEntryUtil
{
public String toString()
{
return this.getClass().getName()+"@"+super.hashCode();
return this.getClass().getName()+"@"+Long.toHexString(super.hashCode());
}
}

View File

@ -190,8 +190,11 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
protected void dump(Appendable out,String indent) throws IOException
{
out.append(toString()).append(isStarted()?" started":" STOPPED").append('\n');
if (Log.isDebugEnabled())
{
out.append(indent).append(" +-").append(String.valueOf(_attributes)).append('\n');
out.append(indent).append(" +-").append(String.valueOf(_contextAttributes)).append('\n');
}
dumpHandlers(out,indent);
}

View File

@ -1487,6 +1487,7 @@ public class ServletHandler extends ScopedHandler
out.append(indent);
out.append(" +-");
out.append(String.valueOf(f.toString()));
if (Log.isDebugEnabled())
out.append(String.valueOf(f.getFilterHolder().getInitParameters()));
out.append('\n');
}
@ -1501,7 +1502,7 @@ public class ServletHandler extends ScopedHandler
out.append(" +-");
out.append(String.valueOf(m));
ServletHolder h = getServlet(m.getServletName());
if (h!=null)
if (h!=null && Log.isDebugEnabled())
out.append(String.valueOf(h.getInitParameters()));
out.append('\n');
}
@ -1516,6 +1517,7 @@ public class ServletHandler extends ScopedHandler
out.append(indent);
out.append(" +-[]==>");
out.append(h.getName());
if (Log.isDebugEnabled())
out.append(String.valueOf(h.getInitParameters()));
out.append('\n');
}

View File

@ -1076,6 +1076,14 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
if (dir!=null && ( !dir.exists() || !dir.isDirectory() || !dir.canWrite()))
throw new IllegalArgumentException("Bad temp directory: "+dir);
try
{
dir=dir.getCanonicalFile();
}
catch(Exception e)
{
Log.warn(e);
}
_tmpDir=dir;
setAttribute(TEMPDIR,_tmpDir);
}