Backport from 7 to 8 of changes to reconciliation of webapp config mechanism. See bugzilla 320073

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2152 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Jan Bartel 2010-07-19 06:15:57 +00:00
parent 18dea730ed
commit 32a89ffaf7
30 changed files with 508 additions and 611 deletions

View File

@ -1,6 +1,8 @@
jetty-7.2-SNAPSHOT jetty-7.2-SNAPSHOT
+ 319334 Concurrent, sharable ResourceCache + 319334 Concurrent, sharable ResourceCache
+ 319370 WebAppClassLoader.Context + 319370 WebAppClassLoader.Context
+ 320073 Reconsile configuration mechanism
+ 320112 Websocket in aggregate jars + 320112 Websocket in aggregate jars
+ JETTY-1245 Do not use direct buffers with NIO SSL + JETTY-1245 Do not use direct buffers with NIO SSL
+ JETTY-1249 Apply max idle time to all connectors + JETTY-1249 Apply max idle time to all connectors

View File

@ -34,7 +34,6 @@ public abstract class AbstractConfiguration implements Configuration
public static final String CONTAINER_JAR_RESOURCES = WebInfConfiguration.CONTAINER_JAR_RESOURCES; public static final String CONTAINER_JAR_RESOURCES = WebInfConfiguration.CONTAINER_JAR_RESOURCES;
public static final String WEB_INF_JAR_RESOURCES = WebInfConfiguration.WEB_INF_JAR_RESOURCES; public static final String WEB_INF_JAR_RESOURCES = WebInfConfiguration.WEB_INF_JAR_RESOURCES;
public static final String WEB_INF_ORDERED_JAR_RESOURCES = WebInfConfiguration.WEB_INF_ORDERED_JAR_RESOURCES; public static final String WEB_INF_ORDERED_JAR_RESOURCES = WebInfConfiguration.WEB_INF_ORDERED_JAR_RESOURCES;
public static final String METADATA_COMPLETE = MetaData.METADATA_COMPLETE;
public static final String WEBXML_CLASSNAMES = MetaData.WEBXML_CLASSNAMES; public static final String WEBXML_CLASSNAMES = MetaData.WEBXML_CLASSNAMES;
public static final String DISCOVERED_ANNOTATIONS = "org.eclipse.jetty.discoveredAnnotations"; public static final String DISCOVERED_ANNOTATIONS = "org.eclipse.jetty.discoveredAnnotations";
@ -74,11 +73,8 @@ public abstract class AbstractConfiguration implements Configuration
return false; return false;
} }
}); });
MetaData metaData = (MetaData)context.getAttribute(MetaData.METADATA);
if (metaData == null)
throw new IllegalStateException ("No metadata");
metaData.addDiscoveredAnnotations((List<DiscoveredAnnotation>)context.getAttribute(DISCOVERED_ANNOTATIONS)); context.getMetaData().addDiscoveredAnnotations((List<DiscoveredAnnotation>)context.getAttribute(DISCOVERED_ANNOTATIONS));
context.removeAttribute(DISCOVERED_ANNOTATIONS); context.removeAttribute(DISCOVERED_ANNOTATIONS);
} }
@ -86,11 +82,7 @@ public abstract class AbstractConfiguration implements Configuration
public void parseWebInfLib (final WebAppContext context, final AnnotationParser parser) public void parseWebInfLib (final WebAppContext context, final AnnotationParser parser)
throws Exception throws Exception
{ {
MetaData metaData = (MetaData)context.getAttribute(MetaData.METADATA); List<FragmentDescriptor> frags = context.getMetaData().getFragments();
if (metaData == null)
throw new IllegalStateException ("No metadata");
List<FragmentDescriptor> frags = metaData.getFragments();
//email from Rajiv Mordani jsrs 315 7 April 2010 //email from Rajiv Mordani jsrs 315 7 April 2010
//jars that do not have a web-fragment.xml are still considered fragments //jars that do not have a web-fragment.xml are still considered fragments
@ -135,7 +127,7 @@ public abstract class AbstractConfiguration implements Configuration
} }
}); });
metaData.addDiscoveredAnnotations(r, discoveredAnnotations); context.getMetaData().addDiscoveredAnnotations(r, discoveredAnnotations);
} }
} }
context.removeAttribute(DISCOVERED_ANNOTATIONS); context.removeAttribute(DISCOVERED_ANNOTATIONS);
@ -150,9 +142,6 @@ public abstract class AbstractConfiguration implements Configuration
Resource classesDir = context.getWebInf().addPath("classes/"); Resource classesDir = context.getWebInf().addPath("classes/");
if (classesDir.exists()) if (classesDir.exists())
{ {
MetaData metaData = (MetaData)context.getAttribute(MetaData.METADATA);
if (metaData == null)
throw new IllegalStateException ("No metadata");
List<DiscoveredAnnotation> discoveredAnnotations = new ArrayList<DiscoveredAnnotation>(); List<DiscoveredAnnotation> discoveredAnnotations = new ArrayList<DiscoveredAnnotation>();
context.setAttribute(DISCOVERED_ANNOTATIONS, discoveredAnnotations); context.setAttribute(DISCOVERED_ANNOTATIONS, discoveredAnnotations);
@ -177,7 +166,7 @@ public abstract class AbstractConfiguration implements Configuration
}); });
//TODO - where to set the annotations discovered from WEB-INF/classes? //TODO - where to set the annotations discovered from WEB-INF/classes?
metaData.addDiscoveredAnnotations (discoveredAnnotations); context.getMetaData().addDiscoveredAnnotations (discoveredAnnotations);
context.removeAttribute(DISCOVERED_ANNOTATIONS); context.removeAttribute(DISCOVERED_ANNOTATIONS);
} }
} }

View File

@ -59,7 +59,7 @@ public class PostConstructAnnotationHandler extends AbstractIntrospectableAnnota
//ServletSpec 3.0 p80 If web.xml declares even one post-construct then all post-constructs //ServletSpec 3.0 p80 If web.xml declares even one post-construct then all post-constructs
//in fragments must be ignored. Otherwise, they are additive. //in fragments must be ignored. Otherwise, they are additive.
MetaData metaData = ((MetaData)_context.getAttribute(MetaData.METADATA)); MetaData metaData = _context.getMetaData();
MetaData.Origin origin = metaData.getOrigin("post-construct"); MetaData.Origin origin = metaData.getOrigin("post-construct");
if (origin != null && if (origin != null &&
(origin == MetaData.Origin.WebXml || (origin == MetaData.Origin.WebXml ||

View File

@ -58,7 +58,7 @@ public class PreDestroyAnnotationHandler extends AbstractIntrospectableAnnotatio
//ServletSpec 3.0 p80 If web.xml declares even one predestroy then all predestroys //ServletSpec 3.0 p80 If web.xml declares even one predestroy then all predestroys
//in fragments must be ignored. Otherwise, they are additive. //in fragments must be ignored. Otherwise, they are additive.
MetaData metaData = ((MetaData)_context.getAttribute(MetaData.METADATA)); MetaData metaData = _context.getMetaData();
MetaData.Origin origin = metaData.getOrigin("pre-destroy"); MetaData.Origin origin = metaData.getOrigin("pre-destroy");
if (origin != null && if (origin != null &&
(origin == MetaData.Origin.WebXml || (origin == MetaData.Origin.WebXml ||

View File

@ -122,7 +122,7 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
//Servlet Spec 3.0 p. 76 //Servlet Spec 3.0 p. 76
//If a descriptor has specified at least 1 injection target for this //If a descriptor has specified at least 1 injection target for this
//resource, then it overrides this annotation //resource, then it overrides this annotation
MetaData metaData = ((MetaData)_context.getAttribute(MetaData.METADATA)); MetaData metaData = _context.getMetaData();
if (metaData.getOriginDescriptor("resource-ref."+name+".injection") != null) if (metaData.getOriginDescriptor("resource-ref."+name+".injection") != null)
{ {
//at least 1 injection was specified for this resource by a descriptor, so //at least 1 injection was specified for this resource by a descriptor, so
@ -265,7 +265,7 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
//Servlet Spec 3.0 p. 76 //Servlet Spec 3.0 p. 76
//If a descriptor has specified at least 1 injection target for this //If a descriptor has specified at least 1 injection target for this
//resource, then it overrides this annotation //resource, then it overrides this annotation
MetaData metaData = ((MetaData)_context.getAttribute(MetaData.METADATA)); MetaData metaData = _context.getMetaData();
if (metaData.getOriginDescriptor("resource-ref."+name+".injection") != null) if (metaData.getOriginDescriptor("resource-ref."+name+".injection") != null)
{ {
//at least 1 injection was specified for this resource by a descriptor, so //at least 1 injection was specified for this resource by a descriptor, so

View File

@ -54,7 +54,7 @@ public class RunAsAnnotationHandler extends AbstractIntrospectableAnnotationHand
ServletHolder holder = getServletHolderForClass(clazz); ServletHolder holder = getServletHolderForClass(clazz);
if (holder != null) if (holder != null)
{ {
MetaData metaData = ((MetaData)_context.getAttribute(MetaData.METADATA)); MetaData metaData = _context.getMetaData();
Descriptor d = metaData.getOriginDescriptor(holder.getName()+".servlet.run-as"); Descriptor d = metaData.getOriginDescriptor(holder.getName()+".servlet.run-as");
//if a descriptor has already set the value for run-as, do not //if a descriptor has already set the value for run-as, do not
//let the annotation override it //let the annotation override it

View File

@ -31,10 +31,6 @@ import org.eclipse.jetty.webapp.WebAppContext;
*/ */
public class TestAnnotationConfiguration extends TestCase public class TestAnnotationConfiguration extends TestCase
{ {
public void testGetFragmentFromJar () public void testGetFragmentFromJar ()
throws Exception throws Exception
{ {
@ -76,8 +72,8 @@ public class TestAnnotationConfiguration extends TestCase
WebAppContext wac = new WebAppContext(); WebAppContext wac = new WebAppContext();
List<FragmentDescriptor> frags = new ArrayList<FragmentDescriptor>(); List<FragmentDescriptor> frags = new ArrayList<FragmentDescriptor>();
frags.add(new FragmentDescriptor(Resource.newResource("jar:"+url+"file.jar!/fooa.props"), null)); frags.add(new FragmentDescriptor(Resource.newResource("jar:"+url+"file.jar!/fooa.props")));
frags.add(new FragmentDescriptor(Resource.newResource("jar:"+url+"file2.jar!/foob.props"), null)); frags.add(new FragmentDescriptor(Resource.newResource("jar:"+url+"file2.jar!/foob.props")));
assertNotNull(config.getFragmentFromJar(jar1, frags)); assertNotNull(config.getFragmentFromJar(jar1, frags));
} }

View File

@ -36,7 +36,6 @@ public class TestServletAnnotations
throws Exception throws Exception
{ {
WebAppContext wac = new WebAppContext(); WebAppContext wac = new WebAppContext();
wac.setAttribute(MetaData.METADATA, new MetaData(wac));
ConstraintSecurityHandler sh = new ConstraintSecurityHandler(); ConstraintSecurityHandler sh = new ConstraintSecurityHandler();
wac.setSecurityHandler(sh); wac.setSecurityHandler(sh);
sh.setRoles(new HashSet<String>(Arrays.asList(new String[]{"humpty", "dumpty"}))); sh.setRoles(new HashSet<String>(Arrays.asList(new String[]{"humpty", "dumpty"})));

View File

@ -34,7 +34,6 @@ public class TestResourceAnnotations
wac.setServer(server); wac.setServer(server);
InjectionCollection injections = new InjectionCollection(); InjectionCollection injections = new InjectionCollection();
wac.setAttribute(InjectionCollection.INJECTION_COLLECTION, injections); wac.setAttribute(InjectionCollection.INJECTION_COLLECTION, injections);
wac.setAttribute(MetaData.METADATA, new MetaData(wac));
InitialContext ic = new InitialContext(); InitialContext ic = new InitialContext();
Context comp = (Context)ic.lookup("java:comp"); Context comp = (Context)ic.lookup("java:comp");
Context env = comp.createSubcontext("env"); Context env = comp.createSubcontext("env");

View File

@ -16,6 +16,7 @@
package org.eclipse.jetty.deploy.providers; package org.eclipse.jetty.deploy.providers;
import org.eclipse.jetty.deploy.test.XmlConfiguredJetty; import org.eclipse.jetty.deploy.test.XmlConfiguredJetty;
import org.eclipse.jetty.util.log.Log;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -30,6 +31,7 @@ public class MonitoredDirAppProviderStartupTest
@BeforeClass @BeforeClass
public static void setupEnvironment() throws Exception public static void setupEnvironment() throws Exception
{ {
Log.getLog().setDebugEnabled(true);
jetty = new XmlConfiguredJetty(); jetty = new XmlConfiguredJetty();
jetty.addConfiguration("jetty.xml"); jetty.addConfiguration("jetty.xml");
jetty.addConfiguration("jetty-deploymgr-contexts.xml"); jetty.addConfiguration("jetty-deploymgr-contexts.xml");

View File

@ -26,7 +26,6 @@ import org.eclipse.jetty.plus.jndi.Transaction;
import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.webapp.FragmentDescriptor; import org.eclipse.jetty.webapp.FragmentDescriptor;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.webapp.MetaData;
/** /**
@ -59,29 +58,7 @@ public class Configuration implements org.eclipse.jetty.webapp.Configuration
{ {
bindUserTransaction(context); bindUserTransaction(context);
MetaData metaData = (MetaData)context.getAttribute(MetaData.METADATA); context.getMetaData().addDescriptorProcessor(new PlusDescriptorProcessor());
if (metaData == null)
throw new IllegalStateException ("No metadata");
metaData.addDescriptorProcessor(new PlusDescriptorProcessor());
/*
* THE PROCESSING IS NOW DONE IN metadata.resolve ()
PlusDescriptorProcessor plusProcessor = new PlusDescriptorProcessor(metaData);
plusProcessor.process(metaData.getWebDefault());
plusProcessor.process(metaData.getWebXml());
//Process plus-elements of each descriptor
for (FragmentDescriptor frag: metaData.getOrderedFragments())
{
plusProcessor.process(frag);
}
//process the override-web.xml descriptor
plusProcessor.process(metaData.getOverrideWeb());
*/
} }
public void postConfigure(WebAppContext context) throws Exception public void postConfigure(WebAppContext context) throws Exception

View File

@ -48,9 +48,6 @@ import org.eclipse.jetty.xml.XmlParser;
public class PlusDescriptorProcessor extends IterativeDescriptorProcessor public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
{ {
protected WebAppContext _context;
protected MetaData _metaData;
public PlusDescriptorProcessor () public PlusDescriptorProcessor ()
{ {
try try
@ -69,22 +66,18 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
} }
/** /**
* @see org.eclipse.jetty.webapp.IterativeDescriptorProcessor#start(org.eclipse.jetty.webapp.Descriptor) * @see org.eclipse.jetty.webapp.IterativeDescriptorProcessor#start(WebAppContext, org.eclipse.jetty.webapp.Descriptor)
*/ */
public void start(Descriptor descriptor) public void start(WebAppContext context, Descriptor descriptor)
{ {
_metaData = descriptor.getMetaData();
_context = _metaData.getContext();
} }
/** /**
* @see org.eclipse.jetty.webapp.IterativeDescriptorProcessor#end(org.eclipse.jetty.webapp.Descriptor) * @see org.eclipse.jetty.webapp.IterativeDescriptorProcessor#end(org.eclipse.jetty.webapp.Descriptor, WebAppContext)
*/ */
public void end(Descriptor descriptor) public void end(WebAppContext context,Descriptor descriptor)
{ {
_metaData = null;
_context = null;
} }
@ -96,7 +89,7 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
* @param node * @param node
* @throws Exception * @throws Exception
*/ */
public void visitEnvEntry (Descriptor descriptor, XmlParser.Node node) public void visitEnvEntry (WebAppContext context, Descriptor descriptor, XmlParser.Node node)
throws Exception throws Exception
{ {
String name=node.getString("env-entry-name",false,true); String name=node.getString("env-entry-name",false,true);
@ -111,19 +104,19 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
return; return;
} }
Origin o = _metaData.getOrigin("env-entry."+name); Origin o = context.getMetaData().getOrigin("env-entry."+name);
switch (o) switch (o)
{ {
case NotSet: case NotSet:
{ {
//no descriptor has configured an env-entry of this name previously //no descriptor has configured an env-entry of this name previously
_metaData.setOrigin("env-entry."+name, descriptor); context.getMetaData().setOrigin("env-entry."+name, descriptor);
//the javaee_5.xsd says that the env-entry-type is optional //the javaee_5.xsd says that the env-entry-type is optional
//if there is an <injection> element, because you can get //if there is an <injection> element, because you can get
//type from the element, but what to do if there is more //type from the element, but what to do if there is more
//than one <injection> element, do you just pick the type //than one <injection> element, do you just pick the type
//of the first one? //of the first one?
addInjections (descriptor, node, name, TypeUtil.fromName(type)); addInjections (context, descriptor, node, name, TypeUtil.fromName(type));
Object value = TypeUtil.valueOf(type,valueStr); Object value = TypeUtil.valueOf(type,valueStr);
bindEnvEntry(name, value); bindEnvEntry(name, value);
break; break;
@ -139,8 +132,8 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
{ {
//We're processing web-defaults, web.xml or web-override. Any of them can //We're processing web-defaults, web.xml or web-override. Any of them can
//set or change the env-entry. //set or change the env-entry.
_metaData.setOrigin("env-entry."+name, descriptor); context.getMetaData().setOrigin("env-entry."+name, descriptor);
addInjections (descriptor, node, name, TypeUtil.fromName(type)); addInjections (context, descriptor, node, name, TypeUtil.fromName(type));
Object value = TypeUtil.valueOf(type,valueStr); Object value = TypeUtil.valueOf(type,valueStr);
bindEnvEntry(name, value); bindEnvEntry(name, value);
} }
@ -149,9 +142,9 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
//A web.xml declared the env-entry. Check to see if any injections have been //A web.xml declared the env-entry. Check to see if any injections have been
//declared for it. If it was declared in web.xml then don't merge any injections. //declared for it. If it was declared in web.xml then don't merge any injections.
//If it was declared in a web-fragment, then we can keep merging fragments. //If it was declared in a web-fragment, then we can keep merging fragments.
Descriptor d = _metaData.getOriginDescriptor("env-entry."+name+".injection"); Descriptor d = context.getMetaData().getOriginDescriptor("env-entry."+name+".injection");
if (d==null || d instanceof FragmentDescriptor) if (d==null || d instanceof FragmentDescriptor)
addInjections(descriptor, node, name, TypeUtil.fromName(type)); addInjections(context, descriptor, node, name, TypeUtil.fromName(type));
} }
break; break;
} }
@ -193,7 +186,7 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
* @param node * @param node
* @throws Exception * @throws Exception
*/ */
public void visitResourceRef (Descriptor descriptor, XmlParser.Node node) public void visitResourceRef (WebAppContext context, Descriptor descriptor, XmlParser.Node node)
throws Exception throws Exception
{ {
String jndiName = node.getString("res-ref-name",false,true); String jndiName = node.getString("res-ref-name",false,true);
@ -201,20 +194,20 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
String auth = node.getString("res-auth", false, true); String auth = node.getString("res-auth", false, true);
String shared = node.getString("res-sharing-scope", false, true); String shared = node.getString("res-sharing-scope", false, true);
Origin o = _metaData.getOrigin("resource-ref."+jndiName); Origin o = context.getMetaData().getOrigin("resource-ref."+jndiName);
switch (o) switch (o)
{ {
case NotSet: case NotSet:
{ {
//No descriptor or annotation previously declared a resource-ref of this name. //No descriptor or annotation previously declared a resource-ref of this name.
_metaData.setOrigin("resource-ref."+jndiName, descriptor); context.getMetaData().setOrigin("resource-ref."+jndiName, descriptor);
//check for <injection> elements //check for <injection> elements
Class typeClass = TypeUtil.fromName(type); Class<?> typeClass = TypeUtil.fromName(type);
if (typeClass==null) if (typeClass==null)
typeClass = _context.loadClass(type); typeClass = context.loadClass(type);
addInjections(descriptor, node, jndiName, typeClass); addInjections(context, descriptor, node, jndiName, typeClass);
bindResourceRef(jndiName, typeClass); bindResourceRef(context,jndiName, typeClass);
break; break;
} }
case WebXml: case WebXml:
@ -226,17 +219,17 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
{ {
//We're processing web-defaults, web.xml or web-override. Any of them can //We're processing web-defaults, web.xml or web-override. Any of them can
//set or change the resource-ref. //set or change the resource-ref.
_metaData.setOrigin("resource-ref."+jndiName, descriptor); context.getMetaData().setOrigin("resource-ref."+jndiName, descriptor);
//check for <injection> elements //check for <injection> elements
Class typeClass = TypeUtil.fromName(type); Class<?> typeClass = TypeUtil.fromName(type);
if (typeClass==null) if (typeClass==null)
typeClass = _context.loadClass(type); typeClass = context.loadClass(type);
addInjections(descriptor, node, jndiName, typeClass); addInjections(context, descriptor, node, jndiName, typeClass);
//bind the entry into jndi //bind the entry into jndi
bindResourceRef(jndiName, typeClass); bindResourceRef(context,jndiName, typeClass);
} }
else else
{ {
@ -244,13 +237,13 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
//web-fragment. Check to see if any injections were declared for it by web.xml. //web-fragment. Check to see if any injections were declared for it by web.xml.
//If any injection was declared in web.xml then don't merge any injections. //If any injection was declared in web.xml then don't merge any injections.
//If it was declared in a web-fragment, then we can keep merging fragments. //If it was declared in a web-fragment, then we can keep merging fragments.
Descriptor d = _metaData.getOriginDescriptor("resource-ref."+jndiName+".injection"); Descriptor d = context.getMetaData().getOriginDescriptor("resource-ref."+jndiName+".injection");
if (d==null || d instanceof FragmentDescriptor) if (d==null || d instanceof FragmentDescriptor)
{ {
Class typeClass = TypeUtil.fromName(type); Class<?> typeClass = TypeUtil.fromName(type);
if (typeClass==null) if (typeClass==null)
typeClass = _context.loadClass(type); typeClass = context.loadClass(type);
addInjections(descriptor, node, jndiName, TypeUtil.fromName(type)); addInjections(context, descriptor, node, jndiName, TypeUtil.fromName(type));
} }
} }
break; break;
@ -275,13 +268,13 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
* @param node * @param node
* @throws Exception * @throws Exception
*/ */
public void visitResourceEnvRef (Descriptor descriptor, XmlParser.Node node) public void visitResourceEnvRef (WebAppContext context, Descriptor descriptor, XmlParser.Node node)
throws Exception throws Exception
{ {
String jndiName = node.getString("resource-env-ref-name",false,true); String jndiName = node.getString("resource-env-ref-name",false,true);
String type = node.getString("resource-env-ref-type", false, true); String type = node.getString("resource-env-ref-type", false, true);
Origin o = _metaData.getOrigin("resource-env-ref."+jndiName); Origin o = context.getMetaData().getOrigin("resource-env-ref."+jndiName);
switch (o) switch (o)
{ {
case NotSet: case NotSet:
@ -289,11 +282,11 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
//First declaration of resource-env-ref with this jndiName //First declaration of resource-env-ref with this jndiName
//JavaEE Spec sec 5.7.1.3 says the resource-env-ref-type //JavaEE Spec sec 5.7.1.3 says the resource-env-ref-type
//is mandatory, but the schema says it is optional! //is mandatory, but the schema says it is optional!
Class typeClass = TypeUtil.fromName(type); Class<?> typeClass = TypeUtil.fromName(type);
if (typeClass==null) if (typeClass==null)
typeClass = _context.loadClass(type); typeClass = context.loadClass(type);
addInjections (descriptor, node, jndiName, typeClass); addInjections (context, descriptor, node, jndiName, typeClass);
bindResourceEnvRef(jndiName, typeClass); bindResourceEnvRef(context,jndiName, typeClass);
break; break;
} }
case WebXml: case WebXml:
@ -306,24 +299,24 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
{ {
//We're processing web-defaults, web.xml or web-override. Any of them can //We're processing web-defaults, web.xml or web-override. Any of them can
//set or change the resource-env-ref. //set or change the resource-env-ref.
_metaData.setOrigin("resource-env-ref."+jndiName, descriptor); context.getMetaData().setOrigin("resource-env-ref."+jndiName, descriptor);
Class typeClass = TypeUtil.fromName(type); Class<?> typeClass = TypeUtil.fromName(type);
if (typeClass==null) if (typeClass==null)
typeClass = _context.loadClass(type); typeClass = context.loadClass(type);
addInjections (descriptor, node, jndiName, typeClass); addInjections (context, descriptor, node, jndiName, typeClass);
bindResourceEnvRef(jndiName, typeClass); bindResourceEnvRef(context,jndiName, typeClass);
} }
else else
{ {
//We're processing a web-fragment. It can only contribute injections if the //We're processing a web-fragment. It can only contribute injections if the
//there haven't been any injections declared yet, or they weren't declared in a WebXml file. //there haven't been any injections declared yet, or they weren't declared in a WebXml file.
Descriptor d = _metaData.getOriginDescriptor("resource-env-ref."+jndiName+".injection"); Descriptor d = context.getMetaData().getOriginDescriptor("resource-env-ref."+jndiName+".injection");
if (d == null || d instanceof FragmentDescriptor) if (d == null || d instanceof FragmentDescriptor)
{ {
Class typeClass = TypeUtil.fromName(type); Class<?> typeClass = TypeUtil.fromName(type);
if (typeClass==null) if (typeClass==null)
typeClass = _context.loadClass(type); typeClass = context.loadClass(type);
addInjections (descriptor, node, jndiName, typeClass); addInjections (context, descriptor, node, jndiName, typeClass);
} }
} }
break; break;
@ -345,25 +338,25 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
* @param node * @param node
* @throws Exception * @throws Exception
*/ */
public void visitMessageDestinationRef (Descriptor descriptor, XmlParser.Node node) public void visitMessageDestinationRef (WebAppContext context, Descriptor descriptor, XmlParser.Node node)
throws Exception throws Exception
{ {
String jndiName = node.getString("message-destination-ref-name",false,true); String jndiName = node.getString("message-destination-ref-name",false,true);
String type = node.getString("message-destination-type",false,true); String type = node.getString("message-destination-type",false,true);
String usage = node.getString("message-destination-usage",false,true); String usage = node.getString("message-destination-usage",false,true);
Origin o = _metaData.getOrigin("message-destination-ref."+jndiName); Origin o = context.getMetaData().getOrigin("message-destination-ref."+jndiName);
switch (o) switch (o)
{ {
case NotSet: case NotSet:
{ {
//A message-destination-ref of this name has not been previously declared //A message-destination-ref of this name has not been previously declared
Class typeClass = TypeUtil.fromName(type); Class<?> typeClass = TypeUtil.fromName(type);
if (typeClass==null) if (typeClass==null)
typeClass = _context.loadClass(type); typeClass = context.loadClass(type);
addInjections(descriptor, node, jndiName, typeClass); addInjections(context, descriptor, node, jndiName, typeClass);
bindMessageDestinationRef(jndiName, typeClass); bindMessageDestinationRef(context,jndiName, typeClass);
_metaData.setOrigin("message-destination-ref."+jndiName, descriptor); context.getMetaData().setOrigin("message-destination-ref."+jndiName, descriptor);
break; break;
} }
case WebXml: case WebXml:
@ -374,24 +367,24 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
//Only allow other web-default, web.xml, web-override to change it. //Only allow other web-default, web.xml, web-override to change it.
if (!(descriptor instanceof FragmentDescriptor)) if (!(descriptor instanceof FragmentDescriptor))
{ {
Class typeClass = TypeUtil.fromName(type); Class<?> typeClass = TypeUtil.fromName(type);
if (typeClass==null) if (typeClass==null)
typeClass = _context.loadClass(type); typeClass = context.loadClass(type);
addInjections(descriptor, node, jndiName, typeClass); addInjections(context, descriptor, node, jndiName, typeClass);
bindMessageDestinationRef(jndiName, typeClass); bindMessageDestinationRef(context,jndiName, typeClass);
_metaData.setOrigin("message-destination-ref."+jndiName, descriptor); context.getMetaData().setOrigin("message-destination-ref."+jndiName, descriptor);
} }
else else
{ {
//A web-fragment has declared a message-destination-ref with the same name as a web xml. //A web-fragment has declared a message-destination-ref with the same name as a web xml.
//It can only contribute injections, and only if the web xml didn't declare any. //It can only contribute injections, and only if the web xml didn't declare any.
Descriptor d = _metaData.getOriginDescriptor("message-destination-ref."+jndiName+".injection"); Descriptor d = context.getMetaData().getOriginDescriptor("message-destination-ref."+jndiName+".injection");
if (d == null || d instanceof FragmentDescriptor) if (d == null || d instanceof FragmentDescriptor)
{ {
Class typeClass = TypeUtil.fromName(type); Class<?> typeClass = TypeUtil.fromName(type);
if (typeClass==null) if (typeClass==null)
typeClass = _context.loadClass(type); typeClass = context.loadClass(type);
addInjections(descriptor, node, jndiName, typeClass); addInjections(context, descriptor, node, jndiName, typeClass);
} }
} }
break; break;
@ -416,7 +409,7 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
* resources have been setup but before the class is put into use * resources have been setup but before the class is put into use
* @param node * @param node
*/ */
public void visitPostConstruct(Descriptor descriptor, XmlParser.Node node) public void visitPostConstruct(WebAppContext context, Descriptor descriptor, XmlParser.Node node)
{ {
String className = node.getString("lifecycle-callback-class", false, true); String className = node.getString("lifecycle-callback-class", false, true);
String methodName = node.getString("lifecycle-callback-method", false, true); String methodName = node.getString("lifecycle-callback-method", false, true);
@ -431,20 +424,20 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
Log.warn("No lifecycle-callback-method specified for class "+className); Log.warn("No lifecycle-callback-method specified for class "+className);
return; return;
} }
LifeCycleCallbackCollection callbacks = (LifeCycleCallbackCollection)_context.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION); LifeCycleCallbackCollection callbacks = (LifeCycleCallbackCollection)context.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION);
//ServletSpec 3.0 p80 If web.xml declares a post-construct then all post-constructs //ServletSpec 3.0 p80 If web.xml declares a post-construct then all post-constructs
//in fragments must be ignored. Otherwise, they are additive. //in fragments must be ignored. Otherwise, they are additive.
Origin o = _metaData.getOrigin("post-construct"); Origin o = context.getMetaData().getOrigin("post-construct");
switch (o) switch (o)
{ {
case NotSet: case NotSet:
{ {
//No post-constructs have been declared previously. //No post-constructs have been declared previously.
_metaData.setOrigin("post-construct", descriptor); context.getMetaData().setOrigin("post-construct", descriptor);
try try
{ {
Class clazz = _context.loadClass(className); Class<?> clazz = context.loadClass(className);
LifeCycleCallback callback = new PostConstructCallback(); LifeCycleCallback callback = new PostConstructCallback();
callback.setTarget(clazz, methodName); callback.setTarget(clazz, methodName);
callbacks.add(callback); callbacks.add(callback);
@ -465,7 +458,7 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
{ {
try try
{ {
Class clazz = _context.loadClass(className); Class<?> clazz = context.loadClass(className);
LifeCycleCallback callback = new PostConstructCallback(); LifeCycleCallback callback = new PostConstructCallback();
callback.setTarget(clazz, methodName); callback.setTarget(clazz, methodName);
callbacks.add(callback); callbacks.add(callback);
@ -482,7 +475,7 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
//A web-fragment first declared a post-construct. Allow all other web-fragments to merge in their post-constructs //A web-fragment first declared a post-construct. Allow all other web-fragments to merge in their post-constructs
try try
{ {
Class clazz = _context.loadClass(className); Class<?> clazz = context.loadClass(className);
LifeCycleCallback callback = new PostConstructCallback(); LifeCycleCallback callback = new PostConstructCallback();
callback.setTarget(clazz, methodName); callback.setTarget(clazz, methodName);
callbacks.add(callback); callbacks.add(callback);
@ -504,7 +497,7 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
* the instance is being destroyed * the instance is being destroyed
* @param node * @param node
*/ */
public void visitPreDestroy(Descriptor descriptor, XmlParser.Node node) public void visitPreDestroy(WebAppContext context, Descriptor descriptor, XmlParser.Node node)
{ {
String className = node.getString("lifecycle-callback-class", false, true); String className = node.getString("lifecycle-callback-class", false, true);
String methodName = node.getString("lifecycle-callback-method", false, true); String methodName = node.getString("lifecycle-callback-method", false, true);
@ -518,19 +511,19 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
Log.warn("No lifecycle-callback-method specified for pre-destroy class "+className); Log.warn("No lifecycle-callback-method specified for pre-destroy class "+className);
return; return;
} }
LifeCycleCallbackCollection callbacks = (LifeCycleCallbackCollection)_context.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION); LifeCycleCallbackCollection callbacks = (LifeCycleCallbackCollection)context.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION);
Origin o = _metaData.getOrigin("pre-destroy"); Origin o = context.getMetaData().getOrigin("pre-destroy");
switch(o) switch(o)
{ {
case NotSet: case NotSet:
{ {
//No pre-destroys have been declared previously. Record this descriptor //No pre-destroys have been declared previously. Record this descriptor
//as the first declarer. //as the first declarer.
_metaData.setOrigin("pre-destroy", descriptor); context.getMetaData().setOrigin("pre-destroy", descriptor);
try try
{ {
Class clazz = _context.loadClass(className); Class<?> clazz = context.loadClass(className);
LifeCycleCallback callback = new PreDestroyCallback(); LifeCycleCallback callback = new PreDestroyCallback();
callback.setTarget(clazz, methodName); callback.setTarget(clazz, methodName);
callbacks.add(callback); callbacks.add(callback);
@ -551,7 +544,7 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
{ {
try try
{ {
Class clazz = _context.loadClass(className); Class<?> clazz = context.loadClass(className);
LifeCycleCallback callback = new PreDestroyCallback(); LifeCycleCallback callback = new PreDestroyCallback();
callback.setTarget(clazz, methodName); callback.setTarget(clazz, methodName);
callbacks.add(callback); callbacks.add(callback);
@ -568,7 +561,7 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
//No pre-destroys in web xml, so allow all fragments to merge their pre-destroys. //No pre-destroys in web xml, so allow all fragments to merge their pre-destroys.
try try
{ {
Class clazz = _context.loadClass(className); Class<?> clazz = context.loadClass(className);
LifeCycleCallback callback = new PreDestroyCallback(); LifeCycleCallback callback = new PreDestroyCallback();
callback.setTarget(clazz, methodName); callback.setTarget(clazz, methodName);
callbacks.add(callback); callbacks.add(callback);
@ -592,7 +585,7 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
* @param valueClass * @param valueClass
* @return * @return
*/ */
public void addInjections (Descriptor descriptor, XmlParser.Node node, String jndiName, Class valueClass) public void addInjections (WebAppContext context, Descriptor descriptor, XmlParser.Node node, String jndiName, Class<?> valueClass)
{ {
Iterator itor = node.iterator("injection-target"); Iterator itor = node.iterator("injection-target");
@ -612,20 +605,20 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
continue; continue;
} }
InjectionCollection injections = (InjectionCollection)_context.getAttribute(InjectionCollection.INJECTION_COLLECTION); InjectionCollection injections = (InjectionCollection)context.getAttribute(InjectionCollection.INJECTION_COLLECTION);
// comments in the javaee_5.xsd file specify that the targetName is looked // comments in the javaee_5.xsd file specify that the targetName is looked
// for first as a java bean property, then if that fails, as a field // for first as a java bean property, then if that fails, as a field
try try
{ {
Class clazz = _context.loadClass(targetClassName); Class<?> clazz = context.loadClass(targetClassName);
Injection injection = new Injection(); Injection injection = new Injection();
injection.setJndiName(jndiName); injection.setJndiName(jndiName);
injection.setTarget(clazz, targetName, valueClass); injection.setTarget(clazz, targetName, valueClass);
injections.add(injection); injections.add(injection);
//Record which was the first descriptor to declare an injection for this name //Record which was the first descriptor to declare an injection for this name
if (_metaData.getOriginDescriptor(node.getTag()+"."+jndiName+".injection") == null) if (context.getMetaData().getOriginDescriptor(node.getTag()+"."+jndiName+".injection") == null)
_metaData.setOrigin(node.getTag()+"."+jndiName+".injection", descriptor); context.getMetaData().setOrigin(node.getTag()+"."+jndiName+".injection", descriptor);
} }
catch (ClassNotFoundException e) catch (ClassNotFoundException e)
{ {
@ -683,10 +676,10 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
* @param name * @param name
* @throws Exception * @throws Exception
*/ */
public void bindResourceRef(String name, Class typeClass) public void bindResourceRef(WebAppContext context, String name, Class<?> typeClass)
throws Exception throws Exception
{ {
bindEntry(name, typeClass); bindEntry(context, name, typeClass);
} }
/** /**
@ -694,17 +687,17 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
* @param name * @param name
* @throws Exception * @throws Exception
*/ */
public void bindResourceEnvRef(String name, Class typeClass) public void bindResourceEnvRef(WebAppContext context, String name, Class<?> typeClass)
throws Exception throws Exception
{ {
bindEntry(name, typeClass); bindEntry(context, name, typeClass);
} }
public void bindMessageDestinationRef(String name, Class typeClass) public void bindMessageDestinationRef(WebAppContext context, String name, Class<?> typeClass)
throws Exception throws Exception
{ {
bindEntry(name, typeClass); bindEntry(context, name, typeClass);
} }
@ -723,7 +716,7 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
* @param typeClass * @param typeClass
* @throws Exception * @throws Exception
*/ */
protected void bindEntry (String name, Class typeClass) protected void bindEntry (WebAppContext context, String name, Class<?> typeClass)
throws Exception throws Exception
{ {
String nameInEnvironment = name; String nameInEnvironment = name;
@ -731,7 +724,7 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
//check if the name in web.xml has been mapped to something else //check if the name in web.xml has been mapped to something else
//check a context-specific naming environment first //check a context-specific naming environment first
Object scope = _context; Object scope = context;
NamingEntry ne = NamingEntryUtil.lookupNamingEntry(scope, name); NamingEntry ne = NamingEntryUtil.lookupNamingEntry(scope, name);
if (ne!=null && (ne instanceof Link)) if (ne!=null && (ne instanceof Link))
@ -742,14 +735,14 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
} }
//try finding that mapped name in the webapp's environment first //try finding that mapped name in the webapp's environment first
scope = _context; scope = context;
bound = NamingEntryUtil.bindToENC(scope, name, nameInEnvironment); bound = NamingEntryUtil.bindToENC(scope, name, nameInEnvironment);
if (bound) if (bound)
return; return;
//try the server's environment //try the server's environment
scope = _context.getServer(); scope = context.getServer();
bound = NamingEntryUtil.bindToENC(scope, name, nameInEnvironment); bound = NamingEntryUtil.bindToENC(scope, name, nameInEnvironment);
if (bound) if (bound)
return; return;
@ -764,7 +757,7 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
//eg javax.sql.DataSource/default //eg javax.sql.DataSource/default
nameInEnvironment = typeClass.getName()+"/default"; nameInEnvironment = typeClass.getName()+"/default";
//First try the server scope //First try the server scope
NamingEntry defaultNE = NamingEntryUtil.lookupNamingEntry(_context.getServer(), nameInEnvironment); NamingEntry defaultNE = NamingEntryUtil.lookupNamingEntry(context.getServer(), nameInEnvironment);
if (defaultNE==null) if (defaultNE==null)
defaultNE = NamingEntryUtil.lookupNamingEntry(null, nameInEnvironment); defaultNE = NamingEntryUtil.lookupNamingEntry(null, nameInEnvironment);

View File

@ -83,6 +83,7 @@ public class TestConfiguration
Thread.currentThread().setContextClassLoader(wac.getClassLoader()); Thread.currentThread().setContextClassLoader(wac.getClassLoader());
MetaData metadata = new MetaData(wac);
envConfig.preConfigure(wac); envConfig.preConfigure(wac);
envConfig.configure(wac); envConfig.configure(wac);
envConfig.bindEnvEntries(wac); envConfig.bindEnvEntries(wac);

View File

@ -43,8 +43,8 @@ public class ErrorPageErrorHandler extends ErrorHandler
public final static String ERROR_PAGE="org.eclipse.jetty.server.error_page"; public final static String ERROR_PAGE="org.eclipse.jetty.server.error_page";
protected ServletContext _servletContext; protected ServletContext _servletContext;
protected Map _errorPages; // code or exception to URL private final Map<String,String> _errorPages= new HashMap<String,String>(); // code or exception to URL
protected List _errorPageList; // list of ErrorCode by range private final List<ErrorCodeRange> _errorPageList=new ArrayList<ErrorCodeRange>(); // list of ErrorCode by range
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
public ErrorPageErrorHandler() public ErrorPageErrorHandler()
@ -54,6 +54,7 @@ public class ErrorPageErrorHandler extends ErrorHandler
/** /**
* @see org.eclipse.jetty.server.handler.ErrorHandler#handle(String, Request, HttpServletRequest, HttpServletResponse) * @see org.eclipse.jetty.server.handler.ErrorHandler#handle(String, Request, HttpServletRequest, HttpServletResponse)
*/ */
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException
{ {
String method = request.getMethod(); String method = request.getMethod();
@ -65,7 +66,7 @@ public class ErrorPageErrorHandler extends ErrorHandler
if (_errorPages!=null) if (_errorPages!=null)
{ {
String error_page= null; String error_page= null;
Class exClass= (Class)request.getAttribute(Dispatcher.ERROR_EXCEPTION_TYPE); Class<?> exClass= (Class<?>)request.getAttribute(Dispatcher.ERROR_EXCEPTION_TYPE);
if (ServletException.class.equals(exClass)) if (ServletException.class.equals(exClass))
{ {
@ -147,7 +148,7 @@ public class ErrorPageErrorHandler extends ErrorHandler
/** /**
* @return Returns the errorPages. * @return Returns the errorPages.
*/ */
public Map getErrorPages() public Map<String,String> getErrorPages()
{ {
return _errorPages; return _errorPages;
} }
@ -156,9 +157,11 @@ public class ErrorPageErrorHandler extends ErrorHandler
/** /**
* @param errorPages The errorPages to set. A map of Exception class name or error code as a string to URI string * @param errorPages The errorPages to set. A map of Exception class name or error code as a string to URI string
*/ */
public void setErrorPages(Map errorPages) public void setErrorPages(Map<String,String> errorPages)
{ {
_errorPages = errorPages; _errorPages.clear();
if (errorPages!=null)
_errorPages.putAll(errorPages);
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@ -168,12 +171,22 @@ public class ErrorPageErrorHandler extends ErrorHandler
* @param exception The exception * @param exception The exception
* @param uri The URI of the error page. * @param uri The URI of the error page.
*/ */
public void addErrorPage(Class exception,String uri) public void addErrorPage(Class<? extends Throwable> exception,String uri)
{ {
if (_errorPages==null)
_errorPages=new HashMap();
_errorPages.put(exception.getName(),uri); _errorPages.put(exception.getName(),uri);
} }
/* ------------------------------------------------------------ */
/** Add Error Page mapping for an exception class
* This method is called as a result of an exception-type element in a web.xml file
* or may be called directly
* @param exception The exception
* @param uri The URI of the error page.
*/
public void addErrorPage(String exceptionClassName,String uri)
{
_errorPages.put(exceptionClassName,uri);
}
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/** Add Error Page mapping for a status code. /** Add Error Page mapping for a status code.
@ -184,8 +197,6 @@ public class ErrorPageErrorHandler extends ErrorHandler
*/ */
public void addErrorPage(int code,String uri) public void addErrorPage(int code,String uri)
{ {
if (_errorPages==null)
_errorPages=new HashMap();
_errorPages.put(Integer.toString(code),uri); _errorPages.put(Integer.toString(code),uri);
} }
@ -199,14 +210,11 @@ public class ErrorPageErrorHandler extends ErrorHandler
*/ */
public void addErrorPage(int from, int to, String uri) public void addErrorPage(int from, int to, String uri)
{ {
if (_errorPageList == null)
{
_errorPageList = new ArrayList();
}
_errorPageList.add(new ErrorCodeRange(from, to, uri)); _errorPageList.add(new ErrorCodeRange(from, to, uri));
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@Override
protected void doStart() throws Exception protected void doStart() throws Exception
{ {
super.doStart(); super.doStart();
@ -214,6 +222,7 @@ public class ErrorPageErrorHandler extends ErrorHandler
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@Override
protected void doStop() throws Exception protected void doStop() throws Exception
{ {
// TODO Auto-generated method stub // TODO Auto-generated method stub
@ -254,6 +263,7 @@ public class ErrorPageErrorHandler extends ErrorHandler
return _uri; return _uri;
} }
@Override
public String toString() public String toString()
{ {
return "from: " + _from + ",to: " + _to + ",uri: " + _uri; return "from: " + _from + ",to: " + _to + ",uri: " + _uri;

View File

@ -14,14 +14,12 @@
package org.eclipse.jetty.servlet; package org.eclipse.jetty.servlet;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.EventListener; import java.util.EventListener;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import javax.servlet.Filter; import javax.servlet.Filter;
import javax.servlet.RequestDispatcher; import javax.servlet.RequestDispatcher;
@ -74,8 +72,6 @@ public class ServletContextHandler extends ContextHandler
protected Decorator _decorator; protected Decorator _decorator;
protected Object _restrictedContextListeners; protected Object _restrictedContextListeners;
protected final Set<Object> _created = Collections.newSetFromMap(new ConcurrentHashMap<Object,Boolean>());
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
public ServletContextHandler() public ServletContextHandler()
{ {
@ -142,7 +138,6 @@ public class ServletContextHandler extends ContextHandler
@Override @Override
protected void doStart() throws Exception protected void doStart() throws Exception
{ {
_created.clear();
super.doStart(); super.doStart();
} }
@ -154,20 +149,6 @@ public class ServletContextHandler extends ContextHandler
protected void doStop() throws Exception protected void doStop() throws Exception
{ {
super.doStop(); super.doStop();
_created.clear();
}
/* ------------------------------------------------------------ */
/**
* Check if instance was created by a call to {@link ServletContext#createFilter(Class)},
* {@link ServletContext#createServlet(Class)} or {@link ServletContext#createListener(Class)}
* @param instance Instance of {@link Servlet}, {@link Filter} or {@link EventListener}
* @return True if the instance was created by a call to {@link ServletContext#createFilter(Class)},
* {@link ServletContext#createServlet(Class)} or {@link ServletContext#createListener(Class)}
*/
public boolean isCreatedInstance(Object instance)
{
return _created.contains(instance);
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@ -595,7 +576,6 @@ public class ServletContextHandler extends ContextHandler
T f = c.newInstance(); T f = c.newInstance();
if (_decorator!=null) if (_decorator!=null)
f=_decorator.decorateFilterInstance(f); f=_decorator.decorateFilterInstance(f);
_created.add(f);
return f; return f;
} }
catch (InstantiationException e) catch (InstantiationException e)
@ -616,7 +596,6 @@ public class ServletContextHandler extends ContextHandler
T s = c.newInstance(); T s = c.newInstance();
if (_decorator!=null) if (_decorator!=null)
s=_decorator.decorateServletInstance(s); s=_decorator.decorateServletInstance(s);
_created.add(s);
return s; return s;
} }
catch (InstantiationException e) catch (InstantiationException e)
@ -734,7 +713,6 @@ public class ServletContextHandler extends ContextHandler
if (_decorator!=null) if (_decorator!=null)
l=_decorator.decorateListenerInstance(l); l=_decorator.decorateListenerInstance(l);
_created.add(l);
return l; return l;
} }
catch(ServletException e) catch(ServletException e)

View File

@ -31,7 +31,6 @@ public interface Configuration
/* ------------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- */
/** Configure WebApp. /** Configure WebApp.
*
* @throws Exception * @throws Exception
*/ */
public void configure (WebAppContext context) throws Exception; public void configure (WebAppContext context) throws Exception;

View File

@ -18,12 +18,11 @@ import org.eclipse.jetty.util.resource.Resource;
/** /**
* DefaultsDescriptor * DefaultsDescriptor
* *
*
*/ */
public class DefaultsDescriptor extends Descriptor public class DefaultsDescriptor extends Descriptor
{ {
public DefaultsDescriptor(Resource xml, MetaData processor) public DefaultsDescriptor(Resource xml)
{ {
super(xml, processor); super(xml);
} }
} }

View File

@ -44,7 +44,6 @@ public class Descriptor
protected ArrayList<String> _classNames = new ArrayList<String>(); protected ArrayList<String> _classNames = new ArrayList<String>();
protected boolean _distributable; protected boolean _distributable;
protected boolean _validating; protected boolean _validating;
protected MetaData _metaData;
protected boolean _isOrdered = false; protected boolean _isOrdered = false;
protected List<String> _ordering = new ArrayList<String>(); protected List<String> _ordering = new ArrayList<String>();
@ -75,7 +74,7 @@ public class Descriptor
try try
{ {
Class jsp_page = Loader.loadClass(WebXmlConfiguration.class, "javax.servlet.jsp.JspPage"); Class<?> jsp_page = Loader.loadClass(WebXmlConfiguration.class, "javax.servlet.jsp.JspPage");
jsp20xsd = jsp_page.getResource("/javax/servlet/resources/jsp_2_0.xsd"); jsp20xsd = jsp_page.getResource("/javax/servlet/resources/jsp_2_0.xsd");
jsp21xsd = jsp_page.getResource("/javax/servlet/resources/jsp_2_1.xsd"); jsp21xsd = jsp_page.getResource("/javax/servlet/resources/jsp_2_1.xsd");
} }
@ -131,10 +130,9 @@ public class Descriptor
public Descriptor (Resource xml, MetaData md) public Descriptor (Resource xml)
{ {
_xml = xml; _xml = xml;
_metaData = md;
} }
public void parse () public void parse ()
@ -180,11 +178,6 @@ public class Descriptor
return _xml; return _xml;
} }
public MetaData getMetaData()
{
return _metaData;
}
public void processVersion () public void processVersion ()
{ {
String version = _root.getAttribute("version", "DTD"); String version = _root.getAttribute("version", "DTD");

View File

@ -20,5 +20,5 @@ package org.eclipse.jetty.webapp;
*/ */
public interface DescriptorProcessor public interface DescriptorProcessor
{ {
public void process (Descriptor descriptor) throws Exception; public void process (WebAppContext context, Descriptor descriptor) throws Exception;
} }

View File

@ -34,12 +34,8 @@ public class FragmentConfiguration implements Configuration
if (!context.isConfigurationDiscovered()) if (!context.isConfigurationDiscovered())
return; return;
MetaData metaData = (MetaData)context.getAttribute(MetaData.METADATA);
if (metaData == null)
throw new IllegalStateException("No metadata");
//find all web-fragment.xmls //find all web-fragment.xmls
findWebFragments(context, metaData); findWebFragments(context, context.getMetaData());
} }
@ -48,12 +44,8 @@ public class FragmentConfiguration implements Configuration
if (!context.isConfigurationDiscovered()) if (!context.isConfigurationDiscovered())
return; return;
MetaData metaData = (MetaData)context.getAttribute(MetaData.METADATA);
if (metaData == null)
throw new IllegalStateException("No metadata");
//order the fragments //order the fragments
metaData.orderFragments(); context.getMetaData().orderFragments();
} }
public void deconfigure(WebAppContext context) throws Exception public void deconfigure(WebAppContext context) throws Exception

View File

@ -40,11 +40,11 @@ public class FragmentDescriptor extends Descriptor
protected List<String> _afters = new ArrayList<String>(); protected List<String> _afters = new ArrayList<String>();
protected String _name; protected String _name;
public FragmentDescriptor (Resource xml, MetaData processor) public FragmentDescriptor (Resource xml)
throws Exception throws Exception
{ {
super (xml, processor); super (xml);
} }
public String getName () public String getName ()
@ -52,8 +52,9 @@ public class FragmentDescriptor extends Descriptor
return _name; return _name;
} }
@Override
public void parse () public void parse ()
throws Exception throws Exception
{ {
super.parse(); super.parse();
processName(); processName();
@ -71,6 +72,7 @@ public class FragmentDescriptor extends Descriptor
_name = tmp; _name = tmp;
} }
} }
@Override
public void processOrdering () public void processOrdering ()
{ {
//Process a fragment jar's web-fragment.xml<ordering> elements //Process a fragment jar's web-fragment.xml<ordering> elements

View File

@ -29,10 +29,10 @@ import org.eclipse.jetty.xml.XmlParser;
*/ */
public abstract class IterativeDescriptorProcessor implements DescriptorProcessor public abstract class IterativeDescriptorProcessor implements DescriptorProcessor
{ {
public static final Class[] __signature = new Class[]{Descriptor.class, XmlParser.Node.class}; public static final Class<?>[] __signature = new Class[]{WebAppContext.class, Descriptor.class, XmlParser.Node.class};
protected Map<String, Method> _visitors = new HashMap<String, Method>(); protected Map<String, Method> _visitors = new HashMap<String, Method>();
public abstract void start(Descriptor descriptor); public abstract void start(WebAppContext context, Descriptor descriptor);
public abstract void end(Descriptor descriptor); public abstract void end(WebAppContext context, Descriptor descriptor);
/** /**
* Register a method to be called back when visiting the node with the given name. * Register a method to be called back when visiting the node with the given name.
@ -50,13 +50,13 @@ public abstract class IterativeDescriptorProcessor implements DescriptorProcesso
/** /**
* @see org.eclipse.jetty.webapp.DescriptorProcessor#process(org.eclipse.jetty.webapp.Descriptor) * @see org.eclipse.jetty.webapp.DescriptorProcessor#process(org.eclipse.jetty.webapp.Descriptor)
*/ */
public void process(Descriptor descriptor) public void process(WebAppContext context, Descriptor descriptor)
throws Exception throws Exception
{ {
if (descriptor == null) if (descriptor == null)
return; return;
start(descriptor); start(context,descriptor);
XmlParser.Node root = descriptor.getRoot(); XmlParser.Node root = descriptor.getRoot();
Iterator iter = root.iterator(); Iterator iter = root.iterator();
@ -66,19 +66,19 @@ public abstract class IterativeDescriptorProcessor implements DescriptorProcesso
Object o = iter.next(); Object o = iter.next();
if (!(o instanceof XmlParser.Node)) continue; if (!(o instanceof XmlParser.Node)) continue;
node = (XmlParser.Node) o; node = (XmlParser.Node) o;
visit(descriptor, node); visit(context, descriptor, node);
} }
end(descriptor); end(context,descriptor);
} }
protected void visit (final Descriptor descriptor, final XmlParser.Node node) protected void visit (WebAppContext context, Descriptor descriptor, XmlParser.Node node)
throws Exception throws Exception
{ {
String name = node.getTag(); String name = node.getTag();
Method m = _visitors.get(name); Method m = _visitors.get(name);
if (m != null) if (m != null)
m.invoke(this, new Object[]{descriptor, node}); m.invoke(this, new Object[]{context, descriptor, node});
} }
} }

View File

@ -36,8 +36,6 @@ import org.eclipse.jetty.util.resource.Resource;
*/ */
public class MetaData public class MetaData
{ {
public static final String METADATA = "org.eclipse.jetty.metaData";
public static final String METADATA_COMPLETE = "org.eclipse.jetty.metadataComplete";
public static final String WEBXML_MAJOR_VERSION = "org.eclipse.jetty.webXmlMajorVersion"; public static final String WEBXML_MAJOR_VERSION = "org.eclipse.jetty.webXmlMajorVersion";
public static final String WEBXML_MINOR_VERSION = "org.eclipse.jetty.webXmlMinorVersion"; public static final String WEBXML_MINOR_VERSION = "org.eclipse.jetty.webXmlMinorVersion";
public static final String WEBXML_CLASSNAMES = "org.eclipse.jetty.webXmlClassNames"; public static final String WEBXML_CLASSNAMES = "org.eclipse.jetty.webXmlClassNames";
@ -50,6 +48,7 @@ public class MetaData
protected Descriptor _webDefaultsRoot; protected Descriptor _webDefaultsRoot;
protected Descriptor _webXmlRoot; protected Descriptor _webXmlRoot;
protected Descriptor _webOverrideRoot; protected Descriptor _webOverrideRoot;
protected boolean _metaDataComplete;
protected List<DiscoveredAnnotation> _annotations = new ArrayList<DiscoveredAnnotation>(); protected List<DiscoveredAnnotation> _annotations = new ArrayList<DiscoveredAnnotation>();
protected List<DescriptorProcessor> _descriptorProcessors = new ArrayList<DescriptorProcessor>(); protected List<DescriptorProcessor> _descriptorProcessors = new ArrayList<DescriptorProcessor>();
protected List<FragmentDescriptor> _webFragmentRoots = new ArrayList<FragmentDescriptor>(); protected List<FragmentDescriptor> _webFragmentRoots = new ArrayList<FragmentDescriptor>();
@ -137,6 +136,7 @@ public class MetaData
* Order the list of jars in WEB-INF/lib according to the ordering declarations in the descriptors * Order the list of jars in WEB-INF/lib according to the ordering declarations in the descriptors
* @see org.eclipse.jetty.webapp.MetaData.Ordering#order(java.util.List) * @see org.eclipse.jetty.webapp.MetaData.Ordering#order(java.util.List)
*/ */
@Override
public List<Resource> order(List<Resource> jars) public List<Resource> order(List<Resource> jars)
{ {
List<Resource> orderedList = new ArrayList<Resource>(); List<Resource> orderedList = new ArrayList<Resource>();
@ -144,7 +144,7 @@ public class MetaData
//1. put everything into the list of named others, and take the named ones out of there, //1. put everything into the list of named others, and take the named ones out of there,
//assuming we will want to use the <other> clause //assuming we will want to use the <other> clause
Map<String,FragmentDescriptor> others = new HashMap(getNamedFragments()); Map<String,FragmentDescriptor> others = new HashMap<String,FragmentDescriptor>(getNamedFragments());
//2. for each name, take out of the list of others, add to tail of list //2. for each name, take out of the list of others, add to tail of list
int index = -1; int index = -1;
@ -174,6 +174,7 @@ public class MetaData
return orderedList; return orderedList;
} }
@Override
public boolean isAbsolute() public boolean isAbsolute()
{ {
return true; return true;
@ -193,6 +194,7 @@ public class MetaData
_order.add(OTHER); _order.add(OTHER);
} }
@Override
public boolean hasOther () public boolean hasOther ()
{ {
return _hasOther; return _hasOther;
@ -216,6 +218,7 @@ public class MetaData
* in the various web-fragment.xml files. * in the various web-fragment.xml files.
* @see org.eclipse.jetty.webapp.MetaData.Ordering#order(java.util.List) * @see org.eclipse.jetty.webapp.MetaData.Ordering#order(java.util.List)
*/ */
@Override
public List<Resource> order(List<Resource> jars) public List<Resource> order(List<Resource> jars)
{ {
//for each jar, put it into the ordering according to the fragment ordering //for each jar, put it into the ordering according to the fragment ordering
@ -285,11 +288,13 @@ public class MetaData
return orderedList; return orderedList;
} }
@Override
public boolean isAbsolute () public boolean isAbsolute ()
{ {
return false; return false;
} }
@Override
public boolean hasOther () public boolean hasOther ()
{ {
return !_beforeOthers.isEmpty() || !_afterOthers.isEmpty(); return !_beforeOthers.isEmpty() || !_afterOthers.isEmpty();
@ -314,7 +319,7 @@ public class MetaData
{ {
//Take a copy of the list so we can iterate over it and at the same time do random insertions //Take a copy of the list so we can iterate over it and at the same time do random insertions
boolean changes = false; boolean changes = false;
List<Resource> iterable = new ArrayList(list); List<Resource> iterable = new ArrayList<Resource>(list);
Iterator<Resource> itor = iterable.iterator(); Iterator<Resource> itor = iterable.iterator();
while (itor.hasNext()) while (itor.hasNext())
@ -553,10 +558,8 @@ public class MetaData
return resources.indexOf(r); return resources.indexOf(r);
} }
} }
public MetaData (WebAppContext context) throws ClassNotFoundException public MetaData (WebAppContext context)
{ {
_context = context; _context = context;
@ -572,7 +575,7 @@ public class MetaData
public void setDefaults (Resource webDefaults) public void setDefaults (Resource webDefaults)
throws Exception throws Exception
{ {
_webDefaultsRoot = new DefaultsDescriptor(webDefaults, this); _webDefaultsRoot = new DefaultsDescriptor(webDefaults);
_webDefaultsRoot.parse(); _webDefaultsRoot.parse();
if (_webDefaultsRoot.isOrdered()) if (_webDefaultsRoot.isOrdered())
{ {
@ -593,12 +596,9 @@ public class MetaData
public void setWebXml (Resource webXml) public void setWebXml (Resource webXml)
throws Exception throws Exception
{ {
_webXmlRoot = new Descriptor(webXml, this); _webXmlRoot = new Descriptor(webXml);
_webXmlRoot.parse(); _webXmlRoot.parse();
if (_webXmlRoot.getMetaDataComplete() == Descriptor.MetaDataComplete.True) _metaDataComplete=_webXmlRoot.getMetaDataComplete() == Descriptor.MetaDataComplete.True;
_context.setAttribute(METADATA_COMPLETE, Boolean.TRUE);
else
_context.setAttribute(METADATA_COMPLETE, Boolean.FALSE);
_context.setAttribute(WEBXML_CLASSNAMES, _webXmlRoot.getClassNames()); _context.setAttribute(WEBXML_CLASSNAMES, _webXmlRoot.getClassNames());
@ -621,13 +621,21 @@ public class MetaData
public void setOverride (Resource override) public void setOverride (Resource override)
throws Exception throws Exception
{ {
_webOverrideRoot = new OverrideDescriptor(override, this); _webOverrideRoot = new OverrideDescriptor(override);
_webOverrideRoot.setValidating(false); _webOverrideRoot.setValidating(false);
_webOverrideRoot.parse(); _webOverrideRoot.parse();
if (_webOverrideRoot.getMetaDataComplete() == Descriptor.MetaDataComplete.True)
_context.setAttribute(METADATA_COMPLETE, Boolean.TRUE); switch(_webOverrideRoot.getMetaDataComplete())
else if (_webOverrideRoot.getMetaDataComplete() == Descriptor.MetaDataComplete.False) {
_context.setAttribute(METADATA_COMPLETE, Boolean.FALSE); case True:
_metaDataComplete=true;
break;
case False:
_metaDataComplete=true;
break;
case NotSet:
break;
}
if (_webOverrideRoot.isOrdered()) if (_webOverrideRoot.isOrdered())
{ {
@ -656,12 +664,11 @@ public class MetaData
public void addFragment (Resource jarResource, Resource xmlResource) public void addFragment (Resource jarResource, Resource xmlResource)
throws Exception throws Exception
{ {
Boolean metaComplete = (Boolean)_context.getAttribute(METADATA_COMPLETE); if (_metaDataComplete)
if (metaComplete != null && metaComplete.booleanValue())
return; //do not process anything else if web.xml/web-override.xml set metadata-complete return; //do not process anything else if web.xml/web-override.xml set metadata-complete
//Metadata-complete is not set, or there is no web.xml //Metadata-complete is not set, or there is no web.xml
FragmentDescriptor descriptor = new FragmentDescriptor(xmlResource, this); FragmentDescriptor descriptor = new FragmentDescriptor(xmlResource);
_webFragmentResourceMap.put(jarResource, descriptor); _webFragmentResourceMap.put(jarResource, descriptor);
_webFragmentRoots.add(descriptor); _webFragmentRoots.add(descriptor);
@ -732,7 +739,7 @@ public class MetaData
* Resolve all servlet/filter/listener metadata from all sources: descriptors and annotations. * Resolve all servlet/filter/listener metadata from all sources: descriptors and annotations.
* *
*/ */
public void resolve () public void resolve (WebAppContext context)
throws Exception throws Exception
{ {
//TODO - apply all descriptors and annotations in order: //TODO - apply all descriptors and annotations in order:
@ -747,9 +754,9 @@ public class MetaData
for (DescriptorProcessor p:_descriptorProcessors) for (DescriptorProcessor p:_descriptorProcessors)
{ {
p.process(getWebDefault()); p.process(context,getWebDefault());
p.process(getWebXml()); p.process(context,getWebXml());
p.process(getOverrideWeb()); p.process(context,getOverrideWeb());
} }
for (DiscoveredAnnotation a:_annotations) for (DiscoveredAnnotation a:_annotations)
@ -764,7 +771,7 @@ public class MetaData
{ {
for (DescriptorProcessor p:_descriptorProcessors) for (DescriptorProcessor p:_descriptorProcessors)
{ {
p.process(fd); p.process(context,fd);
} }
} }
@ -817,7 +824,8 @@ public class MetaData
public List<Resource> getOrderedResources () public List<Resource> getOrderedResources ()
{ {
return _orderedResources; return _orderedResources == null? new ArrayList<Resource>(): _orderedResources;
//return _orderedResources;
} }
public List<FragmentDescriptor> getOrderedFragments () public List<FragmentDescriptor> getOrderedFragments ()
@ -908,4 +916,9 @@ public class MetaData
OriginInfo x = new OriginInfo (name, Origin.Annotation); OriginInfo x = new OriginInfo (name, Origin.Annotation);
_origins.put(name, x); _origins.put(name, x);
} }
public boolean isMetaDataComplete()
{
return _metaDataComplete;
}
} }

View File

@ -22,8 +22,8 @@ import org.eclipse.jetty.util.resource.Resource;
*/ */
public class OverrideDescriptor extends Descriptor public class OverrideDescriptor extends Descriptor
{ {
public OverrideDescriptor(Resource xml, MetaData processor) public OverrideDescriptor(Resource xml)
{ {
super(xml, processor); super(xml);
} }
} }

View File

@ -134,6 +134,8 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
private boolean _configurationDiscovered=true; private boolean _configurationDiscovered=true;
private boolean _configurationClassesSet=false; private boolean _configurationClassesSet=false;
private boolean _configurationsSet=false; private boolean _configurationsSet=false;
private final MetaData _metadata;
public static WebAppContext getCurrentWebAppContext() public static WebAppContext getCurrentWebAppContext()
{ {
@ -152,7 +154,9 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
{ {
super(SESSIONS|SECURITY); super(SESSIONS|SECURITY);
_scontext=new Context(); _scontext=new Context();
setErrorHandler(new ErrorPageErrorHandler()); setErrorHandler(new ErrorPageErrorHandler());
//Make a new MetaData to hold descriptor and annotation metadata
_metadata = new MetaData(this);
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@ -166,7 +170,9 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
_scontext=new Context(); _scontext=new Context();
setContextPath(contextPath); setContextPath(contextPath);
setWar(webApp); setWar(webApp);
setErrorHandler(new ErrorPageErrorHandler()); setErrorHandler(new ErrorPageErrorHandler());
//Make a new MetaData to hold descriptor and annotation metadata
_metadata = new MetaData(this);
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@ -180,7 +186,9 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
super(parent,contextPath,SESSIONS|SECURITY); super(parent,contextPath,SESSIONS|SECURITY);
_scontext=new Context(); _scontext=new Context();
setWar(webApp); setWar(webApp);
setErrorHandler(new ErrorPageErrorHandler()); setErrorHandler(new ErrorPageErrorHandler());
//Make a new MetaData to hold descriptor and annotation metadata
_metadata = new MetaData(this);
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@ -190,7 +198,9 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
{ {
super(null,sessionHandler,securityHandler,servletHandler,errorHandler); super(null,sessionHandler,securityHandler,servletHandler,errorHandler);
_scontext=new Context(); _scontext=new Context();
setErrorHandler(errorHandler!=null?errorHandler:new ErrorPageErrorHandler()); setErrorHandler(errorHandler!=null?errorHandler:new ErrorPageErrorHandler());
//Make a new MetaData to hold descriptor and annotation metadata
_metadata = new MetaData(this);
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@ -370,11 +380,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
} }
// Prepare for configuration
// Prepare for configuration
//Make a new MetaData to hold descriptor and annotation metadata
MetaData metadata = new MetaData(this);
setAttribute(MetaData.METADATA, metadata);
for (int i=0;i<_configurations.length;i++) for (int i=0;i<_configurations.length;i++)
_configurations[i].preConfigure(this); _configurations[i].preConfigure(this);
@ -802,7 +808,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
*/ */
@Override @Override
public void addEventListener(EventListener listener) public void addEventListener(EventListener listener)
{ {
setEventListeners((EventListener[])LazyList.addToArray(getEventListeners(), listener, EventListener.class)); setEventListeners((EventListener[])LazyList.addToArray(getEventListeners(), listener, EventListener.class));
} }
@ -996,7 +1002,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
_configurations[i].configure(this); _configurations[i].configure(this);
//resolve the metadata //resolve the metadata
((MetaData)getAttribute(MetaData.METADATA)).resolve(); _metadata.resolve(this);
super.startContext(); super.startContext();
} }
@ -1026,4 +1032,10 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
} }
} }
/* ------------------------------------------------------------ */
public MetaData getMetaData()
{
return _metadata;
}
} }

View File

@ -40,12 +40,6 @@ public class WebXmlConfiguration implements Configuration
*/ */
public void preConfigure (WebAppContext context) throws Exception public void preConfigure (WebAppContext context) throws Exception
{ {
MetaData metaData = (MetaData)context.getAttribute(MetaData.METADATA);
if (metaData == null)
throw new IllegalStateException("No metadata");
//parse webdefault.xml //parse webdefault.xml
String defaultsDescriptor = context.getDefaultsDescriptor(); String defaultsDescriptor = context.getDefaultsDescriptor();
if (defaultsDescriptor != null && defaultsDescriptor.length() > 0) if (defaultsDescriptor != null && defaultsDescriptor.length() > 0)
@ -53,7 +47,7 @@ public class WebXmlConfiguration implements Configuration
Resource dftResource = Resource.newSystemResource(defaultsDescriptor); Resource dftResource = Resource.newSystemResource(defaultsDescriptor);
if (dftResource == null) if (dftResource == null)
dftResource = context.newResource(defaultsDescriptor); dftResource = context.newResource(defaultsDescriptor);
metaData.setDefaults (dftResource); context.getMetaData().setDefaults (dftResource);
} }
@ -61,7 +55,7 @@ public class WebXmlConfiguration implements Configuration
Resource webxml = findWebXml(context); Resource webxml = findWebXml(context);
if (webxml != null) if (webxml != null)
{ {
metaData.setWebXml(webxml); context.getMetaData().setWebXml(webxml);
} }
//parse but don't process override-web.xml //parse but don't process override-web.xml
@ -71,7 +65,7 @@ public class WebXmlConfiguration implements Configuration
Resource orideResource = Resource.newSystemResource(overrideDescriptor); Resource orideResource = Resource.newSystemResource(overrideDescriptor);
if (orideResource == null) if (orideResource == null)
orideResource = context.newResource(overrideDescriptor); orideResource = context.newResource(overrideDescriptor);
metaData.setOverride(orideResource); context.getMetaData().setOverride(orideResource);
} }
} }
@ -89,28 +83,24 @@ public class WebXmlConfiguration implements Configuration
return; return;
} }
MetaData metaData = (MetaData)context.getAttribute(MetaData.METADATA); context.getMetaData().addDescriptorProcessor(new StandardDescriptorProcessor());
if (metaData == null)
throw new IllegalStateException("No metadata");
metaData.addDescriptorProcessor(new StandardDescriptorProcessor());
/* /*
StandardDescriptorProcessor descriptorProcessor = (StandardDescriptorProcessor)context.getAttribute(StandardDescriptorProcessor.STANDARD_PROCESSOR); StandardDescriptorProcessor descriptorProcessor = (StandardDescriptorProcessor)context.getAttribute(StandardDescriptorProcessor.STANDARD_PROCESSOR);
if (descriptorProcessor == null) if (descriptorProcessor == null)
{ {
descriptorProcessor = new StandardDescriptorProcessor(metaData); descriptorProcessor = new StandardDescriptorProcessor(context.getMetaData());
context.setAttribute(StandardDescriptorProcessor.STANDARD_PROCESSOR, descriptorProcessor); context.setAttribute(StandardDescriptorProcessor.STANDARD_PROCESSOR, descriptorProcessor);
} }
//process web-default.xml //process web-default.xml
descriptorProcessor.process(metaData.getWebDefault()); descriptorProcessor.process(context.getMetaData().getWebDefault());
//process web.xml //process web.xml
descriptorProcessor.process(metaData.getWebXml()); descriptorProcessor.process(context.getMetaData().getWebXml());
//process override-web.xml //process override-web.xml
descriptorProcessor.process(metaData.getOverrideWeb()); descriptorProcessor.process(context.getMetaData().getOverrideWeb());
*/ */
} }

View File

@ -26,7 +26,6 @@ import junit.framework.TestCase;
import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.MetaData.AbsoluteOrdering; import org.eclipse.jetty.webapp.MetaData.AbsoluteOrdering;
import org.eclipse.jetty.webapp.MetaData.RelativeOrdering;
/** /**
* OrderingTest * OrderingTest
@ -47,51 +46,52 @@ public class OrderingTest extends TestCase
/** /**
* @see org.eclipse.jetty.util.resource.Resource#addPath(java.lang.String) * @see org.eclipse.jetty.util.resource.Resource#addPath(java.lang.String)
*/ */
@Override
public Resource addPath(String path) throws IOException, MalformedURLException public Resource addPath(String path) throws IOException, MalformedURLException
{ {
// TODO Auto-generated method stub
return null; return null;
} }
/** /**
* @see org.eclipse.jetty.util.resource.Resource#delete() * @see org.eclipse.jetty.util.resource.Resource#delete()
*/ */
@Override
public boolean delete() throws SecurityException public boolean delete() throws SecurityException
{ {
// TODO Auto-generated method stub
return false; return false;
} }
/** /**
* @see org.eclipse.jetty.util.resource.Resource#exists() * @see org.eclipse.jetty.util.resource.Resource#exists()
*/ */
@Override
public boolean exists() public boolean exists()
{ {
// TODO Auto-generated method stub
return false; return false;
} }
/** /**
* @see org.eclipse.jetty.util.resource.Resource#getFile() * @see org.eclipse.jetty.util.resource.Resource#getFile()
*/ */
@Override
public File getFile() throws IOException public File getFile() throws IOException
{ {
// TODO Auto-generated method stub
return null; return null;
} }
/** /**
* @see org.eclipse.jetty.util.resource.Resource#getInputStream() * @see org.eclipse.jetty.util.resource.Resource#getInputStream()
*/ */
@Override
public InputStream getInputStream() throws IOException public InputStream getInputStream() throws IOException
{ {
// TODO Auto-generated method stub
return null; return null;
} }
/** /**
* @see org.eclipse.jetty.util.resource.Resource#getName() * @see org.eclipse.jetty.util.resource.Resource#getName()
*/ */
@Override
public String getName() public String getName()
{ {
return _name; return _name;
@ -100,81 +100,80 @@ public class OrderingTest extends TestCase
/** /**
* @see org.eclipse.jetty.util.resource.Resource#getOutputStream() * @see org.eclipse.jetty.util.resource.Resource#getOutputStream()
*/ */
@Override
public OutputStream getOutputStream() throws IOException, SecurityException public OutputStream getOutputStream() throws IOException, SecurityException
{ {
// TODO Auto-generated method stub
return null; return null;
} }
/** /**
* @see org.eclipse.jetty.util.resource.Resource#getURL() * @see org.eclipse.jetty.util.resource.Resource#getURL()
*/ */
@Override
public URL getURL() public URL getURL()
{ {
// TODO Auto-generated method stub
return null; return null;
} }
/** /**
* @see org.eclipse.jetty.util.resource.Resource#isContainedIn(org.eclipse.jetty.util.resource.Resource) * @see org.eclipse.jetty.util.resource.Resource#isContainedIn(org.eclipse.jetty.util.resource.Resource)
*/ */
@Override
public boolean isContainedIn(Resource r) throws MalformedURLException public boolean isContainedIn(Resource r) throws MalformedURLException
{ {
// TODO Auto-generated method stub
return false; return false;
} }
/** /**
* @see org.eclipse.jetty.util.resource.Resource#isDirectory() * @see org.eclipse.jetty.util.resource.Resource#isDirectory()
*/ */
@Override
public boolean isDirectory() public boolean isDirectory()
{ {
// TODO Auto-generated method stub
return false; return false;
} }
/** /**
* @see org.eclipse.jetty.util.resource.Resource#lastModified() * @see org.eclipse.jetty.util.resource.Resource#lastModified()
*/ */
@Override
public long lastModified() public long lastModified()
{ {
// TODO Auto-generated method stub
return 0; return 0;
} }
/** /**
* @see org.eclipse.jetty.util.resource.Resource#length() * @see org.eclipse.jetty.util.resource.Resource#length()
*/ */
@Override
public long length() public long length()
{ {
// TODO Auto-generated method stub
return 0; return 0;
} }
/** /**
* @see org.eclipse.jetty.util.resource.Resource#list() * @see org.eclipse.jetty.util.resource.Resource#list()
*/ */
@Override
public String[] list() public String[] list()
{ {
// TODO Auto-generated method stub
return null; return null;
} }
/** /**
* @see org.eclipse.jetty.util.resource.Resource#release() * @see org.eclipse.jetty.util.resource.Resource#release()
*/ */
@Override
public void release() public void release()
{ {
// TODO Auto-generated method stub
} }
/** /**
* @see org.eclipse.jetty.util.resource.Resource#renameTo(org.eclipse.jetty.util.resource.Resource) * @see org.eclipse.jetty.util.resource.Resource#renameTo(org.eclipse.jetty.util.resource.Resource)
*/ */
@Override
public boolean renameTo(Resource dest) throws SecurityException public boolean renameTo(Resource dest) throws SecurityException
{ {
// TODO Auto-generated method stub
return false; return false;
} }
@ -194,7 +193,7 @@ public class OrderingTest extends TestCase
TestResource jar1 = new TestResource("A"); TestResource jar1 = new TestResource("A");
resources.add(jar1); resources.add(jar1);
TestResource r1 = new TestResource("A/web-fragment.xml"); TestResource r1 = new TestResource("A/web-fragment.xml");
FragmentDescriptor f1 = new FragmentDescriptor(r1, metaData); FragmentDescriptor f1 = new FragmentDescriptor(r1);
f1._name = "A"; f1._name = "A";
metaData._webFragmentNameMap.put(f1._name, f1); metaData._webFragmentNameMap.put(f1._name, f1);
metaData._webFragmentResourceMap.put(jar1, f1); metaData._webFragmentResourceMap.put(jar1, f1);
@ -206,7 +205,7 @@ public class OrderingTest extends TestCase
TestResource jar2 = new TestResource("B"); TestResource jar2 = new TestResource("B");
resources.add(jar2); resources.add(jar2);
TestResource r2 = new TestResource("B/web-fragment.xml"); TestResource r2 = new TestResource("B/web-fragment.xml");
FragmentDescriptor f2 = new FragmentDescriptor(r2, metaData); FragmentDescriptor f2 = new FragmentDescriptor(r2);
f2._name="B"; f2._name="B";
metaData._webFragmentNameMap.put(f2._name, f2); metaData._webFragmentNameMap.put(f2._name, f2);
metaData._webFragmentResourceMap.put(jar2, f2); metaData._webFragmentResourceMap.put(jar2, f2);
@ -217,7 +216,7 @@ public class OrderingTest extends TestCase
TestResource jar3 = new TestResource("C"); TestResource jar3 = new TestResource("C");
resources.add(jar3); resources.add(jar3);
TestResource r3 = new TestResource("C/web-fragment.xml"); TestResource r3 = new TestResource("C/web-fragment.xml");
FragmentDescriptor f3 = new FragmentDescriptor(r3, metaData); FragmentDescriptor f3 = new FragmentDescriptor(r3);
f3._name="C"; f3._name="C";
metaData._webFragmentNameMap.put(f3._name, f3); metaData._webFragmentNameMap.put(f3._name, f3);
metaData._webFragmentResourceMap.put(jar3, f3); metaData._webFragmentResourceMap.put(jar3, f3);
@ -228,7 +227,7 @@ public class OrderingTest extends TestCase
TestResource jar4 = new TestResource("D"); TestResource jar4 = new TestResource("D");
resources.add(jar4); resources.add(jar4);
TestResource r4 = new TestResource("D/web-fragment.xml"); TestResource r4 = new TestResource("D/web-fragment.xml");
FragmentDescriptor f4 = new FragmentDescriptor(r4, metaData); FragmentDescriptor f4 = new FragmentDescriptor(r4);
f4._name="D"; f4._name="D";
metaData._webFragmentNameMap.put(f4._name, f4); metaData._webFragmentNameMap.put(f4._name, f4);
metaData._webFragmentResourceMap.put(jar4, f4); metaData._webFragmentResourceMap.put(jar4, f4);
@ -239,7 +238,7 @@ public class OrderingTest extends TestCase
TestResource jar5 = new TestResource("E"); TestResource jar5 = new TestResource("E");
resources.add(jar5); resources.add(jar5);
TestResource r5 = new TestResource("E/web-fragment.xml"); TestResource r5 = new TestResource("E/web-fragment.xml");
FragmentDescriptor f5 = new FragmentDescriptor(r5, metaData); FragmentDescriptor f5 = new FragmentDescriptor(r5);
f5._name="E"; f5._name="E";
metaData._webFragmentNameMap.put(f5._name, f5); metaData._webFragmentNameMap.put(f5._name, f5);
metaData._webFragmentResourceMap.put(jar5, f5); metaData._webFragmentResourceMap.put(jar5, f5);
@ -250,7 +249,7 @@ public class OrderingTest extends TestCase
TestResource jar6 = new TestResource("F"); TestResource jar6 = new TestResource("F");
resources.add(jar6); resources.add(jar6);
TestResource r6 = new TestResource("F/web-fragment.xml"); TestResource r6 = new TestResource("F/web-fragment.xml");
FragmentDescriptor f6 = new FragmentDescriptor(r6, metaData); FragmentDescriptor f6 = new FragmentDescriptor(r6);
f6._name="F"; f6._name="F";
metaData._webFragmentNameMap.put(f6._name, f6); metaData._webFragmentNameMap.put(f6._name, f6);
metaData._webFragmentResourceMap.put(jar6,f6); metaData._webFragmentResourceMap.put(jar6,f6);
@ -288,7 +287,7 @@ public class OrderingTest extends TestCase
TestResource jar1 = new TestResource("plain"); TestResource jar1 = new TestResource("plain");
resources.add(jar1); resources.add(jar1);
TestResource r1 = new TestResource("plain/web-fragment.xml"); TestResource r1 = new TestResource("plain/web-fragment.xml");
FragmentDescriptor f1 = new FragmentDescriptor(r1, metaData); FragmentDescriptor f1 = new FragmentDescriptor(r1);
f1._name = FragmentDescriptor.NAMELESS+"1"; f1._name = FragmentDescriptor.NAMELESS+"1";
metaData._webFragmentNameMap.put(f1._name, f1); metaData._webFragmentNameMap.put(f1._name, f1);
metaData._webFragmentResourceMap.put(jar1,f1); metaData._webFragmentResourceMap.put(jar1,f1);
@ -300,7 +299,7 @@ public class OrderingTest extends TestCase
TestResource jar2 = new TestResource("B"); TestResource jar2 = new TestResource("B");
resources.add(jar2); resources.add(jar2);
TestResource r2 = new TestResource("B/web-fragment.xml"); TestResource r2 = new TestResource("B/web-fragment.xml");
FragmentDescriptor f2 = new FragmentDescriptor(r2, metaData); FragmentDescriptor f2 = new FragmentDescriptor(r2);
f2._name="B"; f2._name="B";
metaData._webFragmentNameMap.put(f2._name, f2); metaData._webFragmentNameMap.put(f2._name, f2);
metaData._webFragmentResourceMap.put(jar2,f2); metaData._webFragmentResourceMap.put(jar2,f2);
@ -311,7 +310,7 @@ public class OrderingTest extends TestCase
TestResource jar3 = new TestResource("C"); TestResource jar3 = new TestResource("C");
resources.add(jar3); resources.add(jar3);
TestResource r3 = new TestResource("C/web-fragment.xml"); TestResource r3 = new TestResource("C/web-fragment.xml");
FragmentDescriptor f3 = new FragmentDescriptor(r3, metaData); FragmentDescriptor f3 = new FragmentDescriptor(r3);
f3._name="C"; f3._name="C";
metaData._webFragmentNameMap.put(f3._name, f3); metaData._webFragmentNameMap.put(f3._name, f3);
metaData._webFragmentResourceMap.put(jar3,f3); metaData._webFragmentResourceMap.put(jar3,f3);
@ -322,7 +321,7 @@ public class OrderingTest extends TestCase
TestResource jar4 = new TestResource("D"); TestResource jar4 = new TestResource("D");
resources.add(jar4); resources.add(jar4);
TestResource r4 = new TestResource("D/web-fragment.xml"); TestResource r4 = new TestResource("D/web-fragment.xml");
FragmentDescriptor f4 = new FragmentDescriptor(r4, metaData); FragmentDescriptor f4 = new FragmentDescriptor(r4);
f4._name="D"; f4._name="D";
metaData._webFragmentNameMap.put(f4._name, f4); metaData._webFragmentNameMap.put(f4._name, f4);
metaData._webFragmentResourceMap.put(jar4,f4); metaData._webFragmentResourceMap.put(jar4,f4);
@ -333,7 +332,7 @@ public class OrderingTest extends TestCase
TestResource jar5 = new TestResource("E"); TestResource jar5 = new TestResource("E");
resources.add(jar5); resources.add(jar5);
TestResource r5 = new TestResource("E/web-fragment.xml"); TestResource r5 = new TestResource("E/web-fragment.xml");
FragmentDescriptor f5 = new FragmentDescriptor(r5, metaData); FragmentDescriptor f5 = new FragmentDescriptor(r5);
f5._name="E"; f5._name="E";
metaData._webFragmentNameMap.put(f5._name, f5); metaData._webFragmentNameMap.put(f5._name, f5);
metaData._webFragmentResourceMap.put(jar5,f5); metaData._webFragmentResourceMap.put(jar5,f5);
@ -344,7 +343,7 @@ public class OrderingTest extends TestCase
TestResource jar6 = new TestResource("F"); TestResource jar6 = new TestResource("F");
resources.add(jar6); resources.add(jar6);
TestResource r6 = new TestResource("F/web-fragment.xml"); TestResource r6 = new TestResource("F/web-fragment.xml");
FragmentDescriptor f6 = new FragmentDescriptor(r6, metaData); FragmentDescriptor f6 = new FragmentDescriptor(r6);
f6._name="F"; f6._name="F";
metaData._webFragmentNameMap.put(f6._name, f6); metaData._webFragmentNameMap.put(f6._name, f6);
metaData._webFragmentResourceMap.put(jar6,f6); metaData._webFragmentResourceMap.put(jar6,f6);
@ -389,7 +388,7 @@ public class OrderingTest extends TestCase
TestResource jar1 = new TestResource("A"); TestResource jar1 = new TestResource("A");
resources.add(jar1); resources.add(jar1);
TestResource r1 = new TestResource("A/web-fragment.xml"); TestResource r1 = new TestResource("A/web-fragment.xml");
FragmentDescriptor f1 = new FragmentDescriptor(r1, metaData); FragmentDescriptor f1 = new FragmentDescriptor(r1);
f1._name = "A"; f1._name = "A";
metaData._webFragmentNameMap.put(f1._name, f1); metaData._webFragmentNameMap.put(f1._name, f1);
metaData._webFragmentResourceMap.put(jar1, f1); metaData._webFragmentResourceMap.put(jar1, f1);
@ -401,7 +400,7 @@ public class OrderingTest extends TestCase
TestResource jar2 = new TestResource("B"); TestResource jar2 = new TestResource("B");
resources.add(jar2); resources.add(jar2);
TestResource r2 = new TestResource("B/web-fragment.xml"); TestResource r2 = new TestResource("B/web-fragment.xml");
FragmentDescriptor f2 = new FragmentDescriptor(r2, metaData); FragmentDescriptor f2 = new FragmentDescriptor(r2);
f2._name="B"; f2._name="B";
metaData._webFragmentNameMap.put(f2._name, f2); metaData._webFragmentNameMap.put(f2._name, f2);
metaData._webFragmentResourceMap.put(jar2, f2); metaData._webFragmentResourceMap.put(jar2, f2);
@ -412,7 +411,7 @@ public class OrderingTest extends TestCase
TestResource jar3 = new TestResource("C"); TestResource jar3 = new TestResource("C");
resources.add(jar3); resources.add(jar3);
TestResource r3 = new TestResource("C/web-fragment.xml"); TestResource r3 = new TestResource("C/web-fragment.xml");
FragmentDescriptor f3 = new FragmentDescriptor(r3, metaData); FragmentDescriptor f3 = new FragmentDescriptor(r3);
f3._name="C"; f3._name="C";
metaData._webFragmentNameMap.put(f3._name, f3); metaData._webFragmentNameMap.put(f3._name, f3);
metaData._webFragmentResourceMap.put(jar3,f3); metaData._webFragmentResourceMap.put(jar3,f3);
@ -423,7 +422,7 @@ public class OrderingTest extends TestCase
TestResource jar4 = new TestResource("D"); TestResource jar4 = new TestResource("D");
resources.add(jar4); resources.add(jar4);
TestResource r4 = new TestResource("D/web-fragment.xml"); TestResource r4 = new TestResource("D/web-fragment.xml");
FragmentDescriptor f4 = new FragmentDescriptor(r4, metaData); FragmentDescriptor f4 = new FragmentDescriptor(r4);
f4._name="D"; f4._name="D";
metaData._webFragmentNameMap.put(f4._name, f4); metaData._webFragmentNameMap.put(f4._name, f4);
metaData._webFragmentResourceMap.put(jar4, f4); metaData._webFragmentResourceMap.put(jar4, f4);
@ -462,7 +461,7 @@ public class OrderingTest extends TestCase
TestResource jar1 = new TestResource("A"); TestResource jar1 = new TestResource("A");
resources.add(jar1); resources.add(jar1);
TestResource r1 = new TestResource("A/web-fragment.xml"); TestResource r1 = new TestResource("A/web-fragment.xml");
FragmentDescriptor f1 = new FragmentDescriptor(r1, metaData); FragmentDescriptor f1 = new FragmentDescriptor(r1);
f1._name = "A"; f1._name = "A";
metaData._webFragmentNameMap.put(f1._name, f1); metaData._webFragmentNameMap.put(f1._name, f1);
metaData._webFragmentResourceMap.put(jar1, f1); metaData._webFragmentResourceMap.put(jar1, f1);
@ -474,7 +473,7 @@ public class OrderingTest extends TestCase
TestResource jar2 = new TestResource("B"); TestResource jar2 = new TestResource("B");
resources.add(jar2); resources.add(jar2);
TestResource r2 = new TestResource("B/web-fragment.xml"); TestResource r2 = new TestResource("B/web-fragment.xml");
FragmentDescriptor f2 = new FragmentDescriptor(r2, metaData); FragmentDescriptor f2 = new FragmentDescriptor(r2);
f2._name="B"; f2._name="B";
metaData._webFragmentNameMap.put(f2._name, f2); metaData._webFragmentNameMap.put(f2._name, f2);
metaData._webFragmentResourceMap.put(jar2,f2); metaData._webFragmentResourceMap.put(jar2,f2);
@ -486,7 +485,7 @@ public class OrderingTest extends TestCase
TestResource jar3 = new TestResource("C"); TestResource jar3 = new TestResource("C");
resources.add(jar3); resources.add(jar3);
TestResource r3 = new TestResource("C/web-fragment.xml"); TestResource r3 = new TestResource("C/web-fragment.xml");
FragmentDescriptor f3 = new FragmentDescriptor(r3, metaData); FragmentDescriptor f3 = new FragmentDescriptor(r3);
f3._name="C"; f3._name="C";
metaData._webFragmentNameMap.put(f3._name, f3); metaData._webFragmentNameMap.put(f3._name, f3);
metaData._webFragmentResourceMap.put(jar3,f3); metaData._webFragmentResourceMap.put(jar3,f3);
@ -520,7 +519,7 @@ public class OrderingTest extends TestCase
TestResource jar1 = new TestResource("A"); TestResource jar1 = new TestResource("A");
resources.add(jar1); resources.add(jar1);
TestResource r1 = new TestResource("A/web-fragment.xml"); TestResource r1 = new TestResource("A/web-fragment.xml");
FragmentDescriptor f1 = new FragmentDescriptor(r1, metaData); FragmentDescriptor f1 = new FragmentDescriptor(r1);
f1._name = "A"; f1._name = "A";
metaData._webFragmentNameMap.put(f1._name, f1); metaData._webFragmentNameMap.put(f1._name, f1);
metaData._webFragmentResourceMap.put(jar1, f1); metaData._webFragmentResourceMap.put(jar1, f1);
@ -532,7 +531,7 @@ public class OrderingTest extends TestCase
TestResource jar2 = new TestResource("B"); TestResource jar2 = new TestResource("B");
resources.add(jar2); resources.add(jar2);
TestResource r2 = new TestResource("B/web-fragment.xml"); TestResource r2 = new TestResource("B/web-fragment.xml");
FragmentDescriptor f2 = new FragmentDescriptor(r2, metaData); FragmentDescriptor f2 = new FragmentDescriptor(r2);
f2._name="B"; f2._name="B";
metaData._webFragmentNameMap.put(f2._name, f2); metaData._webFragmentNameMap.put(f2._name, f2);
metaData._webFragmentResourceMap.put(jar2, f2); metaData._webFragmentResourceMap.put(jar2, f2);
@ -566,7 +565,7 @@ public class OrderingTest extends TestCase
TestResource jar1 = new TestResource("A"); TestResource jar1 = new TestResource("A");
resources.add(jar1); resources.add(jar1);
TestResource r1 = new TestResource("A/web-fragment.xml"); TestResource r1 = new TestResource("A/web-fragment.xml");
FragmentDescriptor f1 = new FragmentDescriptor(r1, metaData); FragmentDescriptor f1 = new FragmentDescriptor(r1);
f1._name = "A"; f1._name = "A";
metaData._webFragmentNameMap.put(f1._name, f1); metaData._webFragmentNameMap.put(f1._name, f1);
metaData._webFragmentResourceMap.put(jar1,f1); metaData._webFragmentResourceMap.put(jar1,f1);
@ -578,7 +577,7 @@ public class OrderingTest extends TestCase
TestResource jar2 = new TestResource("B"); TestResource jar2 = new TestResource("B");
resources.add(jar2); resources.add(jar2);
TestResource r2 = new TestResource("B/web-fragment.xml"); TestResource r2 = new TestResource("B/web-fragment.xml");
FragmentDescriptor f2 = new FragmentDescriptor(r2, metaData); FragmentDescriptor f2 = new FragmentDescriptor(r2);
f2._name="B"; f2._name="B";
metaData._webFragmentNameMap.put(f2._name, f2); metaData._webFragmentNameMap.put(f2._name, f2);
metaData._webFragmentResourceMap.put(jar2,f2); metaData._webFragmentResourceMap.put(jar2,f2);
@ -590,7 +589,7 @@ public class OrderingTest extends TestCase
TestResource jar3 = new TestResource("C"); TestResource jar3 = new TestResource("C");
resources.add(jar3); resources.add(jar3);
TestResource r3 = new TestResource("C/web-fragment.xml"); TestResource r3 = new TestResource("C/web-fragment.xml");
FragmentDescriptor f3 = new FragmentDescriptor(r3, metaData); FragmentDescriptor f3 = new FragmentDescriptor(r3);
f3._name="C"; f3._name="C";
metaData._webFragmentNameMap.put(f3._name, f3); metaData._webFragmentNameMap.put(f3._name, f3);
metaData._webFragmentResourceMap.put(jar3,f3); metaData._webFragmentResourceMap.put(jar3,f3);
@ -631,7 +630,7 @@ public class OrderingTest extends TestCase
TestResource jar1 = new TestResource("A"); TestResource jar1 = new TestResource("A");
resources.add(jar1); resources.add(jar1);
TestResource r1 = new TestResource("A/web-fragment.xml"); TestResource r1 = new TestResource("A/web-fragment.xml");
FragmentDescriptor f1 = new FragmentDescriptor(r1, metaData); FragmentDescriptor f1 = new FragmentDescriptor(r1);
f1._name = "A"; f1._name = "A";
metaData._webFragmentNameMap.put(f1._name, f1); metaData._webFragmentNameMap.put(f1._name, f1);
metaData._webFragmentResourceMap.put(jar1,f1); metaData._webFragmentResourceMap.put(jar1,f1);
@ -639,7 +638,7 @@ public class OrderingTest extends TestCase
TestResource jar2 = new TestResource("B"); TestResource jar2 = new TestResource("B");
resources.add(jar2); resources.add(jar2);
TestResource r2 = new TestResource("B/web-fragment.xml"); TestResource r2 = new TestResource("B/web-fragment.xml");
FragmentDescriptor f2 = new FragmentDescriptor(r2, metaData); FragmentDescriptor f2 = new FragmentDescriptor(r2);
f2._name="B"; f2._name="B";
metaData._webFragmentNameMap.put(f2._name, f2); metaData._webFragmentNameMap.put(f2._name, f2);
metaData._webFragmentResourceMap.put(jar2, f2); metaData._webFragmentResourceMap.put(jar2, f2);
@ -647,7 +646,7 @@ public class OrderingTest extends TestCase
TestResource jar3 = new TestResource("C"); TestResource jar3 = new TestResource("C");
resources.add(jar3); resources.add(jar3);
TestResource r3 = new TestResource("C/web-fragment.xml"); TestResource r3 = new TestResource("C/web-fragment.xml");
FragmentDescriptor f3 = new FragmentDescriptor(r3, metaData); FragmentDescriptor f3 = new FragmentDescriptor(r3);
f3._name="C"; f3._name="C";
metaData._webFragmentNameMap.put(f3._name, f3); metaData._webFragmentNameMap.put(f3._name, f3);
metaData._webFragmentResourceMap.put(jar3, f3); metaData._webFragmentResourceMap.put(jar3, f3);
@ -655,7 +654,7 @@ public class OrderingTest extends TestCase
TestResource jar4 = new TestResource("D"); TestResource jar4 = new TestResource("D");
resources.add(jar4); resources.add(jar4);
TestResource r4 = new TestResource("D/web-fragment.xml"); TestResource r4 = new TestResource("D/web-fragment.xml");
FragmentDescriptor f4 = new FragmentDescriptor((Resource)null, metaData); FragmentDescriptor f4 = new FragmentDescriptor((Resource)null);
f4._name="D"; f4._name="D";
metaData._webFragmentNameMap.put(f4._name, f4); metaData._webFragmentNameMap.put(f4._name, f4);
metaData._webFragmentResourceMap.put(jar4, f4); metaData._webFragmentResourceMap.put(jar4, f4);
@ -663,7 +662,7 @@ public class OrderingTest extends TestCase
TestResource jar5 = new TestResource("E"); TestResource jar5 = new TestResource("E");
resources.add(jar5); resources.add(jar5);
TestResource r5 = new TestResource("E/web-fragment.xml"); TestResource r5 = new TestResource("E/web-fragment.xml");
FragmentDescriptor f5 = new FragmentDescriptor((Resource)null, metaData); FragmentDescriptor f5 = new FragmentDescriptor((Resource)null);
f5._name="E"; f5._name="E";
metaData._webFragmentNameMap.put(f5._name, f5); metaData._webFragmentNameMap.put(f5._name, f5);
metaData._webFragmentResourceMap.put(jar5, f5); metaData._webFragmentResourceMap.put(jar5, f5);
@ -671,7 +670,7 @@ public class OrderingTest extends TestCase
TestResource jar6 = new TestResource("plain"); TestResource jar6 = new TestResource("plain");
resources.add(jar6); resources.add(jar6);
TestResource r6 = new TestResource ("plain/web-fragment.xml"); TestResource r6 = new TestResource ("plain/web-fragment.xml");
FragmentDescriptor f6 = new FragmentDescriptor((Resource)null, metaData); FragmentDescriptor f6 = new FragmentDescriptor((Resource)null);
f6._name=FragmentDescriptor.NAMELESS+"1"; f6._name=FragmentDescriptor.NAMELESS+"1";
metaData._webFragmentNameMap.put(f6._name, f6); metaData._webFragmentNameMap.put(f6._name, f6);
metaData._webFragmentResourceMap.put(jar6, f6); metaData._webFragmentResourceMap.put(jar6, f6);
@ -704,7 +703,7 @@ public class OrderingTest extends TestCase
TestResource jar1 = new TestResource("A"); TestResource jar1 = new TestResource("A");
resources.add(jar1); resources.add(jar1);
TestResource r1 = new TestResource("A/web-fragment.xml"); TestResource r1 = new TestResource("A/web-fragment.xml");
FragmentDescriptor f1 = new FragmentDescriptor(r1, metaData); FragmentDescriptor f1 = new FragmentDescriptor(r1);
f1._name = "A"; f1._name = "A";
metaData._webFragmentNameMap.put(f1._name, f1); metaData._webFragmentNameMap.put(f1._name, f1);
metaData._webFragmentResourceMap.put(jar1,f1); metaData._webFragmentResourceMap.put(jar1,f1);
@ -712,7 +711,7 @@ public class OrderingTest extends TestCase
TestResource jar2 = new TestResource("B"); TestResource jar2 = new TestResource("B");
resources.add(jar2); resources.add(jar2);
TestResource r2 = new TestResource("B/web-fragment.xml"); TestResource r2 = new TestResource("B/web-fragment.xml");
FragmentDescriptor f2 = new FragmentDescriptor(r2, metaData); FragmentDescriptor f2 = new FragmentDescriptor(r2);
f2._name="B"; f2._name="B";
metaData._webFragmentNameMap.put(f2._name, f2); metaData._webFragmentNameMap.put(f2._name, f2);
metaData._webFragmentResourceMap.put(jar2,f2); metaData._webFragmentResourceMap.put(jar2,f2);
@ -720,7 +719,7 @@ public class OrderingTest extends TestCase
TestResource jar3 = new TestResource("C"); TestResource jar3 = new TestResource("C");
resources.add(jar3); resources.add(jar3);
TestResource r3 = new TestResource("C/web-fragment.xml"); TestResource r3 = new TestResource("C/web-fragment.xml");
FragmentDescriptor f3 = new FragmentDescriptor(r3, metaData); FragmentDescriptor f3 = new FragmentDescriptor(r3);
f3._name="C"; f3._name="C";
metaData._webFragmentNameMap.put(f3._name, f3); metaData._webFragmentNameMap.put(f3._name, f3);
metaData._webFragmentResourceMap.put(jar3,f3); metaData._webFragmentResourceMap.put(jar3,f3);
@ -728,7 +727,7 @@ public class OrderingTest extends TestCase
TestResource jar4 = new TestResource("D"); TestResource jar4 = new TestResource("D");
resources.add(jar4); resources.add(jar4);
TestResource r4 = new TestResource("D/web-fragment.xml"); TestResource r4 = new TestResource("D/web-fragment.xml");
FragmentDescriptor f4 = new FragmentDescriptor(r4, metaData); FragmentDescriptor f4 = new FragmentDescriptor(r4);
f4._name="D"; f4._name="D";
metaData._webFragmentNameMap.put(f4._name, f4); metaData._webFragmentNameMap.put(f4._name, f4);
metaData._webFragmentResourceMap.put(jar4,f4); metaData._webFragmentResourceMap.put(jar4,f4);
@ -736,7 +735,7 @@ public class OrderingTest extends TestCase
TestResource jar5 = new TestResource("E"); TestResource jar5 = new TestResource("E");
resources.add(jar5); resources.add(jar5);
TestResource r5 = new TestResource("E/web-fragment.xml"); TestResource r5 = new TestResource("E/web-fragment.xml");
FragmentDescriptor f5 = new FragmentDescriptor(r5, metaData); FragmentDescriptor f5 = new FragmentDescriptor(r5);
f5._name="E"; f5._name="E";
metaData._webFragmentNameMap.put(f5._name, f5); metaData._webFragmentNameMap.put(f5._name, f5);
metaData._webFragmentResourceMap.put(jar5,f5); metaData._webFragmentResourceMap.put(jar5,f5);
@ -744,7 +743,7 @@ public class OrderingTest extends TestCase
TestResource jar6 = new TestResource("plain"); TestResource jar6 = new TestResource("plain");
resources.add(jar6); resources.add(jar6);
TestResource r6 = new TestResource("plain/web-fragment.xml"); TestResource r6 = new TestResource("plain/web-fragment.xml");
FragmentDescriptor f6 = new FragmentDescriptor(r6, metaData); FragmentDescriptor f6 = new FragmentDescriptor(r6);
f6._name=FragmentDescriptor.NAMELESS+"1"; f6._name=FragmentDescriptor.NAMELESS+"1";
metaData._webFragmentNameMap.put(f6._name, f6); metaData._webFragmentNameMap.put(f6._name, f6);
metaData._webFragmentResourceMap.put(jar6,f6); metaData._webFragmentResourceMap.put(jar6,f6);
@ -791,7 +790,7 @@ public class OrderingTest extends TestCase
TestResource jar1 = new TestResource("A"); TestResource jar1 = new TestResource("A");
resources.add(jar1); resources.add(jar1);
TestResource r1 = new TestResource("A/web-fragment.xml"); TestResource r1 = new TestResource("A/web-fragment.xml");
FragmentDescriptor f1 = new FragmentDescriptor(r1, metaData); FragmentDescriptor f1 = new FragmentDescriptor(r1);
f1._name = "A"; f1._name = "A";
metaData._webFragmentNameMap.put(f1._name, f1); metaData._webFragmentNameMap.put(f1._name, f1);
metaData._webFragmentResourceMap.put(jar1, f1); metaData._webFragmentResourceMap.put(jar1, f1);
@ -803,7 +802,7 @@ public class OrderingTest extends TestCase
TestResource jar2 = new TestResource("B"); TestResource jar2 = new TestResource("B");
resources.add(jar2); resources.add(jar2);
TestResource r2 = new TestResource("B/web-fragment.xml"); TestResource r2 = new TestResource("B/web-fragment.xml");
FragmentDescriptor f2 = new FragmentDescriptor(r2, metaData); FragmentDescriptor f2 = new FragmentDescriptor(r2);
f2._name="B"; f2._name="B";
metaData._webFragmentNameMap.put(f2._name, f2); metaData._webFragmentNameMap.put(f2._name, f2);
metaData._webFragmentResourceMap.put(jar2,f2); metaData._webFragmentResourceMap.put(jar2,f2);
@ -815,7 +814,7 @@ public class OrderingTest extends TestCase
TestResource jar3 = new TestResource("C"); TestResource jar3 = new TestResource("C");
resources.add(jar3); resources.add(jar3);
TestResource r3 = new TestResource("C/web-fragment.xml"); TestResource r3 = new TestResource("C/web-fragment.xml");
FragmentDescriptor f3 = new FragmentDescriptor(r3, metaData); FragmentDescriptor f3 = new FragmentDescriptor(r3);
f3._name="C"; f3._name="C";
metaData._webFragmentNameMap.put(f3._name, f3); metaData._webFragmentNameMap.put(f3._name, f3);
metaData._webFragmentResourceMap.put(jar3,f3); metaData._webFragmentResourceMap.put(jar3,f3);
@ -861,7 +860,7 @@ public class OrderingTest extends TestCase
TestResource jar1 = new TestResource("A"); TestResource jar1 = new TestResource("A");
resources.add(jar1); resources.add(jar1);
TestResource r1 = new TestResource("A/web-fragment.xml"); TestResource r1 = new TestResource("A/web-fragment.xml");
FragmentDescriptor f1 = new FragmentDescriptor(r1, metaData); FragmentDescriptor f1 = new FragmentDescriptor(r1);
f1._name = "A"; f1._name = "A";
metaData._webFragmentNameMap.put(f1._name, f1); metaData._webFragmentNameMap.put(f1._name, f1);
metaData._webFragmentResourceMap.put(jar1,f1); metaData._webFragmentResourceMap.put(jar1,f1);
@ -869,7 +868,7 @@ public class OrderingTest extends TestCase
TestResource jar2 = new TestResource("B"); TestResource jar2 = new TestResource("B");
resources.add(jar2); resources.add(jar2);
TestResource r2 = new TestResource("B/web-fragment.xml"); TestResource r2 = new TestResource("B/web-fragment.xml");
FragmentDescriptor f2 = new FragmentDescriptor(r2, metaData); FragmentDescriptor f2 = new FragmentDescriptor(r2);
f2._name="B"; f2._name="B";
metaData._webFragmentNameMap.put(f2._name, f2); metaData._webFragmentNameMap.put(f2._name, f2);
metaData._webFragmentResourceMap.put(jar2, f2); metaData._webFragmentResourceMap.put(jar2, f2);
@ -877,7 +876,7 @@ public class OrderingTest extends TestCase
TestResource jar3 = new TestResource("C"); TestResource jar3 = new TestResource("C");
resources.add(jar3); resources.add(jar3);
TestResource r3 = new TestResource("C/web-fragment.xml"); TestResource r3 = new TestResource("C/web-fragment.xml");
FragmentDescriptor f3 = new FragmentDescriptor(r3, metaData); FragmentDescriptor f3 = new FragmentDescriptor(r3);
f3._name="C"; f3._name="C";
metaData._webFragmentNameMap.put(f3._name, f3); metaData._webFragmentNameMap.put(f3._name, f3);
metaData._webFragmentResourceMap.put(jar3, f3); metaData._webFragmentResourceMap.put(jar3, f3);
@ -885,7 +884,7 @@ public class OrderingTest extends TestCase
TestResource jar4 = new TestResource("D"); TestResource jar4 = new TestResource("D");
resources.add(jar4); resources.add(jar4);
TestResource r4 = new TestResource("D/web-fragment.xml"); TestResource r4 = new TestResource("D/web-fragment.xml");
FragmentDescriptor f4 = new FragmentDescriptor((Resource)null, metaData); FragmentDescriptor f4 = new FragmentDescriptor((Resource)null);
f4._name="D"; f4._name="D";
metaData._webFragmentNameMap.put(f4._name, f4); metaData._webFragmentNameMap.put(f4._name, f4);
metaData._webFragmentResourceMap.put(jar4, f4); metaData._webFragmentResourceMap.put(jar4, f4);
@ -893,7 +892,7 @@ public class OrderingTest extends TestCase
TestResource jar5 = new TestResource("E"); TestResource jar5 = new TestResource("E");
resources.add(jar5); resources.add(jar5);
TestResource r5 = new TestResource("E/web-fragment.xml"); TestResource r5 = new TestResource("E/web-fragment.xml");
FragmentDescriptor f5 = new FragmentDescriptor((Resource)null, metaData); FragmentDescriptor f5 = new FragmentDescriptor((Resource)null);
f5._name="E"; f5._name="E";
metaData._webFragmentNameMap.put(f5._name, f5); metaData._webFragmentNameMap.put(f5._name, f5);
metaData._webFragmentResourceMap.put(jar5, f5); metaData._webFragmentResourceMap.put(jar5, f5);
@ -901,7 +900,7 @@ public class OrderingTest extends TestCase
TestResource jar6 = new TestResource("plain"); TestResource jar6 = new TestResource("plain");
resources.add(jar6); resources.add(jar6);
TestResource r6 = new TestResource("plain/web-fragment.xml"); TestResource r6 = new TestResource("plain/web-fragment.xml");
FragmentDescriptor f6 = new FragmentDescriptor((Resource)null, metaData); FragmentDescriptor f6 = new FragmentDescriptor((Resource)null);
f6._name=FragmentDescriptor.NAMELESS+"1"; f6._name=FragmentDescriptor.NAMELESS+"1";
metaData._webFragmentNameMap.put(f6._name, f6); metaData._webFragmentNameMap.put(f6._name, f6);
metaData._webFragmentResourceMap.put(jar6, f6); metaData._webFragmentResourceMap.put(jar6, f6);

View File

@ -741,14 +741,15 @@ public class XmlParser
* @param tag The tag of the nodes. * @param tag The tag of the nodes.
* @return Iterator over all child nodes with the specified tag. * @return Iterator over all child nodes with the specified tag.
*/ */
public Iterator iterator(final String tag) public Iterator<Node> iterator(final String tag)
{ {
return new Iterator() return new Iterator<Node>()
{ {
int c = 0; int c = 0;
Node _node; Node _node;
/* -------------------------------------------------- */ /* -------------------------------------------------- */
@Override
public boolean hasNext() public boolean hasNext()
{ {
if (_node != null) if (_node != null)
@ -771,7 +772,8 @@ public class XmlParser
} }
/* -------------------------------------------------- */ /* -------------------------------------------------- */
public Object next() @Override
public Node next()
{ {
try try
{ {
@ -787,6 +789,7 @@ public class XmlParser
} }
/* -------------------------------------------------- */ /* -------------------------------------------------- */
@Override
public void remove() public void remove()
{ {
throw new UnsupportedOperationException("Not supported"); throw new UnsupportedOperationException("Not supported");

View File

@ -18,7 +18,6 @@ import java.lang.management.ManagementFactory;
import org.eclipse.jetty.jmx.MBeanContainer; import org.eclipse.jetty.jmx.MBeanContainer;
import org.eclipse.jetty.security.HashLoginService; import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NCSARequestLog; import org.eclipse.jetty.server.NCSARequestLog;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;