Issue #2191 JPMS Support
Renamed ClasspathPattern to ClassMatcher as it also supports JPMS modules etc. Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
parent
4265978d08
commit
42cda7bc7f
|
@ -19,7 +19,7 @@
|
|||
package org.eclipse.jetty.example.asyncrest;
|
||||
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.webapp.ClasspathPattern;
|
||||
import org.eclipse.jetty.webapp.ClassMatcher;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
public class DemoServer
|
||||
|
@ -35,7 +35,7 @@ public class DemoServer
|
|||
webapp.setContextPath("/");
|
||||
webapp.setWar(jetty_home+"/target/async-rest/");
|
||||
webapp.setParentLoaderPriority(true);
|
||||
webapp.setServerClasspathPattern(new ClasspathPattern());
|
||||
webapp.setServerClassMatcher(new ClassMatcher());
|
||||
server.setHandler(webapp);
|
||||
|
||||
server.start();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
|
||||
|
||||
<Call name="getServerClasspathPattern">
|
||||
<Call name="getServerClassMatcher">
|
||||
<Call name="include">
|
||||
<Arg>org.eclipse.foo.</Arg>
|
||||
</Call>`
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
<!-- Weld needs access to some internal classes. Same configuration as "cdi2" module provides on server. -->
|
||||
|
||||
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
|
||||
<Call name="addServerClasspathPattern">
|
||||
<Call name="addServerClassMatcher">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.webapp.ClasspathPattern">
|
||||
<New class="org.eclipse.jetty.webapp.ClassMatcher">
|
||||
<Arg>
|
||||
<Array type="java.lang.String">
|
||||
<Item>-org.eclipse.jetty.util.Decorator</Item>
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.eclipse.jetty.server.Server;
|
|||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||
import org.eclipse.jetty.util.component.Destroyable;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.webapp.ClasspathPattern;
|
||||
import org.eclipse.jetty.webapp.ClassMatcher;
|
||||
import org.eclipse.jetty.webapp.WebAppClassLoader;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
@ -52,8 +52,8 @@ public class TemplateContext extends ContainerLifeCycle implements WebAppClassLo
|
|||
private final MimeTypes _mimeTypes;
|
||||
private final WebAppClassLoader _webappLoader;
|
||||
|
||||
private ClasspathPattern _systemClasses;
|
||||
private ClasspathPattern _serverClasses;
|
||||
private ClassMatcher _systemClasses;
|
||||
private ClassMatcher _serverClasses;
|
||||
private PermissionCollection _permissions;
|
||||
|
||||
private boolean _parentLoaderPriority;
|
||||
|
@ -86,9 +86,9 @@ public class TemplateContext extends ContainerLifeCycle implements WebAppClassLo
|
|||
_resourceCache=new ResourceCache(null,baseResource,_mimeTypes,false,false);
|
||||
|
||||
String[] patterns = (String[])_server.getAttribute(WebAppContext.SERVER_SRV_CLASSES);
|
||||
_serverClasses=new ClasspathPattern(patterns==null?WebAppContext.__dftServerClasses:patterns);
|
||||
_serverClasses=new ClassMatcher(patterns==null?WebAppContext.__dftServerClasses:patterns);
|
||||
patterns = (String[])_server.getAttribute(WebAppContext.SERVER_SYS_CLASSES);
|
||||
_systemClasses=new ClasspathPattern(patterns==null?WebAppContext.__dftSystemClasses:patterns);
|
||||
_systemClasses=new ClassMatcher(patterns==null?WebAppContext.__dftSystemClasses:patterns);
|
||||
_libLoader=libLoader;
|
||||
|
||||
|
||||
|
@ -227,7 +227,7 @@ public class TemplateContext extends ContainerLifeCycle implements WebAppClassLo
|
|||
*/
|
||||
public void setServerClasses(String[] serverClasses)
|
||||
{
|
||||
_serverClasses = new ClasspathPattern(serverClasses);
|
||||
_serverClasses = new ClassMatcher(serverClasses);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -247,7 +247,7 @@ public class TemplateContext extends ContainerLifeCycle implements WebAppClassLo
|
|||
*/
|
||||
public void setSystemClasses(String[] systemClasses)
|
||||
{
|
||||
_systemClasses = new ClasspathPattern(systemClasses);
|
||||
_systemClasses = new ClassMatcher(systemClasses);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.eclipse.jetty.plus.jndi.EnvEntry;
|
|||
import org.eclipse.jetty.plus.jndi.NamingEntry;
|
||||
import org.eclipse.jetty.plus.jndi.NamingEntryUtil;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.webapp.Configuration;
|
||||
import org.eclipse.jetty.webapp.MetaData;
|
||||
import org.eclipse.jetty.webapp.WebAppClassLoader;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
@ -50,8 +49,8 @@ public class TestConfiguration
|
|||
WebAppContext wac = new WebAppContext();
|
||||
wac.setServer(server);
|
||||
wac.setClassLoader(new WebAppClassLoader(Thread.currentThread().getContextClassLoader(), wac));
|
||||
wac.getSystemClasspathPattern().include("org.eclipse.jetty.jndi.");
|
||||
wac.getServerClasspathPattern().exclude("org.eclipse.jetty.jndi.");
|
||||
wac.getSystemClassMatcher().include("org.eclipse.jetty.jndi.");
|
||||
wac.getServerClassMatcher().exclude("org.eclipse.jetty.jndi.");
|
||||
|
||||
MetaData metaData = new MetaData();
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ public class AbstractConfiguration implements Configuration
|
|||
private final boolean _disabledByDefault;
|
||||
private final List<String> _after=new ArrayList<>();
|
||||
private final List<String> _beforeThis=new ArrayList<>();
|
||||
private final ClasspathPattern _system=new ClasspathPattern();
|
||||
private final ClasspathPattern _server=new ClasspathPattern();
|
||||
private final ClassMatcher _system=new ClassMatcher();
|
||||
private final ClassMatcher _server=new ClassMatcher();
|
||||
|
||||
protected AbstractConfiguration()
|
||||
{
|
||||
|
@ -149,13 +149,13 @@ public class AbstractConfiguration implements Configuration
|
|||
}
|
||||
|
||||
@Override
|
||||
public ClasspathPattern getSystemClasses()
|
||||
public ClassMatcher getSystemClasses()
|
||||
{
|
||||
return _system;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClasspathPattern getServerClasses()
|
||||
public ClassMatcher getServerClasses()
|
||||
{
|
||||
return _server;
|
||||
}
|
||||
|
|
|
@ -46,8 +46,9 @@ import org.eclipse.jetty.util.log.Logger;
|
|||
import org.eclipse.jetty.util.resource.Resource;
|
||||
|
||||
/**
|
||||
* Classpath classes list performs pattern matching of a class name
|
||||
* against an internal array of classpath pattern entries.
|
||||
* A matcher for classes based on package and/or location and/or module/
|
||||
* <p>
|
||||
* Performs pattern matching of a class against a set of pattern entries.
|
||||
* A class pattern is a string of one of the forms:<ul>
|
||||
* <li>'org.package.SomeClass' will match a specific class
|
||||
* <li>'org.package.' will match a specific package hierarchy
|
||||
|
@ -65,9 +66,9 @@ import org.eclipse.jetty.util.resource.Resource;
|
|||
* in this string should be separated by ':' (semicolon) or ',' (comma).
|
||||
*/
|
||||
|
||||
public class ClasspathPattern extends AbstractSet<String>
|
||||
public class ClassMatcher extends AbstractSet<String>
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ClasspathPattern.class);
|
||||
private static final Logger LOG = Log.getLogger(ClassMatcher.class);
|
||||
|
||||
private static class Entry
|
||||
{
|
||||
|
@ -491,23 +492,23 @@ public class ClasspathPattern extends AbstractSet<String>
|
|||
IncludeExcludeSet<Entry,String> _patterns = new IncludeExcludeSet<>(ByPackageOrName.class);
|
||||
IncludeExcludeSet<Entry,URI> _locations = new IncludeExcludeSet<>(ByLocationOrModule.class);
|
||||
|
||||
public ClasspathPattern()
|
||||
public ClassMatcher()
|
||||
{
|
||||
}
|
||||
|
||||
public ClasspathPattern(ClasspathPattern patterns)
|
||||
public ClassMatcher(ClassMatcher patterns)
|
||||
{
|
||||
if (patterns!=null)
|
||||
setAll(patterns.getPatterns());
|
||||
}
|
||||
|
||||
public ClasspathPattern(String... patterns)
|
||||
public ClassMatcher(String... patterns)
|
||||
{
|
||||
if (patterns!=null && patterns.length>0)
|
||||
setAll(patterns);
|
||||
}
|
||||
|
||||
public ClasspathPattern(String pattern)
|
||||
public ClassMatcher(String pattern)
|
||||
{
|
||||
add(pattern);
|
||||
}
|
|
@ -87,14 +87,14 @@ public interface Configuration
|
|||
default Collection<String> getDependents(){ return Collections.emptyList(); }
|
||||
|
||||
/** Get the system classes associated with this Configuration.
|
||||
* @return ClasspathPattern of system classes.
|
||||
* @return ClassMatcher of system classes.
|
||||
*/
|
||||
default ClasspathPattern getSystemClasses() { return new ClasspathPattern(); }
|
||||
default ClassMatcher getSystemClasses() { return new ClassMatcher(); }
|
||||
|
||||
/** Get the system classes associated with this Configuration.
|
||||
* @return ClasspathPattern of server classes.
|
||||
* @return ClassMatcher of server classes.
|
||||
*/
|
||||
default ClasspathPattern getServerClasses() { return new ClasspathPattern(); }
|
||||
default ClassMatcher getServerClasses() { return new ClassMatcher(); }
|
||||
|
||||
/** Set up for configuration.
|
||||
* <p>
|
||||
|
|
|
@ -170,7 +170,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
// System classes are classes that cannot be replaced by
|
||||
// the web application, and they are *always* loaded via
|
||||
// system classloader.
|
||||
public final static ClasspathPattern __dftSystemClasses = new ClasspathPattern
|
||||
public final static ClassMatcher __dftSystemClasses = new ClassMatcher
|
||||
(
|
||||
"java.", // Java SE classes (per servlet spec v2.5 / SRV.9.7.2)
|
||||
"javax.", // Java SE classes (per servlet spec v2.5 / SRV.9.7.2)
|
||||
|
@ -182,14 +182,14 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
// loaded by the web application using system classloader,
|
||||
// so if web application needs to load any of such classes,
|
||||
// it has to include them in its distribution.
|
||||
public final static ClasspathPattern __dftServerClasses =new ClasspathPattern
|
||||
public final static ClassMatcher __dftServerClasses =new ClassMatcher
|
||||
(
|
||||
"org.eclipse.jetty." // hide jetty classes
|
||||
);
|
||||
|
||||
private final Configurations _configurations = new Configurations();
|
||||
private final ClasspathPattern _systemClasses = new ClasspathPattern(__dftSystemClasses);
|
||||
private final ClasspathPattern _serverClasses = new ClasspathPattern(__dftServerClasses);
|
||||
private final ClassMatcher _systemClasses = new ClassMatcher(__dftSystemClasses);
|
||||
private final ClassMatcher _serverClasses = new ClassMatcher(__dftServerClasses);
|
||||
|
||||
private String _defaultsDescriptor=WEB_DEFAULTS_XML;
|
||||
private String _descriptor=null;
|
||||
|
@ -703,7 +703,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
* @param serverClasses the server classes pattern
|
||||
*
|
||||
*/
|
||||
public void setServerClasspathPattern(ClasspathPattern serverClasses)
|
||||
public void setServerClassMatcher(ClassMatcher serverClasses)
|
||||
{
|
||||
_serverClasses.clear();
|
||||
_serverClasses.add(serverClasses.getPatterns());
|
||||
|
@ -718,38 +718,48 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
* regardless of the value of {@link #setParentLoaderPriority(boolean)}.
|
||||
* @param systemClasses the system classes pattern
|
||||
*/
|
||||
public void setSystemClasspathPattern(ClasspathPattern systemClasses)
|
||||
public void setSystemClassMatcher(ClassMatcher systemClasses)
|
||||
{
|
||||
_systemClasses.clear();
|
||||
_systemClasses.add(systemClasses.getPatterns());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a ClassMatcher for server classes by combining with
|
||||
* any existing matcher.
|
||||
* @param serverClasses The class matcher of patterns to add to the server ClassMatcher
|
||||
*/
|
||||
/* ------------------------------------------------------------ */
|
||||
public void addServerClasspathPattern(ClasspathPattern serverClasses)
|
||||
public void addServerClassMatcher(ClassMatcher serverClasses)
|
||||
{
|
||||
_serverClasses.add(serverClasses.getPatterns());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a ClassMatcher for system classes by combining with
|
||||
* any existing matcher.
|
||||
* @param systemClasses The class matcher of patterns to add to the system ClassMatcher
|
||||
*/
|
||||
/* ------------------------------------------------------------ */
|
||||
public void addSystemClasspathPattern(ClasspathPattern systemClasses)
|
||||
public void addSystemClassMatcher(ClassMatcher systemClasses)
|
||||
{
|
||||
_systemClasses.add(systemClasses.getPatterns());
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return The ClasspathPattern used to match System (protected) classes
|
||||
* @return The ClassMatcher used to match System (protected) classes
|
||||
*/
|
||||
public ClasspathPattern getSystemClasspathPattern()
|
||||
public ClassMatcher getSystemClassMatcher()
|
||||
{
|
||||
return _systemClasses;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return The ClasspathPattern used to match Server (hidden) classes
|
||||
* @return The ClassMatcher used to match Server (hidden) classes
|
||||
*/
|
||||
public ClasspathPattern getServerClasspathPattern()
|
||||
public ClassMatcher getServerClassMatcher()
|
||||
{
|
||||
return _serverClasses;
|
||||
}
|
||||
|
@ -819,18 +829,18 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
{
|
||||
Object systemClasses = server.getAttribute(SERVER_SYS_CLASSES);
|
||||
if (systemClasses instanceof String[])
|
||||
systemClasses = new ClasspathPattern((String[])systemClasses);
|
||||
if (systemClasses instanceof ClasspathPattern)
|
||||
_systemClasses.add(((ClasspathPattern)systemClasses).getPatterns());
|
||||
systemClasses = new ClassMatcher((String[])systemClasses);
|
||||
if (systemClasses instanceof ClassMatcher)
|
||||
_systemClasses.add(((ClassMatcher)systemClasses).getPatterns());
|
||||
}
|
||||
|
||||
if (__dftServerClasses.equals(_serverClasses))
|
||||
{
|
||||
Object serverClasses = server.getAttribute(SERVER_SRV_CLASSES);
|
||||
if (serverClasses instanceof String[])
|
||||
serverClasses = new ClasspathPattern((String[])serverClasses);
|
||||
if (serverClasses instanceof ClasspathPattern)
|
||||
_serverClasses.add(((ClasspathPattern)serverClasses).getPatterns());
|
||||
serverClasses = new ClassMatcher((String[])serverClasses);
|
||||
if (serverClasses instanceof ClassMatcher)
|
||||
_serverClasses.add(((ClassMatcher)serverClasses).getPatterns());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1526,9 +1536,9 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
// look for a Server attribute with the list of Server classes
|
||||
// to apply to every web application. If not present, use our defaults.
|
||||
Object o = server.getAttribute(SERVER_SRV_CLASSES);
|
||||
if (o instanceof ClasspathPattern)
|
||||
if (o instanceof ClassMatcher)
|
||||
{
|
||||
((ClasspathPattern)o).add(pattern);
|
||||
((ClassMatcher)o).add(pattern);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1552,9 +1562,9 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
// look for a Server attribute with the list of System classes
|
||||
// to apply to every web application. If not present, use our defaults.
|
||||
Object o = server.getAttribute(SERVER_SYS_CLASSES);
|
||||
if (o instanceof ClasspathPattern)
|
||||
if (o instanceof ClassMatcher)
|
||||
{
|
||||
((ClasspathPattern)o).add(pattern);
|
||||
((ClassMatcher)o).add(pattern);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@ import org.junit.jupiter.api.condition.DisabledOnJre;
|
|||
import org.junit.jupiter.api.condition.EnabledOnJre;
|
||||
import org.junit.jupiter.api.condition.JRE;
|
||||
|
||||
public class ClasspathPatternTest
|
||||
public class ClassMatcherTest
|
||||
{
|
||||
private final ClasspathPattern _pattern = new ClasspathPattern();
|
||||
private final ClassMatcher _pattern = new ClassMatcher();
|
||||
|
||||
@BeforeEach
|
||||
public void before()
|
||||
|
@ -129,14 +129,14 @@ public class ClasspathPatternTest
|
|||
// System.err.println(loc_junit);
|
||||
|
||||
// class file
|
||||
URI loc_test = TypeUtil.getLocationOfClass(ClasspathPatternTest.class);
|
||||
URI loc_test = TypeUtil.getLocationOfClass(ClassMatcherTest.class);
|
||||
// System.err.println(loc_test);
|
||||
|
||||
ClasspathPattern pattern = new ClasspathPattern();
|
||||
ClassMatcher pattern = new ClassMatcher();
|
||||
pattern.include("something");
|
||||
assertThat(pattern.match(String.class), Matchers.is(false));
|
||||
assertThat(pattern.match(Test.class), Matchers.is(false));
|
||||
assertThat(pattern.match(ClasspathPatternTest.class), Matchers.is(false));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), Matchers.is(false));
|
||||
|
||||
// Add directory for both JVM classes
|
||||
pattern.include(Paths.get(loc_string).getParent().toUri().toString());
|
||||
|
@ -146,12 +146,12 @@ public class ClasspathPatternTest
|
|||
|
||||
assertThat(pattern.match(String.class), Matchers.is(true));
|
||||
assertThat(pattern.match(Test.class), Matchers.is(true));
|
||||
assertThat(pattern.match(ClasspathPatternTest.class), Matchers.is(true));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), Matchers.is(true));
|
||||
|
||||
pattern.add("-java.lang.String");
|
||||
assertThat(pattern.match(String.class), Matchers.is(false));
|
||||
assertThat(pattern.match(Test.class), Matchers.is(true));
|
||||
assertThat(pattern.match(ClasspathPatternTest.class), Matchers.is(true));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), Matchers.is(true));
|
||||
}
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
|
@ -168,14 +168,14 @@ public class ClasspathPatternTest
|
|||
// System.err.println(loc_junit);
|
||||
|
||||
// class file
|
||||
URI loc_test = TypeUtil.getLocationOfClass(ClasspathPatternTest.class);
|
||||
URI loc_test = TypeUtil.getLocationOfClass(ClassMatcherTest.class);
|
||||
// System.err.println(loc_test);
|
||||
|
||||
ClasspathPattern pattern = new ClasspathPattern();
|
||||
ClassMatcher pattern = new ClassMatcher();
|
||||
pattern.include("something");
|
||||
assertThat(pattern.match(String.class), Matchers.is(false));
|
||||
assertThat(pattern.match(Test.class), Matchers.is(false));
|
||||
assertThat(pattern.match(ClasspathPatternTest.class), Matchers.is(false));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), Matchers.is(false));
|
||||
|
||||
// Add module for all JVM base classes
|
||||
pattern.include("jrt:/java.base");
|
||||
|
@ -185,12 +185,12 @@ public class ClasspathPatternTest
|
|||
|
||||
assertThat(pattern.match(String.class), Matchers.is(true));
|
||||
assertThat(pattern.match(Test.class), Matchers.is(true));
|
||||
assertThat(pattern.match(ClasspathPatternTest.class), Matchers.is(true));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), Matchers.is(true));
|
||||
|
||||
pattern.add("-java.lang.String");
|
||||
assertThat(pattern.match(String.class), Matchers.is(false));
|
||||
assertThat(pattern.match(Test.class), Matchers.is(true));
|
||||
assertThat(pattern.match(ClasspathPatternTest.class), Matchers.is(true));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), Matchers.is(true));
|
||||
}
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
|
@ -207,17 +207,17 @@ public class ClasspathPatternTest
|
|||
// System.err.println(loc_junit);
|
||||
|
||||
// class file
|
||||
URI loc_test = TypeUtil.getLocationOfClass(ClasspathPatternTest.class);
|
||||
URI loc_test = TypeUtil.getLocationOfClass(ClassMatcherTest.class);
|
||||
// System.err.println(loc_test);
|
||||
|
||||
ClasspathPattern pattern = new ClasspathPattern();
|
||||
ClassMatcher pattern = new ClassMatcher();
|
||||
|
||||
// include everything
|
||||
pattern.include(".");
|
||||
|
||||
assertThat(pattern.match(String.class), Matchers.is(true));
|
||||
assertThat(pattern.match(Test.class), Matchers.is(true));
|
||||
assertThat(pattern.match(ClasspathPatternTest.class), Matchers.is(true));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), Matchers.is(true));
|
||||
|
||||
// Add directory for both JVM classes
|
||||
pattern.exclude(Paths.get(loc_string).getParent().toUri().toString());
|
||||
|
@ -227,7 +227,7 @@ public class ClasspathPatternTest
|
|||
|
||||
assertThat(pattern.match(String.class), Matchers.is(false));
|
||||
assertThat(pattern.match(Test.class), Matchers.is(false));
|
||||
assertThat(pattern.match(ClasspathPatternTest.class), Matchers.is(false));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), Matchers.is(false));
|
||||
}
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
|
@ -244,17 +244,17 @@ public class ClasspathPatternTest
|
|||
// System.err.println(loc_junit);
|
||||
|
||||
// class file
|
||||
URI loc_test = TypeUtil.getLocationOfClass(ClasspathPatternTest.class);
|
||||
URI loc_test = TypeUtil.getLocationOfClass(ClassMatcherTest.class);
|
||||
// System.err.println(loc_test);
|
||||
|
||||
ClasspathPattern pattern = new ClasspathPattern();
|
||||
ClassMatcher pattern = new ClassMatcher();
|
||||
|
||||
// include everything
|
||||
pattern.include(".");
|
||||
|
||||
assertThat(pattern.match(String.class), Matchers.is(true));
|
||||
assertThat(pattern.match(Test.class), Matchers.is(true));
|
||||
assertThat(pattern.match(ClasspathPatternTest.class), Matchers.is(true));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), Matchers.is(true));
|
||||
|
||||
// Add directory for both JVM classes
|
||||
pattern.exclude("jrt:/java.base/");
|
||||
|
@ -264,13 +264,13 @@ public class ClasspathPatternTest
|
|||
|
||||
assertThat(pattern.match(String.class), Matchers.is(false));
|
||||
assertThat(pattern.match(Test.class), Matchers.is(false));
|
||||
assertThat(pattern.match(ClasspathPatternTest.class), Matchers.is(false));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), Matchers.is(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLarge()
|
||||
{
|
||||
ClasspathPattern pattern = new ClasspathPattern();
|
||||
ClassMatcher pattern = new ClassMatcher();
|
||||
for (int i = 0; i < 500; i++)
|
||||
{
|
||||
assertTrue(pattern.add("n" + i + "." + Integer.toHexString(100 + i) + ".Name"));
|
|
@ -199,7 +199,7 @@ public class WebAppClassLoaderTest
|
|||
String[] newSC=new String[oldSC.length+1];
|
||||
newSC[0]="-org.eclipse.jetty.webapp.Configuration";
|
||||
System.arraycopy(oldSC,0,newSC,1,oldSC.length);
|
||||
_context.setServerClasspathPattern(new ClasspathPattern(newSC));
|
||||
_context.setServerClassMatcher(new ClassMatcher(newSC));
|
||||
|
||||
assertCanLoadClass("org.acme.webapp.ClassInJarA");
|
||||
assertCanLoadClass("org.acme.webapp.ClassInJarB");
|
||||
|
@ -212,7 +212,7 @@ public class WebAppClassLoaderTest
|
|||
@Test
|
||||
public void testExposedClass() throws Exception
|
||||
{
|
||||
_context.getServerClasspathPattern().exclude("org.eclipse.jetty.webapp.Configuration");
|
||||
_context.getServerClassMatcher().exclude("org.eclipse.jetty.webapp.Configuration");
|
||||
|
||||
assertCanLoadClass("org.acme.webapp.ClassInJarA");
|
||||
assertCanLoadClass("org.acme.webapp.ClassInJarB");
|
||||
|
@ -231,13 +231,13 @@ public class WebAppClassLoaderTest
|
|||
newServC[0]="org.eclipse.jetty.webapp.Configuration";
|
||||
System.arraycopy(oldServC,0,newServC,1,oldServC.length);
|
||||
|
||||
_context.setServerClasspathPattern(new ClasspathPattern(newServC));
|
||||
_context.setServerClassMatcher(new ClassMatcher(newServC));
|
||||
|
||||
String[] oldSysC=_context.getSystemClasses();
|
||||
String[] newSysC=new String[oldSysC.length+1];
|
||||
newSysC[0]="org.eclipse.jetty.webapp.";
|
||||
System.arraycopy(oldSysC,0,newSysC,1,oldSysC.length);
|
||||
_context.setSystemClasspathPattern(new ClasspathPattern(newSysC));
|
||||
_context.setSystemClassMatcher(new ClassMatcher(newSysC));
|
||||
|
||||
assertCanLoadClass("org.acme.webapp.ClassInJarA");
|
||||
assertCanLoadClass("org.acme.webapp.ClassInJarB");
|
||||
|
@ -249,24 +249,24 @@ public class WebAppClassLoaderTest
|
|||
newSysC=new String[oldSysC.length+1];
|
||||
newSysC[0]="org.acme.webapp.ClassInJarA";
|
||||
System.arraycopy(oldSysC,0,newSysC,1,oldSysC.length);
|
||||
_context.setSystemClasspathPattern(new ClasspathPattern(newSysC));
|
||||
_context.setSystemClassMatcher(new ClassMatcher(newSysC));
|
||||
|
||||
assertCanLoadResource("org/acme/webapp/ClassInJarA.class");
|
||||
_context.setSystemClasspathPattern(new ClasspathPattern(oldSysC));
|
||||
_context.setSystemClassMatcher(new ClassMatcher(oldSysC));
|
||||
|
||||
oldServC=_context.getServerClasses();
|
||||
newServC=new String[oldServC.length+1];
|
||||
newServC[0]="org.acme.webapp.ClassInJarA";
|
||||
System.arraycopy(oldServC,0,newServC,1,oldServC.length);
|
||||
_context.setServerClasspathPattern(new ClasspathPattern(newServC));
|
||||
_context.setServerClassMatcher(new ClassMatcher(newServC));
|
||||
assertCanLoadResource("org/acme/webapp/ClassInJarA.class");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSystemServerClass() throws Exception
|
||||
{
|
||||
_context.getServerClasspathPattern().add("org.eclipse.jetty.webapp.Configuration");
|
||||
_context.getSystemClasspathPattern().add("org.eclipse.jetty.webapp.");
|
||||
_context.getServerClassMatcher().add("org.eclipse.jetty.webapp.Configuration");
|
||||
_context.getSystemClassMatcher().add("org.eclipse.jetty.webapp.");
|
||||
|
||||
assertCanLoadClass("org.acme.webapp.ClassInJarA");
|
||||
assertCanLoadClass("org.acme.webapp.ClassInJarB");
|
||||
|
@ -274,11 +274,11 @@ public class WebAppClassLoaderTest
|
|||
assertCantLoadClass("org.eclipse.jetty.webapp.Configuration");
|
||||
assertCantLoadClass("org.eclipse.jetty.webapp.JarScanner");
|
||||
|
||||
_context.getSystemClasspathPattern().add("org.acme.webapp.ClassInJarA");
|
||||
_context.getSystemClassMatcher().add("org.acme.webapp.ClassInJarA");
|
||||
assertCanLoadResource("org/acme/webapp/ClassInJarA.class");
|
||||
_context.getSystemClasspathPattern().remove("org.acme.webapp.ClassInJarA");
|
||||
_context.getSystemClassMatcher().remove("org.acme.webapp.ClassInJarA");
|
||||
|
||||
_context.getServerClasspathPattern().add("org.acme.webapp.ClassInJarA");
|
||||
_context.getServerClassMatcher().add("org.acme.webapp.ClassInJarA");
|
||||
assertCanLoadResource("org/acme/webapp/ClassInJarA.class");
|
||||
}
|
||||
|
||||
|
@ -329,7 +329,7 @@ public class WebAppClassLoaderTest
|
|||
String[] newServC=new String[oldServC.length+1];
|
||||
newServC[0]="org.acme.";
|
||||
System.arraycopy(oldServC,0,newServC,1,oldServC.length);
|
||||
_context.setServerClasspathPattern(new ClasspathPattern(newServC));
|
||||
_context.setServerClassMatcher(new ClassMatcher(newServC));
|
||||
|
||||
_context.setParentLoaderPriority(true);
|
||||
// dump(_context);
|
||||
|
@ -346,12 +346,12 @@ public class WebAppClassLoaderTest
|
|||
// assertEquals(0,resources.get(0).toString().indexOf("jar:file:"));
|
||||
// assertEquals(0,resources.get(1).toString().indexOf("file:"));
|
||||
|
||||
_context.setServerClasspathPattern(new ClasspathPattern(oldServC));
|
||||
_context.setServerClassMatcher(new ClassMatcher(oldServC));
|
||||
String[] oldSysC=_context.getSystemClasses();
|
||||
String[] newSysC=new String[oldSysC.length+1];
|
||||
newSysC[0]="org.acme.";
|
||||
System.arraycopy(oldSysC,0,newSysC,1,oldSysC.length);
|
||||
_context.setSystemClasspathPattern(new ClasspathPattern(newSysC));
|
||||
_context.setSystemClassMatcher(new ClassMatcher(newSysC));
|
||||
|
||||
_context.setParentLoaderPriority(true);
|
||||
// dump(_context);
|
||||
|
|
|
@ -9,7 +9,7 @@ org.eclipse.jetty.servlet.WebApplicationContext object
|
|||
-->
|
||||
|
||||
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
|
||||
<Get name="ServerClasspathPattern">
|
||||
<Get name="ServerClassMatcher">
|
||||
<Call name="exclude">
|
||||
<Arg>
|
||||
<Array type="String">
|
||||
|
|
Loading…
Reference in New Issue