diff --git a/VERSION.txt b/VERSION.txt index fb86a38c907..e786f689bf8 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -11,6 +11,7 @@ jetty-7.1.4-SNAPSHOT + 315715 Improved Cookie version handling. Server.setMaxCookieVersion + 315744 Fixed STOP.PORT and STOP.KEY in start.jar + 315748 Removed --fromDaemon from start.jar + + 315925 Improved context xml configuration handling jetty-7.1.3.v20100526 + 296567 HttpClient RedirectListener handles new HttpDestination diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/App.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/App.java index 6b37f79bdfb..4dc1f5a3700 100644 --- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/App.java +++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/App.java @@ -96,7 +96,15 @@ public class App if (_context == null) { _context = getAppProvider().createContextHandler(this); - this._context.setAttributes(new AttributesMap(_manager.getContextAttributes())); + + AttributesMap attributes = _manager.getContextAttributes(); + if (attributes!=null && attributes.size()>0) + { + // Merge the manager attributes under the existing attributes + attributes = new AttributesMap(attributes); + attributes.addAll(_context.getAttributes()); + _context.setAttributes(attributes); + } } return _context; } diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/ContextDeployer.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/ContextDeployer.java index 74b905c8c48..0a7c6c29dea 100644 --- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/ContextDeployer.java +++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/ContextDeployer.java @@ -448,7 +448,14 @@ public class ContextDeployer extends AbstractLifeCycle xmlConfiguration.setProperties(properties); ContextHandler context=(ContextHandler)xmlConfiguration.configure(); - context.setAttributes(new AttributesMap(_contextAttributes)); + + // merge attributes + if (_contextAttributes!=null && _contextAttributes.size()>0) + { + AttributesMap attributes = new AttributesMap(_contextAttributes); + attributes.addAll(context.getAttributes()); + context.setAttributes(attributes); + } return context; } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java index d73af80be39..c76db7e8aec 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java @@ -102,11 +102,11 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server. protected Context _scontext; - private AttributesMap _attributes; - private AttributesMap _contextAttributes; + private final AttributesMap _attributes; + private final AttributesMap _contextAttributes; + private final Map _initParams; private ClassLoader _classLoader; private String _contextPath="/"; - private Map _initParams; private String _displayName; private Resource _baseResource; private MimeTypes _mimeTypes; @@ -144,6 +144,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server. super(); _scontext=new Context(); _attributes=new AttributesMap(); + _contextAttributes=new AttributesMap(); _initParams=new HashMap(); } @@ -156,6 +157,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server. super(); _scontext=context; _attributes=new AttributesMap(); + _contextAttributes=new AttributesMap(); _initParams=new HashMap(); } @@ -563,7 +565,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server. Thread current_thread=null; Context old_context=null; - _contextAttributes=new AttributesMap(); + _contextAttributes.clearAttributes(); try { @@ -700,9 +702,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server. current_thread.setContextClassLoader(old_classloader); } - if (_contextAttributes!=null) - _contextAttributes.clearAttributes(); - _contextAttributes=null; + _contextAttributes.clearAttributes(); } /* ------------------------------------------------------------ */ @@ -1029,27 +1029,13 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server. */ public void setAttributes(Attributes attributes) { - if (attributes instanceof AttributesMap) + _attributes.clearAttributes(); + _attributes.addAll(attributes); + Enumeration e = _attributes.getAttributeNames(); + while (e.hasMoreElements()) { - _attributes = (AttributesMap)attributes; - Enumeration e = _attributes.getAttributeNames(); - while (e.hasMoreElements()) - { - String name = (String)e.nextElement(); - checkManagedAttribute(name,attributes.getAttribute(name)); - } - } - else - { - _attributes=new AttributesMap(); - Enumeration e = attributes.getAttributeNames(); - while (e.hasMoreElements()) - { - String name = (String)e.nextElement(); - Object value=attributes.getAttribute(name); - checkManagedAttribute(name,value); - _attributes.setAttribute(name,value); - } + String name = (String)e.nextElement(); + checkManagedAttribute(name,attributes.getAttribute(name)); } } @@ -1108,17 +1094,6 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server. } } - /* ------------------------------------------------------------ */ - /** - * @param initParams The initParams to set. - */ - public void setInitParams(Map initParams) - { - if (initParams == null) - return; - _initParams = new HashMap(initParams); - } - /* ------------------------------------------------------------ */ /** * @param servletContextName The servletContextName to set. diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/AttributesMap.java b/jetty-util/src/main/java/org/eclipse/jetty/util/AttributesMap.java index d433996e7cf..ce23e549c84 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/AttributesMap.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/AttributesMap.java @@ -40,7 +40,8 @@ public class AttributesMap implements Attributes { _map=map; } - + + /* ------------------------------------------------------------ */ public AttributesMap(AttributesMap map) { _map=new HashMap(map._map); @@ -117,7 +118,13 @@ public class AttributesMap implements Attributes { _map.clear(); } - + + /* ------------------------------------------------------------ */ + public int size() + { + return _map.size(); + } + /* ------------------------------------------------------------ */ @Override public String toString() @@ -130,5 +137,16 @@ public class AttributesMap implements Attributes { return _map.keySet(); } + + /* ------------------------------------------------------------ */ + public void addAll(Attributes attributes) + { + Enumeration e = attributes.getAttributeNames(); + while (e.hasMoreElements()) + { + String name=e.nextElement(); + setAttribute(name,attributes.getAttribute(name)); + } + } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/ResourceCollection.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/ResourceCollection.java index 415f1728348..8d55ee2f3fe 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/ResourceCollection.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/ResourceCollection.java @@ -462,12 +462,9 @@ public class ResourceCollection extends Resource public String toString() { if(_resources==null) - return ""; + return "[]"; - StringBuilder buffer = new StringBuilder(); - for(Resource r : _resources) - buffer.append(r.toString()).append(';'); - return buffer.toString(); + return String.valueOf(Arrays.asList(_resources)); } /* ------------------------------------------------------------ */ diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java index e775e5f3247..2a4b111c561 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java @@ -31,6 +31,7 @@ import org.eclipse.jetty.util.LazyList; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.resource.Resource; +import org.eclipse.jetty.util.resource.ResourceCollection; /* ------------------------------------------------------------ */ @@ -123,6 +124,24 @@ public class WebAppClassLoader extends URLClassLoader { return _context; } + + /* ------------------------------------------------------------ */ + /** + * @param classPath Comma or semicolon separated path of filenames or URLs + * pointing to directories or jar files. Directories should end + * with '/'. + */ + public void addClassPath(Resource resource) + throws IOException + { + if (resource instanceof ResourceCollection) + { + for (Resource r : ((ResourceCollection)resource).getResources()) + addClassPath(r); + } + else + addURL(resource.getURL()); + } /* ------------------------------------------------------------ */ /** @@ -188,10 +207,11 @@ public class WebAppClassLoader extends URLClassLoader String[] files=lib.list(); for (int f=0;files!=null && f