Features work in progress
convert more server/system classes to Configurations
This commit is contained in:
parent
037e04bfe5
commit
22a6cd05b7
|
@ -0,0 +1 @@
|
||||||
|
org.eclipse.jetty.webapp.JspConfiguration
|
|
@ -62,6 +62,8 @@ public class OneWebApp
|
||||||
// Start things up!
|
// Start things up!
|
||||||
server.start();
|
server.start();
|
||||||
|
|
||||||
|
server.dumpStdErr();
|
||||||
|
|
||||||
// The use of server.join() the will make the current thread join and
|
// The use of server.join() the will make the current thread join and
|
||||||
// wait until the server is done executing.
|
// wait until the server is done executing.
|
||||||
// See http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#join()
|
// See http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#join()
|
||||||
|
|
|
@ -98,7 +98,8 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
|
|
||||||
public AnnotationConfiguration()
|
public AnnotationConfiguration()
|
||||||
{
|
{
|
||||||
super(new String[]{WebXmlConfiguration.class.getName(),MetaInfConfiguration.class.getName(),FragmentConfiguration.class.getName(),PlusConfiguration.class.getName()},
|
super(false,
|
||||||
|
new String[]{WebXmlConfiguration.class.getName(),MetaInfConfiguration.class.getName(),FragmentConfiguration.class.getName(),PlusConfiguration.class.getName()},
|
||||||
new String[]{JettyWebXmlConfiguration.class.getName()},
|
new String[]{JettyWebXmlConfiguration.class.getName()},
|
||||||
new String[]{"org.eclipse.jetty.util.annotation."},
|
new String[]{"org.eclipse.jetty.util.annotation."},
|
||||||
new String[]{"-org.eclipse.jetty.util.annotation.","org.objectweb.asm."});
|
new String[]{"-org.eclipse.jetty.util.annotation.","org.objectweb.asm."});
|
||||||
|
|
|
@ -73,29 +73,6 @@ public class AntWebAppContext extends WebAppContext
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(WebAppContext.class);
|
private static final Logger LOG = Log.getLogger(WebAppContext.class);
|
||||||
|
|
||||||
public final AntWebInfConfiguration antWebInfConfiguration = new AntWebInfConfiguration();
|
|
||||||
public final WebXmlConfiguration webXmlConfiguration = new WebXmlConfiguration();
|
|
||||||
public final MetaInfConfiguration metaInfConfiguration = new MetaInfConfiguration();
|
|
||||||
public final FragmentConfiguration fragmentConfiguration = new FragmentConfiguration();
|
|
||||||
public final EnvConfiguration envConfiguration = new EnvConfiguration();
|
|
||||||
public final PlusConfiguration plusConfiguration = new PlusConfiguration();
|
|
||||||
public final AnnotationConfiguration annotationConfiguration = new AnnotationConfiguration();
|
|
||||||
public final JettyWebXmlConfiguration jettyWebXmlConfiguration = new JettyWebXmlConfiguration();
|
|
||||||
|
|
||||||
|
|
||||||
public final Configuration[] DEFAULT_CONFIGURATIONS =
|
|
||||||
{
|
|
||||||
antWebInfConfiguration,
|
|
||||||
webXmlConfiguration,
|
|
||||||
metaInfConfiguration,
|
|
||||||
fragmentConfiguration,
|
|
||||||
envConfiguration,
|
|
||||||
plusConfiguration,
|
|
||||||
annotationConfiguration,
|
|
||||||
jettyWebXmlConfiguration
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
public final static String DEFAULT_CONTAINER_INCLUDE_JAR_PATTERN =
|
public final static String DEFAULT_CONTAINER_INCLUDE_JAR_PATTERN =
|
||||||
".*/.*jsp-api-[^/]*\\.jar$|.*/.*jsp-[^/]*\\.jar$|.*/.*taglibs[^/]*\\.jar$|.*/.*jstl[^/]*\\.jar$|.*/.*jsf-impl-[^/]*\\.jar$|.*/.*javax.faces-[^/]*\\.jar$|.*/.*myfaces-impl-[^/]*\\.jar$";
|
".*/.*jsp-api-[^/]*\\.jar$|.*/.*jsp-[^/]*\\.jar$|.*/.*taglibs[^/]*\\.jar$|.*/.*jstl[^/]*\\.jar$|.*/.*jsf-impl-[^/]*\\.jar$|.*/.*javax.faces-[^/]*\\.jar$|.*/.*myfaces-impl-[^/]*\\.jar$";
|
||||||
|
|
||||||
|
@ -432,7 +409,6 @@ public class AntWebAppContext extends WebAppContext
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
this.project = project;
|
this.project = project;
|
||||||
setConfigurations(DEFAULT_CONFIGURATIONS);
|
|
||||||
setAttribute(WebInfConfiguration.CONTAINER_JAR_PATTERN, DEFAULT_CONTAINER_INCLUDE_JAR_PATTERN);
|
setAttribute(WebInfConfiguration.CONTAINER_JAR_PATTERN, DEFAULT_CONTAINER_INCLUDE_JAR_PATTERN);
|
||||||
setParentLoaderPriority(true);
|
setParentLoaderPriority(true);
|
||||||
}
|
}
|
||||||
|
@ -632,8 +608,10 @@ public class AntWebAppContext extends WebAppContext
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
TaskLog.logWithTimestamp("Starting web application "+this.getDescriptor());
|
TaskLog.logWithTimestamp("Starting web application "+this.getDescriptor());
|
||||||
|
addConfiguration(new AntWebInfConfiguration(),new AntWebXmlConfiguration());
|
||||||
|
|
||||||
if (jettyEnvXml != null && jettyEnvXml.exists())
|
if (jettyEnvXml != null && jettyEnvXml.exists())
|
||||||
envConfiguration.setJettyEnvXml(Resource.toURL(jettyEnvXml));
|
getConfiguration(EnvConfiguration.class).setJettyEnvXml(Resource.toURL(jettyEnvXml));
|
||||||
|
|
||||||
ClassLoader parentLoader = this.getClass().getClassLoader();
|
ClassLoader parentLoader = this.getClass().getClassLoader();
|
||||||
if (parentLoader instanceof AntClassLoader)
|
if (parentLoader instanceof AntClassLoader)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
org.eclipse.jetty.webapp.JaasConfiguration
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Declared in the jmx package, but defined in the webapp package (as it depends on the Configuration interface)
|
||||||
|
org.eclipse.jetty.webapp.JmxConfiguration
|
|
@ -0,0 +1 @@
|
||||||
|
org.eclipse.jetty.webapp.ServletsConfiguration
|
|
@ -18,13 +18,14 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.webapp;
|
package org.eclipse.jetty.webapp;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class AbstractConfiguration implements Configuration
|
public class AbstractConfiguration implements Configuration
|
||||||
{
|
{
|
||||||
|
private final boolean _enabledByDefault;
|
||||||
private final List<String> _after;
|
private final List<String> _after;
|
||||||
private final List<String> _before;
|
private final List<String> _before;
|
||||||
private final List<String> _system;
|
private final List<String> _system;
|
||||||
|
@ -32,19 +33,61 @@ public class AbstractConfiguration implements Configuration
|
||||||
|
|
||||||
protected AbstractConfiguration()
|
protected AbstractConfiguration()
|
||||||
{
|
{
|
||||||
_after=Collections.emptyList();
|
this(false,(String[])null,(String[])null,null,null);
|
||||||
_before=Collections.emptyList();
|
|
||||||
_system=Collections.emptyList();
|
|
||||||
_server=Collections.emptyList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractConfiguration(String[] before,String[] after)
|
protected AbstractConfiguration(String[] before,String[] after)
|
||||||
{
|
{
|
||||||
this(before,after,null,null);
|
this(false,before,after,null,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected AbstractConfiguration(boolean enableByDefault,String[] before,String[] after)
|
||||||
|
{
|
||||||
|
this(enableByDefault,before,after,null,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param before Configurations that come before this configuration
|
||||||
|
* @param after Configuration that come after this configuration
|
||||||
|
* @param systemClasses
|
||||||
|
* @param serverClasses
|
||||||
|
*/
|
||||||
protected AbstractConfiguration(String[] before,String[] after,String[] systemClasses,String[] serverClasses)
|
protected AbstractConfiguration(String[] before,String[] after,String[] systemClasses,String[] serverClasses)
|
||||||
{
|
{
|
||||||
|
this (false,before,after,systemClasses,serverClasses);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param enabledByDefault
|
||||||
|
* @param before Configurations that come before this configuration
|
||||||
|
* @param after Configuration that come after this configuration
|
||||||
|
* @param systemClasses
|
||||||
|
* @param serverClasses
|
||||||
|
*/
|
||||||
|
protected AbstractConfiguration(
|
||||||
|
boolean enableByDefault,
|
||||||
|
Class<? extends Configuration>[] before,
|
||||||
|
Class<? extends Configuration>[] after,
|
||||||
|
String[] systemClasses,
|
||||||
|
String[] serverClasses)
|
||||||
|
{
|
||||||
|
_enabledByDefault=enableByDefault;
|
||||||
|
_after=Collections.unmodifiableList(after==null?Collections.emptyList():Arrays.asList(after).stream().map(Class::getName).collect(Collectors.toList()));
|
||||||
|
_before=Collections.unmodifiableList(before==null?Collections.emptyList():Arrays.asList(before).stream().map(Class::getName).collect(Collectors.toList()));
|
||||||
|
_system=Collections.unmodifiableList(systemClasses==null?Collections.emptyList():Arrays.asList(systemClasses));
|
||||||
|
_server=Collections.unmodifiableList(serverClasses==null?Collections.emptyList():Arrays.asList(serverClasses));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param enabledByDefault
|
||||||
|
* @param before Configurations that come before this configuration
|
||||||
|
* @param after Configuration that come after this configuration
|
||||||
|
* @param systemClasses
|
||||||
|
* @param serverClasses
|
||||||
|
*/
|
||||||
|
protected AbstractConfiguration(boolean enableByDefault,String[] before,String[] after,String[] systemClasses,String[] serverClasses)
|
||||||
|
{
|
||||||
|
_enabledByDefault=enableByDefault;
|
||||||
_after=Collections.unmodifiableList(after==null?Collections.emptyList():Arrays.asList(after));
|
_after=Collections.unmodifiableList(after==null?Collections.emptyList():Arrays.asList(after));
|
||||||
_before=Collections.unmodifiableList(before==null?Collections.emptyList():Arrays.asList(before));
|
_before=Collections.unmodifiableList(before==null?Collections.emptyList():Arrays.asList(before));
|
||||||
_system=Collections.unmodifiableList(systemClasses==null?Collections.emptyList():Arrays.asList(systemClasses));
|
_system=Collections.unmodifiableList(systemClasses==null?Collections.emptyList():Arrays.asList(systemClasses));
|
||||||
|
@ -98,4 +141,10 @@ public class AbstractConfiguration implements Configuration
|
||||||
public void cloneConfigure(WebAppContext template, WebAppContext context) throws Exception
|
public void cloneConfigure(WebAppContext template, WebAppContext context) throws Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabledByDefault()
|
||||||
|
{
|
||||||
|
return _enabledByDefault;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,7 @@ public class ClasspathPattern
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public ClasspathPattern(String... patterns)
|
public ClasspathPattern(String... patterns)
|
||||||
{
|
{
|
||||||
|
if (patterns!=null && patterns.length>0)
|
||||||
add(patterns);
|
add(patterns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +93,9 @@ public class ClasspathPattern
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public void add(String... patterns)
|
public void add(String... patterns)
|
||||||
{
|
{
|
||||||
|
if (patterns==null || patterns.length==0)
|
||||||
|
return;
|
||||||
|
|
||||||
for (String p :patterns)
|
for (String p :patterns)
|
||||||
{
|
{
|
||||||
if (_entries.stream().anyMatch(e->{return p.equals(e.toString());}))
|
if (_entries.stream().anyMatch(e->{return p.equals(e.toString());}))
|
||||||
|
|
|
@ -48,6 +48,7 @@ public class Configurations extends AbstractList<Configuration>
|
||||||
ServiceLoader<Configuration> configs = ServiceLoader.load(Configuration.class);
|
ServiceLoader<Configuration> configs = ServiceLoader.load(Configuration.class);
|
||||||
for (Configuration configuration : configs)
|
for (Configuration configuration : configs)
|
||||||
__known.put(configuration.getName(),configuration);
|
__known.put(configuration.getName(),configuration);
|
||||||
|
|
||||||
LOG.debug("Known Configurations {}",__known.keySet());
|
LOG.debug("Known Configurations {}",__known.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2016 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.webapp;
|
||||||
|
|
||||||
|
import java.util.ServiceLoader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>JAAS Configuration</p>
|
||||||
|
* <p>This configuration configures the WebAppContext server/system classes to
|
||||||
|
* be able to see the org.eclipse.jetty.jaas package.
|
||||||
|
* This class is defined in the webapp package, as it implements the {@link Configuration} interface,
|
||||||
|
* which is unknown to the jaas package. However, the corresponding {@link ServiceLoader}
|
||||||
|
* resource is defined in the jaas package, so that this configuration only be
|
||||||
|
* loaded if the jetty-jaas jars are on the classpath.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public class JaasConfiguration extends AbstractConfiguration
|
||||||
|
{
|
||||||
|
public JaasConfiguration()
|
||||||
|
{
|
||||||
|
super(true,
|
||||||
|
new String[]{WebXmlConfiguration.class.getName(),MetaInfConfiguration.class.getName(),WebInfConfiguration.class.getName(),FragmentConfiguration.class.getName()},
|
||||||
|
new String[]{WebAppConfiguration.class.getName()},
|
||||||
|
new String[]{
|
||||||
|
"org.eclipse.jetty.jaas."
|
||||||
|
},
|
||||||
|
new String[]{
|
||||||
|
"-org.eclipse.jetty.jaas.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -51,13 +51,7 @@ public class JettyWebXmlConfiguration extends AbstractConfiguration
|
||||||
|
|
||||||
public JettyWebXmlConfiguration()
|
public JettyWebXmlConfiguration()
|
||||||
{
|
{
|
||||||
super(new String[]{WebXmlConfiguration.class.getName(),FragmentConfiguration.class.getName(),MetaInfConfiguration.class.getName()},null);
|
super(true,new String[]{WebXmlConfiguration.class.getName(),FragmentConfiguration.class.getName(),MetaInfConfiguration.class.getName()},null);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEnabledByDefault()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2016 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.webapp;
|
||||||
|
|
||||||
|
import java.util.ServiceLoader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>JMX Configuration</p>
|
||||||
|
* <p>This configuration configures the WebAppContext server/system classes to
|
||||||
|
* be able to see the org.eclipse.jetty.jmx package. This class is defined
|
||||||
|
* in the webapp package, as it implements the {@link Configuration} interface,
|
||||||
|
* which is unknown to the jmx package. However, the corresponding {@link ServiceLoader}
|
||||||
|
* resource is defined in the jmx package, so that this configuration only be
|
||||||
|
* loaded if the jetty-jmx jars are on the classpath.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class JmxConfiguration extends AbstractConfiguration
|
||||||
|
{
|
||||||
|
public JmxConfiguration()
|
||||||
|
{
|
||||||
|
super(true,
|
||||||
|
null,
|
||||||
|
new String[]{WebXmlConfiguration.class.getName(),MetaInfConfiguration.class.getName(),WebInfConfiguration.class.getName()},
|
||||||
|
new String[]{"org.eclipse.jetty.jmx."},
|
||||||
|
new String[]{"-org.eclipse.jetty.jmx."});
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2016 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.webapp;
|
||||||
|
|
||||||
|
import java.util.ServiceLoader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>JSP Configuration</p>
|
||||||
|
* <p>This configuration configures the WebAppContext server/system classes to
|
||||||
|
* be able to see the org.eclipse.jetty.jsp and org.eclipse.jetty.apache packages.
|
||||||
|
* This class is defined in the webapp package, as it implements the {@link Configuration} interface,
|
||||||
|
* which is unknown to the jsp package. However, the corresponding {@link ServiceLoader}
|
||||||
|
* resource is defined in the jsp package, so that this configuration only be
|
||||||
|
* loaded if the jetty-jsp jars are on the classpath.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class JspConfiguration extends AbstractConfiguration
|
||||||
|
{
|
||||||
|
public JspConfiguration()
|
||||||
|
{
|
||||||
|
super(true,
|
||||||
|
new String[]{WebXmlConfiguration.class.getName(),MetaInfConfiguration.class.getName(),WebInfConfiguration.class.getName(),FragmentConfiguration.class.getName()},
|
||||||
|
new String[]{WebAppConfiguration.class.getName()},
|
||||||
|
new String[]{
|
||||||
|
"org.eclipse.jetty.jsp.JettyJspServlet"},
|
||||||
|
new String[]{
|
||||||
|
"-org.eclipse.jetty.jsp.",
|
||||||
|
"-org.eclipse.jetty.apache.",
|
||||||
|
"org.eclipse.jdt."});
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2016 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.webapp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Jetty Servlets Configuration</p>
|
||||||
|
* <p>This configuration configures the WebAppContext server/system classes to
|
||||||
|
* expose the jetty utility servlets if they are on the server classpath.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ServletsConfiguration extends AbstractConfiguration
|
||||||
|
{
|
||||||
|
public ServletsConfiguration()
|
||||||
|
{
|
||||||
|
super(true,
|
||||||
|
new String[]{WebXmlConfiguration.class.getName(),MetaInfConfiguration.class.getName(),WebInfConfiguration.class.getName(),WebAppConfiguration.class.getName()},
|
||||||
|
new String[]{JettyWebXmlConfiguration.class.getName()},
|
||||||
|
new String[]{
|
||||||
|
"org.eclipse.jetty.servlets.PushCacheFilter", //must be loaded by container classpath
|
||||||
|
"org.eclipse.jetty.servlets.PushSessionCacheFilter" //must be loaded by container classpath
|
||||||
|
|
||||||
|
},
|
||||||
|
new String[]{
|
||||||
|
"-org.eclipse.jetty.servlets.", // don't hide jetty servlets
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2016 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.webapp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>WebApp Configuration</p>
|
||||||
|
* <p>This configuration configures the WebAppContext server/system classes to
|
||||||
|
* be able to see default servlets.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class WebAppConfiguration extends AbstractConfiguration
|
||||||
|
{
|
||||||
|
public WebAppConfiguration()
|
||||||
|
{
|
||||||
|
super(true,
|
||||||
|
new String[]{WebXmlConfiguration.class.getName(),MetaInfConfiguration.class.getName(),WebInfConfiguration.class.getName()},
|
||||||
|
null,
|
||||||
|
new String[]{
|
||||||
|
"org.eclipse.jetty.util.log.",
|
||||||
|
"org.eclipse.jetty.servlet.DefaultServlet",
|
||||||
|
"org.eclipse.jetty.servlet.NoJspServlet",
|
||||||
|
"org.eclipse.jetty.continuation.",
|
||||||
|
},
|
||||||
|
new String[]{
|
||||||
|
"-org.eclipse.jetty.util.log.",
|
||||||
|
"-org.eclipse.jetty.servlet.DefaultServlet",
|
||||||
|
"-org.eclipse.jetty.servlet.NoJspServlet",
|
||||||
|
"-org.eclipse.jetty.servlet.listener.",
|
||||||
|
"-org.eclipse.jetty.continuation.",
|
||||||
|
"-org.eclipse.jetty.alpn.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,7 +25,6 @@ import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.security.PermissionCollection;
|
import java.security.PermissionCollection;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.EventListener;
|
import java.util.EventListener;
|
||||||
|
@ -33,7 +32,6 @@ import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.ServiceLoader;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
@ -60,9 +58,7 @@ import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
|
||||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||||
import org.eclipse.jetty.servlet.ServletHandler;
|
import org.eclipse.jetty.servlet.ServletHandler;
|
||||||
import org.eclipse.jetty.util.AttributesMap;
|
import org.eclipse.jetty.util.AttributesMap;
|
||||||
import org.eclipse.jetty.util.Loader;
|
|
||||||
import org.eclipse.jetty.util.MultiException;
|
import org.eclipse.jetty.util.MultiException;
|
||||||
import org.eclipse.jetty.util.TopologicalSort;
|
|
||||||
import org.eclipse.jetty.util.URIUtil;
|
import org.eclipse.jetty.util.URIUtil;
|
||||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||||
|
@ -103,57 +99,28 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
||||||
*/
|
*/
|
||||||
public static final String[] DEFAULT_CONFIGURATION_CLASSES =
|
public static final String[] DEFAULT_CONFIGURATION_CLASSES =
|
||||||
Configurations.getKnown().stream()
|
Configurations.getKnown().stream()
|
||||||
.filter(c->{return c.isEnabledByDefault();})
|
.filter(Configuration::isEnabledByDefault)
|
||||||
.map(c->{return c.getClass().getName();})
|
.map(c->c.getClass().getName())
|
||||||
.toArray(String[]::new);
|
.toArray(String[]::new);
|
||||||
|
|
||||||
// System classes are classes that cannot be replaced by
|
// System classes are classes that cannot be replaced by
|
||||||
// the web application, and they are *always* loaded via
|
// the web application, and they are *always* loaded via
|
||||||
// system classloader.
|
// system classloader.
|
||||||
// TODO This centrally managed list of features that are exposed/hidden needs to be replaced
|
|
||||||
// with a more automatic distributed mechanism
|
|
||||||
public final static String[] __dftSystemClasses =
|
public final static String[] __dftSystemClasses =
|
||||||
{
|
{
|
||||||
"java.", // Java SE classes (per servlet spec v2.5 / SRV.9.7.2)
|
"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)
|
"javax.", // Java SE classes (per servlet spec v2.5 / SRV.9.7.2)
|
||||||
"org.xml.", // needed by javax.xml
|
"org.xml.", // javax.xml
|
||||||
"org.w3c.", // needed by javax.xml
|
"org.w3c.", // javax.xml
|
||||||
|
|
||||||
|
|
||||||
"org.eclipse.jetty.jmx.", // webapp cannot change jmx classes
|
|
||||||
"org.eclipse.jetty.continuation.", // webapp cannot change continuation classes
|
|
||||||
"org.eclipse.jetty.jaas.", // webapp cannot change jaas classes
|
|
||||||
"org.eclipse.jetty.websocket.", // webapp cannot change / replace websocket classes
|
|
||||||
"org.eclipse.jetty.util.log.", // webapp should use server log
|
|
||||||
"org.eclipse.jetty.servlet.DefaultServlet", // webapp cannot change default servlets
|
|
||||||
"org.eclipse.jetty.jsp.JettyJspServlet", //webapp cannot change jetty jsp servlet
|
|
||||||
"org.eclipse.jetty.servlets.PushCacheFilter", //must be loaded by container classpath
|
|
||||||
"org.eclipse.jetty.servlets.PushSessionCacheFilter" //must be loaded by container classpath
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
// Server classes are classes that are hidden from being
|
// Server classes are classes that are hidden from being
|
||||||
// loaded by the web application using system classloader,
|
// loaded by the web application using system classloader,
|
||||||
// so if web application needs to load any of such classes,
|
// so if web application needs to load any of such classes,
|
||||||
// it has to include them in its distribution.
|
// it has to include them in its distribution.
|
||||||
// TODO This centrally managed list of features that are exposed/hidden needs to be replaced
|
|
||||||
// with a more automatic distributed mechanism
|
|
||||||
public final static String[] __dftServerClasses =
|
public final static String[] __dftServerClasses =
|
||||||
{
|
{
|
||||||
"-org.eclipse.jetty.jmx.", // don't hide jmx classes
|
"org.eclipse.jetty." // hide jetty classes
|
||||||
"-org.eclipse.jetty.continuation.", // don't hide continuation classes
|
|
||||||
"-org.eclipse.jetty.jaas.", // don't hide jaas classes
|
|
||||||
"-org.eclipse.jetty.servlets.", // don't hide jetty servlets
|
|
||||||
"-org.eclipse.jetty.servlet.DefaultServlet", // don't hide default servlet
|
|
||||||
"-org.eclipse.jetty.servlet.NoJspServlet", // don't hide noJspServlet servlet
|
|
||||||
"-org.eclipse.jetty.jsp.", //don't hide jsp servlet
|
|
||||||
"-org.eclipse.jetty.servlet.listener.", // don't hide useful listeners
|
|
||||||
"-org.eclipse.jetty.websocket.", // don't hide websocket classes from webapps (allow webapp to use ones from system classloader)
|
|
||||||
"-org.eclipse.jetty.apache.", // don't hide jetty apache impls
|
|
||||||
"-org.eclipse.jetty.util.log.", // don't hide server log
|
|
||||||
"-org.eclipse.jetty.alpn.", // don't hide ALPN
|
|
||||||
"org.eclipse.jdt.", // hide jdt used by jetty
|
|
||||||
|
|
||||||
"org.eclipse.jetty." // hide other jetty classes
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
private final Configurations _configurations = new Configurations();
|
private final Configurations _configurations = new Configurations();
|
||||||
|
@ -989,6 +956,16 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
||||||
_configurations.add(configuration);
|
_configurations.add(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
public <T> T getConfiguration(Class<? extends T> configClass)
|
||||||
|
{
|
||||||
|
loadConfigurations();
|
||||||
|
for (Configuration configuration : _configurations)
|
||||||
|
if (configClass.isAssignableFrom(configuration.getClass()) && configuration.getName().equals(configClass.getName()))
|
||||||
|
return (T)configuration;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* The default descriptor is a web.xml format file that is applied to the context before the standard WEB-INF/web.xml
|
* The default descriptor is a web.xml format file that is applied to the context before the standard WEB-INF/web.xml
|
||||||
|
@ -1165,7 +1142,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
||||||
*
|
*
|
||||||
* @param contextWhiteList the whitelist of contexts for {@link org.eclipse.jetty.servlet.ServletContextHandler.Context#getContext(String)}
|
* @param contextWhiteList the whitelist of contexts for {@link org.eclipse.jetty.servlet.ServletContextHandler.Context#getContext(String)}
|
||||||
*/
|
*/
|
||||||
public void setContextWhiteList(String[] contextWhiteList)
|
public void setContextWhiteList(String... contextWhiteList)
|
||||||
{
|
{
|
||||||
_contextWhiteList = contextWhiteList;
|
_contextWhiteList = contextWhiteList;
|
||||||
}
|
}
|
||||||
|
@ -1180,7 +1157,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
||||||
* A {@link ClasspathPattern} is used to match the server classes.
|
* A {@link ClasspathPattern} is used to match the server classes.
|
||||||
* @param serverClasses The serverClasses to set.
|
* @param serverClasses The serverClasses to set.
|
||||||
*/
|
*/
|
||||||
public void setServerClasses(String[] serverClasses)
|
public void setServerClasses(String... serverClasses)
|
||||||
{
|
{
|
||||||
_serverClasses = new ClasspathPattern(serverClasses);
|
_serverClasses = new ClasspathPattern(serverClasses);
|
||||||
}
|
}
|
||||||
|
@ -1195,7 +1172,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
||||||
* A {@link ClasspathPattern} is used to match the system classes.
|
* A {@link ClasspathPattern} is used to match the system classes.
|
||||||
* @param systemClasses The systemClasses to set.
|
* @param systemClasses The systemClasses to set.
|
||||||
*/
|
*/
|
||||||
public void setSystemClasses(String[] systemClasses)
|
public void setSystemClasses(String... systemClasses)
|
||||||
{
|
{
|
||||||
_systemClasses = new ClasspathPattern(systemClasses);
|
_systemClasses = new ClasspathPattern(systemClasses);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2016 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.webapp;
|
||||||
|
|
||||||
|
import java.util.ServiceLoader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Websocket Configuration</p>
|
||||||
|
* <p>This configuration configures the WebAppContext server/system classes to
|
||||||
|
* be able to see the org.eclipse.jetty.websocket package.
|
||||||
|
* This class is defined in the webapp package, as it implements the {@link Configuration} interface,
|
||||||
|
* which is unknown to the websocket package. However, the corresponding {@link ServiceLoader}
|
||||||
|
* resource is defined in the websocket package, so that this configuration only be
|
||||||
|
* loaded if the jetty-websocket jars are on the classpath.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public class WebSocketConfiguration extends AbstractConfiguration
|
||||||
|
{
|
||||||
|
public WebSocketConfiguration()
|
||||||
|
{
|
||||||
|
super(true,
|
||||||
|
new String[]{WebXmlConfiguration.class.getName(),MetaInfConfiguration.class.getName(),WebInfConfiguration.class.getName(),FragmentConfiguration.class.getName()},
|
||||||
|
new String[]{"org.eclipse.jetty.annotations.AnnotationConfiguration",WebAppConfiguration.class.getName()},
|
||||||
|
new String[]{
|
||||||
|
"org.eclipse.jetty.websocket."
|
||||||
|
},
|
||||||
|
new String[]{
|
||||||
|
"-org.eclipse.jetty.websocket.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,3 +3,4 @@ org.eclipse.jetty.webapp.JettyWebXmlConfiguration
|
||||||
org.eclipse.jetty.webapp.MetaInfConfiguration
|
org.eclipse.jetty.webapp.MetaInfConfiguration
|
||||||
org.eclipse.jetty.webapp.WebInfConfiguration
|
org.eclipse.jetty.webapp.WebInfConfiguration
|
||||||
org.eclipse.jetty.webapp.WebXmlConfiguration
|
org.eclipse.jetty.webapp.WebXmlConfiguration
|
||||||
|
org.eclipse.jetty.webapp.WebAppConfiguration
|
||||||
|
|
|
@ -70,10 +70,12 @@ public class WebAppContextTest
|
||||||
wac.setServer(new Server());
|
wac.setServer(new Server());
|
||||||
Assert.assertThat(Arrays.asList(wac.getConfigurations()).stream().map(Configuration::getName).collect(Collectors.toList()),
|
Assert.assertThat(Arrays.asList(wac.getConfigurations()).stream().map(Configuration::getName).collect(Collectors.toList()),
|
||||||
Matchers.contains(
|
Matchers.contains(
|
||||||
|
"org.eclipse.jetty.webapp.JmxConfiguration",
|
||||||
"org.eclipse.jetty.webapp.WebInfConfiguration",
|
"org.eclipse.jetty.webapp.WebInfConfiguration",
|
||||||
"org.eclipse.jetty.webapp.WebXmlConfiguration",
|
"org.eclipse.jetty.webapp.WebXmlConfiguration",
|
||||||
"org.eclipse.jetty.webapp.MetaInfConfiguration",
|
"org.eclipse.jetty.webapp.MetaInfConfiguration",
|
||||||
"org.eclipse.jetty.webapp.FragmentConfiguration",
|
"org.eclipse.jetty.webapp.FragmentConfiguration",
|
||||||
|
"org.eclipse.jetty.webapp.WebAppConfiguration",
|
||||||
"org.eclipse.jetty.webapp.JettyWebXmlConfiguration"));
|
"org.eclipse.jetty.webapp.JettyWebXmlConfiguration"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,16 +112,7 @@ public class WSServer
|
||||||
context.setBaseResource(Resource.newResource(this.contextDir));
|
context.setBaseResource(Resource.newResource(this.contextDir));
|
||||||
context.setAttribute("org.eclipse.jetty.websocket.jsr356",Boolean.TRUE);
|
context.setAttribute("org.eclipse.jetty.websocket.jsr356",Boolean.TRUE);
|
||||||
|
|
||||||
// @formatter:off
|
context.addConfiguration(new AnnotationConfiguration(),new PlusConfiguration(),new EnvConfiguration());
|
||||||
context.setConfigurations(new Configuration[] {
|
|
||||||
new AnnotationConfiguration(),
|
|
||||||
new WebXmlConfiguration(),
|
|
||||||
new WebInfConfiguration(),
|
|
||||||
new PlusConfiguration(),
|
|
||||||
new MetaInfConfiguration(),
|
|
||||||
new FragmentConfiguration(),
|
|
||||||
new EnvConfiguration()});
|
|
||||||
// @formatter:on
|
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
org.eclipse.jetty.webapp.WebSocketConfiguration
|
Loading…
Reference in New Issue