329410 Enforce XmlConfiguration properties as Map<String,String>

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2469 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2010-11-04 02:08:49 +00:00
parent c4da2ad0fe
commit 543118f837
13 changed files with 175 additions and 142 deletions

View File

@ -11,6 +11,7 @@ jetty-7.2.1-SNAPSHOT
+ 328885 web overrides do not override
+ 328988 Idle saving of session values
+ 329180 Spin check for Selector to stop
+ 329410 Enforce XmlConfiguration properties as Map<String,String>
+ JETTY-748 Prevent race close of socket by old acceptor threads
+ JETTY-1291 Extract query parameters even if POST content consumed
+ JETTY-1295 Contexts mixed up when hot-deploying on virtual hosts

View File

@ -22,5 +22,5 @@ import java.util.Map;
*/
public interface ConfigurationManager
{
public Map<String, Object> getProperties();
public Map<String, String> getProperties();
}

View File

@ -30,7 +30,7 @@ import org.eclipse.jetty.util.resource.Resource;
public class FileConfigurationManager implements ConfigurationManager
{
private Resource _file;
private Map<String,Object> _map = new HashMap<String,Object>();
private Map<String,String> _map = new HashMap<String,String>();
public FileConfigurationManager()
{
@ -44,7 +44,7 @@ public class FileConfigurationManager implements ConfigurationManager
/**
* @see org.eclipse.jetty.deploy.ConfigurationManager#getProperties()
*/
public Map<String, Object> getProperties()
public Map<String, String> getProperties()
{
try
{
@ -64,7 +64,7 @@ public class FileConfigurationManager implements ConfigurationManager
Properties properties = new Properties();
properties.load(_file.getInputStream());
for (Map.Entry<Object, Object> entry : properties.entrySet())
_map.put(entry.getKey().toString(),entry.getValue());
_map.put(entry.getKey().toString(),String.valueOf(entry.getValue()));
}
}
}

View File

@ -64,8 +64,9 @@ public class ContextProvider extends ScanningAppProvider
if (resource.exists() && FileID.isXmlFile(file))
{
XmlConfiguration xmlc = new XmlConfiguration(resource.getURL());
Map<String,Object> props = new HashMap<String,Object>();
props.put("Server",getDeploymentManager().getServer());
Map<String,String> props = new HashMap<String,String>();
xmlc.getIdMap().put("Server",getDeploymentManager().getServer());
if (getConfigurationManager() != null)
props.putAll(getConfigurationManager().getProperties());
xmlc.setProperties(props);

View File

@ -213,14 +213,18 @@ public abstract class ScanningAppProvider extends AbstractLifeCycle implements A
}
/* ------------------------------------------------------------ */
@Deprecated
/**
* @deprecated use {@link #setMonitoredDirResource(Resource)}
*/
public void setMonitoredDir(Resource dir)
{
setMonitoredDirResource(dir);
}
/* ------------------------------------------------------------ */
@Deprecated
/**
* @deprecated use {@link #setMonitoredDirName(String)}
*/
public void setMonitoredDir(String dir)
{
setMonitoredDirName(dir);

View File

@ -28,7 +28,9 @@ import java.net.URL;
import java.net.URLConnection;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.eclipse.jetty.deploy.DeploymentManager;
@ -48,12 +50,12 @@ import org.junit.Assert;
*/
public class XmlConfiguredJetty
{
private List<URL> xmlConfigurations;
private Properties properties = new Properties();
private Server server;
private int serverPort;
private String scheme = HttpSchemes.HTTP;
private File jettyHome;
private List<URL> _xmlConfigurations;
private Map<String,String> _properties = new HashMap<String,String>();
private Server _server;
private int _serverPort;
private String _scheme = HttpSchemes.HTTP;
private File _jettyHome;
public XmlConfiguredJetty() throws IOException
{
@ -62,52 +64,52 @@ public class XmlConfiguredJetty
public XmlConfiguredJetty(String testname) throws IOException
{
xmlConfigurations = new ArrayList<URL>();
properties = new Properties();
_xmlConfigurations = new ArrayList<URL>();
Properties properties = new Properties();
String jettyHomeBase = MavenTestingUtils.getTargetTestingDir(testname).getAbsolutePath();
// Ensure we have a new (pristene) directory to work with.
int idx = 0;
jettyHome = new File(jettyHomeBase + "#" + idx);
while (jettyHome.exists())
_jettyHome = new File(jettyHomeBase + "#" + idx);
while (_jettyHome.exists())
{
idx++;
jettyHome = new File(jettyHomeBase + "#" + idx);
_jettyHome = new File(jettyHomeBase + "#" + idx);
}
deleteContents(jettyHome);
deleteContents(_jettyHome);
// Prepare Jetty.Home (Test) dir
jettyHome.mkdirs();
_jettyHome.mkdirs();
File logsDir = new File(jettyHome,"logs");
File logsDir = new File(_jettyHome,"logs");
logsDir.mkdirs();
File etcDir = new File(jettyHome,"etc");
File etcDir = new File(_jettyHome,"etc");
etcDir.mkdirs();
IO.copyFile(MavenTestingUtils.getTestResourceFile("etc/realm.properties"),new File(etcDir,"realm.properties"));
IO.copyFile(MavenTestingUtils.getTestResourceFile("etc/webdefault.xml"),new File(etcDir,"webdefault.xml"));
File contextsDir = new File(jettyHome,"contexts");
File contextsDir = new File(_jettyHome,"contexts");
if (contextsDir.exists())
{
deleteContents(contextsDir);
}
contextsDir.mkdirs();
File webappsDir = new File(jettyHome,"webapps");
File webappsDir = new File(_jettyHome,"webapps");
if (webappsDir.exists())
{
deleteContents(webappsDir);
}
webappsDir.mkdirs();
File tmpDir = new File(jettyHome,"tmp");
File tmpDir = new File(_jettyHome,"tmp");
if (tmpDir.exists())
{
deleteContents(tmpDir);
}
tmpDir.mkdirs();
File workishDir = new File(jettyHome,"workish");
File workishDir = new File(_jettyHome,"workish");
if (workishDir.exists())
{
deleteContents(workishDir);
@ -116,8 +118,8 @@ public class XmlConfiguredJetty
// Setup properties
System.setProperty("java.io.tmpdir",tmpDir.getAbsolutePath());
properties.setProperty("jetty.home",jettyHome.getAbsolutePath());
System.setProperty("jetty.home",jettyHome.getAbsolutePath());
properties.setProperty("jetty.home",_jettyHome.getAbsolutePath());
System.setProperty("jetty.home",_jettyHome.getAbsolutePath());
properties.setProperty("test.basedir",MavenTestingUtils.getBasedir().getAbsolutePath());
properties.setProperty("test.resourcesdir",MavenTestingUtils.getTestResourcesDir().getAbsolutePath());
properties.setProperty("test.webapps",webappsDir.getAbsolutePath());
@ -128,11 +130,13 @@ public class XmlConfiguredJetty
File testConfig = MavenTestingUtils.getTargetFile("xml-configured-jetty.properties");
FileOutputStream out = new FileOutputStream(testConfig);
properties.store(out,"Generated by " + XmlConfiguredJetty.class.getName());
for (Object key:properties.keySet())
_properties.put(String.valueOf(key),String.valueOf(properties.get(key)));
}
public void addConfiguration(File xmlConfigFile) throws MalformedURLException
{
xmlConfigurations.add(xmlConfigFile.toURI().toURL());
_xmlConfigurations.add(xmlConfigFile.toURI().toURL());
}
public void addConfiguration(String testConfigName) throws MalformedURLException
@ -142,7 +146,7 @@ public class XmlConfiguredJetty
public void addConfiguration(URL xmlConfig)
{
xmlConfigurations.add(xmlConfig);
_xmlConfigurations.add(xmlConfig);
}
public void assertNoWebAppContexts()
@ -221,7 +225,7 @@ public class XmlConfiguredJetty
{
System.out.printf("Copying Context: %s -> %s%n",srcName,destName);
File srcDir = MavenTestingUtils.getTestResourceDir("contexts");
File destDir = new File(jettyHome,"contexts");
File destDir = new File(_jettyHome,"contexts");
File srcFile = new File(srcDir,srcName);
File destFile = new File(destDir,destName);
@ -242,7 +246,7 @@ public class XmlConfiguredJetty
{
System.out.printf("Copying Webapp: %s -> %s%n",srcName,destName);
File srcDir = MavenTestingUtils.getTestResourceDir("webapps");
File destDir = new File(jettyHome,"webapps");
File destDir = new File(_jettyHome,"webapps");
File srcFile = new File(srcDir,srcName);
File destFile = new File(destDir,destName);
@ -276,48 +280,48 @@ public class XmlConfiguredJetty
public DeploymentManager getActiveDeploymentManager()
{
return server.getBean(DeploymentManager.class);
return _server.getBean(DeploymentManager.class);
}
public File getJettyDir(String name)
{
return new File(jettyHome,name);
return new File(_jettyHome,name);
}
public File getJettyHome()
{
return jettyHome;
return _jettyHome;
}
public String getScheme()
{
return scheme;
return _scheme;
}
public Server getServer()
{
return server;
return _server;
}
public int getServerPort()
{
return serverPort;
return _serverPort;
}
public URI getServerURI() throws UnknownHostException
{
StringBuffer uri = new StringBuffer();
uri.append(this.scheme).append("://");
uri.append(this._scheme).append("://");
uri.append(InetAddress.getLocalHost().getHostAddress());
uri.append(":").append(this.serverPort);
uri.append(":").append(this._serverPort);
return URI.create(uri.toString());
}
public List<WebAppContext> getWebAppContexts()
{
List<WebAppContext> contexts = new ArrayList<WebAppContext>();
HandlerCollection handlers = (HandlerCollection)server.getHandler();
System.out.println(server.dump());
HandlerCollection handlers = (HandlerCollection)_server.getHandler();
System.out.println(_server.dump());
Handler children[] = handlers.getChildHandlers();
for (Handler handler : children)
@ -336,18 +340,18 @@ public class XmlConfiguredJetty
public void load() throws Exception
{
XmlConfiguration last = null;
Object[] obj = new Object[this.xmlConfigurations.size()];
Object[] obj = new Object[this._xmlConfigurations.size()];
// Configure everything
for (int i = 0; i < this.xmlConfigurations.size(); i++)
for (int i = 0; i < this._xmlConfigurations.size(); i++)
{
URL configURL = this.xmlConfigurations.get(i);
URL configURL = this._xmlConfigurations.get(i);
XmlConfiguration configuration = new XmlConfiguration(configURL);
if (last != null)
{
configuration.getIdMap().putAll(last.getIdMap());
}
configuration.setProperties(properties);
configuration.setProperties(_properties);
obj[i] = configuration.configure();
last = configuration;
}
@ -355,7 +359,7 @@ public class XmlConfiguredJetty
// Test for Server Instance.
Server foundServer = null;
int serverCount = 0;
for (int i = 0; i < this.xmlConfigurations.size(); i++)
for (int i = 0; i < this._xmlConfigurations.size(); i++)
{
if (obj[i] instanceof Server)
{
@ -376,14 +380,14 @@ public class XmlConfiguredJetty
Assert.assertEquals("Server load count",1,serverCount);
this.server = foundServer;
this.server.setGracefulShutdown(10);
this._server = foundServer;
this._server.setGracefulShutdown(10);
}
public void removeContext(String name)
{
File destDir = new File(jettyHome,"contexts");
File destDir = new File(_jettyHome,"contexts");
File contextFile = new File(destDir,name);
if (contextFile.exists())
{
@ -393,34 +397,34 @@ public class XmlConfiguredJetty
public void setProperty(String key, String value)
{
properties.setProperty(key,value);
_properties.put(key,value);
}
public void setScheme(String scheme)
{
this.scheme = scheme;
this._scheme = scheme;
}
public void start() throws Exception
{
Assert.assertNotNull("Server should not be null (failed load?)",server);
Assert.assertNotNull("Server should not be null (failed load?)",_server);
server.start();
_server.start();
// Find the active server port.
this.serverPort = (-1);
Connector connectors[] = server.getConnectors();
this._serverPort = (-1);
Connector connectors[] = _server.getConnectors();
for (int i = 0; i < connectors.length; i++)
{
Connector connector = connectors[i];
if (connector.getLocalPort() > 0)
{
this.serverPort = connector.getLocalPort();
this._serverPort = connector.getLocalPort();
break;
}
}
Assert.assertTrue("Server Port is between 1 and 65535. Actually <" + serverPort + ">",(1 <= this.serverPort) && (this.serverPort <= 65535));
Assert.assertTrue("Server Port is between 1 and 65535. Actually <" + _serverPort + ">",(1 <= this._serverPort) && (this._serverPort <= 65535));
// Uncomment to have server start and continue to run (without exiting)
// System.out.printf("Listening to port %d%n",this.serverPort);
@ -429,7 +433,7 @@ public class XmlConfiguredJetty
public void stop() throws Exception
{
server.stop();
_server.stop();
}

View File

@ -248,27 +248,27 @@ public class ServerInstanceWrapper {
{
return;
}
Map<Object,Object> id_map = new HashMap<Object,Object>();
Map<String,Object> id_map = new HashMap<String,Object>();
id_map.put("Server",server);
Map<Object,Object> properties = new HashMap<Object,Object>();
Enumeration en = props.keys();
Map<String,String> properties = new HashMap<String,String>();
Enumeration<Object> en = props.keys();
while (en.hasMoreElements())
{
Object key = en.nextElement();
Object value = props.get(key);
properties.put(key, value);
Object key = en.nextElement();
Object value = props.get(key);
properties.put(String.valueOf(key), String.valueOf(value));
}
for (URL jettyConfiguration : jettyConfigurations)
{
InputStream is = null;
InputStream is = null;
try
{
// Execute a Jetty configuration file
is = jettyConfiguration.openStream();
XmlConfiguration config = new XmlConfiguration(is);
config.setIdMap(id_map);
config.setProperties(properties);
config.getIdMap().putAll(id_map);
config.getProperties().putAll(properties);
config.configure();
id_map=config.getIdMap();
}

View File

@ -305,6 +305,12 @@ public class ResourceCache
return null;
}
}
/* ------------------------------------------------------------ */
public String toString()
{
return "ResourceCache["+_parent+","+_factory+"]@"+hashCode();
}
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */

View File

@ -97,13 +97,15 @@ public class JettyWebXmlConfiguration extends AbstractConfiguration
*/
private void setupXmlConfiguration(XmlConfiguration jetty_config, Resource web_inf)
{
Map<Object,Object> props = jetty_config.getProperties();
Map<String,String> props = jetty_config.getProperties();
if (props == null)
{
props = new HashMap<Object, Object>();
props = new HashMap<String, String>();
jetty_config.setProperties(props);
}
props.put(PROPERTY_THIS_WEB_INF_URL, web_inf.getURL());
// TODO - should this be an id rather than a property?
props.put(PROPERTY_THIS_WEB_INF_URL, String.valueOf(web_inf.getURL()));
}
}

View File

@ -25,6 +25,7 @@ import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import org.eclipse.jetty.server.handler.ContextHandler;
@ -52,15 +53,13 @@ import org.eclipse.jetty.util.resource.ResourceCollection;
* context classloader will be used. If that is null then the
* classloader that loaded this class is used as the parent.
*
*
*/
public class WebAppClassLoader extends URLClassLoader
{
private final Context _context;
private final ClassLoader _parent;
private final Set<String> _extensions=new HashSet<String>();
private String _name=String.valueOf(hashCode());
private Context _context;
private ClassLoader _parent;
private HashSet<String> _extensions;
/* ------------------------------------------------------------ */
/** The Context in which the classloader operates.
@ -142,10 +141,10 @@ public class WebAppClassLoader extends URLClassLoader
if (_parent==null)
throw new IllegalArgumentException("no parent classloader!");
_extensions = new HashSet<String>();
_extensions.add(".jar");
_extensions.add(".zip");
// TODO remove this system property
String extensions = System.getProperty(WebAppClassLoader.class.getName() + ".extensions");
if(extensions!=null)
{
@ -222,25 +221,22 @@ public class WebAppClassLoader extends URLClassLoader
if (Log.isDebugEnabled())
Log.debug("Path resource=" + resource);
// Resolve file path if possible
File file= resource.getFile();
if (file != null)
{
URL url= resource.getURL();
addURL(url);
}
// Add the resource
if (resource.isDirectory() && resource instanceof ResourceCollection)
addClassPath(resource);
else
{
// Add resource or expand jar/
if (!resource.isDirectory() && file == null)
{
throw new IllegalArgumentException("!file: "+resource);
}
else
// Resolve file path if possible
File file= resource.getFile();
if (file != null)
{
URL url= resource.getURL();
addURL(url);
}
else if (resource.isDirectory())
addURL(resource.getURL());
else
throw new IllegalArgumentException("!file: "+resource);
}
}
}
@ -286,12 +282,6 @@ public class WebAppClassLoader extends URLClassLoader
}
}
}
/* ------------------------------------------------------------ */
public void destroy()
{
this._parent=null;
}
/* ------------------------------------------------------------ */
public PermissionCollection getPermissions(CodeSource cs)
@ -308,7 +298,6 @@ public class WebAppClassLoader extends URLClassLoader
boolean system_class=_context.isSystemClass(name);
boolean server_class=_context.isServerClass(name);
List<URL> from_parent = toList(server_class?null:_parent.getResources(name));
List<URL> from_webapp = toList((system_class&&!from_parent.isEmpty())?null:this.findResources(name));
@ -446,5 +435,4 @@ public class WebAppClassLoader extends URLClassLoader
return "WebAppClassLoader@" + _name + "(" + LazyList.array2List(getURLs()) + ") / " + _parent;
return "WebAppClassLoader@" + _name;
}
}

View File

@ -867,13 +867,23 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
/* ------------------------------------------------------------ */
/**
* The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml
* @param overrideDescriptor The overrideDescritpor to set.
* @param overrideDescriptor The overrideDescriptors (file or URL) to set.
*/
public void setOverrideDescriptors(List<String> overrideDescriptors)
{
_overrideDescriptors.clear();
_overrideDescriptors.addAll(overrideDescriptors);
}
/* ------------------------------------------------------------ */
/**
* The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml
* @param overrideDescriptor The overrideDescriptor (file or URL) to add.
*/
public void addOverrideDescriptor(String overrideDescriptor)
{
_overrideDescriptors.add(overrideDescriptor);
}
/* ------------------------------------------------------------ */
/**

View File

@ -68,8 +68,8 @@ public class XmlConfiguration
/* ------------------------------------------------------------ */
private static XmlParser __parser;
private XmlParser.Node _config;
private Map _idMap = new HashMap();
private Map _propertyMap = new HashMap();
private final Map<String,Object> _idMap = new HashMap<String,Object>();
private final Map<String,String> _propertyMap = new HashMap<String,String>();
/* ------------------------------------------------------------ */
private synchronized static void initParser() throws IOException
@ -156,25 +156,33 @@ public class XmlConfiguration
}
/* ------------------------------------------------------------ */
public Map getIdMap()
public Map<String,Object> getIdMap()
{
return _idMap;
}
/* ------------------------------------------------------------ */
public void setIdMap(Map map)
/**
* @deprecated use {@link #getIdMap()}.put(...)
*/
public void setIdMap(Map<String,Object> map)
{
_idMap=map;
_idMap.clear();
_idMap.putAll(map);
}
/* ------------------------------------------------------------ */
public void setProperties (Map map)
/**
* @deprecated use {@link #getProperties()}.put(...)
*/
public void setProperties (Map<String,String> map)
{
_propertyMap = map;
_propertyMap.clear();
_propertyMap.putAll(map);
}
/* ------------------------------------------------------------ */
public Map getProperties ()
public Map<String,String> getProperties ()
{
return _propertyMap;
}
@ -465,7 +473,7 @@ public class XmlConfiguration
{
if (!(obj instanceof Map))
throw new IllegalArgumentException("Object for put is not a Map: " + obj);
Map map = (Map) obj;
Map<Object,Object> map = (Map<Object,Object>) obj;
String name = node.getAttribute("name");
Object value = value(obj, node);
@ -735,7 +743,7 @@ public class XmlConfiguration
{
String id = node.getAttribute("id");
Map map = new HashMap();
Map<Object,Object> map = new HashMap<Object,Object>();
if (id != null) _idMap.put(id, map);
for (int i = 0; i < node.size(); i++)
@ -892,7 +900,7 @@ public class XmlConfiguration
if ("String".equals(type) || "java.lang.String".equals(type)) return value.toString();
Class pClass = TypeUtil.fromName(type);
Class<?> pClass = TypeUtil.fromName(type);
if (pClass != null) return TypeUtil.valueOf(pClass, value.toString());
if ("URL".equals(type) || "java.net.URL".equals(type))
@ -1009,7 +1017,6 @@ public class XmlConfiguration
Log.warn(e);
}
// If no start.config properties, use clean slate
if (properties==null)
properties = new Properties();
@ -1030,7 +1037,12 @@ public class XmlConfiguration
if ( last != null )
configuration.getIdMap().putAll( last.getIdMap() );
if ( properties.size() > 0 )
configuration.setProperties( properties );
{
Map<String,String> props = new HashMap<String,String>();
for (Object key:properties.keySet())
props.put(key.toString(),String.valueOf(properties.get(key)));
configuration.setProperties( props );
}
obj[i] = configuration.configure();
last = configuration;
}

View File

@ -25,7 +25,9 @@ import java.net.URI;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.eclipse.jetty.http.HttpSchemes;
@ -41,11 +43,11 @@ import org.junit.Ignore;
@Ignore
public class TestableJettyServer
{
private List<URL> xmlConfigurations;
private Properties properties = new Properties();
private Server server;
private int serverPort;
private String scheme = HttpSchemes.HTTP;
private List<URL> _xmlConfigurations;
private final Map<String,String> _properties = new HashMap<String, String>();
private Server _server;
private int _serverPort;
private String _scheme = HttpSchemes.HTTP;
/* Popular Directories */
private File baseDir;
@ -53,8 +55,8 @@ public class TestableJettyServer
public TestableJettyServer() throws IOException
{
xmlConfigurations = new ArrayList<URL>();
properties = new Properties();
_xmlConfigurations = new ArrayList<URL>();
Properties properties = new Properties();
/* Establish Popular Directories */
String baseDirPath = System.getProperty("basedir");
@ -81,16 +83,19 @@ public class TestableJettyServer
File testConfig = new File(targetDir,"testable-jetty-server-config.properties");
FileOutputStream out = new FileOutputStream(testConfig);
properties.store(out,"Generated by " + TestableJettyServer.class.getName());
for (Object key:properties.keySet())
_properties.put(String.valueOf(key),String.valueOf(properties.get(key)));
}
public void addConfiguration(URL xmlConfig)
{
xmlConfigurations.add(xmlConfig);
_xmlConfigurations.add(xmlConfig);
}
public void addConfiguration(File xmlConfigFile) throws MalformedURLException
{
xmlConfigurations.add(xmlConfigFile.toURI().toURL());
_xmlConfigurations.add(xmlConfigFile.toURI().toURL());
}
public void addConfiguration(String testConfigName) throws MalformedURLException
@ -100,25 +105,25 @@ public class TestableJettyServer
public void setProperty(String key, String value)
{
properties.setProperty(key,value);
_properties.put(key,value);
}
@SuppressWarnings("unchecked")
public void load() throws Exception
{
XmlConfiguration last = null;
Object[] obj = new Object[this.xmlConfigurations.size()];
Object[] obj = new Object[this._xmlConfigurations.size()];
// Configure everything
for (int i = 0; i < this.xmlConfigurations.size(); i++)
for (int i = 0; i < this._xmlConfigurations.size(); i++)
{
URL configURL = this.xmlConfigurations.get(i);
URL configURL = this._xmlConfigurations.get(i);
XmlConfiguration configuration = new XmlConfiguration(configURL);
if (last != null)
{
configuration.getIdMap().putAll(last.getIdMap());
}
configuration.setProperties(properties);
configuration.setProperties(_properties);
obj[i] = configuration.configure();
last = configuration;
}
@ -126,7 +131,7 @@ public class TestableJettyServer
// Test for Server Instance.
Server foundServer = null;
int serverCount = 0;
for (int i = 0; i < this.xmlConfigurations.size(); i++)
for (int i = 0; i < this._xmlConfigurations.size(); i++)
{
if (obj[i] instanceof Server)
{
@ -147,59 +152,59 @@ public class TestableJettyServer
Assert.assertEquals("Server load count",1,serverCount);
this.server = foundServer;
this.server.setGracefulShutdown(10);
this._server = foundServer;
this._server.setGracefulShutdown(10);
}
public String getScheme()
{
return scheme;
return _scheme;
}
public void setScheme(String scheme)
{
this.scheme = scheme;
this._scheme = scheme;
}
public void start() throws Exception
{
Assert.assertNotNull("Server should not be null (failed load?)",server);
Assert.assertNotNull("Server should not be null (failed load?)",_server);
server.start();
_server.start();
// Find the active server port.
this.serverPort = (-1);
Connector connectors[] = server.getConnectors();
this._serverPort = (-1);
Connector connectors[] = _server.getConnectors();
for (int i = 0; i < connectors.length; i++)
{
Connector connector = connectors[i];
if (connector.getLocalPort() > 0)
{
this.serverPort = connector.getLocalPort();
this._serverPort = connector.getLocalPort();
break;
}
}
Assert.assertTrue("Server Port is between 1 and 65535. Actually <" + serverPort + ">",(1 <= this.serverPort) && (this.serverPort <= 65535));
Assert.assertTrue("Server Port is between 1 and 65535. Actually <" + _serverPort + ">",(1 <= this._serverPort) && (this._serverPort <= 65535));
}
public int getServerPort()
{
return serverPort;
return _serverPort;
}
public void stop() throws Exception
{
server.stop();
_server.stop();
}
public URI getServerURI() throws UnknownHostException
{
StringBuffer uri = new StringBuffer();
uri.append(this.scheme).append("://");
uri.append(this._scheme).append("://");
uri.append(InetAddress.getLocalHost().getHostAddress());
uri.append(":").append(this.serverPort);
uri.append(":").append(this._serverPort);
return URI.create(uri.toString());
}
}