JETTY-1297 Make ServletContext.getContext(String) virtual host aware
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2479 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
37c2f8088b
commit
df79fb183b
|
@ -18,6 +18,7 @@ jetty-7.2.1-SNAPSHOT
|
||||||
+ JETTY-748 Prevent race close of socket by old acceptor threads
|
+ JETTY-748 Prevent race close of socket by old acceptor threads
|
||||||
+ JETTY-1291 Extract query parameters even if POST content consumed
|
+ JETTY-1291 Extract query parameters even if POST content consumed
|
||||||
+ JETTY-1295 Contexts mixed up when hot-deploying on virtual hosts
|
+ JETTY-1295 Contexts mixed up when hot-deploying on virtual hosts
|
||||||
|
+ JETTY-1297 Make ServletContext.getContext(String) virtual host aware
|
||||||
|
|
||||||
jetty-7.2.0.v20101020 20 October 2010
|
jetty-7.2.0.v20101020 20 October 2010
|
||||||
+ 289540 added javadoc into distribution
|
+ 289540 added javadoc into distribution
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
#HSQL Database Engine 1.8.0.10
|
||||||
|
#Mon Nov 08 13:35:35 EST 2010
|
||||||
|
hsqldb.script_format=0
|
||||||
|
runtime.gc_interval=0
|
||||||
|
sql.enforce_strict_size=false
|
||||||
|
hsqldb.cache_size_scale=8
|
||||||
|
readonly=false
|
||||||
|
hsqldb.nio_data_file=true
|
||||||
|
hsqldb.cache_scale=14
|
||||||
|
version=1.8.0
|
||||||
|
hsqldb.default_table_type=memory
|
||||||
|
hsqldb.cache_file_scale=1
|
||||||
|
hsqldb.log_size=200
|
||||||
|
modified=no
|
||||||
|
hsqldb.cache_version=1.7.0
|
||||||
|
hsqldb.original_version=1.8.0
|
||||||
|
hsqldb.compatible_version=1.8.0
|
|
@ -0,0 +1,4 @@
|
||||||
|
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
|
||||||
|
CREATE USER SA PASSWORD ""
|
||||||
|
GRANT DBA TO SA
|
||||||
|
SET WRITE_DELAY 10
|
|
@ -107,6 +107,7 @@ public class LikeJettyXml
|
||||||
server.addBean(context_provider);
|
server.addBean(context_provider);
|
||||||
deployer.addAppProvider(context_provider);
|
deployer.addAppProvider(context_provider);
|
||||||
|
|
||||||
|
/*
|
||||||
WebAppProvider webapp_provider = new WebAppProvider();
|
WebAppProvider webapp_provider = new WebAppProvider();
|
||||||
webapp_provider.setMonitoredDir(jetty_home + "/webapps");
|
webapp_provider.setMonitoredDir(jetty_home + "/webapps");
|
||||||
webapp_provider.setParentLoaderPriority(false);
|
webapp_provider.setParentLoaderPriority(false);
|
||||||
|
@ -115,6 +116,7 @@ public class LikeJettyXml
|
||||||
webapp_provider.setDefaultsDescriptor(jetty_home + "/etc/webdefault.xml");
|
webapp_provider.setDefaultsDescriptor(jetty_home + "/etc/webdefault.xml");
|
||||||
webapp_provider.setContextXmlDir(jetty_home + "/contexts");
|
webapp_provider.setContextXmlDir(jetty_home + "/contexts");
|
||||||
deployer.addAppProvider(webapp_provider);
|
deployer.addAppProvider(webapp_provider);
|
||||||
|
*/
|
||||||
|
|
||||||
HashLoginService login = new HashLoginService();
|
HashLoginService login = new HashLoginService();
|
||||||
login.setName("Test Realm");
|
login.setName("Test Realm");
|
||||||
|
|
|
@ -19,12 +19,14 @@ import java.io.InputStream;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.EventListener;
|
import java.util.EventListener;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -1443,8 +1445,10 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
||||||
*/
|
*/
|
||||||
public ServletContext getContext(String uripath)
|
public ServletContext getContext(String uripath)
|
||||||
{
|
{
|
||||||
ContextHandler context=null;
|
List<ContextHandler> contexts=new ArrayList<ContextHandler>();
|
||||||
Handler[] handlers = getServer().getChildHandlersByClass(ContextHandler.class);
|
Handler[] handlers = getServer().getChildHandlersByClass(ContextHandler.class);
|
||||||
|
String matched_path=null;
|
||||||
|
|
||||||
for (int i=0;i<handlers.length;i++)
|
for (int i=0;i<handlers.length;i++)
|
||||||
{
|
{
|
||||||
if (handlers[i]==null || !handlers[i].isStarted())
|
if (handlers[i]==null || !handlers[i].isStarted())
|
||||||
|
@ -1454,13 +1458,50 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
||||||
|
|
||||||
if (uripath.equals(context_path) || (uripath.startsWith(context_path)&&uripath.charAt(context_path.length())=='/') || "/".equals(context_path))
|
if (uripath.equals(context_path) || (uripath.startsWith(context_path)&&uripath.charAt(context_path.length())=='/') || "/".equals(context_path))
|
||||||
{
|
{
|
||||||
if (context==null || context_path.length()>context.getContextPath().length())
|
if (matched_path==null || context_path.length()>matched_path.length())
|
||||||
context=ch;
|
{
|
||||||
|
contexts.clear();
|
||||||
|
matched_path=context_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matched_path.equals(context_path))
|
||||||
|
contexts.add(ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (contexts.size())
|
||||||
|
{
|
||||||
|
case 0: return null;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
return contexts.get(0)._scontext;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Multiple contexts
|
||||||
|
// Does this context match?
|
||||||
|
if (contexts.contains(ContextHandler.this))
|
||||||
|
{
|
||||||
|
return _scontext;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Are there matching virtual hosts?
|
||||||
|
if (getVirtualHosts()!=null && getVirtualHosts().length>0)
|
||||||
|
{
|
||||||
|
for (ContextHandler ch : contexts)
|
||||||
|
{
|
||||||
|
if (ch.getVirtualHosts()!=null && ch.getVirtualHosts().length>0)
|
||||||
|
{
|
||||||
|
for (String h1 : getVirtualHosts())
|
||||||
|
for (String h2 : ch.getVirtualHosts())
|
||||||
|
if (h1.equals(h2))
|
||||||
|
{
|
||||||
|
return ch._scontext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context!=null)
|
|
||||||
return context._scontext;
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -431,8 +431,6 @@ public class WebAppClassLoader extends URLClassLoader
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
if (Log.isDebugEnabled())
|
|
||||||
return "WebAppClassLoader@" + _name + "(" + LazyList.array2List(getURLs()) + ") / " + _parent;
|
|
||||||
return "WebAppClassLoader@" + _name;
|
return "WebAppClassLoader@" + _name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue