Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2016-01-12 20:47:12 -0500
committerGreg Wilkins2016-01-12 20:47:25 -0500
commite2a0794d91e91a810f23c1c0ea45249a62a19b11 (patch)
treebd3f4d214ad2e8c394b16a4b97519f12a103f76f /jetty-quickstart
parenta7b3a9f4816b25811a88840b830975b5704fa6fc (diff)
downloadorg.eclipse.jetty.project-e2a0794d91e91a810f23c1c0ea45249a62a19b11.tar.gz
org.eclipse.jetty.project-e2a0794d91e91a810f23c1c0ea45249a62a19b11.tar.xz
org.eclipse.jetty.project-e2a0794d91e91a810f23c1c0ea45249a62a19b11.zip
485712 - Quickstart web.xml is absolute
Diffstat (limited to 'jetty-quickstart')
-rw-r--r--jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartDescriptorGenerator.java42
-rw-r--r--jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartDescriptorProcessor.java9
2 files changed, 36 insertions, 15 deletions
diff --git a/jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartDescriptorGenerator.java b/jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartDescriptorGenerator.java
index 5db988d893..34c401222a 100644
--- a/jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartDescriptorGenerator.java
+++ b/jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartDescriptorGenerator.java
@@ -22,6 +22,9 @@ package org.eclipse.jetty.quickstart;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
import java.util.Collection;
import java.util.Collections;
import java.util.EventListener;
@@ -55,6 +58,7 @@ import org.eclipse.jetty.servlet.ServletMapping;
import org.eclipse.jetty.util.QuotedStringTokenizer;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
+import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.webapp.MetaData;
import org.eclipse.jetty.webapp.MetaData.OriginInfo;
@@ -128,16 +132,16 @@ public class QuickStartDescriptorGenerator
// Set some special context parameters
// The location of the war file on disk
- String resourceBase = _webApp.getBaseResource().getFile().getCanonicalFile().getAbsoluteFile().toURI().toString();
+ AttributeNormalizer normalizer = new AttributeNormalizer(_webApp.getBaseResource());
// The library order
addContextParamFromAttribute(out,ServletContext.ORDERED_LIBS);
//the servlet container initializers
addContextParamFromAttribute(out,AnnotationConfiguration.CONTAINER_INITIALIZERS);
//the tlds discovered
- addContextParamFromAttribute(out,MetaInfConfiguration.METAINF_TLDS,resourceBase);
+ addContextParamFromAttribute(out,MetaInfConfiguration.METAINF_TLDS,normalizer);
//the META-INF/resources discovered
- addContextParamFromAttribute(out,MetaInfConfiguration.METAINF_RESOURCES,resourceBase);
+ addContextParamFromAttribute(out,MetaInfConfiguration.METAINF_RESOURCES,normalizer);
// init params
@@ -515,7 +519,27 @@ public class QuickStartDescriptorGenerator
*/
private void addContextParamFromAttribute(XmlAppendable out, String attribute) throws IOException
{
- addContextParamFromAttribute(out,attribute,null);
+ Object o = _webApp.getAttribute(attribute);
+ if (o == null)
+ return;
+
+ Collection<?> c = (o instanceof Collection)? (Collection<?>)o:Collections.singletonList(o);
+ StringBuilder v=new StringBuilder();
+ for (Object i:c)
+ {
+ if (i!=null)
+ {
+ if (v.length()>0)
+ v.append(",\n ");
+ else
+ v.append("\n ");
+ QuotedStringTokenizer.quote(v,i.toString());
+ }
+ }
+ out.openTag("context-param")
+ .tag("param-name",attribute)
+ .tagCDATA("param-value",v.toString())
+ .closeTag();
}
/**
@@ -526,7 +550,7 @@ public class QuickStartDescriptorGenerator
* @param resourceBase
* @throws IOException
*/
- private void addContextParamFromAttribute(XmlAppendable out, String attribute, String resourceBase) throws IOException
+ private void addContextParamFromAttribute(XmlAppendable out, String attribute, AttributeNormalizer normalizer) throws IOException
{
Object o = _webApp.getAttribute(attribute);
if (o == null)
@@ -542,16 +566,14 @@ public class QuickStartDescriptorGenerator
v.append(",\n ");
else
v.append("\n ");
- if (resourceBase==null)
- QuotedStringTokenizer.quote(v,i.toString());
- else
- QuotedStringTokenizer.quote(v,i.toString().replace(resourceBase,"${WAR}/"));
+ QuotedStringTokenizer.quote(v,normalizer.normalize(i));
}
}
out.openTag("context-param")
.tag("param-name",attribute)
.tagCDATA("param-value",v.toString())
- .closeTag();
+ .closeTag();
+
}
/**
diff --git a/jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartDescriptorProcessor.java b/jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartDescriptorProcessor.java
index 924b0dd5f9..35d41ea17a 100644
--- a/jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartDescriptorProcessor.java
+++ b/jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartDescriptorProcessor.java
@@ -99,6 +99,7 @@ public class QuickStartDescriptorProcessor extends IterativeDescriptorProcessor
values.add(value);
}
+ AttributeNormalizer normalizer = new AttributeNormalizer(context.getBaseResource());
// handle values
switch(name)
{
@@ -125,15 +126,14 @@ public class QuickStartDescriptorProcessor extends IterativeDescriptorProcessor
case MetaInfConfiguration.METAINF_TLDS:
{
List<Object> tlds = new ArrayList<>();
- String war=context.getBaseResource().getURI().toString();
Object o=context.getAttribute(MetaInfConfiguration.METAINF_TLDS);
if (o instanceof Collection<?>)
tlds.addAll((Collection<?>)o);
for (String i : values)
{
- Resource r = Resource.newResource(i.replace("${WAR}/",war));
+ Resource r = Resource.newResource(normalizer.expand(i));
if (r.exists())
- tlds.add(r.getURL());
+ tlds.add(r.getURI().toURL());
else
throw new IllegalArgumentException("TLD not found: "+r);
}
@@ -145,10 +145,9 @@ public class QuickStartDescriptorProcessor extends IterativeDescriptorProcessor
case MetaInfConfiguration.METAINF_RESOURCES:
{
- String war=context.getBaseResource().getURI().toString();
for (String i : values)
{
- Resource r = Resource.newResource(i.replace("${WAR}/",war));
+ Resource r = Resource.newResource(normalizer.expand(i));
if (r.exists())
visitMetaInfResource(context,r);
else

Back to the top