Merge branch 'master' into javawebsocket-jsr
This commit is contained in:
commit
3464f4c374
|
@ -55,6 +55,11 @@
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-plus</artifactId>
|
<artifactId>jetty-plus</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-proxy</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -84,6 +84,7 @@ public class DeploymentManagerTest
|
||||||
{
|
{
|
||||||
jetty = new XmlConfiguredJetty(testdir);
|
jetty = new XmlConfiguredJetty(testdir);
|
||||||
jetty.addConfiguration("jetty.xml");
|
jetty.addConfiguration("jetty.xml");
|
||||||
|
jetty.addConfiguration("jetty-http.xml");
|
||||||
jetty.addConfiguration("jetty-deploymgr-contexts.xml");
|
jetty.addConfiguration("jetty-deploymgr-contexts.xml");
|
||||||
|
|
||||||
// Should not throw an Exception
|
// Should not throw an Exception
|
||||||
|
|
|
@ -53,6 +53,7 @@ public class GlobalWebappConfigBindingTest
|
||||||
{
|
{
|
||||||
jetty = new XmlConfiguredJetty(testdir);
|
jetty = new XmlConfiguredJetty(testdir);
|
||||||
jetty.addConfiguration("jetty.xml");
|
jetty.addConfiguration("jetty.xml");
|
||||||
|
jetty.addConfiguration("jetty-http.xml");
|
||||||
|
|
||||||
// Setup initial context
|
// Setup initial context
|
||||||
jetty.copyWebapp("foo.xml","foo.xml");
|
jetty.copyWebapp("foo.xml","foo.xml");
|
||||||
|
|
|
@ -54,6 +54,7 @@ public class ScanningAppProviderRuntimeUpdatesTest
|
||||||
{
|
{
|
||||||
jetty = new XmlConfiguredJetty(testdir);
|
jetty = new XmlConfiguredJetty(testdir);
|
||||||
jetty.addConfiguration("jetty.xml");
|
jetty.addConfiguration("jetty.xml");
|
||||||
|
jetty.addConfiguration("jetty-http.xml");
|
||||||
jetty.addConfiguration("jetty-deploymgr-contexts.xml");
|
jetty.addConfiguration("jetty-deploymgr-contexts.xml");
|
||||||
|
|
||||||
// Should not throw an Exception
|
// Should not throw an Exception
|
||||||
|
|
|
@ -39,6 +39,7 @@ public class ScanningAppProviderStartupTest
|
||||||
{
|
{
|
||||||
jetty = new XmlConfiguredJetty(testdir);
|
jetty = new XmlConfiguredJetty(testdir);
|
||||||
jetty.addConfiguration("jetty.xml");
|
jetty.addConfiguration("jetty.xml");
|
||||||
|
jetty.addConfiguration("jetty-http.xml");
|
||||||
jetty.addConfiguration("jetty-deploymgr-contexts.xml");
|
jetty.addConfiguration("jetty-deploymgr-contexts.xml");
|
||||||
|
|
||||||
// Setup initial context
|
// Setup initial context
|
||||||
|
|
|
@ -40,6 +40,7 @@ public class WebAppProviderTest
|
||||||
{
|
{
|
||||||
jetty = new XmlConfiguredJetty(testdir);
|
jetty = new XmlConfiguredJetty(testdir);
|
||||||
jetty.addConfiguration("jetty.xml");
|
jetty.addConfiguration("jetty.xml");
|
||||||
|
jetty.addConfiguration("jetty-http.xml");
|
||||||
jetty.addConfiguration("jetty-deploy-wars.xml");
|
jetty.addConfiguration("jetty-deploy-wars.xml");
|
||||||
|
|
||||||
// Setup initial context
|
// Setup initial context
|
||||||
|
|
|
@ -9,13 +9,18 @@
|
||||||
<Ref refid="Contexts" />
|
<Ref refid="Contexts" />
|
||||||
</Set>
|
</Set>
|
||||||
|
|
||||||
<!-- Providers of Apps -->
|
<Call name="setContextAttribute">
|
||||||
<Set name="appProviders">
|
<Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
|
||||||
<Array type="org.eclipse.jetty.deploy.AppProvider">
|
<Arg>.*/servlet-api-[^/]*\.jar$</Arg>
|
||||||
<Item>
|
</Call>
|
||||||
<New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
|
|
||||||
<Set name="monitoredDirName"><SystemProperty name="jetty.home" />/webapps</Set>
|
<Call id="webappprovider" name="addAppProvider">
|
||||||
|
<Arg>
|
||||||
|
<New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
|
||||||
|
<Set name="monitoredDirName"><Property name="jetty.home" default="." />/webapps</Set>
|
||||||
|
<Set name="defaultsDescriptor"><Property name="jetty.home" default="." />/etc/webdefault.xml</Set>
|
||||||
<Set name="scanInterval">1</Set>
|
<Set name="scanInterval">1</Set>
|
||||||
|
<Set name="extractWars">true</Set>
|
||||||
<Set name="configurationManager">
|
<Set name="configurationManager">
|
||||||
<New class="org.eclipse.jetty.deploy.PropertiesConfigurationManager">
|
<New class="org.eclipse.jetty.deploy.PropertiesConfigurationManager">
|
||||||
<Set name="file">
|
<Set name="file">
|
||||||
|
@ -23,10 +28,10 @@
|
||||||
</Set>
|
</Set>
|
||||||
</New>
|
</New>
|
||||||
</Set>
|
</Set>
|
||||||
</New>
|
</New>
|
||||||
</Item>
|
</Arg>
|
||||||
</Array>
|
</Call>
|
||||||
</Set>
|
|
||||||
</New>
|
</New>
|
||||||
</Arg>
|
</Arg>
|
||||||
</Call>
|
</Call>
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
|
||||||
|
|
||||||
|
<!-- ============================================================= -->
|
||||||
|
<!-- Configure the Jetty Server instance with an ID "Server" -->
|
||||||
|
<!-- by adding a HTTP connector. -->
|
||||||
|
<!-- This configuration must be used in conjunction with jetty.xml -->
|
||||||
|
<!-- ============================================================= -->
|
||||||
|
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
||||||
|
|
||||||
|
<!-- =========================================================== -->
|
||||||
|
<!-- Add a HTTP Connector. -->
|
||||||
|
<!-- Configure an o.e.j.server.ServerConnector with a single -->
|
||||||
|
<!-- HttpConnectionFactory instance using the common httpConfig -->
|
||||||
|
<!-- instance defined in jetty.xml -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- Consult the javadoc of o.e.j.server.ServerConnector and -->
|
||||||
|
<!-- o.e.j.server.HttpConnectionFactory for all configuration -->
|
||||||
|
<!-- that may be set here. -->
|
||||||
|
<!-- =========================================================== -->
|
||||||
|
<Call name="addConnector">
|
||||||
|
<Arg>
|
||||||
|
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||||
|
<Arg name="server"><Ref refid="Server" /></Arg>
|
||||||
|
<Arg name="factories">
|
||||||
|
<Array type="org.eclipse.jetty.server.ConnectionFactory">
|
||||||
|
<Item>
|
||||||
|
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
|
||||||
|
<Arg name="config"><Ref refid="httpConfig" /></Arg>
|
||||||
|
</New>
|
||||||
|
</Item>
|
||||||
|
</Array>
|
||||||
|
</Arg>
|
||||||
|
<Set name="host"></Set>
|
||||||
|
<Set name="port">0</Set>
|
||||||
|
<Set name="idleTimeout">300000</Set>
|
||||||
|
</New>
|
||||||
|
</Arg>
|
||||||
|
</Call>
|
||||||
|
|
||||||
|
</Configure>
|
|
@ -2,54 +2,108 @@
|
||||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
|
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
|
||||||
|
|
||||||
<!-- =============================================================== -->
|
<!-- =============================================================== -->
|
||||||
<!-- Configure the Jetty Server -->
|
|
||||||
<!-- -->
|
|
||||||
<!-- Documentation of this file format can be found at: -->
|
<!-- Documentation of this file format can be found at: -->
|
||||||
<!-- http://docs.codehaus.org/display/JETTY/jetty.xml -->
|
<!-- http://wiki.eclipse.org/Jetty/Reference/jetty.xml_syntax -->
|
||||||
<!-- -->
|
<!-- -->
|
||||||
|
<!-- Additional configuration files are available in $JETTY_HOME/etc -->
|
||||||
|
<!-- and can be mixed in. See start.ini file for the default -->
|
||||||
|
<!-- configuration files. -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- For a description of the configuration mechanism, see the -->
|
||||||
|
<!-- output of: -->
|
||||||
|
<!-- java -jar start.jar -? -->
|
||||||
<!-- =============================================================== -->
|
<!-- =============================================================== -->
|
||||||
|
|
||||||
|
<!-- =============================================================== -->
|
||||||
|
<!-- Configure a Jetty Server instance with an ID "Server" -->
|
||||||
|
<!-- Other configuration files may also configure the "Server" -->
|
||||||
|
<!-- ID, in which case they are adding configuration to the same -->
|
||||||
|
<!-- instance. If other configuration have a different ID, they -->
|
||||||
|
<!-- will create and configure another instance of Jetty. -->
|
||||||
|
<!-- Consult the javadoc of o.e.j.server.Server for all -->
|
||||||
|
<!-- configuration that may be set here. -->
|
||||||
|
<!-- =============================================================== -->
|
||||||
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
||||||
|
|
||||||
<!-- =========================================================== -->
|
<!-- =========================================================== -->
|
||||||
<!-- Server Thread Pool -->
|
<!-- Configure the Server Thread Pool. -->
|
||||||
|
<!-- The server holds a common thread pool which is used by -->
|
||||||
|
<!-- default as the executor used by all connectors and servlet -->
|
||||||
|
<!-- dispatches. -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- Configuring a fixed thread pool is vital to controlling the -->
|
||||||
|
<!-- maximal memory footprint of the server and is a key tuning -->
|
||||||
|
<!-- parameter for tuning. In an application that rarely blocks -->
|
||||||
|
<!-- then maximal threads may be close to the number of 5*CPUs. -->
|
||||||
|
<!-- In an application that frequently blocks, then maximal -->
|
||||||
|
<!-- threads should be set as high as possible given the memory -->
|
||||||
|
<!-- available. -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- Consult the javadoc of o.e.j.util.thread.QueuedThreadPool -->
|
||||||
|
<!-- for all configuration that may be set here. -->
|
||||||
<!-- =========================================================== -->
|
<!-- =========================================================== -->
|
||||||
|
<!-- uncomment to change type of threadpool
|
||||||
|
<Arg name="threadpool"><New id="threadpool" class="org.eclipse.jetty.util.thread.QueuedThreadPool"/></Arg>
|
||||||
|
-->
|
||||||
<Get name="ThreadPool">
|
<Get name="ThreadPool">
|
||||||
<Set name="minThreads" type="int">10</Set>
|
<Set name="minThreads" type="int"><Property name="threads.min" default="10"/></Set>
|
||||||
<Set name="maxThreads" type="int">200</Set>
|
<Set name="maxThreads" type="int"><Property name="threads.max" default="200"/></Set>
|
||||||
|
<Set name="idleTimeout" type="int"><Property name="threads.timeout" default="60000"/></Set>
|
||||||
|
<Set name="detailedDump">false</Set>
|
||||||
</Get>
|
</Get>
|
||||||
|
|
||||||
<!-- =========================================================== -->
|
<!-- =========================================================== -->
|
||||||
<!-- Set connectors -->
|
<!-- Add shared Scheduler instance -->
|
||||||
<!-- =========================================================== -->
|
<!-- =========================================================== -->
|
||||||
|
<Call name="addBean">
|
||||||
<Call name="addConnector">
|
|
||||||
<Arg>
|
<Arg>
|
||||||
<New class="org.eclipse.jetty.server.ServerConnector">
|
<New class="org.eclipse.jetty.util.thread.ScheduledExecutorScheduler"/>
|
||||||
<Arg><Ref refid="Server" /></Arg>
|
|
||||||
<Set name="host"></Set>
|
|
||||||
<Set name="port">0</Set>
|
|
||||||
<Set name="idleTimeout">300000</Set>
|
|
||||||
</New>
|
|
||||||
</Arg>
|
</Arg>
|
||||||
</Call>
|
</Call>
|
||||||
|
|
||||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
<!-- =========================================================== -->
|
||||||
<!-- To add a HTTPS SSL connector -->
|
<!-- Http Configuration. -->
|
||||||
<!-- mixin jetty-ssl.xml: -->
|
<!-- This is a common configuration instance used by all -->
|
||||||
<!-- java -jar start.jar etc/jetty-ssl.xml -->
|
<!-- connectors that can carry HTTP semantics (HTTP, HTTPS, SPDY)-->
|
||||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
<!-- It configures the non wire protocol aspects of the HTTP -->
|
||||||
|
<!-- semantic. -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- This configuration is only defined here and is used by -->
|
||||||
|
<!-- reference from the jetty-http.xml, jetty-https.xml and -->
|
||||||
|
<!-- jetty-spdy.xml configuration files which instantiate the -->
|
||||||
|
<!-- connectors. -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- Consult the javadoc of o.e.j.server.HttpConfiguration -->
|
||||||
|
<!-- for all configuration that may be set here. -->
|
||||||
|
<!-- =========================================================== -->
|
||||||
|
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
||||||
|
<Set name="secureScheme">https</Set>
|
||||||
|
<Set name="securePort" type="java.lang.Integer"><Property name="jetty.secure.port" default="8443" /></Set>
|
||||||
|
<Set name="outputBufferSize">32768</Set>
|
||||||
|
<Set name="requestHeaderSize">8192</Set>
|
||||||
|
<Set name="responseHeaderSize">8192</Set>
|
||||||
|
<Set name="sendServerVersion">true</Set>
|
||||||
|
<Set name="sendDateHeader">false</Set>
|
||||||
|
<Set name="headerCacheSize">512</Set>
|
||||||
|
|
||||||
|
<!-- Uncomment to enable handling of X-Forwarded- style headers
|
||||||
|
<Call name="addCustomizer">
|
||||||
|
<Arg><New class="org.eclipse.jetty.server.ForwardedRequestCustomizer"/></Arg>
|
||||||
|
</Call>
|
||||||
|
-->
|
||||||
|
</New>
|
||||||
|
|
||||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
||||||
<!-- To allow Jetty to be started from xinetd -->
|
|
||||||
<!-- mixin jetty-xinetd.xml: -->
|
|
||||||
<!-- java -jar start.jar etc/jetty-xinetd.xml -->
|
|
||||||
<!-- -->
|
|
||||||
<!-- See jetty-xinetd.xml for further instructions. -->
|
|
||||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
||||||
|
|
||||||
<!-- =========================================================== -->
|
<!-- =========================================================== -->
|
||||||
<!-- Set handler Collection Structure -->
|
<!-- Set the default handler structure for the Server -->
|
||||||
|
<!-- A handler collection is used to pass received requests to -->
|
||||||
|
<!-- both the ContextHandlerCollection, which selects the next -->
|
||||||
|
<!-- handler by context path and virtual host, and the -->
|
||||||
|
<!-- DefaultHandler, which handles any requests not handled by -->
|
||||||
|
<!-- the context handlers. -->
|
||||||
|
<!-- Other handlers may be added to the "Handlers" collection, -->
|
||||||
|
<!-- for example the jetty-requestlog.xml file adds the -->
|
||||||
|
<!-- RequestLogHandler after the default handler -->
|
||||||
<!-- =========================================================== -->
|
<!-- =========================================================== -->
|
||||||
<Set name="handler">
|
<Set name="handler">
|
||||||
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
|
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
|
||||||
|
@ -61,56 +115,17 @@
|
||||||
<Item>
|
<Item>
|
||||||
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
||||||
</Item>
|
</Item>
|
||||||
<Item>
|
|
||||||
<New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
|
|
||||||
</Item>
|
|
||||||
</Array>
|
</Array>
|
||||||
</Set>
|
</Set>
|
||||||
</New>
|
</New>
|
||||||
</Set>
|
</Set>
|
||||||
|
|
||||||
<!-- =========================================================== -->
|
<!-- =========================================================== -->
|
||||||
<!-- Configure Authentication Login Service -->
|
<!-- extra server options -->
|
||||||
<!-- Realms may be configured for the entire server here, or -->
|
|
||||||
<!-- they can be configured for a specific web app in a context -->
|
|
||||||
<!-- configuration (see $(jetty.home)/contexts/test.xml for an -->
|
|
||||||
<!-- example). -->
|
|
||||||
<!-- =========================================================== -->
|
|
||||||
<Call name="addBean">
|
|
||||||
<Arg>
|
|
||||||
<New class="org.eclipse.jetty.security.HashLoginService">
|
|
||||||
<Set name="name">Test Realm</Set>
|
|
||||||
<Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
|
|
||||||
<Set name="refreshInterval">0</Set>
|
|
||||||
</New>
|
|
||||||
</Arg>
|
|
||||||
</Call>
|
|
||||||
|
|
||||||
<!-- =========================================================== -->
|
|
||||||
<!-- Configure Request Log -->
|
|
||||||
<!-- Request logs may be configured for the entire server here, -->
|
|
||||||
<!-- or they can be configured for a specific web app in a -->
|
|
||||||
<!-- contexts configuration (see $(jetty.home)/contexts/test.xml -->
|
|
||||||
<!-- for an example). -->
|
|
||||||
<!-- =========================================================== -->
|
|
||||||
<Ref refid="RequestLog">
|
|
||||||
<Set name="requestLog">
|
|
||||||
<New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
|
|
||||||
<Set name="filename"><SystemProperty name="jetty.home" default="."/>/logs/yyyy_mm_dd.request.log</Set>
|
|
||||||
<Set name="filenameDateFormat">yyyy_MM_dd</Set>
|
|
||||||
<Set name="retainDays">90</Set>
|
|
||||||
<Set name="append">true</Set>
|
|
||||||
<Set name="extended">false</Set>
|
|
||||||
<Set name="logCookies">false</Set>
|
|
||||||
<Set name="LogTimeZone">GMT</Set>
|
|
||||||
</New>
|
|
||||||
</Set>
|
|
||||||
</Ref>
|
|
||||||
|
|
||||||
<!-- =========================================================== -->
|
|
||||||
<!-- extra options -->
|
|
||||||
<!-- =========================================================== -->
|
<!-- =========================================================== -->
|
||||||
<Set name="stopAtShutdown">true</Set>
|
<Set name="stopAtShutdown">true</Set>
|
||||||
<Set name="stopTimeout">1000</Set>
|
<Set name="stopTimeout">5000</Set>
|
||||||
|
<Set name="dumpAfterStart"><Property name="jetty.dump.start" default="false"/></Set>
|
||||||
|
<Set name="dumpBeforeStop"><Property name="jetty.dump.stop" default="false"/></Set>
|
||||||
|
|
||||||
</Configure>
|
</Configure>
|
||||||
|
|
|
@ -742,37 +742,40 @@ public class XmlConfiguration
|
||||||
{
|
{
|
||||||
Class<?> oClass = nodeClass(node);
|
Class<?> oClass = nodeClass(node);
|
||||||
int argIndex = node.size();
|
int argIndex = node.size();
|
||||||
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"))
|
|
||||||
{
|
|
||||||
argIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Object> namedArgMap = new HashMap<>();
|
Map<String, Object> namedArgMap = new HashMap<>();
|
||||||
List<Object> arguments = new LinkedList<>();
|
List<Object> arguments = new LinkedList<>();
|
||||||
|
XmlParser.Node child;
|
||||||
|
|
||||||
|
// Find the <Arg> elements
|
||||||
for (int i = 0; i < node.size(); i++)
|
for (int i = 0; i < node.size(); i++)
|
||||||
{
|
{
|
||||||
Object o = node.get(i);
|
Object o = node.get(i);
|
||||||
|
|
||||||
if (o instanceof String)
|
if (o instanceof String)
|
||||||
{
|
{
|
||||||
|
// Skip raw String nodes
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlParser.Node argNode = (XmlParser.Node)o;
|
child = (XmlParser.Node)o;
|
||||||
|
if(child.getTag().equals("Arg"))
|
||||||
String namedAttribute = argNode.getAttribute("name");
|
{
|
||||||
Object value=value(obj,(XmlParser.Node)o);
|
String namedAttribute = child.getAttribute("name");
|
||||||
if (namedAttribute != null)
|
Object value=value(obj,child);
|
||||||
namedArgMap.put(namedAttribute,value);
|
if (namedAttribute != null)
|
||||||
arguments.add(value);
|
{
|
||||||
|
// named arguments
|
||||||
|
namedArgMap.put(namedAttribute,value);
|
||||||
|
}
|
||||||
|
// raw arguments
|
||||||
|
arguments.add(value);
|
||||||
|
} else {
|
||||||
|
// The first non <Arg> child is the start of
|
||||||
|
// elements that configure the class, such as
|
||||||
|
// <Set> and <Call> nodes
|
||||||
|
argIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -552,10 +552,10 @@ public class XmlConfigurationTest
|
||||||
" <Arg>arg2</Arg> " +
|
" <Arg>arg2</Arg> " +
|
||||||
" <Arg>arg3</Arg> " +
|
" <Arg>arg3</Arg> " +
|
||||||
" <Set name=\"nested\"> " +
|
" <Set name=\"nested\"> " +
|
||||||
" <New class=\"org.eclipse.jetty.xml.AnnotatedTestConfiguration\">\n" +
|
" <New class=\"org.eclipse.jetty.xml.AnnotatedTestConfiguration\">\n" +
|
||||||
" <Arg>arg1</Arg>\n" +
|
" <Arg>arg1</Arg>\n" +
|
||||||
" <Arg>arg2</Arg>\n" +
|
" <Arg>arg2</Arg>\n" +
|
||||||
" <Arg>arg3</Arg>\n" +
|
" <Arg>arg3</Arg>\n" +
|
||||||
" </New>" +
|
" </New>" +
|
||||||
" </Set>" +
|
" </Set>" +
|
||||||
"</Configure>").getBytes("ISO-8859-1")));
|
"</Configure>").getBytes("ISO-8859-1")));
|
||||||
|
@ -571,6 +571,34 @@ public class XmlConfigurationTest
|
||||||
Assert.assertEquals("nested third parameter not wired correctly","arg3", atc.getNested().getThird());
|
Assert.assertEquals("nested third parameter not wired correctly","arg3", atc.getNested().getThird());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetGetIgnoredMissingDTD() throws Exception
|
||||||
|
{
|
||||||
|
XmlConfiguration xmlConfiguration = new XmlConfiguration(new ByteArrayInputStream(("" +
|
||||||
|
"<Configure class=\"org.eclipse.jetty.xml.DefaultTestConfiguration\">" +
|
||||||
|
" <Set name=\"first\">arg1</Set> " +
|
||||||
|
" <Set name=\"second\">arg2</Set> " +
|
||||||
|
" <Set name=\"third\">arg3</Set> " +
|
||||||
|
" <Set name=\"nested\"> " +
|
||||||
|
" <New class=\"org.eclipse.jetty.xml.DefaultTestConfiguration\">\n" +
|
||||||
|
" <Set name=\"first\">arg1</Set> " +
|
||||||
|
" <Set name=\"second\">arg2</Set> " +
|
||||||
|
" <Set name=\"third\">arg3</Set> " +
|
||||||
|
" </New>" +
|
||||||
|
" </Set>" +
|
||||||
|
"</Configure>").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
|
@Test
|
||||||
public void testNestedConstructorNamedInjectionUnorderedMixed() throws Exception
|
public void testNestedConstructorNamedInjectionUnorderedMixed() throws Exception
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue