Updated jetty-spring module.
This commit is contained in:
parent
dd180a8c48
commit
a5df0ab456
|
@ -1,5 +0,0 @@
|
|||
This jetty module is an example of how spring can be used to
|
||||
configure and run Jetty.
|
||||
|
||||
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<name>Example :: Jetty Spring</name>
|
||||
|
||||
<properties>
|
||||
<spring-version>2.5.6</spring-version>
|
||||
<spring-version>3.1.3.RELEASE</spring-version>
|
||||
<dependencies>target/dependencies</dependencies>
|
||||
</properties>
|
||||
|
||||
|
@ -38,24 +38,25 @@
|
|||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-webapp</artifactId>
|
||||
<artifactId>jetty-xml</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-plus</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-deploy</artifactId>
|
||||
<artifactId>jetty-util</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring</artifactId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
<version>${spring-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-test-helper</artifactId>
|
||||
|
|
|
@ -5,32 +5,24 @@
|
|||
<!-- Configure the Jetty Server with Spring -->
|
||||
<!-- This file is the similar to jetty.xml, but written in spring -->
|
||||
<!-- XmlBeanFactory format. -->
|
||||
<!-- -->
|
||||
<!-- This file may be run with: -->
|
||||
<!-- java -jar start.jar OPTIONS=Server,spring \ -->
|
||||
<!-- start.class=org.eclipse.jetty.spring.Main \ -->
|
||||
<!-- etc/jetty-spring.xml -->
|
||||
<!-- -->
|
||||
<!-- The spring and commons-logging jars may need to be added -->
|
||||
<!-- to the classpath -->
|
||||
<!-- =============================================================== -->
|
||||
|
||||
<beans>
|
||||
|
||||
<bean id="contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
|
||||
<bean id="Server" name="Main" class="org.eclipse.jetty.spring.Server" init-method="start" destroy-method="stop">
|
||||
|
||||
<property name="threadPool">
|
||||
<bean id="ThreadPool" class="org.eclipse.jetty.util.thread.QueuedThreadPool">
|
||||
<bean id="server" name="Main" class="org.eclipse.jetty.server.Server" init-method="start" destroy-method="stop">
|
||||
<constructor-arg>
|
||||
<bean id="threadPool" class="org.eclipse.jetty.util.thread.QueuedThreadPool">
|
||||
<property name="minThreads" value="10"/>
|
||||
<property name="maxThreads" value="50"/>
|
||||
</bean>
|
||||
</property>
|
||||
</constructor-arg>
|
||||
|
||||
<property name="connectors">
|
||||
<list>
|
||||
<bean id="Connector" class="org.eclipse.jetty.server.ServerConnector">
|
||||
<bean id="connector" class="org.eclipse.jetty.server.ServerConnector">
|
||||
<constructor-arg ref="server"/>
|
||||
<property name="port" value="8080"/>
|
||||
</bean>
|
||||
</list>
|
||||
|
@ -49,25 +41,18 @@
|
|||
|
||||
<property name="beans">
|
||||
<list>
|
||||
<bean id="ContextDeployer" class="org.eclipse.jetty.deploy.ContextDeployer">
|
||||
<bean id="deploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
|
||||
<property name="contexts" ref="contexts"/>
|
||||
<property name="directory" value="contexts"/>
|
||||
<property name="scanInterval" value="5"/>
|
||||
<property name="appProviders">
|
||||
<list>
|
||||
<bean id="webAppProvider" class="org.eclipse.jetty.deploy.providers.WebAppProvider">
|
||||
<property name="monitoredDirName" value="webapps"/>
|
||||
<property name="scanInterval" value="1"/>
|
||||
<property name="extractWars" value="true"/>
|
||||
</bean>
|
||||
|
||||
<bean id="WebAppDeployer" class="org.eclipse.jetty.deploy.WebAppDeployer">
|
||||
<property name="contexts" ref="contexts"/>
|
||||
<property name="webAppDir" value="webapps"/>
|
||||
<property name="extract" value="true"/>
|
||||
<property name="defaultsDescriptor" value="etc/webdefault.xml"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean class="org.eclipse.jetty.security.HashLoginService">
|
||||
<property name="name" value="Test Realm"/>
|
||||
<property name="config" value="etc/realm.properties"/>
|
||||
<property name="refreshInterval" value="0"/>
|
||||
</bean>
|
||||
|
||||
</list>
|
||||
</property>
|
||||
|
||||
|
|
|
@ -16,23 +16,19 @@
|
|||
// ========================================================================
|
||||
//
|
||||
|
||||
|
||||
package org.eclipse.jetty.spring;
|
||||
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Run Jetty from Spring configuration.
|
||||
* @see <a href="http://svn.codehaus.org/jetty/jetty/trunk/jetty-spring/src/main/config/etc/jetty-spring.xml">jetty-spring.xml</a>
|
||||
/**
|
||||
* Runs Jetty from a Spring configuration file passed as argument.
|
||||
*/
|
||||
public class Main
|
||||
{
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
Resource config = Resource.newResource(args.length == 1?args[0]:"src/main/config/etc/jetty-spring.xml");
|
||||
XmlConfiguration.main(new String[]{config.getFile().getAbsolutePath()});
|
||||
|
||||
Resource config = Resource.newResource(args.length == 1 ? args[0] : "etc/jetty-spring.xml");
|
||||
XmlConfiguration.main(config.getFile().getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2012 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.spring;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.eclipse.jetty.util.thread.ThreadPool;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Convenience class for jetty with Spring.
|
||||
* This class provides a setBeans method as an alternate
|
||||
* access to the {@link #addBean(Object)} API.
|
||||
*/
|
||||
public class Server extends org.eclipse.jetty.server.Server
|
||||
{
|
||||
public Server()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public Server(InetSocketAddress addr)
|
||||
{
|
||||
super(addr);
|
||||
}
|
||||
|
||||
public Server(int port)
|
||||
{
|
||||
super(port);
|
||||
}
|
||||
|
||||
public Server(ThreadPool pool)
|
||||
{
|
||||
super(pool);
|
||||
}
|
||||
|
||||
public void setBeans(Collection<Object> beans)
|
||||
{
|
||||
for (Object o:beans)
|
||||
addBean(o);
|
||||
}
|
||||
}
|
|
@ -22,7 +22,9 @@ package org.eclipse.jetty.spring;
|
|||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.xml.ConfigurationProcessor;
|
||||
import org.eclipse.jetty.xml.ConfigurationProcessorFactory;
|
||||
|
@ -35,48 +37,50 @@ import org.springframework.core.io.UrlResource;
|
|||
|
||||
/**
|
||||
* Spring ConfigurationProcessor
|
||||
* <p>
|
||||
* <p/>
|
||||
* A {@link ConfigurationProcessor} that uses a spring XML file to emulate the {@link XmlConfiguration} format.
|
||||
* <p>
|
||||
* <p/>
|
||||
* {@link XmlConfiguration} expects a primary object that is either passed in to a call to {@link #configure(Object)}
|
||||
* or that is constructed by a call to {@link #configure()}. This processor looks for a bean definition
|
||||
* with an id, name or alias of "Main" as uses that as the primary bean.
|
||||
* <p>
|
||||
* <p/>
|
||||
* The objects mapped by {@link XmlConfiguration#getIdMap()} are set as singletons before any configuration calls
|
||||
* and if the spring configuration file contains a definition for the singleton id, the the singleton is updated
|
||||
* with a call to {@link XmlBeanFactory#configureBean(Object, String)}.
|
||||
* <p>
|
||||
* <p/>
|
||||
* The property map obtained via {@link XmlConfiguration#getProperties()} is set as a singleton called "properties"
|
||||
* and values can be accessed by somewhat verbose
|
||||
* usage of {@link org.springframework.beans.factory.config.MethodInvokingFactoryBean}.
|
||||
* <p>
|
||||
* <p/>
|
||||
* This processor is returned by the {@link SpringConfigurationProcessorFactory} for any XML document whos first
|
||||
* element is "beans". The factory is discovered by a {@link ServiceLoader} for {@link ConfigurationProcessorFactory}.
|
||||
*/
|
||||
public class SpringConfigurationProcessor implements ConfigurationProcessor
|
||||
{
|
||||
static final Logger __log = org.eclipse.jetty.util.log.Log.getLogger(SpringConfigurationProcessor.class.getName());
|
||||
private static final Logger LOG = Log.getLogger(SpringConfigurationProcessor.class);
|
||||
|
||||
Map<String, Object> _idMap;
|
||||
Map<String, String> _propertyMap;
|
||||
XmlBeanFactory _beanFactory;
|
||||
String _main;
|
||||
private Map<String, Object> _idMap;
|
||||
private Map<String, String> _propertyMap;
|
||||
private XmlBeanFactory _beanFactory;
|
||||
private String _main;
|
||||
|
||||
public void init(URL url, XmlParser.Node config, Map<String, Object> idMap, Map<String, String> properties)
|
||||
{
|
||||
try
|
||||
{
|
||||
_idMap=idMap;
|
||||
_propertyMap=properties;
|
||||
_idMap = idMap;
|
||||
_propertyMap = properties;
|
||||
|
||||
Resource resource = (url!=null)
|
||||
?new UrlResource(url)
|
||||
:new ByteArrayResource(("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE beans PUBLIC \"-//SPRING//DTD BEAN//EN\" \"http://www.springframework.org/dtd/spring-beans.dtd\">"+config).getBytes("UTF-8"));
|
||||
|
||||
_beanFactory=new XmlBeanFactory(resource);
|
||||
Resource resource = url != null
|
||||
? new UrlResource(url)
|
||||
: new ByteArrayResource(("" +
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||
"<!DOCTYPE beans PUBLIC \"-//SPRING//DTD BEAN//EN\" \"http://www.springframework.org/dtd/spring-beans.dtd\">" +
|
||||
config).getBytes("UTF-8"));
|
||||
|
||||
_beanFactory = new XmlBeanFactory(resource);
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -85,11 +89,12 @@ public class SpringConfigurationProcessor implements ConfigurationProcessor
|
|||
public Object configure(Object obj) throws Exception
|
||||
{
|
||||
doConfigure();
|
||||
return _beanFactory.configureBean(obj,_main);
|
||||
return _beanFactory.configureBean(obj, _main);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a configured bean. If a bean has the id or alias of "Main", then it is returned, otherwise the first bean in the file is returned.
|
||||
*
|
||||
* @see org.eclipse.jetty.xml.ConfigurationProcessor#configure()
|
||||
*/
|
||||
public Object configure() throws Exception
|
||||
|
@ -100,28 +105,28 @@ public class SpringConfigurationProcessor implements ConfigurationProcessor
|
|||
|
||||
private void doConfigure()
|
||||
{
|
||||
_beanFactory.registerSingleton("properties",_propertyMap);
|
||||
_beanFactory.registerSingleton("properties", _propertyMap);
|
||||
|
||||
// Look for the main bean;
|
||||
for (String bean : _beanFactory.getBeanDefinitionNames())
|
||||
{
|
||||
__log.debug("{} - {}",bean,Arrays.asList(_beanFactory.getAliases(bean)));
|
||||
LOG.debug("{} - {}", bean, Arrays.asList(_beanFactory.getAliases(bean)));
|
||||
String[] aliases = _beanFactory.getAliases(bean);
|
||||
if ("Main".equals(bean) || aliases!=null && Arrays.asList(aliases).contains("Main"))
|
||||
if ("Main".equals(bean) || aliases != null && Arrays.asList(aliases).contains("Main"))
|
||||
{
|
||||
_main=bean;
|
||||
_main = bean;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (_main==null)
|
||||
_main=_beanFactory.getBeanDefinitionNames()[0];
|
||||
if (_main == null)
|
||||
_main = _beanFactory.getBeanDefinitionNames()[0];
|
||||
|
||||
// Register id beans as singletons
|
||||
__log.debug("idMap {}",_idMap);
|
||||
LOG.debug("idMap {}", _idMap);
|
||||
for (String id : _idMap.keySet())
|
||||
{
|
||||
__log.debug("register {}",id);
|
||||
_beanFactory.registerSingleton(id,_idMap.get(id));
|
||||
LOG.debug("register {}", id);
|
||||
_beanFactory.registerSingleton(id, _idMap.get(id));
|
||||
}
|
||||
|
||||
// Apply configuration to existing singletons
|
||||
|
@ -129,13 +134,13 @@ public class SpringConfigurationProcessor implements ConfigurationProcessor
|
|||
{
|
||||
if (_beanFactory.containsBeanDefinition(id))
|
||||
{
|
||||
__log.debug("reconfigure {}",id);
|
||||
_beanFactory.configureBean(_idMap.get(id),id);
|
||||
LOG.debug("reconfigure {}", id);
|
||||
_beanFactory.configureBean(_idMap.get(id), id);
|
||||
}
|
||||
}
|
||||
|
||||
// Extract id's for next time.
|
||||
for (String id : _beanFactory.getSingletonNames())
|
||||
_idMap.put(id,_beanFactory.getBean(id));
|
||||
_idMap.put(id, _beanFactory.getBean(id));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
// ========================================================================
|
||||
//
|
||||
|
||||
|
||||
package org.eclipse.jetty.spring;
|
||||
|
||||
import org.eclipse.jetty.xml.ConfigurationProcessor;
|
||||
|
@ -25,12 +24,12 @@ import org.eclipse.jetty.xml.XmlConfiguration;
|
|||
|
||||
/**
|
||||
* Spring ConfigurationProcessor Factory
|
||||
* <p>
|
||||
* <p/>
|
||||
* Create a {@link SpringConfigurationProcessor} for XML documents with a "beans" element.
|
||||
* The factory is discovered by a {@link ServiceLoader} for {@link ConfigurationProcessorFactory}.
|
||||
* The factory is discovered by a {@link java.util.ServiceLoader} for {@link ConfigurationProcessorFactory}.
|
||||
*
|
||||
* @see SpringConfigurationProcessor
|
||||
* @see XmlConfiguration
|
||||
*
|
||||
*/
|
||||
public class SpringConfigurationProcessorFactory implements ConfigurationProcessorFactory
|
||||
{
|
||||
|
|
|
@ -24,13 +24,13 @@ import java.util.Map;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class SpringXmlConfigurationTest
|
||||
{
|
||||
protected String _configure="org/eclipse/jetty/spring/configure.xml";
|
||||
|
@ -60,7 +60,7 @@ public class SpringXmlConfigurationTest
|
|||
URL url = SpringXmlConfigurationTest.class.getClassLoader().getResource(_configure);
|
||||
XmlConfiguration configuration = new XmlConfiguration(url);
|
||||
|
||||
Map<String,String> properties = new HashMap<String,String>();
|
||||
Map<String,String> properties = new HashMap<>();
|
||||
properties.put("test", "xxx");
|
||||
|
||||
TestConfiguration nested = new TestConfiguration();
|
||||
|
@ -74,20 +74,20 @@ public class SpringXmlConfigurationTest
|
|||
|
||||
tc=(TestConfiguration)configuration.configure(tc);
|
||||
|
||||
assertEquals("preconfig",tc.getTestString0());
|
||||
assertEquals(42,tc.getTestInt0());
|
||||
assertEquals("SetValue",tc.getTestString1());
|
||||
assertEquals(1,tc.getTestInt1());
|
||||
Assert.assertEquals("preconfig", tc.getTestString0());
|
||||
Assert.assertEquals(42, tc.getTestInt0());
|
||||
Assert.assertEquals("SetValue", tc.getTestString1());
|
||||
Assert.assertEquals(1, tc.getTestInt1());
|
||||
|
||||
assertEquals("nested",tc.getNested().getTestString0());
|
||||
assertEquals("nested",tc.getNested().getTestString1());
|
||||
assertEquals("default",tc.getNested().getNested().getTestString0());
|
||||
assertEquals("deep",tc.getNested().getNested().getTestString1());
|
||||
Assert.assertEquals("nested", tc.getNested().getTestString0());
|
||||
Assert.assertEquals("nested", tc.getNested().getTestString1());
|
||||
Assert.assertEquals("default", tc.getNested().getNested().getTestString0());
|
||||
Assert.assertEquals("deep", tc.getNested().getNested().getTestString1());
|
||||
|
||||
assertEquals("deep",((TestConfiguration)configuration.getIdMap().get("nestedDeep")).getTestString1());
|
||||
assertEquals(2,((TestConfiguration)configuration.getIdMap().get("nestedDeep")).getTestInt2());
|
||||
Assert.assertEquals("deep", ((TestConfiguration)configuration.getIdMap().get("nestedDeep")).getTestString1());
|
||||
Assert.assertEquals(2, ((TestConfiguration)configuration.getIdMap().get("nestedDeep")).getTestInt2());
|
||||
|
||||
assertEquals("xxx",tc.getTestString2());
|
||||
Assert.assertEquals("xxx", tc.getTestString2());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -98,7 +98,7 @@ public class SpringXmlConfigurationTest
|
|||
URL url = SpringXmlConfigurationTest.class.getClassLoader().getResource(_configure);
|
||||
XmlConfiguration configuration = new XmlConfiguration(url);
|
||||
|
||||
Map<String,String> properties = new HashMap<String,String>();
|
||||
Map<String,String> properties = new HashMap<>();
|
||||
properties.put("test", "xxx");
|
||||
|
||||
TestConfiguration nested = new TestConfiguration();
|
||||
|
@ -108,20 +108,20 @@ public class SpringXmlConfigurationTest
|
|||
configuration.getProperties().putAll(properties);
|
||||
TestConfiguration tc = (TestConfiguration)configuration.configure();
|
||||
|
||||
assertEquals("default",tc.getTestString0());
|
||||
assertEquals(-1,tc.getTestInt0());
|
||||
assertEquals("SetValue",tc.getTestString1());
|
||||
assertEquals(1,tc.getTestInt1());
|
||||
Assert.assertEquals("default", tc.getTestString0());
|
||||
Assert.assertEquals(-1, tc.getTestInt0());
|
||||
Assert.assertEquals("SetValue", tc.getTestString1());
|
||||
Assert.assertEquals(1, tc.getTestInt1());
|
||||
|
||||
assertEquals("nested",tc.getNested().getTestString0());
|
||||
assertEquals("nested",tc.getNested().getTestString1());
|
||||
assertEquals("default",tc.getNested().getNested().getTestString0());
|
||||
assertEquals("deep",tc.getNested().getNested().getTestString1());
|
||||
Assert.assertEquals("nested", tc.getNested().getTestString0());
|
||||
Assert.assertEquals("nested", tc.getNested().getTestString1());
|
||||
Assert.assertEquals("default", tc.getNested().getNested().getTestString0());
|
||||
Assert.assertEquals("deep", tc.getNested().getNested().getTestString1());
|
||||
|
||||
assertEquals("deep",((TestConfiguration)configuration.getIdMap().get("nestedDeep")).getTestString1());
|
||||
assertEquals(2,((TestConfiguration)configuration.getIdMap().get("nestedDeep")).getTestInt2());
|
||||
Assert.assertEquals("deep", ((TestConfiguration)configuration.getIdMap().get("nestedDeep")).getTestString1());
|
||||
Assert.assertEquals(2, ((TestConfiguration)configuration.getIdMap().get("nestedDeep")).getTestInt2());
|
||||
|
||||
assertEquals("xxx",tc.getTestString2());
|
||||
Assert.assertEquals("xxx", tc.getTestString2());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -133,13 +133,11 @@ public class SpringXmlConfigurationTest
|
|||
Server server = (Server)configuration.configure();
|
||||
|
||||
server.dumpStdErr();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void XmlConfigurationMain() throws Exception
|
||||
{
|
||||
XmlConfiguration.main(new String[]{"src/test/resources/org/eclipse/jetty/spring/jetty.xml"});
|
||||
|
||||
XmlConfiguration.main("src/test/resources/org/eclipse/jetty/spring/jetty.xml");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,13 +25,13 @@ import org.junit.Ignore;
|
|||
@Ignore
|
||||
public class TestConfiguration
|
||||
{
|
||||
public static int VALUE=77;
|
||||
public static int VALUE = 77;
|
||||
|
||||
public TestConfiguration nested;
|
||||
public String testString0="default";
|
||||
public String testString0 = "default";
|
||||
public String testString1;
|
||||
public String testString2;
|
||||
public int testInt0=-1;
|
||||
public int testInt0 = -1;
|
||||
public int testInt1;
|
||||
public int testInt2;
|
||||
public URL url;
|
||||
|
@ -43,6 +43,7 @@ public class TestConfiguration
|
|||
{
|
||||
return VALUE;
|
||||
}
|
||||
|
||||
public static void setVALUE(int vALUE)
|
||||
{
|
||||
VALUE = vALUE;
|
||||
|
@ -56,82 +57,99 @@ public class TestConfiguration
|
|||
{
|
||||
return nested;
|
||||
}
|
||||
|
||||
public void setNested(TestConfiguration nested)
|
||||
{
|
||||
this.nested = nested;
|
||||
}
|
||||
|
||||
public String getTestString0()
|
||||
{
|
||||
return testString0;
|
||||
}
|
||||
|
||||
public void setTestString0(String testString0)
|
||||
{
|
||||
this.testString0 = testString0;
|
||||
}
|
||||
|
||||
public String getTestString1()
|
||||
{
|
||||
return testString1;
|
||||
}
|
||||
|
||||
public void setTestString1(String testString1)
|
||||
{
|
||||
this.testString1 = testString1;
|
||||
}
|
||||
|
||||
public String getTestString2()
|
||||
{
|
||||
return testString2;
|
||||
}
|
||||
|
||||
public void setTestString2(String testString2)
|
||||
{
|
||||
this.testString2 = testString2;
|
||||
}
|
||||
|
||||
public int getTestInt0()
|
||||
{
|
||||
return testInt0;
|
||||
}
|
||||
|
||||
public void setTestInt0(int testInt0)
|
||||
{
|
||||
this.testInt0 = testInt0;
|
||||
}
|
||||
|
||||
public int getTestInt1()
|
||||
{
|
||||
return testInt1;
|
||||
}
|
||||
|
||||
public void setTestInt1(int testInt1)
|
||||
{
|
||||
this.testInt1 = testInt1;
|
||||
}
|
||||
|
||||
public int getTestInt2()
|
||||
{
|
||||
return testInt2;
|
||||
}
|
||||
|
||||
public void setTestInt2(int testInt2)
|
||||
{
|
||||
this.testInt2 = testInt2;
|
||||
}
|
||||
|
||||
public URL getUrl()
|
||||
{
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(URL url)
|
||||
{
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public Object[] getObjArray()
|
||||
{
|
||||
return objArray;
|
||||
}
|
||||
|
||||
public void setObjArray(Object[] objArray)
|
||||
{
|
||||
this.objArray = objArray;
|
||||
}
|
||||
|
||||
public int[] getIntArray()
|
||||
{
|
||||
return intArray;
|
||||
}
|
||||
|
||||
public void setIntArray(int[] intArray)
|
||||
{
|
||||
this.intArray = intArray;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,26 +8,26 @@
|
|||
<!-- extract a value from the property map -->
|
||||
<bean id="testProperty" singleton="false" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
<property name="targetObject"><ref local="properties" /></property>
|
||||
<property name="targetMethod"><value>get</value></property>
|
||||
<property name="targetMethod" value="get" />
|
||||
<property name="arguments"><list><value>test</value></list></property>
|
||||
</bean>
|
||||
|
||||
<bean id="root" name="Some,Names,Main" class="org.eclipse.jetty.spring.TestConfiguration">
|
||||
<property name="testString1"><value>SetValue</value></property>
|
||||
<property name="testInt1"><value>1</value></property>
|
||||
<property name="nested" ref="nested"/>
|
||||
<property name="testString1" value="SetValue" />
|
||||
<property name="testInt1" value="1" />
|
||||
<property name="nested" ref="nested" />
|
||||
<property name="testString2" ref="testProperty"/>
|
||||
</bean>
|
||||
|
||||
<bean id="nested" class="org.eclipse.jetty.spring.TestConfiguration">
|
||||
<property name="testInt2"><value>2</value></property>
|
||||
<property name="testString1"><value>nested</value></property>
|
||||
<property name="nested" ref="nestedDeep"/>
|
||||
<property name="testInt2" value="2" />
|
||||
<property name="testString1" value="nested" />
|
||||
<property name="nested" ref="nestedDeep" />
|
||||
</bean>
|
||||
|
||||
<bean id="nestedDeep" class="org.eclipse.jetty.spring.TestConfiguration">
|
||||
<property name="testString1"><value>deep</value></property>
|
||||
<property name="testInt2"><value>2</value></property>
|
||||
<property name="testString1" value="deep" />
|
||||
<property name="testInt2" value="2" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
|
||||
|
||||
<beans>
|
||||
<bean id="Server" name="Main" class="org.eclipse.jetty.spring.Server">
|
||||
|
||||
<!--
|
||||
<property name="beans">
|
||||
<list>
|
||||
<bean id="ContextDeployer" class="org.eclipse.jetty.spring.ContextDeployer">
|
||||
<property name="contexts" ref="contexts"/>
|
||||
<property name="contextsDir" value="contexts"/>
|
||||
<property name="scanInterval" value="5"/>
|
||||
</bean>
|
||||
|
||||
<bean id="WebAppDeployer" class="org.eclipse.jetty.deploy.WebAppDeployer">
|
||||
<property name="contexts" ref="contexts"/>
|
||||
<property name="webAppDir" value="webapps"/>
|
||||
<property name="extract" value="true"/>
|
||||
<property name="defaultsDescriptor" value="etc/webdefault.xml"/>
|
||||
</bean>
|
||||
|
||||
<bean class="org.eclipse.jetty.security.HashLoginService">
|
||||
<property name="name" value="Test Realm"/>
|
||||
<property name="config" value="etc/realm.properties"/>
|
||||
<property name="refreshInterval" value="0"/>
|
||||
</bean>
|
||||
|
||||
</list>
|
||||
</property>
|
||||
-->
|
||||
|
||||
</bean>
|
||||
</beans>
|
||||
|
||||
|
|
@ -2,31 +2,29 @@
|
|||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
|
||||
|
||||
<beans>
|
||||
<bean id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
<bean id="Server" name="Main" class="org.eclipse.jetty.spring.Server">
|
||||
<bean id="contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
<bean id="server" name="Main" class="org.eclipse.jetty.server.Server">
|
||||
<constructor-arg type="org.eclipse.jetty.util.thread.ThreadPool">
|
||||
<bean id="ThreadPool" class="org.eclipse.jetty.util.thread.QueuedThreadPool">
|
||||
<bean id="threadPool" class="org.eclipse.jetty.util.thread.QueuedThreadPool">
|
||||
<property name="minThreads" value="10"/>
|
||||
<property name="maxThreads" value="200"/>
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
|
||||
<!--
|
||||
<property name="connectors">
|
||||
<list>
|
||||
<bean id="Connector" class="org.eclipse.jetty.server.ServerConnector">
|
||||
<constructor-arg type="org.eclipse.jetty.spring.Server"><ref bean="Server"/></constructor-arg>
|
||||
<property name="port" value="0"/>
|
||||
<bean id="connector" class="org.eclipse.jetty.server.ServerConnector">
|
||||
<constructor-arg type="org.eclipse.jetty.server.Server" ref="server" />
|
||||
<property name="port" value="8080"/>
|
||||
</bean>
|
||||
</list>
|
||||
</property>
|
||||
-->
|
||||
|
||||
<property name="handler">
|
||||
<bean id="handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
|
||||
<property name="handlers">
|
||||
<list>
|
||||
<ref bean="Contexts"/>
|
||||
<ref bean="contexts"/>
|
||||
<bean id="defaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
||||
</list>
|
||||
</property>
|
||||
|
|
|
@ -381,13 +381,18 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<Object> getBeans()
|
||||
{
|
||||
return getBeans(Object.class);
|
||||
}
|
||||
|
||||
public void setBeans(Collection<Object> beans)
|
||||
{
|
||||
for (Object bean : beans)
|
||||
addBean(bean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Collection<T> getBeans(Class<T> clazz)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue