diff --git a/examples/embedded/pom.xml b/examples/embedded/pom.xml index 8ee3c4a090c..7b70eb04614 100644 --- a/examples/embedded/pom.xml +++ b/examples/embedded/pom.xml @@ -55,6 +55,11 @@ org.eclipse.jetty jetty-plus ${project.version} + + + org.eclipse.jetty + jetty-proxy + ${project.version} org.eclipse.jetty.toolchain diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ProxyServer.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ProxyServer.java new file mode 100644 index 00000000000..e7aead73beb --- /dev/null +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ProxyServer.java @@ -0,0 +1,49 @@ +// +// ======================================================================== +// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.embedded; + +import org.eclipse.jetty.proxy.ConnectHandler; +import org.eclipse.jetty.proxy.ProxyServlet; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; + +public class ProxyServer +{ + public static void main(String[] args) throws Exception + { + Server server = new Server(); + ServerConnector connector = new ServerConnector(server); + connector.setPort(8888); + + // Setup proxy handler to handle CONNECT methods + ConnectHandler proxy = new ConnectHandler(); + server.setHandler(proxy); + + // Setup proxy servlet + ServletContextHandler context = new ServletContextHandler(proxy, "/", ServletContextHandler.SESSIONS); + ServletHolder proxyServlet = new ServletHolder(ProxyServlet.class); + proxyServlet.setInitParameter("blackList", "www.eclipse.org"); + context.addServlet(proxyServlet, "/*"); + + server.start(); + } + +} diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerTest.java index c7d85200ab4..c1998a2761f 100644 --- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerTest.java +++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerTest.java @@ -84,6 +84,7 @@ public class DeploymentManagerTest { jetty = new XmlConfiguredJetty(testdir); jetty.addConfiguration("jetty.xml"); + jetty.addConfiguration("jetty-http.xml"); jetty.addConfiguration("jetty-deploymgr-contexts.xml"); // Should not throw an Exception diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/bindings/GlobalWebappConfigBindingTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/bindings/GlobalWebappConfigBindingTest.java index 1b2741a4473..b258b2605a3 100644 --- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/bindings/GlobalWebappConfigBindingTest.java +++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/bindings/GlobalWebappConfigBindingTest.java @@ -53,6 +53,7 @@ public class GlobalWebappConfigBindingTest { jetty = new XmlConfiguredJetty(testdir); jetty.addConfiguration("jetty.xml"); + jetty.addConfiguration("jetty-http.xml"); // Setup initial context jetty.copyWebapp("foo.xml","foo.xml"); diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java index 0879ed7a78a..513a8c91df3 100644 --- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java +++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java @@ -54,6 +54,7 @@ public class ScanningAppProviderRuntimeUpdatesTest { jetty = new XmlConfiguredJetty(testdir); jetty.addConfiguration("jetty.xml"); + jetty.addConfiguration("jetty-http.xml"); jetty.addConfiguration("jetty-deploymgr-contexts.xml"); // Should not throw an Exception diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderStartupTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderStartupTest.java index f361d5da9f3..cfac205961e 100644 --- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderStartupTest.java +++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderStartupTest.java @@ -39,6 +39,7 @@ public class ScanningAppProviderStartupTest { jetty = new XmlConfiguredJetty(testdir); jetty.addConfiguration("jetty.xml"); + jetty.addConfiguration("jetty-http.xml"); jetty.addConfiguration("jetty-deploymgr-contexts.xml"); // Setup initial context diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java index a734718ba13..f76b80a4cb5 100644 --- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java +++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java @@ -40,6 +40,7 @@ public class WebAppProviderTest { jetty = new XmlConfiguredJetty(testdir); jetty.addConfiguration("jetty.xml"); + jetty.addConfiguration("jetty-http.xml"); jetty.addConfiguration("jetty-deploy-wars.xml"); // Setup initial context diff --git a/jetty-deploy/src/test/resources/jetty-deploymgr-contexts.xml b/jetty-deploy/src/test/resources/jetty-deploymgr-contexts.xml index 04cfa34ac60..8d55d22010c 100644 --- a/jetty-deploy/src/test/resources/jetty-deploymgr-contexts.xml +++ b/jetty-deploy/src/test/resources/jetty-deploymgr-contexts.xml @@ -8,14 +8,19 @@ - - - - - - - /webapps + + + org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern + .*/servlet-api-[^/]*\.jar$ + + + + + + /webapps + /etc/webdefault.xml 1 + true @@ -23,10 +28,10 @@ - - - - + + + + diff --git a/jetty-deploy/src/test/resources/jetty-http.xml b/jetty-deploy/src/test/resources/jetty-http.xml new file mode 100644 index 00000000000..42b889b3830 --- /dev/null +++ b/jetty-deploy/src/test/resources/jetty-http.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 300000 + + + + + diff --git a/jetty-deploy/src/test/resources/jetty.xml b/jetty-deploy/src/test/resources/jetty.xml index 732adfb3f74..25332f61255 100644 --- a/jetty-deploy/src/test/resources/jetty.xml +++ b/jetty-deploy/src/test/resources/jetty.xml @@ -2,54 +2,108 @@ - - - + + + + + + + + - + + + + + + + + + + - + + + + + + + + + + + + + + + + - 10 - 200 + + + + false - + - - + - - - - 0 - 300000 - + - - - - - + + + + + + + + + + + + + + + + + https + + 32768 + 8192 + 8192 + true + false + 512 + + + - - - - - - - - + + + + + + + + + @@ -61,56 +115,17 @@ - - - - - - - - - - - - - Test Realm - /etc/realm.properties - 0 - - - - - - - - - - - - - - - /logs/yyyy_mm_dd.request.log - yyyy_MM_dd - 90 - true - false - false - GMT - - - - - - + true - 1000 + 5000 + + diff --git a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java index fc798536913..f68a308b3ae 100644 --- a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java +++ b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java @@ -742,39 +742,42 @@ public class XmlConfiguration { Class oClass = nodeClass(node); int argIndex = node.size(); + + Map namedArgMap = new HashMap<>(); + List arguments = new LinkedList<>(); + XmlParser.Node child; + + // Find the elements for (int i = 0; i < node.size(); i++) { Object o = node.get(i); if (o instanceof String) - continue; - if (!((XmlParser.Node)o).getTag().equals("Arg")) { + // Skip raw String nodes + continue; + } + + child = (XmlParser.Node)o; + if(child.getTag().equals("Arg")) + { + String namedAttribute = child.getAttribute("name"); + Object value=value(obj,child); + if (namedAttribute != null) + { + // named arguments + namedArgMap.put(namedAttribute,value); + } + // raw arguments + arguments.add(value); + } else { + // The first non child is the start of + // elements that configure the class, such as + // and nodes argIndex = i; break; } } - Map namedArgMap = new HashMap<>(); - List arguments = new LinkedList<>(); - - for (int i = 0; i < node.size(); i++) - { - Object o = node.get(i); - - if (o instanceof String) - { - continue; - } - - XmlParser.Node argNode = (XmlParser.Node)o; - - String namedAttribute = argNode.getAttribute("name"); - Object value=value(obj,(XmlParser.Node)o); - if (namedAttribute != null) - namedArgMap.put(namedAttribute,value); - arguments.add(value); - } - if (LOG.isDebugEnabled()) LOG.debug("XML new " + oClass); diff --git a/jetty-xml/src/test/java/org/eclipse/jetty/xml/DefaultTestConfiguration.java b/jetty-xml/src/test/java/org/eclipse/jetty/xml/DefaultTestConfiguration.java new file mode 100644 index 00000000000..40c0927b89a --- /dev/null +++ b/jetty-xml/src/test/java/org/eclipse/jetty/xml/DefaultTestConfiguration.java @@ -0,0 +1,74 @@ +// +// ======================================================================== +// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.xml; + +public class DefaultTestConfiguration +{ + private String first; + private String second; + private String third; + + DefaultTestConfiguration nested; + + public DefaultTestConfiguration() + { + /* default constructor */ + } + + public String getFirst() + { + return first; + } + + public void setFirst(String first) + { + this.first = first; + } + + public String getSecond() + { + return second; + } + + public void setSecond(String second) + { + this.second = second; + } + + public String getThird() + { + return third; + } + + public void setThird(String third) + { + this.third = third; + } + + public DefaultTestConfiguration getNested() + { + return nested; + } + + public void setNested(DefaultTestConfiguration nested) + { + this.nested = nested; + } + +} diff --git a/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java b/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java index 22267cfdd4d..f4b76f1fca2 100644 --- a/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java +++ b/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java @@ -552,10 +552,10 @@ public class XmlConfigurationTest " arg2 " + " arg3 " + " " + - " \n" + - " arg1\n" + - " arg2\n" + - " arg3\n" + + " \n" + + " arg1\n" + + " arg2\n" + + " arg3\n" + " " + " " + "").getBytes("ISO-8859-1"))); @@ -571,6 +571,34 @@ public class XmlConfigurationTest Assert.assertEquals("nested third parameter not wired correctly","arg3", atc.getNested().getThird()); } + @Test + public void testSetGetIgnoredMissingDTD() throws Exception + { + XmlConfiguration xmlConfiguration = new XmlConfiguration(new ByteArrayInputStream(("" + + "" + + " arg1 " + + " arg2 " + + " arg3 " + + " " + + " \n" + + " arg1 " + + " arg2 " + + " arg3 " + + " " + + " " + + "").getBytes("ISO-8859-1"))); +// XmlConfiguration xmlConfiguration = new XmlConfiguration(url); + + DefaultTestConfiguration atc = (DefaultTestConfiguration)xmlConfiguration.configure(); + + Assert.assertEquals("first parameter not wired correctly","arg1", atc.getFirst()); + Assert.assertEquals("second parameter not wired correctly","arg2", atc.getSecond()); + Assert.assertEquals("third parameter not wired correctly","arg3", atc.getThird()); + Assert.assertEquals("nested first parameter not wired correctly","arg1", atc.getNested().getFirst()); + Assert.assertEquals("nested second parameter not wired correctly","arg2", atc.getNested().getSecond()); + Assert.assertEquals("nested third parameter not wired correctly","arg3", atc.getNested().getThird()); + } + @Test public void testNestedConstructorNamedInjectionUnorderedMixed() throws Exception {