Merge branch 'master' into release-9
This commit is contained in:
commit
80d7237ea5
|
@ -26,6 +26,7 @@
|
|||
</goals>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-Description>Jetty-specific ServletContainerInitializer for Jasper</Bundle-Description>
|
||||
<Export-Package>org.eclipse.jetty.apache.jsp.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"</Export-Package>
|
||||
<Require-Capability>osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)"</Require-Capability>
|
||||
<Provide-Capability>osgi.serviceloader; osgi.serviceloader=javax.servlet.ServletContainerInitializer</Provide-Capability>
|
||||
|
@ -35,6 +36,29 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>artifact-jar</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test-jar</id>
|
||||
<goals>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
|
|
|
@ -23,14 +23,14 @@ import java.net.URL;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.apache.jasper.servlet.JasperInitializer;
|
||||
import org.apache.jasper.servlet.TldPreScanned;
|
||||
import org.apache.jasper.servlet.TldScanner;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
|
@ -39,6 +39,7 @@ import org.xml.sax.SAXException;
|
|||
*/
|
||||
public class JettyJasperInitializer extends JasperInitializer
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(JettyJasperInitializer.class);
|
||||
|
||||
/**
|
||||
* NullTldScanner
|
||||
|
@ -99,14 +100,18 @@ public class JettyJasperInitializer extends JasperInitializer
|
|||
String tmp = context.getInitParameter("org.eclipse.jetty.jsp.precompiled");
|
||||
if (tmp!=null && !tmp.equals("") && Boolean.valueOf(tmp))
|
||||
{
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Jsp precompilation detected");
|
||||
return new NullTldScanner(context, namespaceAware, validate, blockExternal);
|
||||
}
|
||||
|
||||
Collection<URL> tldUrls = (Collection<URL>)context.getAttribute("org.eclipse.jetty.tlds");
|
||||
if (tldUrls != null && !tldUrls.isEmpty())
|
||||
if (tldUrls != null)
|
||||
{
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Tld pre-scan detected");
|
||||
return new TldPreScanned(context,namespaceAware,validate,blockExternal,tldUrls);
|
||||
}
|
||||
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Defaulting to jasper tld scanning");
|
||||
return super.newTldScanner(context, namespaceAware, validate, blockExternal);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,9 @@
|
|||
<Call id="webappprovider" name="addAppProvider">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
|
||||
<Set name="monitoredDirName"><Property name="jetty.home" default="." />/other-webapps</Set>
|
||||
<Set name="monitoredDirName"><Property name="jetty.base" default="." />/other-webapps</Set>
|
||||
<Set name="defaultsDescriptor"><Property name="jetty.home" default="." />/etc/webdefault.xml</Set>
|
||||
<Set name="extractWars">true</Set>
|
||||
<Set name="configurationManager">
|
||||
<New class="org.eclipse.jetty.deploy.PropertiesConfigurationManager"/>
|
||||
</Set>
|
||||
|
|
|
@ -47,6 +47,5 @@
|
|||
-->
|
||||
<module>async-rest</module>
|
||||
<module>embedded</module>
|
||||
<module>quickstart</module>
|
||||
</modules>
|
||||
</project>
|
||||
|
|
|
@ -34,3 +34,9 @@ etc/protonego-alpn.xml
|
|||
lib/
|
||||
lib/alpn/
|
||||
|
||||
[license]
|
||||
ALPN is a hosted at github under the GPL v2 with ClassPath Exception.
|
||||
ALPM replaces/modifies OpenJDK classes in the java.sun.security.ssl package.
|
||||
http://github.com/jetty-project/jetty-alpn
|
||||
http://openjdk.java.net/legal/gplv2+ce.html
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.ServletContainerInitializer;
|
||||
import javax.servlet.annotation.HandlesTypes;
|
||||
|
||||
|
@ -62,6 +64,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
|||
{
|
||||
private static final Logger LOG = Log.getLogger(AnnotationConfiguration.class);
|
||||
|
||||
public static final String SERVLET_CONTAINER_INITIALIZER_EXCLUSION_PATTERN = "org.eclipse.jetty.containerInitializerExclusionPattern";
|
||||
public static final String SERVLET_CONTAINER_INITIALIZER_ORDER = "org.eclipse.jetty.containerInitializerOrder";
|
||||
public static final String CLASS_INHERITANCE_MAP = "org.eclipse.jetty.classInheritanceMap";
|
||||
public static final String CONTAINER_INITIALIZERS = "org.eclipse.jetty.containerInitializers";
|
||||
|
@ -83,6 +86,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
|||
protected CounterStatistic _containerPathStats;
|
||||
protected CounterStatistic _webInfLibStats;
|
||||
protected CounterStatistic _webInfClassesStats;
|
||||
protected Pattern _sciExcludePattern;
|
||||
|
||||
/**
|
||||
* TimeStatistic
|
||||
|
@ -390,6 +394,8 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
|||
{
|
||||
_webAppClassNameResolver = new WebAppClassNameResolver(context);
|
||||
_containerClassNameResolver = new ContainerClassNameResolver(context);
|
||||
String tmp = (String)context.getAttribute(SERVLET_CONTAINER_INITIALIZER_EXCLUSION_PATTERN);
|
||||
_sciExcludePattern = (tmp==null?null:Pattern.compile(tmp));
|
||||
}
|
||||
|
||||
|
||||
|
@ -747,9 +753,11 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
|||
if (context == null)
|
||||
throw new IllegalArgumentException("WebAppContext null");
|
||||
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Checking {} for jar exclusion", sci);
|
||||
|
||||
//A ServletContainerInitializer that came from the container's classpath cannot be excluded by an ordering
|
||||
//of WEB-INF/lib jars
|
||||
if (sci.getClass().getClassLoader()==context.getClassLoader().getParent())
|
||||
if (isFromContainerClassPath(context, sci))
|
||||
return false;
|
||||
|
||||
List<Resource> orderedJars = context.getMetaData().getOrderedWebInfJars();
|
||||
|
@ -778,6 +786,38 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the ServletContainerIntializer is excluded by the
|
||||
* o.e.j.containerInitializerExclusionPattern
|
||||
* @param context
|
||||
* @param sci
|
||||
* @return
|
||||
*/
|
||||
public boolean matchesExclusionPattern(ServletContainerInitializer sci)
|
||||
{
|
||||
//no exclusion pattern, no SCI is excluded by it
|
||||
if (_sciExcludePattern == null)
|
||||
return false;
|
||||
|
||||
//test if name of class matches the regex
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Checking {} against containerInitializerExclusionPattern",sci.getClass().getName());
|
||||
return _sciExcludePattern.matcher(sci.getClass().getName()).matches();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the ServletContainerInitializer is from the container classpath
|
||||
*
|
||||
* @param context
|
||||
* @param sci
|
||||
* @return
|
||||
*/
|
||||
public boolean isFromContainerClassPath (WebAppContext context, ServletContainerInitializer sci)
|
||||
{
|
||||
if (sci == null)
|
||||
return false;
|
||||
return sci.getClass().getClassLoader()==context.getClassLoader().getParent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
|
@ -809,73 +849,79 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
|||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Service loaders found in {}ms", (TimeUnit.MILLISECONDS.convert((System.nanoTime()-start), TimeUnit.NANOSECONDS)));
|
||||
|
||||
|
||||
|
||||
Map<ServletContainerInitializer,Resource> sciResourceMap = new HashMap<ServletContainerInitializer,Resource>();
|
||||
ServletContainerInitializerOrdering initializerOrdering = getInitializerOrdering(context);
|
||||
|
||||
|
||||
//Get initial set of SCIs that aren't from excluded jars or excluded by the containerExclusionPattern, or excluded
|
||||
//because containerInitializerOrdering omits it
|
||||
for (ServletContainerInitializer sci:loadedInitializers)
|
||||
{
|
||||
if (matchesExclusionPattern(sci))
|
||||
{
|
||||
if (LOG.isDebugEnabled()) LOG.debug("{} excluded by pattern", sci);
|
||||
continue;
|
||||
}
|
||||
|
||||
Resource sciResource = getJarFor(sci);
|
||||
if (isFromExcludedJar(context, sci, sciResource))
|
||||
{
|
||||
if (LOG.isDebugEnabled()) LOG.debug("{} is from excluded jar", sci);
|
||||
continue;
|
||||
}
|
||||
|
||||
//check containerInitializerOrdering doesn't exclude it
|
||||
String name = sci.getClass().getName();
|
||||
if (initializerOrdering != null
|
||||
&& (!initializerOrdering.hasWildcard() && initializerOrdering.getIndexOf(name) < 0))
|
||||
{
|
||||
if (LOG.isDebugEnabled()) LOG.debug("{} is excluded by ordering", sci);
|
||||
continue;
|
||||
}
|
||||
|
||||
sciResourceMap.put(sci, sciResource);
|
||||
}
|
||||
|
||||
//Order the SCIs that are included
|
||||
if (initializerOrdering != null && !initializerOrdering.isDefaultOrder())
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Ordering ServletContainerInitializers with "+initializerOrdering);
|
||||
|
||||
|
||||
//There is an ordering that is not just "*".
|
||||
//Arrange ServletContainerInitializers according to the ordering of classnames given, irrespective of coming from container or webapp classpaths
|
||||
for (ServletContainerInitializer sci:loadedInitializers)
|
||||
{
|
||||
Resource sciResource = getJarFor(sci);
|
||||
if (!isFromExcludedJar(context, sci, sciResource))
|
||||
{
|
||||
String name = sci.getClass().getName();
|
||||
if (initializerOrdering.getIndexOf(name) >= 0 || initializerOrdering.hasWildcard())
|
||||
nonExcludedInitializers.add(sci);
|
||||
}
|
||||
}
|
||||
|
||||
//apply the ordering
|
||||
nonExcludedInitializers.addAll(sciResourceMap.keySet());
|
||||
Collections.sort(nonExcludedInitializers, new ServletContainerInitializerComparator(initializerOrdering));
|
||||
}
|
||||
else
|
||||
{
|
||||
//No ordering specified, or just the wildcard value "*" specified.
|
||||
//No jetty-specific ordering specified, or just the wildcard value "*" specified.
|
||||
//Fallback to ordering the ServletContainerInitializers according to:
|
||||
//container classpath first, WEB-INF/clases then WEB-INF/lib (obeying any web.xml jar ordering)
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Ordering ServletContainerInitializers as container path, webapp path");
|
||||
|
||||
Map<ServletContainerInitializer,Resource> webappPathInitializerResourceMap = new HashMap<ServletContainerInitializer,Resource>();
|
||||
for (ServletContainerInitializer sci : loadedInitializers)
|
||||
{
|
||||
//if its on the container's classpath then add it
|
||||
if (sci.getClass().getClassLoader() == context.getClassLoader().getParent())
|
||||
{
|
||||
nonExcludedInitializers.add(sci);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if on the webapp's classpath then check the containing jar is not excluded from consideration
|
||||
Resource sciResource = getJarFor(sci);
|
||||
if (!isFromExcludedJar(context, sci, sciResource))
|
||||
{
|
||||
webappPathInitializerResourceMap.put(sci, sciResource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//add the webapp classpath ones according to any web.xml ordering
|
||||
//container classpath first, WEB-INF/classes then WEB-INF/lib (obeying any web.xml jar ordering)
|
||||
|
||||
//no web.xml ordering defined, add SCIs in any order
|
||||
if (context.getMetaData().getOrdering() == null)
|
||||
nonExcludedInitializers.addAll(webappPathInitializerResourceMap.keySet()); //no ordering, just add them
|
||||
{
|
||||
if (LOG.isDebugEnabled()) LOG.debug("No web.xml ordering, ServletContainerInitializers in random order");
|
||||
nonExcludedInitializers.addAll(sciResourceMap.keySet());
|
||||
}
|
||||
else
|
||||
{
|
||||
//add in any ServletContainerInitializers which are not in a jar, as they must be from WEB-INF/classes
|
||||
for (Map.Entry<ServletContainerInitializer, Resource> entry:webappPathInitializerResourceMap.entrySet())
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Ordering ServletContainerInitializers with ordering {}",context.getMetaData().getOrdering());
|
||||
for (Map.Entry<ServletContainerInitializer, Resource> entry:sciResourceMap.entrySet())
|
||||
{
|
||||
if (entry.getValue() == null)
|
||||
//add in SCIs from the container classpath
|
||||
if (entry.getKey().getClass().getClassLoader()==context.getClassLoader().getParent())
|
||||
nonExcludedInitializers.add(entry.getKey());
|
||||
else if (entry.getValue() == null) //add in SCIs not in a jar, as they must be from WEB-INF/classes and can't be ordered
|
||||
nonExcludedInitializers.add(entry.getKey());
|
||||
}
|
||||
|
||||
//add ServletContainerInitializers according to the ordering of its containing jar
|
||||
|
||||
//add SCIs according to the ordering of its containing jar
|
||||
for (Resource webInfJar:context.getMetaData().getOrderedWebInfJars())
|
||||
{
|
||||
for (Map.Entry<ServletContainerInitializer, Resource> entry:webappPathInitializerResourceMap.entrySet())
|
||||
for (Map.Entry<ServletContainerInitializer, Resource> entry:sciResourceMap.entrySet())
|
||||
{
|
||||
if (webInfJar.equals(entry.getValue()))
|
||||
nonExcludedInitializers.add(entry.getKey());
|
||||
|
@ -883,7 +929,13 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
int i=0;
|
||||
for (ServletContainerInitializer sci:nonExcludedInitializers)
|
||||
LOG.debug("ServletContainerInitializer: {} {}",(++i), sci.getClass().getName());
|
||||
}
|
||||
return nonExcludedInitializers;
|
||||
}
|
||||
|
||||
|
|
|
@ -88,11 +88,14 @@ public abstract class AbstractHttpClientTransport extends ContainerLifeCycle imp
|
|||
channel.bind(bindAddress);
|
||||
configure(client, channel);
|
||||
channel.configureBlocking(false);
|
||||
channel.connect(address);
|
||||
|
||||
context.put(SslClientConnectionFactory.SSL_PEER_HOST_CONTEXT_KEY, destination.getHost());
|
||||
context.put(SslClientConnectionFactory.SSL_PEER_PORT_CONTEXT_KEY, destination.getPort());
|
||||
selectorManager.connect(channel, context);
|
||||
|
||||
if (channel.connect(address))
|
||||
selectorManager.accept(channel, context);
|
||||
else
|
||||
selectorManager.connect(channel, context);
|
||||
}
|
||||
// Must catch all exceptions, since some like
|
||||
// UnresolvedAddressException are not IOExceptions.
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
|
||||
|
||||
<Configure id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
|
||||
<Call name="addHandler">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.webapp.WebAppContext">
|
||||
<Set name="contextPath">/hawtio</Set>
|
||||
<Set name="war"><Property name="jetty.base" default="."/>/lib/hawtio/hawtio.war</Set>
|
||||
<Set name="extractWAR">true</Set>
|
||||
<Set name="copyWebDir">false</Set>
|
||||
<Set name="defaultsDescriptor"><Property name="jetty.home" default="."/>/etc/webdefault.xml</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
</Configure>
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
|
||||
|
||||
<!-- =============================================================== -->
|
||||
<!-- Mixin the Jamon Handler -->
|
||||
<!-- =============================================================== -->
|
||||
|
||||
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
||||
|
||||
<Get id="oldhandler" name="handler" />
|
||||
<Set name="handler">
|
||||
<New id="JamonHandler" class="com.jamonapi.http.JAMonJettyHandlerNew">
|
||||
<Set name="handler"><Ref refid="oldhandler" /></Set>
|
||||
<Set name="summaryLabels"><Property name="jamon.summaryLabels" /></Set>
|
||||
</New>
|
||||
</Set>
|
||||
|
||||
<Ref refid="Contexts">
|
||||
<Call name="addHandler">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.webapp.WebAppContext">
|
||||
<Set name="contextPath">/jamon</Set>
|
||||
<Set name="war"><Property name="jetty.base" default="."/>/lib/jamon/jamon.war</Set>
|
||||
<Set name="extractWAR">true</Set>
|
||||
<Set name="copyWebDir">false</Set>
|
||||
<Set name="defaultsDescriptor"><Property name="jetty.home" default="."/>/etc/webdefault.xml</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
</Ref>
|
||||
|
||||
</Configure>
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
|
||||
|
||||
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
||||
<Call name="addBean">
|
||||
<Arg>
|
||||
<New class="org.jminix.console.tool.StandaloneMiniConsole">
|
||||
<Arg type="int"><Property name="jminix.port" default="8088" /></Arg>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
</Configure>
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
|
||||
|
||||
<Configure id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
|
||||
<Call name="addHandler">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.webapp.WebAppContext">
|
||||
<Set name="contextPath">/jolokia</Set>
|
||||
<Set name="war"><Property name="jetty.base" default="."/>/lib/jolokia/jolokia.war</Set>
|
||||
<Set name="extractWAR">true</Set>
|
||||
<Set name="copyWebDir">false</Set>
|
||||
<Set name="defaultsDescriptor"><Property name="jetty.home" default="."/>/etc/webdefault.xml</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
</Configure>
|
|
@ -0,0 +1,28 @@
|
|||
#
|
||||
# Hawtio x module
|
||||
#
|
||||
|
||||
[depend]
|
||||
stats
|
||||
deploy
|
||||
jmx
|
||||
|
||||
[xml]
|
||||
etc/hawtio.xml
|
||||
|
||||
[files]
|
||||
etc/hawtio/
|
||||
lib/hawtio/
|
||||
https://oss.sonatype.org/content/repositories/public/io/hawt/hawtio-default/1.4.16/hawtio-default-1.4.16.war|lib/hawtio/hawtio.war
|
||||
|
||||
[license]
|
||||
Hawtio is a redhat JBoss project released under the Apache License, v2.0
|
||||
http://hawt.io/
|
||||
http://github.com/hawtio/hawtio
|
||||
http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
[ini-template]
|
||||
|
||||
-Dhawtio.authenticationEnabled=false
|
||||
-Dhawtio.dirname=/dirname
|
||||
-Dhawtio.config.dir=${jetty.base}/etc/hawtio
|
|
@ -0,0 +1,30 @@
|
|||
#
|
||||
# JAMon Jetty module
|
||||
#
|
||||
|
||||
[depend]
|
||||
stats
|
||||
deploy
|
||||
jmx
|
||||
jsp
|
||||
|
||||
[xml]
|
||||
etc/jamon.xml
|
||||
|
||||
[files]
|
||||
lib/jamon/
|
||||
http://central.maven.org/maven2/com/jamonapi/jamon/2.79/jamon-2.79.jar|lib/jamon/jamon-2.79.jar
|
||||
http://central.maven.org/maven2/com/jamonapi/jamon_war/2.79/jamon_war-2.79.war|lib/jamon/jamon.war
|
||||
|
||||
[lib]
|
||||
lib/jamon/**.jar
|
||||
|
||||
[license]
|
||||
JAMon is a source forge hosted project released under a BSD derived license.
|
||||
http://jamonapi.sourceforge.net
|
||||
http://jamonapi.sourceforge.net/JAMonLicense.html
|
||||
|
||||
[ini-template]
|
||||
jamon.summaryLabels=default, request.getStatus().contextpath.value.ms
|
||||
#jamon.summaryLabels=demo
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
#
|
||||
# JaMON Jetty module
|
||||
#
|
||||
|
||||
[depend]
|
||||
stats
|
||||
jmx
|
||||
|
||||
[xml]
|
||||
etc/jminix.xml
|
||||
|
||||
[files]
|
||||
lib/jminix/
|
||||
http://central.maven.org/maven2/org/jminix/jminix/1.1.0/jminix-1.1.0.jar|lib/jminix/jminix-1.1.0.jar
|
||||
http://maven.restlet.com/org/restlet/org.restlet/1.1.5/org.restlet-1.1.5.jar|lib/jminix/org.restlet-1.1.5.jar
|
||||
http://maven.restlet.com/org/restlet/org.restlet.ext.velocity/1.1.5/org.restlet.ext.velocity-1.1.5.jar|lib/jminix/org.restlet.ext.velocity-1.1.5.jar
|
||||
http://central.maven.org/maven2/org/apache/velocity/velocity/1.5/velocity-1.5.jar|lib/jminix/velocity-1.5.jar
|
||||
http://central.maven.org/maven2/oro/oro/2.0.8/oro-2.0.8.jar|lib/jminix/oro-2.0.8.jar
|
||||
http://maven.restlet.com/com/noelios/restlet/com.noelios.restlet/1.1.5/com.noelios.restlet-1.1.5.jar|lib/jminix/com.noelios.restlet-1.1.5.jar
|
||||
http://maven.restlet.com/com/noelios/restlet/com.noelios.restlet.ext.servlet/1.1.5/com.noelios.restlet.ext.servlet-1.1.5.jar|lib/jminix/com.noelios.restlet.ext.servlet-1.1.5.jar
|
||||
http://central.maven.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar|lib/jminix/commons-logging-1.1.1.jar
|
||||
http://repo2.maven.org/maven2/net/sf/json-lib/json-lib/2.2.3/json-lib-2.2.3-jdk15.jar|lib/jminix/json-lib-2.2.3-jdk15.jar
|
||||
http://central.maven.org/maven2/commons-lang/commons-lang/2.4/commons-lang-2.4.jar|lib/jminix/commons-lang-2.4.jar
|
||||
http://central.maven.org/maven2/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar|lib/jminix/commons-beanutils-1.7.0.jar
|
||||
http://central.maven.org/maven2/commons-collections/commons-collections/3.2/commons-collections-3.2.jar|lib/jminix/commons-collections-3.2.jar
|
||||
http://central.maven.org/maven2/net/sf/ezmorph/ezmorph/1.0.6/ezmorph-1.0.6.jar|lib/jminix/ezmorph-1.0.6.jar
|
||||
http://central.maven.org/maven2/org/jgroups/jgroups/2.12.1.3.Final/jgroups-2.12.1.3.Final.jar|lib/jminix/jgroups-2.12.1.3.Final.jar
|
||||
http://central.maven.org/maven2/org/jasypt/jasypt/1.8/jasypt-1.8.jar|lib/jminix/jasypt-1.8.jar
|
||||
|
||||
[lib]
|
||||
lib/jminix/**.jar
|
||||
|
||||
[license]
|
||||
JMiniX is a hosted at google code and released under the Apache License 2.0
|
||||
https://code.google.com/p/jminix/
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
[ini-template]
|
||||
# Jminix Configuration
|
||||
jminix.port=8088
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#
|
||||
# Jolokia Jetty module
|
||||
#
|
||||
|
||||
[depend]
|
||||
stats
|
||||
deploy
|
||||
jmx
|
||||
|
||||
[xml]
|
||||
etc/jolokia.xml
|
||||
|
||||
[files]
|
||||
http://repo1.maven.org/maven2/org/jolokia/jolokia-war/1.2.2/jolokia-war-1.2.2.war|lib/jolokia/jolokia.war
|
||||
|
||||
[license]
|
||||
Jolokia is released under the Apache License 2.0
|
||||
http://www.jolokia.org
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
@ -18,6 +18,11 @@
|
|||
|
||||
package org.eclipse.jetty.http;
|
||||
|
||||
import static org.eclipse.jetty.http.HttpTokens.CARRIAGE_RETURN;
|
||||
import static org.eclipse.jetty.http.HttpTokens.LINE_FEED;
|
||||
import static org.eclipse.jetty.http.HttpTokens.SPACE;
|
||||
import static org.eclipse.jetty.http.HttpTokens.TAB;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
|
@ -365,22 +370,22 @@ public class HttpParser
|
|||
|
||||
if (_cr)
|
||||
{
|
||||
if (ch!=HttpTokens.LINE_FEED)
|
||||
if (ch!=LINE_FEED)
|
||||
throw new BadMessage("Bad EOL");
|
||||
_cr=false;
|
||||
return ch;
|
||||
}
|
||||
|
||||
if (ch>=0 && ch<HttpTokens.SPACE)
|
||||
if (ch>=0 && ch<SPACE)
|
||||
{
|
||||
if (ch==HttpTokens.CARRIAGE_RETURN)
|
||||
if (ch==CARRIAGE_RETURN)
|
||||
{
|
||||
if (buffer.hasRemaining())
|
||||
{
|
||||
if(_maxHeaderBytes>0 && _state.ordinal()<State.END.ordinal())
|
||||
_headerBytes++;
|
||||
ch=buffer.get();
|
||||
if (ch!=HttpTokens.LINE_FEED)
|
||||
if (ch!=LINE_FEED)
|
||||
throw new BadMessage("Bad EOL");
|
||||
}
|
||||
else
|
||||
|
@ -392,8 +397,8 @@ public class HttpParser
|
|||
}
|
||||
}
|
||||
// Only LF or TAB acceptable special characters
|
||||
else if (!(ch==HttpTokens.LINE_FEED || ch==HttpTokens.TAB))
|
||||
throw new BadMessage("Illegal character");
|
||||
else if (!(ch==LINE_FEED || ch==TAB))
|
||||
throw new IllegalCharacter(ch,buffer);
|
||||
}
|
||||
|
||||
return ch;
|
||||
|
@ -433,7 +438,7 @@ public class HttpParser
|
|||
{
|
||||
int ch=next(buffer);
|
||||
|
||||
if (ch > HttpTokens.SPACE)
|
||||
if (ch > SPACE)
|
||||
{
|
||||
_string.setLength(0);
|
||||
_string.append((char)ch);
|
||||
|
@ -508,7 +513,7 @@ public class HttpParser
|
|||
switch (_state)
|
||||
{
|
||||
case METHOD:
|
||||
if (ch == HttpTokens.SPACE)
|
||||
if (ch == SPACE)
|
||||
{
|
||||
_length=_string.length();
|
||||
_methodString=takeString();
|
||||
|
@ -517,8 +522,13 @@ public class HttpParser
|
|||
_methodString=method.asString();
|
||||
setState(State.SPACE1);
|
||||
}
|
||||
else if (ch < HttpTokens.SPACE)
|
||||
throw new BadMessage(ch<0?"Illegal character":"No URI");
|
||||
else if (ch < SPACE)
|
||||
{
|
||||
if (ch==LINE_FEED)
|
||||
throw new BadMessage("No URI");
|
||||
else
|
||||
throw new IllegalCharacter(ch,buffer);
|
||||
}
|
||||
else
|
||||
_string.append((char)ch);
|
||||
break;
|
||||
|
@ -534,7 +544,7 @@ public class HttpParser
|
|||
setState(State.SPACE1);
|
||||
}
|
||||
else if (ch < HttpTokens.SPACE)
|
||||
throw new BadMessage(ch<0?"Illegal character":"No Status");
|
||||
throw new IllegalCharacter(ch,buffer);
|
||||
else
|
||||
_string.append((char)ch);
|
||||
break;
|
||||
|
@ -1147,8 +1157,8 @@ public class HttpParser
|
|||
_length=_string.length();
|
||||
break;
|
||||
}
|
||||
|
||||
throw new BadMessage("Illegal character");
|
||||
|
||||
throw new IllegalCharacter(ch,buffer);
|
||||
|
||||
case HEADER_VALUE:
|
||||
if (ch>HttpTokens.SPACE || ch<0)
|
||||
|
@ -1172,8 +1182,8 @@ public class HttpParser
|
|||
setState(State.HEADER);
|
||||
break;
|
||||
}
|
||||
|
||||
throw new BadMessage("Illegal character");
|
||||
|
||||
throw new IllegalCharacter(ch,buffer);
|
||||
|
||||
case HEADER_IN_VALUE:
|
||||
if (ch>=HttpTokens.SPACE || ch<0 || ch==HttpTokens.TAB)
|
||||
|
@ -1201,7 +1211,8 @@ public class HttpParser
|
|||
setState(State.HEADER);
|
||||
break;
|
||||
}
|
||||
throw new BadMessage("Illegal character");
|
||||
|
||||
throw new IllegalCharacter(ch,buffer);
|
||||
|
||||
default:
|
||||
throw new IllegalStateException(_state.toString());
|
||||
|
@ -1577,6 +1588,29 @@ public class HttpParser
|
|||
_state=state;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
public Trie<HttpField> getFieldCache()
|
||||
{
|
||||
return _connectionFields;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
private String getProxyField(ByteBuffer buffer)
|
||||
{
|
||||
_string.setLength(0);
|
||||
_length=0;
|
||||
|
||||
while (buffer.hasRemaining())
|
||||
{
|
||||
// process each character
|
||||
byte ch=next(buffer);
|
||||
if (ch<=' ')
|
||||
return _string.toString();
|
||||
_string.append((char)ch);
|
||||
}
|
||||
throw new BadMessage();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
@Override
|
||||
public String toString()
|
||||
|
@ -1632,11 +1666,17 @@ public class HttpParser
|
|||
public int getHeaderCacheSize();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
public interface ProxyHandler
|
||||
{
|
||||
void proxied(String protocol, String sAddr, String dAddr, int sPort, int dPort);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
public interface RequestHandler<T> extends HttpHandler<T>
|
||||
{
|
||||
/**
|
||||
|
@ -1657,6 +1697,9 @@ public class HttpParser
|
|||
public abstract boolean parsedHostHeader(String host,int port);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
public interface ResponseHandler<T> extends HttpHandler<T>
|
||||
{
|
||||
/**
|
||||
|
@ -1665,24 +1708,14 @@ public class HttpParser
|
|||
public abstract boolean startResponse(HttpVersion version, int status, String reason);
|
||||
}
|
||||
|
||||
public Trie<HttpField> getFieldCache()
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
private class IllegalCharacter extends BadMessage
|
||||
{
|
||||
return _connectionFields;
|
||||
}
|
||||
|
||||
private String getProxyField(ByteBuffer buffer)
|
||||
{
|
||||
_string.setLength(0);
|
||||
_length=0;
|
||||
|
||||
while (buffer.hasRemaining())
|
||||
IllegalCharacter(byte ch,ByteBuffer buffer)
|
||||
{
|
||||
// process each character
|
||||
byte ch=next(buffer);
|
||||
if (ch<=' ')
|
||||
return _string.toString();
|
||||
_string.append((char)ch);
|
||||
super(String.format("Illegal character 0x%x in state=%s in '%s'",ch,_state,BufferUtil.toDebugString(buffer)));
|
||||
}
|
||||
throw new BadMessage();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ package org.eclipse.jetty.io;
|
|||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.nio.channels.CancelledKeyException;
|
||||
import java.nio.channels.SelectionKey;
|
||||
|
@ -39,6 +41,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
|
||||
import org.eclipse.jetty.util.ConcurrentArrayQueue;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
|
@ -65,6 +68,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
private final ManagedSelector[] _selectors;
|
||||
private long _connectTimeout = DEFAULT_CONNECT_TIMEOUT;
|
||||
private long _selectorIndex;
|
||||
private int _priorityDelta;
|
||||
|
||||
protected SelectorManager(Executor executor, Scheduler scheduler)
|
||||
{
|
||||
|
@ -110,6 +114,42 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
_connectTimeout = milliseconds;
|
||||
}
|
||||
|
||||
|
||||
@ManagedAttribute("The priority delta to apply to selector threads")
|
||||
public int getSelectorPriorityDelta()
|
||||
{
|
||||
return _priorityDelta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the selector thread priority delta to the given amount.
|
||||
* <p>This allows the selector threads to run at a different priority.
|
||||
* Typically this would be used to lower the priority to give preference
|
||||
* to handling previously accepted connections rather than accepting
|
||||
* new connections.</p>
|
||||
*
|
||||
* @param selectorPriorityDelta the amount to change the thread priority
|
||||
* delta to (may be negative)
|
||||
* @see Thread#getPriority()
|
||||
*/
|
||||
public void setSelectorPriorityDelta(int selectorPriorityDelta)
|
||||
{
|
||||
int oldDelta = _priorityDelta;
|
||||
_priorityDelta = selectorPriorityDelta;
|
||||
if (oldDelta != selectorPriorityDelta && isStarted())
|
||||
{
|
||||
for (ManagedSelector selector : _selectors)
|
||||
{
|
||||
Thread thread = selector._thread;
|
||||
if (thread != null)
|
||||
{
|
||||
int deltaDiff = selectorPriorityDelta - oldDelta;
|
||||
thread.setPriority(Math.max(Thread.MIN_PRIORITY, Math.min(Thread.MAX_PRIORITY, thread.getPriority() - deltaDiff)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the given task in a different thread.
|
||||
*
|
||||
|
@ -140,11 +180,13 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
|
||||
/**
|
||||
* <p>Registers a channel to perform a non-blocking connect.</p>
|
||||
* <p>The channel must be set in non-blocking mode, and {@link SocketChannel#connect(SocketAddress)}
|
||||
* must be called prior to calling this method.</p>
|
||||
* <p>The channel must be set in non-blocking mode, {@link SocketChannel#connect(SocketAddress)}
|
||||
* must be called prior to calling this method, and the connect operation must not be completed
|
||||
* (the return value of {@link SocketChannel#connect(SocketAddress)} must be false).</p>
|
||||
*
|
||||
* @param channel the channel to register
|
||||
* @param attachment the attachment object
|
||||
* @see #accept(SocketChannel, Object)
|
||||
*/
|
||||
public void connect(SocketChannel channel, Object attachment)
|
||||
{
|
||||
|
@ -152,17 +194,28 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
set.submit(set.new Connect(channel, attachment));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #accept(SocketChannel, Object)
|
||||
*/
|
||||
public void accept(SocketChannel channel)
|
||||
{
|
||||
accept(channel, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Registers a channel to perform non-blocking read/write operations.</p>
|
||||
* <p>This method is called just after a channel has been accepted by {@link ServerSocketChannel#accept()},
|
||||
* or just after having performed a blocking connect via {@link Socket#connect(SocketAddress, int)}.</p>
|
||||
* or just after having performed a blocking connect via {@link Socket#connect(SocketAddress, int)}, or
|
||||
* just after a non-blocking connect via {@link SocketChannel#connect(SocketAddress)} that completed
|
||||
* successfully.</p>
|
||||
*
|
||||
* @param channel the channel to register
|
||||
* @param attachment the attachment object
|
||||
*/
|
||||
public void accept(final SocketChannel channel)
|
||||
public void accept(SocketChannel channel, Object attachment)
|
||||
{
|
||||
final ManagedSelector selector = chooseSelector();
|
||||
selector.submit(selector.new Accept(channel));
|
||||
selector.submit(selector.new Accept(channel, attachment));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -173,7 +226,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
*
|
||||
* @param server the server channel to register
|
||||
*/
|
||||
public void acceptor(final ServerSocketChannel server)
|
||||
public void acceptor(ServerSocketChannel server)
|
||||
{
|
||||
final ManagedSelector selector = chooseSelector();
|
||||
selector.submit(selector.new Acceptor(server));
|
||||
|
@ -479,9 +532,13 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
{
|
||||
_thread = Thread.currentThread();
|
||||
String name = _thread.getName();
|
||||
int priority = _thread.getPriority();
|
||||
try
|
||||
{
|
||||
_thread.setName(name + "-selector-" + SelectorManager.this.getClass().getSimpleName()+"@"+Integer.toHexString(SelectorManager.this.hashCode())+"/"+_id);
|
||||
if (_priorityDelta != 0)
|
||||
_thread.setPriority(Math.max(Thread.MIN_PRIORITY, Math.min(Thread.MAX_PRIORITY, priority + _priorityDelta)));
|
||||
|
||||
_thread.setName(String.format("%s-selector-%s@%h/%d", name, SelectorManager.this.getClass().getSimpleName(), SelectorManager.this.hashCode(), _id));
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Starting {} on {}", _thread, this);
|
||||
while (isRunning())
|
||||
|
@ -494,6 +551,8 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Stopped {} on {}", _thread, this);
|
||||
_thread.setName(name);
|
||||
if (_priorityDelta != 0)
|
||||
_thread.setPriority(priority);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -812,11 +871,13 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
|
||||
private class Accept implements Runnable
|
||||
{
|
||||
private final SocketChannel _channel;
|
||||
private final SocketChannel channel;
|
||||
private final Object attachment;
|
||||
|
||||
public Accept(SocketChannel channel)
|
||||
private Accept(SocketChannel channel, Object attachment)
|
||||
{
|
||||
this._channel = channel;
|
||||
this.channel = channel;
|
||||
this.attachment = attachment;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -824,13 +885,13 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
{
|
||||
try
|
||||
{
|
||||
SelectionKey key = _channel.register(_selector, 0, null);
|
||||
EndPoint endpoint = createEndPoint(_channel, key);
|
||||
SelectionKey key = channel.register(_selector, 0, attachment);
|
||||
EndPoint endpoint = createEndPoint(channel, key);
|
||||
key.attach(endpoint);
|
||||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
closeNoExceptions(_channel);
|
||||
closeNoExceptions(channel);
|
||||
LOG.debug(x);
|
||||
}
|
||||
}
|
||||
|
@ -843,7 +904,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
private final Object attachment;
|
||||
private final Scheduler.Task timeout;
|
||||
|
||||
public Connect(SocketChannel channel, Object attachment)
|
||||
private Connect(SocketChannel channel, Object attachment)
|
||||
{
|
||||
this.channel = channel;
|
||||
this.attachment = attachment;
|
||||
|
@ -863,7 +924,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
}
|
||||
}
|
||||
|
||||
protected void failed(Throwable failure)
|
||||
private void failed(Throwable failure)
|
||||
{
|
||||
if (failed.compareAndSet(false, true))
|
||||
{
|
||||
|
|
|
@ -416,7 +416,10 @@ public class MongoSessionIdManager extends AbstractSessionIdManager
|
|||
_scheduler = new ScheduledExecutorScheduler();
|
||||
_ownScheduler = true;
|
||||
_scheduler.start();
|
||||
}
|
||||
}
|
||||
else if (!_scheduler.isStarted())
|
||||
throw new IllegalStateException("Shared scheduler not started");
|
||||
|
||||
|
||||
//setup the scavenger thread
|
||||
if (_scavengePeriod > 0)
|
||||
|
|
|
@ -39,10 +39,31 @@
|
|||
<!-- Orbit JSP Deps -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-jsp</artifactId>
|
||||
<artifactId>apache-jsp</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.orbit</groupId>
|
||||
<artifactId>javax.servlet.jsp.jstl</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.web</groupId>
|
||||
<artifactId>javax.servlet.jsp.jstl</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mortbay.jasper</groupId>
|
||||
<artifactId>apache-el</artifactId>
|
||||
<version>8.0.9-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>javax.el</groupId>
|
||||
<artifactId>javax.el-api</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
-->
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
@ -96,7 +117,7 @@
|
|||
javax.el;version="[3.0,3.1)",
|
||||
javax.servlet;version="[3.1,3.2)",
|
||||
javax.servlet.resources;version="[3.1,3.2)",
|
||||
javax.servlet.jsp.resources;version="[3.1,3.2)",
|
||||
javax.servlet.jsp.resources;version="[2.3,4)",
|
||||
javax.servlet.jsp;version="[2.3,2.4)",
|
||||
javax.servlet.jsp.el;version="[2.3,2.4)",
|
||||
javax.servlet.jsp.tagext;version="[2.3,2.4)",
|
||||
|
@ -104,16 +125,20 @@
|
|||
javax.servlet.jsp.jstl.fmt;version="1.2";resolution:=optional,
|
||||
javax.servlet.jsp.jstl.sql;version="1.2";resolution:=optional,
|
||||
javax.servlet.jsp.jstl.tlv;version="1.2";resolution:=optional,
|
||||
org.apache.jasper;version="[2.3.2,2.4)";resolution:=optional,
|
||||
org.apache.jasper.compiler;version="[2.3.2,2.4)";resolution:=optional,
|
||||
org.apache.jasper.compiler.tagplugin;version="[2.3.2,2.4)";resolution:=optional,
|
||||
org.apache.jasper.runtime;version="[2.3.2,2.4)";resolution:=optional,
|
||||
org.apache.jasper.security;version="[2.3.2,2.4)";resolution:=optional,
|
||||
org.apache.jasper.servlet;version="[2.3.2,2.4)";resolution:=optional,
|
||||
org.apache.jasper.tagplugins.jstl;version="[2.3.2,2.4)";resolution:=optional,
|
||||
org.apache.jasper.util;version="[2.3.2,2.4)";resolution:=optional,
|
||||
org.apache.jasper.xmlparser;version="[2.3.2,2.4)";resolution:=optional,
|
||||
org.glassfish.jsp.api;version="[2.3.2,2.4)";resolution:=optional,
|
||||
org.apache.el;version="[8.0.9,9)";resolution:=optional,
|
||||
org.apache.el.lang;version="[8.0.9,9)";resolution:=optional,
|
||||
org.apache.el.stream;version="[8.0.9,9)";resolution:=optional,
|
||||
org.apache.el.util;version="[8.0.9,9)";resolution:=optional,
|
||||
org.apache.el.parser;version="[8.0.9,9)";resolution:=optional,
|
||||
org.apache.jasper;version="[8.0.9,9)";resolution:=optional,
|
||||
org.apache.jasper.compiler;version="[8.0.9,9)";resolution:=optional,
|
||||
org.apache.jasper.compiler.tagplugin;version="[8.0.9,9)";resolution:=optional,
|
||||
org.apache.jasper.runtime;version="[8.0.9,9)";resolution:=optional,
|
||||
org.apache.jasper.security;version="[8.0.9,9)";resolution:=optional,
|
||||
org.apache.jasper.servlet;version="[8.0.9,9)";resolution:=optional,
|
||||
org.apache.jasper.tagplugins.jstl;version="[8.0.9,9)";resolution:=optional,
|
||||
org.apache.jasper.util;version="[8.0.9,9)";resolution:=optional,
|
||||
org.apache.jasper.xmlparser;version="[8.0.9,9)";resolution:=optional,
|
||||
org.apache.taglibs.standard;version="1.2";resolution:=optional,
|
||||
org.apache.taglibs.standard.extra.spath;version="1.2";resolution:=optional,
|
||||
org.apache.taglibs.standard.functions;version="1.2";resolution:=optional,
|
||||
|
@ -137,6 +162,7 @@
|
|||
org.apache.taglibs.standard.tag.rt.xml;version="1.2";resolution:=optional,
|
||||
org.apache.taglibs.standard.tei;version="1.2";resolution:=optional,
|
||||
org.apache.taglibs.standard.tlv;version="1.2";resolution:=optional,
|
||||
org.apache.tomcat;version="[8.0.9,9)";resolution:=optional,
|
||||
org.osgi.*,
|
||||
org.xml.*;resolution:=optional,
|
||||
org.xml.sax.*;resolution:=optional,
|
||||
|
@ -145,8 +171,8 @@
|
|||
org.w3c.dom.ls;resolution:=optional,
|
||||
javax.xml.parser;resolution:=optional
|
||||
</Import-Package>
|
||||
<_nouses>true</_nouses>
|
||||
<DynamicImport-Package>org.apache.jasper.*;version="2.3"</DynamicImport-Package>
|
||||
<_nouses>true</_nouses>
|
||||
<DynamicImport-Package>org.apache.jasper.*;version="8.0.9",org.apache.el.*;version="8.0.9"</DynamicImport-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
|
|
@ -27,10 +27,15 @@ import java.util.Set;
|
|||
import java.util.StringTokenizer;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.jsp.JspFactory;
|
||||
|
||||
import org.eclipse.jetty.deploy.DeploymentManager;
|
||||
import org.eclipse.jetty.osgi.boot.JettyBootstrapActivator;
|
||||
import org.eclipse.jetty.osgi.boot.OSGiWebInfConfiguration;
|
||||
import org.eclipse.jetty.osgi.boot.utils.BundleFileLocatorHelper;
|
||||
import org.eclipse.jetty.osgi.boot.utils.TldBundleDiscoverer;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
|
||||
|
@ -39,15 +44,24 @@ import org.osgi.framework.FrameworkUtil;
|
|||
/**
|
||||
* ContainerTldBundleDiscoverer
|
||||
*
|
||||
* Finds bundles that are considered as on the container classpath that
|
||||
* contain tlds.
|
||||
*
|
||||
* Use a System property to define bundles that contain tlds that need to
|
||||
* be treated by jasper as if they were on the jetty container's classpath.
|
||||
* The System property org.eclipse.jetty.osgi.tldbundles is a comma
|
||||
* separated list of exact symbolic names of bundles that have container classpath
|
||||
* tlds.
|
||||
*
|
||||
* The value of the property is evaluated against the DeploymentManager
|
||||
* context attribute "org.eclipse.jetty.server.webapp.containerIncludeBundlePattern",
|
||||
* which defines a pattern of matching bundle names.
|
||||
* The DeploymentManager context attribute "org.eclipse.jetty.server.webapp.containerIncludeBundlePattern"
|
||||
* can be used to define a pattern of symbolic names of bundles that contain container
|
||||
* classpath tlds.
|
||||
*
|
||||
* The bundle locations are converted to URLs for jasper's use.
|
||||
* The matching bundles are converted to URLs that are put onto a special classloader that acts as the
|
||||
* parent classloader for contexts deployed by the jetty Server instance (see ServerInstanceWrapper).
|
||||
*
|
||||
* It also discovers the bundle that contains the jstl taglib and adds it into the
|
||||
* "org.eclipse.jetty.server.webapp.containerIncludeBundlePattern" (if it is not already there) so
|
||||
* that the WebInfOSGiConfiguration class will add the jstl taglib bundle into the list of container
|
||||
* resources.
|
||||
*
|
||||
* Eg:
|
||||
* -Dorg.eclipse.jetty.osgi.tldbundles=org.springframework.web.servlet,com.opensymphony.module.sitemesh
|
||||
|
@ -55,16 +69,20 @@ import org.osgi.framework.FrameworkUtil;
|
|||
*/
|
||||
public class ContainerTldBundleDiscoverer implements TldBundleDiscoverer
|
||||
{
|
||||
|
||||
private static final Logger LOG = Log.getLogger(ContainerTldBundleDiscoverer.class);
|
||||
|
||||
|
||||
private static String DEFAULT_JSP_FACTORY_IMPL_CLASS = "org.apache.jasper.runtime.JspFactoryImpl";
|
||||
/**
|
||||
* Comma separated list of names of bundles that contain tld files that should be
|
||||
* discoved by jasper as if they were on the container's classpath.
|
||||
* Eg:
|
||||
* -Djetty.osgi.tldbundles=org.springframework.web.servlet,com.opensymphony.module.sitemesh
|
||||
* Default name of a class that belongs to the jstl bundle. From that class
|
||||
* we locate the corresponding bundle and register it as a bundle that
|
||||
* contains tld files.
|
||||
*/
|
||||
public static final String SYS_PROP_TLD_BUNDLES = "org.eclipse.jetty.osgi.tldbundles";
|
||||
|
||||
|
||||
private static String DEFAULT_JSTL_BUNDLE_CLASS = "org.apache.taglibs.standard.tag.el.core.WhenTag";
|
||||
|
||||
private Bundle jstlBundle = null;
|
||||
|
||||
/**
|
||||
* Check the System property "org.eclipse.jetty.osgi.tldbundles" for names of
|
||||
* bundles that contain tlds and convert to URLs.
|
||||
|
@ -72,19 +90,18 @@ public class ContainerTldBundleDiscoverer implements TldBundleDiscoverer
|
|||
* @return The location of the jars that contain tld files as URLs.
|
||||
*/
|
||||
public URL[] getUrlsForBundlesWithTlds(DeploymentManager deploymentManager, BundleFileLocatorHelper locatorHelper) throws Exception
|
||||
{
|
||||
// naive way of finding those bundles.
|
||||
// lots of assumptions: for example we assume a single version of each
|
||||
// bundle that would contain tld files.
|
||||
// this is probably good enough as those tlds are loaded system-wide on
|
||||
// jetty.
|
||||
// to do better than this we need to do it on a per webapp basis.
|
||||
// probably using custom properties in the ContextHandler service
|
||||
// and mirroring those in the MANIFEST.MF
|
||||
{
|
||||
if (!isJspAvailable())
|
||||
{
|
||||
return new URL[0];
|
||||
}
|
||||
|
||||
if (jstlBundle == null)
|
||||
jstlBundle = findJstlBundle();
|
||||
|
||||
Bundle[] bundles = FrameworkUtil.getBundle(ContainerTldBundleDiscoverer.class).getBundleContext().getBundles();
|
||||
HashSet<URL> urls = new HashSet<URL>();
|
||||
String tmp = System.getProperty(SYS_PROP_TLD_BUNDLES); //comma separated exact names
|
||||
String tmp = System.getProperty(OSGiWebInfConfiguration.SYS_PROP_TLD_BUNDLES); //comma separated exact names
|
||||
List<String> sysNames = new ArrayList<String>();
|
||||
if (tmp != null)
|
||||
{
|
||||
|
@ -93,13 +110,33 @@ public class ContainerTldBundleDiscoverer implements TldBundleDiscoverer
|
|||
sysNames.add(tokenizer.nextToken());
|
||||
}
|
||||
tmp = (String) deploymentManager.getContextAttribute(OSGiWebInfConfiguration.CONTAINER_BUNDLE_PATTERN); //bundle name patterns
|
||||
|
||||
Pattern pattern = (tmp==null? null : Pattern.compile(tmp));
|
||||
|
||||
//check that the jstl bundle is not already included in the pattern, and include it if it is not because
|
||||
//subsequent classes such as OSGiWebInfConfiguration use this pattern to determine which jars are
|
||||
//considered to be on the container classpath
|
||||
if (jstlBundle != null)
|
||||
{
|
||||
if (pattern == null)
|
||||
{
|
||||
pattern = Pattern.compile(jstlBundle.getSymbolicName());
|
||||
deploymentManager.setContextAttribute(OSGiWebInfConfiguration.CONTAINER_BUNDLE_PATTERN, jstlBundle.getSymbolicName());
|
||||
}
|
||||
else if (!(pattern.matcher(jstlBundle.getSymbolicName()).matches()))
|
||||
{
|
||||
String s = tmp+"|"+jstlBundle.getSymbolicName();
|
||||
pattern = Pattern.compile(s);
|
||||
deploymentManager.setContextAttribute(OSGiWebInfConfiguration.CONTAINER_BUNDLE_PATTERN, s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (Bundle bundle : bundles)
|
||||
{
|
||||
if (sysNames.contains(bundle.getSymbolicName()))
|
||||
convertBundleLocationToURL(locatorHelper, bundle, urls);
|
||||
|
||||
if (pattern != null && pattern.matcher(bundle.getSymbolicName()).matches())
|
||||
convertBundleLocationToURL(locatorHelper, bundle, urls);
|
||||
else if (pattern != null && pattern.matcher(bundle.getSymbolicName()).matches())
|
||||
convertBundleLocationToURL(locatorHelper, bundle, urls);
|
||||
}
|
||||
|
||||
|
@ -107,6 +144,79 @@ public class ContainerTldBundleDiscoverer implements TldBundleDiscoverer
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that jsp is on the classpath
|
||||
* @return
|
||||
*/
|
||||
public boolean isJspAvailable()
|
||||
{
|
||||
try
|
||||
{
|
||||
getClass().getClassLoader().loadClass("org.apache.jasper.servlet.JspServlet");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.warn("Unable to locate the JspServlet: jsp support unavailable.", e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Some versions of JspFactory do Class.forName, which probably won't work in an
|
||||
* OSGi environment.
|
||||
*/
|
||||
public void fixJspFactory ()
|
||||
{
|
||||
try
|
||||
{
|
||||
Class<javax.servlet.ServletContext> servletContextClass = javax.servlet.ServletContext.class;
|
||||
// bug #299733
|
||||
JspFactory fact = JspFactory.getDefaultFactory();
|
||||
if (fact == null)
|
||||
{ // bug #299733
|
||||
// JspFactory does a simple
|
||||
// Class.getForName("org.apache.jasper.runtime.JspFactoryImpl")
|
||||
// however its bundles does not import the jasper package
|
||||
// so it fails. let's help things out:
|
||||
fact = (JspFactory) JettyBootstrapActivator.class.getClassLoader().loadClass(DEFAULT_JSP_FACTORY_IMPL_CLASS).newInstance();
|
||||
JspFactory.setDefaultFactory(fact);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.warn("Unable to set the JspFactory: jsp support incomplete.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find the bundle that contains a jstl implementation class, which assumes that
|
||||
* the jstl taglibs will be inside the same bundle.
|
||||
* @return
|
||||
*/
|
||||
public Bundle findJstlBundle ()
|
||||
{
|
||||
Class<?> jstlClass = null;
|
||||
|
||||
try
|
||||
{
|
||||
jstlClass = JSTLBundleDiscoverer.class.getClassLoader().loadClass(DEFAULT_JSTL_BUNDLE_CLASS);
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
LOG.info("jstl not on classpath", e);
|
||||
}
|
||||
|
||||
if (jstlClass != null)
|
||||
//get the bundle containing jstl
|
||||
return FrameworkUtil.getBundle(jstlClass);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves a bundle that contains tld files as a URL. The URLs are
|
||||
* used by jasper to discover the tld files.
|
||||
|
|
|
@ -20,9 +20,11 @@ package org.eclipse.jetty.osgi.boot.jasper;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.jsp.JspContext;
|
||||
|
@ -30,7 +32,6 @@ import javax.servlet.jsp.JspFactory;
|
|||
|
||||
import org.apache.jasper.Constants;
|
||||
import org.apache.jasper.compiler.Localizer;
|
||||
import org.apache.jasper.xmlparser.ParserUtils;
|
||||
import org.eclipse.jetty.deploy.DeploymentManager;
|
||||
import org.eclipse.jetty.osgi.boot.JettyBootstrapActivator;
|
||||
import org.eclipse.jetty.osgi.boot.utils.BundleFileLocatorHelper;
|
||||
|
@ -85,10 +86,12 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
|
|||
* implementation. bug #299733
|
||||
*/
|
||||
private static String DEFAULT_JSP_FACTORY_IMPL_CLASS = "org.apache.jasper.runtime.JspFactoryImpl";
|
||||
|
||||
private static final Set<URL> __tldBundleCache = new HashSet<URL>();
|
||||
|
||||
public JSTLBundleDiscoverer()
|
||||
{
|
||||
fixupDtdResolution();
|
||||
//fixupDtdResolution();
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -102,6 +105,7 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
|
|||
}
|
||||
try
|
||||
{
|
||||
Class<javax.servlet.ServletContext> servletContextClass = javax.servlet.ServletContext.class;
|
||||
// bug #299733
|
||||
JspFactory fact = JspFactory.getDefaultFactory();
|
||||
if (fact == null)
|
||||
|
@ -143,7 +147,7 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
|
|||
{
|
||||
|
||||
ArrayList<URL> urls = new ArrayList<URL>();
|
||||
HashSet<Class<?>> classesToAddToTheTldBundles = new HashSet<Class<?>>();
|
||||
Class<?> jstlClass = null;
|
||||
|
||||
// Look for the jstl bundle
|
||||
// We assume the jstl's tlds are defined there.
|
||||
|
@ -151,18 +155,21 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
|
|||
// So we can look for this class using this bundle's classloader:
|
||||
try
|
||||
{
|
||||
Class<?> jstlClass = JSTLBundleDiscoverer.class.getClassLoader().loadClass(DEFAULT_JSTL_BUNDLE_CLASS);
|
||||
|
||||
classesToAddToTheTldBundles.add(jstlClass);
|
||||
jstlClass = JSTLBundleDiscoverer.class.getClassLoader().loadClass(DEFAULT_JSTL_BUNDLE_CLASS);
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
LOG.info("jstl not on classpath", e);
|
||||
}
|
||||
for (Class<?> cl : classesToAddToTheTldBundles)
|
||||
|
||||
if (jstlClass != null)
|
||||
{
|
||||
Bundle tldBundle = FrameworkUtil.getBundle(cl);
|
||||
//get the bundle containing jstl
|
||||
Bundle tldBundle = FrameworkUtil.getBundle(jstlClass);
|
||||
File tldBundleLocation = locatorHelper.getBundleInstallLocation(tldBundle);
|
||||
|
||||
System.err.println("jstl bundle: "+tldBundle);
|
||||
System.err.println("jstl bundle location: "+tldBundleLocation);
|
||||
if (tldBundleLocation != null && tldBundleLocation.isDirectory())
|
||||
{
|
||||
// try to find the jar files inside this folder
|
||||
|
@ -170,6 +177,7 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
|
|||
{
|
||||
if (f.getName().endsWith(".jar") && f.isFile())
|
||||
{
|
||||
System.err.println("Tld jar in dir: "+f.toURI());
|
||||
urls.add(f.toURI().toURL());
|
||||
}
|
||||
else if (f.isDirectory() && f.getName().equals("lib"))
|
||||
|
@ -178,6 +186,7 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
|
|||
{
|
||||
if (f2.getName().endsWith(".jar") && f2.isFile())
|
||||
{
|
||||
System.err.println("Tld jar in lib dir: "+f2.toURI());
|
||||
urls.add(f2.toURI().toURL());
|
||||
}
|
||||
}
|
||||
|
@ -187,9 +196,20 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
|
|||
}
|
||||
else if (tldBundleLocation != null)
|
||||
{
|
||||
System.err.println("Tld bundle uri: "+tldBundleLocation.toURI());
|
||||
urls.add(tldBundleLocation.toURI().toURL());
|
||||
|
||||
String pattern = (String)deployer.getContextAttribute("org.eclipse.jetty.server.webapp.containerIncludeBundlePattern");
|
||||
pattern = (pattern==null?"":pattern);
|
||||
if (!pattern.contains(tldBundle.getSymbolicName()))
|
||||
{
|
||||
pattern += "|"+tldBundle.getSymbolicName();
|
||||
deployer.setContextAttribute("org.eclipse.jetty.server.webapp.containerIncludeBundlePattern", pattern);
|
||||
}
|
||||
System.err.println("PATTERN: "+pattern);
|
||||
}
|
||||
}
|
||||
|
||||
return urls.toArray(new URL[urls.size()]);
|
||||
}
|
||||
|
||||
|
@ -209,11 +229,12 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
|
|||
* new value on a static friendly field :(
|
||||
* </p>
|
||||
*/
|
||||
void fixupDtdResolution()
|
||||
void fixupDtdResolution()
|
||||
{
|
||||
try
|
||||
{
|
||||
ParserUtils.setEntityResolver(new MyFixedupEntityResolver());
|
||||
// ParserUtils.setEntityResolver(new MyFixedupEntityResolver());
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -227,21 +248,21 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
|
|||
* Instead of using the ParserUtil's classloader, we use a class that is
|
||||
* indeed next to the resource for sure.
|
||||
*/
|
||||
static class MyFixedupEntityResolver implements EntityResolver
|
||||
{
|
||||
//static class MyFixedupEntityResolver implements EntityResolver
|
||||
//{
|
||||
/**
|
||||
* Same values than in ParserUtils...
|
||||
*/
|
||||
static final String[] CACHED_DTD_PUBLIC_IDS = { Constants.TAGLIB_DTD_PUBLIC_ID_11, Constants.TAGLIB_DTD_PUBLIC_ID_12,
|
||||
/* static final String[] CACHED_DTD_PUBLIC_IDS = { Constants.TAGLIB_DTD_PUBLIC_ID_11, Constants.TAGLIB_DTD_PUBLIC_ID_12,
|
||||
Constants.WEBAPP_DTD_PUBLIC_ID_22, Constants.WEBAPP_DTD_PUBLIC_ID_23, };
|
||||
|
||||
static final String[] CACHED_DTD_RESOURCE_PATHS = { Constants.TAGLIB_DTD_RESOURCE_PATH_11, Constants.TAGLIB_DTD_RESOURCE_PATH_12,
|
||||
Constants.WEBAPP_DTD_RESOURCE_PATH_22, Constants.WEBAPP_DTD_RESOURCE_PATH_23, };
|
||||
|
||||
static final String[] CACHED_SCHEMA_RESOURCE_PATHS = { Constants.TAGLIB_SCHEMA_RESOURCE_PATH_20, Constants.TAGLIB_SCHEMA_RESOURCE_PATH_21,
|
||||
Constants.WEBAPP_SCHEMA_RESOURCE_PATH_24, Constants.WEBAPP_SCHEMA_RESOURCE_PATH_25, };
|
||||
Constants.WEBAPP_SCHEMA_RESOURCE_PATH_24, Constants.WEBAPP_SCHEMA_RESOURCE_PATH_25, };*/
|
||||
|
||||
public InputSource resolveEntity(String publicId, String systemId) throws SAXException
|
||||
/* public InputSource resolveEntity(String publicId, String systemId) throws SAXException
|
||||
{
|
||||
for (int i = 0; i < CACHED_DTD_PUBLIC_IDS.length; i++)
|
||||
{
|
||||
|
@ -255,11 +276,11 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
|
|||
{
|
||||
input = JspContext.class.getResourceAsStream(resourcePath);
|
||||
if (input == null)
|
||||
{
|
||||
{*/
|
||||
// if that failed try again with the original code:
|
||||
// although it is likely not changed.
|
||||
input = this.getClass().getResourceAsStream(resourcePath);
|
||||
}
|
||||
/* input = this.getClass().getResourceAsStream(resourcePath);
|
||||
}
|
||||
}
|
||||
if (input == null) { throw new SAXException(Localizer.getMessage("jsp.error.internal.filenotfound", resourcePath)); }
|
||||
InputSource isrc = new InputSource(input);
|
||||
|
@ -269,6 +290,6 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
|
|||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
|
|
@ -18,17 +18,16 @@
|
|||
|
||||
package org.eclipse.jetty.osgi.boot.jsp;
|
||||
|
||||
import org.eclipse.jetty.osgi.boot.BundleWebAppProvider;
|
||||
|
||||
import org.eclipse.jetty.osgi.boot.internal.serverfactory.ServerInstanceWrapper;
|
||||
import org.eclipse.jetty.osgi.boot.jasper.ContainerTldBundleDiscoverer;
|
||||
import org.eclipse.jetty.osgi.boot.jasper.JSTLBundleDiscoverer;
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* FragmentActivator
|
||||
*
|
||||
* Sets up support for jsp. All relevant jsp jars must also be installed
|
||||
* Sets up support for jsp and jstl. All relevant jsp jars must also be installed
|
||||
* into the osgi environment.
|
||||
* <p>
|
||||
* Note that as this is part of a bundle fragment, this activator is NOT
|
||||
|
@ -54,7 +53,6 @@ public class FragmentActivator implements BundleActivator
|
|||
//set up some classes that will look for bundles with tlds that must be converted
|
||||
//to urls and treated as if they are on the Jetty container's classpath so that
|
||||
//jasper can deal with them
|
||||
ServerInstanceWrapper.addContainerTldBundleDiscoverer(new JSTLBundleDiscoverer());
|
||||
ServerInstanceWrapper.addContainerTldBundleDiscoverer(new ContainerTldBundleDiscoverer());
|
||||
}
|
||||
|
||||
|
|
|
@ -112,8 +112,9 @@
|
|||
javax.servlet.http;version="[3.1,3.2)",
|
||||
javax.transaction;version="1.1.0";resolution:=optional,
|
||||
javax.transaction.xa;version="1.1.0";resolution:=optional,
|
||||
org.eclipse.jetty.annotations;version="9.1";resolution:=optional,
|
||||
org.eclipse.jetty.plus.webapp;version="9.1";resolution:=optional,
|
||||
org.objectweb.asm;version=4;resolution:=optional,
|
||||
org.eclipse.jetty.annotations;version="9.0.0";resolution:=optional,
|
||||
org.osgi.framework,
|
||||
org.osgi.service.cm;version="1.2.0",
|
||||
org.osgi.service.packageadmin,
|
||||
|
|
|
@ -67,6 +67,10 @@ public class AnnotationConfiguration extends org.eclipse.jetty.annotations.Annot
|
|||
}
|
||||
|
||||
|
||||
public AnnotationConfiguration()
|
||||
{
|
||||
System.err.println("Constructed osgi.AnnotationConfiguration");
|
||||
}
|
||||
/**
|
||||
* This parser scans the bundles using the OSGi APIs instead of assuming a jar.
|
||||
*/
|
||||
|
|
|
@ -143,63 +143,12 @@ public abstract class AbstractContextProvider extends AbstractLifeCycle implemen
|
|||
{
|
||||
//apply the contextFile, creating the ContextHandler, the DeploymentManager will register it in the ContextHandlerCollection
|
||||
Resource res = null;
|
||||
|
||||
//try to find the context file in the filesystem
|
||||
if (_contextFile.startsWith("/"))
|
||||
res = getFileAsResource(_contextFile);
|
||||
|
||||
//try to find it relative to jetty home
|
||||
if (res == null)
|
||||
{
|
||||
//See if the specific server we are related to has jetty.home set
|
||||
String jettyHome = (String)getServerInstanceWrapper().getServer().getAttribute(OSGiServerConstants.JETTY_HOME);
|
||||
if (jettyHome != null)
|
||||
res = getFileAsResource(jettyHome, _contextFile);
|
||||
|
||||
//try to see if a SystemProperty for jetty.home is set
|
||||
if (res == null)
|
||||
{
|
||||
jettyHome = System.getProperty(OSGiServerConstants.JETTY_HOME);
|
||||
|
||||
if (jettyHome != null)
|
||||
{
|
||||
if (jettyHome.startsWith("\"") || jettyHome.startsWith("'"))
|
||||
jettyHome = jettyHome.substring(1);
|
||||
if (jettyHome.endsWith("\"") || (jettyHome.endsWith("'")))
|
||||
jettyHome = jettyHome.substring(0,jettyHome.length()-1);
|
||||
|
||||
res = getFileAsResource(jettyHome, _contextFile);
|
||||
LOG.debug("jetty home context file: {}",res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//try to find it relative to an override location that has been specified
|
||||
if (res == null)
|
||||
{
|
||||
if (bundleOverrideLocation != null)
|
||||
{
|
||||
try(Resource location=Resource.newResource(bundleOverrideLocation))
|
||||
{
|
||||
res=location.addPath(_contextFile);
|
||||
}
|
||||
LOG.debug("Bundle override location context file: {}",res);
|
||||
}
|
||||
}
|
||||
|
||||
//try to find it relative to the bundle in which it is being deployed
|
||||
if (res == null)
|
||||
{
|
||||
if (_contextFile.startsWith("./"))
|
||||
_contextFile = _contextFile.substring(1);
|
||||
|
||||
if (!_contextFile.startsWith("/"))
|
||||
_contextFile = "/" + _contextFile;
|
||||
|
||||
URL contextURL = _bundle.getEntry(_contextFile);
|
||||
if (contextURL != null)
|
||||
res = Resource.newResource(contextURL);
|
||||
}
|
||||
|
||||
String jettyHome = (String)getServerInstanceWrapper().getServer().getAttribute(OSGiServerConstants.JETTY_HOME);
|
||||
if (jettyHome == null)
|
||||
jettyHome = System.getProperty(OSGiServerConstants.JETTY_HOME);
|
||||
|
||||
res = findFile(_contextFile, jettyHome, bundleOverrideLocation, _bundle);
|
||||
|
||||
//apply the context xml file, either to an existing ContextHandler, or letting the
|
||||
//it create the ContextHandler as necessary
|
||||
|
@ -266,38 +215,6 @@ public abstract class AbstractContextProvider extends AbstractLifeCycle implemen
|
|||
|
||||
}
|
||||
|
||||
|
||||
private Resource getFileAsResource (String dir, String file)
|
||||
{
|
||||
Resource r = null;
|
||||
try
|
||||
{
|
||||
File asFile = new File (dir, file);
|
||||
if (asFile.exists())
|
||||
r = Resource.newResource(asFile);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
r = null;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
private Resource getFileAsResource (String file)
|
||||
{
|
||||
Resource r = null;
|
||||
try
|
||||
{
|
||||
File asFile = new File (file);
|
||||
if (asFile.exists())
|
||||
r = Resource.newResource(asFile);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
r = null;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
package org.eclipse.jetty.osgi.boot;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.Dictionary;
|
||||
import java.util.Hashtable;
|
||||
|
||||
|
@ -25,6 +27,9 @@ import org.eclipse.jetty.deploy.App;
|
|||
import org.eclipse.jetty.deploy.AppProvider;
|
||||
import org.eclipse.jetty.deploy.DeploymentManager;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.osgi.framework.ServiceRegistration;
|
||||
|
@ -39,6 +44,8 @@ import org.osgi.framework.ServiceRegistration;
|
|||
*/
|
||||
public abstract class AbstractOSGiApp extends App
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(AbstractOSGiApp.class);
|
||||
|
||||
protected Bundle _bundle;
|
||||
protected Dictionary _properties;
|
||||
protected ServiceRegistration _registration;
|
||||
|
@ -118,4 +125,91 @@ public abstract class AbstractOSGiApp extends App
|
|||
_registration = null;
|
||||
}
|
||||
|
||||
protected Resource getFileAsResource (String dir, String file)
|
||||
{
|
||||
Resource r = null;
|
||||
try
|
||||
{
|
||||
File asFile = new File (dir, file);
|
||||
if (asFile.exists())
|
||||
r = Resource.newResource(asFile);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
r = null;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
protected Resource getFileAsResource (String file)
|
||||
{
|
||||
Resource r = null;
|
||||
try
|
||||
{
|
||||
File asFile = new File (file);
|
||||
if (asFile.exists())
|
||||
r = Resource.newResource(asFile);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
r = null;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
protected Resource findFile (String fileName, String jettyHome, String bundleOverrideLocation, Bundle containingBundle)
|
||||
{
|
||||
Resource res = null;
|
||||
|
||||
//try to find the context file in the filesystem
|
||||
if (fileName.startsWith("/"))
|
||||
res = getFileAsResource(fileName);
|
||||
if (res != null)
|
||||
return res;
|
||||
|
||||
//try to find it relative to jetty home
|
||||
if (jettyHome != null)
|
||||
{
|
||||
if (jettyHome.startsWith("\"") || jettyHome.startsWith("'"))
|
||||
jettyHome = jettyHome.substring(1);
|
||||
if (jettyHome.endsWith("\"") || (jettyHome.endsWith("'")))
|
||||
jettyHome = jettyHome.substring(0,jettyHome.length()-1);
|
||||
|
||||
res = getFileAsResource(jettyHome, fileName);
|
||||
}
|
||||
if (res != null)
|
||||
return res;
|
||||
|
||||
|
||||
//try to find it relative to an override location that has been specified
|
||||
if (bundleOverrideLocation != null)
|
||||
{
|
||||
try(Resource location=Resource.newResource(bundleOverrideLocation))
|
||||
{
|
||||
res=location.addPath(fileName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.warn(e);
|
||||
}
|
||||
}
|
||||
if (res != null)
|
||||
return res;
|
||||
|
||||
//try to find it relative to the bundle in which it is being deployed
|
||||
if (containingBundle != null)
|
||||
{
|
||||
if (fileName.startsWith("./"))
|
||||
fileName = fileName.substring(1);
|
||||
|
||||
if (!fileName.startsWith("/"))
|
||||
fileName = "/" + fileName;
|
||||
|
||||
URL entry = _bundle.getEntry(fileName);
|
||||
if (entry != null)
|
||||
res = Resource.newResource(entry);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,12 @@ package org.eclipse.jetty.osgi.boot;
|
|||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Dictionary;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jetty.deploy.App;
|
||||
import org.eclipse.jetty.deploy.AppProvider;
|
||||
|
@ -32,7 +34,9 @@ import org.eclipse.jetty.osgi.boot.internal.serverfactory.ServerInstanceWrapper;
|
|||
import org.eclipse.jetty.osgi.boot.internal.webapp.OSGiWebappClassLoader;
|
||||
import org.eclipse.jetty.osgi.boot.utils.BundleFileLocatorHelperFactory;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.util.ArrayUtil;
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.util.Loader;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.JarResource;
|
||||
|
@ -73,17 +77,23 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
|
|||
|
||||
public static String[] getDefaultConfigurations ()
|
||||
{
|
||||
List<String> configs = ArrayUtil.asMutableList(__defaultConfigurations);
|
||||
if (annotationsAvailable())
|
||||
{
|
||||
String[] configs = new String[__defaultConfigurations.length+1];
|
||||
System.arraycopy(__defaultConfigurations, 0, configs, 0, 4);
|
||||
configs[4] = "org.eclipse.jetty.osgi.annotations.AnnotationConfiguration";
|
||||
configs[5] = __defaultConfigurations[__defaultConfigurations.length-1];
|
||||
return configs;
|
||||
//add before JettyWebXmlConfiguration
|
||||
int i = configs.indexOf("org.eclipse.jetty.webapp.JettyWebXmlConfiguration");
|
||||
configs.add(i, "org.eclipse.jetty.osgi.annotations.AnnotationConfiguration");
|
||||
}
|
||||
|
||||
if (jndiAvailable())
|
||||
{
|
||||
//add in EnvConfiguration and PlusConfiguration just after FragmentConfiguration
|
||||
int i = configs.indexOf("org.eclipse.jetty.webapp.FragmentConfiguration");
|
||||
configs.add(++i, "org.eclipse.jetty.plus.webapp.EnvConfiguration");
|
||||
configs.add(++i, "org.eclipse.jetty.plus.webapp.PlusConfiguration");
|
||||
}
|
||||
|
||||
|
||||
return Arrays.copyOf(__defaultConfigurations, __defaultConfigurations.length);
|
||||
return configs.toArray(new String[configs.size()]);
|
||||
}
|
||||
|
||||
private static boolean annotationsAvailable()
|
||||
|
@ -91,7 +101,7 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
|
|||
boolean result = false;
|
||||
try
|
||||
{
|
||||
Thread.currentThread().getContextClassLoader().loadClass("org.eclipse.jetty.annotations.AnnotationConfiguration");
|
||||
Loader.loadClass(AbstractWebAppProvider.class,"org.eclipse.jetty.annotations.AnnotationConfiguration");
|
||||
result = true;
|
||||
LOG.debug("Annotation support detected");
|
||||
}
|
||||
|
@ -104,6 +114,23 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
private static boolean jndiAvailable()
|
||||
{
|
||||
try
|
||||
{
|
||||
Loader.loadClass(AbstractWebAppProvider.class, "org.eclipse.jetty.plus.jndi.Resource");
|
||||
Loader.loadClass(AbstractWebAppProvider.class, "org.eclipse.jetty.plus.webapp.EnvConfiguration");
|
||||
LOG.debug("JNDI support detected");
|
||||
return true;
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
LOG.debug("No JNDI support detected");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean _parentLoaderPriority;
|
||||
|
||||
|
@ -328,7 +355,7 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
|
|||
|
||||
// apply any META-INF/context.xml file that is found to configure
|
||||
// the webapp first
|
||||
applyMetaInfContextXml(rootResource);
|
||||
applyMetaInfContextXml(rootResource, overrideBundleInstallLocation);
|
||||
|
||||
_webApp.setAttribute(OSGiWebappConstants.REQUIRE_TLD_BUNDLE, requireTldBundles);
|
||||
|
||||
|
@ -384,7 +411,7 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
|
|||
}
|
||||
|
||||
|
||||
protected void applyMetaInfContextXml(Resource rootResource)
|
||||
protected void applyMetaInfContextXml(Resource rootResource, String overrideBundleInstallLocation)
|
||||
throws Exception
|
||||
{
|
||||
if (_bundle == null) return;
|
||||
|
@ -398,8 +425,31 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
|
|||
Thread.currentThread().setContextClassLoader(_webApp.getClassLoader());
|
||||
|
||||
//TODO replace this with getting the InputStream so we don't cache in URL
|
||||
// find if there is a META-INF/context.xml file
|
||||
//Try looking for a context xml file in META-INF with a specific name
|
||||
URL contextXmlUrl = _bundle.getEntry("/META-INF/jetty-webapp-context.xml");
|
||||
|
||||
if (contextXmlUrl == null)
|
||||
{
|
||||
//Didn't find specially named file, try looking for a property that names a context xml file to use
|
||||
if (_properties != null)
|
||||
{
|
||||
String tmp = (String)_properties.get(OSGiWebappConstants.JETTY_CONTEXT_FILE_PATH);
|
||||
if (tmp != null)
|
||||
{
|
||||
String[] filenames = tmp.split(",;");
|
||||
if (filenames != null && filenames.length > 0)
|
||||
{
|
||||
String filename = filenames[0]; //should only be 1 filename in this usage
|
||||
String jettyHome = (String)getServerInstanceWrapper().getServer().getAttribute(OSGiServerConstants.JETTY_HOME);
|
||||
if (jettyHome == null)
|
||||
jettyHome = System.getProperty(OSGiServerConstants.JETTY_HOME);
|
||||
Resource res = findFile(filename, jettyHome, overrideBundleInstallLocation, _bundle);
|
||||
if (res != null)
|
||||
contextXmlUrl = res.getURL();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (contextXmlUrl == null) return;
|
||||
|
||||
// Apply it just as the standard jetty ContextProvider would do
|
||||
|
|
|
@ -106,6 +106,13 @@ public class BundleContextProvider extends AbstractContextProvider implements Bu
|
|||
if (bundle == null)
|
||||
return false;
|
||||
|
||||
//If the bundle defines a Web-ContextPath then its probably a webapp and the BundleWebAppProvider should deploy it
|
||||
if ((String)bundle.getHeaders().get(OSGiWebappConstants.RFC66_WEB_CONTEXTPATH) != null)
|
||||
{
|
||||
if (LOG.isDebugEnabled()) LOG.debug("BundleContextProvider ignoring bundle {} with {} set", bundle.getSymbolicName(), OSGiWebappConstants.RFC66_WEB_CONTEXTPATH);
|
||||
return false;
|
||||
}
|
||||
|
||||
String contextFiles = (String)bundle.getHeaders().get(OSGiWebappConstants.JETTY_CONTEXT_FILE_PATH);
|
||||
if (contextFiles == null)
|
||||
contextFiles = (String)bundle.getHeaders().get(OSGiWebappConstants.SERVICE_PROP_CONTEXT_FILE_PATH);
|
||||
|
@ -113,6 +120,7 @@ public class BundleContextProvider extends AbstractContextProvider implements Bu
|
|||
if (contextFiles == null)
|
||||
return false;
|
||||
|
||||
|
||||
boolean added = false;
|
||||
//bundle defines JETTY_CONTEXT_FILE_PATH header,
|
||||
//a comma separated list of context xml files that each define a ContextHandler
|
||||
|
|
|
@ -50,7 +50,14 @@ public class OSGiWebInfConfiguration extends WebInfConfiguration
|
|||
{
|
||||
private static final Logger LOG = Log.getLogger(WebInfConfiguration.class);
|
||||
|
||||
|
||||
/**
|
||||
* Comma separated list of symbolic names of bundles that contain tlds that should be considered
|
||||
* as on the container classpath
|
||||
*/
|
||||
public static final String SYS_PROP_TLD_BUNDLES = "org.eclipse.jetty.osgi.tldbundles";
|
||||
/**
|
||||
* Regex of symbolic names of bundles that should be considered to be on the container classpath
|
||||
*/
|
||||
public static final String CONTAINER_BUNDLE_PATTERN = "org.eclipse.jetty.server.webapp.containerIncludeBundlePattern";
|
||||
public static final String FRAGMENT_AND_REQUIRED_BUNDLES = "org.eclipse.jetty.osgi.fragmentAndRequiredBundles";
|
||||
public static final String FRAGMENT_AND_REQUIRED_RESOURCES = "org.eclipse.jetty.osgi.fragmentAndRequiredResources";
|
||||
|
@ -84,7 +91,7 @@ public class OSGiWebInfConfiguration extends WebInfConfiguration
|
|||
String tmp = (String)context.getAttribute(CONTAINER_BUNDLE_PATTERN);
|
||||
Pattern pattern = (tmp==null?null:Pattern.compile(tmp));
|
||||
List<String> names = new ArrayList<String>();
|
||||
tmp = System.getProperty("org.eclipse.jetty.osgi.tldbundles");
|
||||
tmp = System.getProperty(SYS_PROP_TLD_BUNDLES);
|
||||
if (tmp != null)
|
||||
{
|
||||
StringTokenizer tokenizer = new StringTokenizer(tmp, ", \n\r\t", false);
|
||||
|
|
|
@ -97,6 +97,12 @@ public class OSGiWebappClassLoader extends WebAppClassLoader implements BundleRe
|
|||
|
||||
|
||||
|
||||
@Override
|
||||
public Class<?> loadClass(String name) throws ClassNotFoundException
|
||||
{
|
||||
return super.loadClass(name);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Returns the <code>Bundle</code> that defined this web-application.
|
||||
|
|
|
@ -130,12 +130,7 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-jsp-fragment</artifactId>
|
||||
<version>2.3.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.osgi</groupId>
|
||||
<artifactId>jetty-httpservice</artifactId>
|
||||
|
@ -144,10 +139,11 @@
|
|||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<scope>test</scope>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-osgi-servlet-api</artifactId>
|
||||
<version>3.1.0.M0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-jta_1.1_spec</artifactId>
|
||||
|
@ -168,6 +164,12 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mortbay.jasper</groupId>
|
||||
<artifactId>apache-el</artifactId>
|
||||
<version>8.0.9-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Jetty Deps -->
|
||||
|
@ -341,6 +343,29 @@
|
|||
<classifier>webbundle</classifier>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
<artifactId>test-spec-webapp</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>war</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
<artifactId>test-container-initializer</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
<artifactId>test-mock-resources</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.osgi</groupId>
|
||||
<artifactId>test-jetty-osgi-context</artifactId>
|
||||
|
|
|
@ -88,13 +88,10 @@ public class TestJettyOSGiBootCore
|
|||
res.add(mavenBundle().groupId( "org.apache.aries" ).artifactId( "org.apache.aries.util" ).versionAsInProject().start());
|
||||
res.add(mavenBundle().groupId( "org.apache.aries.spifly" ).artifactId( "org.apache.aries.spifly.dynamic.bundle" ).versionAsInProject().start());
|
||||
|
||||
res.add(mavenBundle().groupId( "javax.servlet" ).artifactId( "javax.servlet-api" ).versionAsInProject().noStart());
|
||||
res.add(mavenBundle().groupId( "org.eclipse.jetty.toolchain" ).artifactId( "jetty-osgi-servlet-api" ).versionAsInProject().noStart());
|
||||
res.add(mavenBundle().groupId( "javax.annotation" ).artifactId( "javax.annotation-api" ).versionAsInProject().noStart());
|
||||
res.add(mavenBundle().groupId( "org.apache.geronimo.specs" ).artifactId( "geronimo-jta_1.1_spec" ).version("1.1.1").noStart());
|
||||
res.add(mavenBundle().groupId( "org.eclipse.jetty.orbit" ).artifactId( "javax.mail.glassfish" ).version( "1.4.1.v201005082020" ).noStart());
|
||||
|
||||
|
||||
res.add(mavenBundle().groupId( "org.eclipse.jetty.toolchain" ).artifactId( "jetty-schemas" ).versionAsInProject().noStart());
|
||||
|
||||
res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-deploy" ).versionAsInProject().noStart());
|
||||
res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-server" ).versionAsInProject().noStart());
|
||||
|
@ -109,7 +106,7 @@ public class TestJettyOSGiBootCore
|
|||
res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-servlets" ).versionAsInProject().noStart());
|
||||
res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-client" ).versionAsInProject().noStart());
|
||||
res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-jndi" ).versionAsInProject().noStart());
|
||||
res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-plus" ).versionAsInProject().noStart());
|
||||
res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-plus" ).versionAsInProject());
|
||||
res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-annotations" ).versionAsInProject().start());
|
||||
res.add(mavenBundle().groupId( "org.eclipse.jetty.websocket" ).artifactId( "websocket-api" ).versionAsInProject().noStart());
|
||||
res.add(mavenBundle().groupId( "org.eclipse.jetty.websocket" ).artifactId( "websocket-common" ).versionAsInProject().noStart());
|
||||
|
@ -122,6 +119,32 @@ public class TestJettyOSGiBootCore
|
|||
res.add(mavenBundle().groupId( "org.eclipse.jetty.osgi" ).artifactId( "jetty-osgi-boot" ).versionAsInProject().start());
|
||||
return res;
|
||||
}
|
||||
|
||||
public static List<Option> consoleDependencies()
|
||||
{
|
||||
List<Option> res = new ArrayList<Option>();
|
||||
res.add(systemProperty("osgi.console").value("6666"));
|
||||
res.add(systemProperty("osgi.console.enable.builtin").value("true"));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static List<Option> jspDependencies()
|
||||
{
|
||||
List<Option> res = new ArrayList<Option>();
|
||||
|
||||
//jetty jsp bundles
|
||||
res.add(mavenBundle().groupId("org.eclipse.jetty.toolchain").artifactId("jetty-schemas").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.eclipse.jetty.orbit").artifactId("javax.servlet.jsp.jstl").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.mortbay.jasper").artifactId("apache-el").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.mortbay.jasper").artifactId("apache-jsp").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("apache-jsp").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.glassfish.web").artifactId("javax.servlet.jsp.jstl").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.eclipse.jetty.orbit").artifactId("org.eclipse.jdt.core").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.eclipse.jetty.osgi").artifactId("jetty-osgi-boot-jsp").versionAsInProject().noStart());
|
||||
return res;
|
||||
}
|
||||
|
||||
public static List<Option> httpServiceJetty()
|
||||
{
|
||||
|
|
|
@ -110,15 +110,8 @@ public class TestJettyOSGiBootWebAppAsService
|
|||
public static List<Option> jspDependencies()
|
||||
{
|
||||
List<Option> res = new ArrayList<Option>();
|
||||
|
||||
//jsp bundles
|
||||
res.add(mavenBundle().groupId("javax.servlet.jsp").artifactId("javax.servlet.jsp-api").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.eclipse.jetty.orbit").artifactId("javax.servlet.jsp.jstl").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.glassfish.web").artifactId("javax.servlet.jsp.jstl").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.glassfish").artifactId("javax.el").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.eclipse.jetty.orbit").artifactId("org.eclipse.jdt.core").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.eclipse.jetty.toolchain").artifactId("jetty-jsp-fragment").versionAsInProject().noStart());
|
||||
res.add(mavenBundle().groupId("org.eclipse.jetty.osgi").artifactId("jetty-osgi-boot-jsp").versionAsInProject().noStart());
|
||||
|
||||
res.addAll(TestJettyOSGiBootCore.jspDependencies());
|
||||
|
||||
// a bundle that registers a webapp as a service for the jetty osgi core
|
||||
// to pick up and deploy
|
||||
|
|
|
@ -0,0 +1,167 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 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.osgi.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
|
||||
import static org.ops4j.pax.exam.CoreOptions.options;
|
||||
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.api.ContentResponse;
|
||||
import org.eclipse.jetty.client.api.Request;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.osgi.boot.OSGiServerConstants;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.ops4j.pax.exam.Configuration;
|
||||
import org.ops4j.pax.exam.CoreOptions;
|
||||
import org.ops4j.pax.exam.Option;
|
||||
import org.ops4j.pax.exam.junit.PaxExam;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* Pax-Exam to make sure the jetty-osgi-boot can be started along with the
|
||||
* httpservice web-bundle. Then make sure we can deploy an OSGi service on the
|
||||
* top of this.
|
||||
*/
|
||||
@RunWith(PaxExam.class)
|
||||
|
||||
public class TestJettyOSGiBootWithAnnotations
|
||||
{
|
||||
private static final String LOG_LEVEL = "WARN";
|
||||
|
||||
@Inject
|
||||
BundleContext bundleContext = null;
|
||||
|
||||
@Configuration
|
||||
public static Option[] configure()
|
||||
{
|
||||
|
||||
ArrayList<Option> options = new ArrayList<Option>();
|
||||
options.add(CoreOptions.junitBundles());
|
||||
options.addAll(configureJettyHomeAndPort("jetty-selector.xml"));
|
||||
options.add(CoreOptions.bootDelegationPackages("org.xml.sax", "org.xml.*", "org.w3c.*", "javax.sql.*","javax.xml.*", "javax.activation.*"));
|
||||
options.add(CoreOptions.systemPackages("com.sun.org.apache.xalan.internal.res","com.sun.org.apache.xml.internal.utils",
|
||||
"com.sun.org.apache.xml.internal.utils", "com.sun.org.apache.xpath.internal",
|
||||
"com.sun.org.apache.xpath.internal.jaxp", "com.sun.org.apache.xpath.internal.objects"));
|
||||
|
||||
options.addAll(TestJettyOSGiBootCore.coreJettyDependencies());
|
||||
options.addAll(Arrays.asList(options(systemProperty("pax.exam.logging").value("none"))));
|
||||
options.addAll(Arrays.asList(options(systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value(LOG_LEVEL))));
|
||||
options.addAll(Arrays.asList(options(systemProperty("org.eclipse.jetty.annotations.LEVEL").value(LOG_LEVEL))));
|
||||
//options.addAll(TestJettyOSGiBootCore.consoleDependencies());
|
||||
options.addAll(jspDependencies());
|
||||
options.addAll(annotationDependencies());
|
||||
return options.toArray(new Option[options.size()]);
|
||||
}
|
||||
|
||||
public static List<Option> configureJettyHomeAndPort(String jettySelectorFileName)
|
||||
{
|
||||
File etcFolder = new File("src/test/config/etc");
|
||||
String etc = "file://" + etcFolder.getAbsolutePath();
|
||||
List<Option> options = new ArrayList<Option>();
|
||||
String xmlConfigs = etc + "/jetty.xml;"
|
||||
+ etc
|
||||
+ "/"
|
||||
+ jettySelectorFileName
|
||||
+ ";"
|
||||
+ etc
|
||||
+ "/jetty-ssl.xml;"
|
||||
+ etc
|
||||
+ "/jetty-https.xml;"
|
||||
+ etc
|
||||
+ "/jetty-deployer.xml;"
|
||||
+ etc
|
||||
+ "/jetty-testrealm.xml";
|
||||
|
||||
options.add(systemProperty(OSGiServerConstants.MANAGED_JETTY_XML_CONFIG_URLS).value(xmlConfigs));
|
||||
options.add(systemProperty("jetty.port").value(String.valueOf(TestJettyOSGiBootCore.DEFAULT_JETTY_HTTP_PORT)));
|
||||
options.add(systemProperty("jetty.home").value(etcFolder.getParentFile().getAbsolutePath()));
|
||||
return options;
|
||||
}
|
||||
|
||||
public static List<Option> jspDependencies()
|
||||
{
|
||||
return TestJettyOSGiBootCore.jspDependencies();
|
||||
}
|
||||
|
||||
public static List<Option> annotationDependencies()
|
||||
{
|
||||
List<Option> res = new ArrayList<Option>();
|
||||
res.add(mavenBundle().groupId("org.eclipse.jetty.tests").artifactId("test-container-initializer").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.eclipse.jetty.tests").artifactId("test-mock-resources").versionAsInProject());
|
||||
//test webapp bundle
|
||||
res.add(mavenBundle().groupId("org.eclipse.jetty.tests").artifactId("test-spec-webapp").classifier("webbundle").versionAsInProject());
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void assertAllBundlesActiveOrResolved()
|
||||
{
|
||||
TestOSGiUtil.assertAllBundlesActiveOrResolved(bundleContext);
|
||||
}
|
||||
|
||||
// at the moment can't run httpservice with jsp at the same time.
|
||||
// that is a regression in jetty-9
|
||||
@Ignore
|
||||
@Test
|
||||
public void testHttpService() throws Exception
|
||||
{
|
||||
TestOSGiUtil.testHttpServiceGreetings(bundleContext, "http", TestJettyOSGiBootCore.DEFAULT_JETTY_HTTP_PORT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testIndex() throws Exception
|
||||
{
|
||||
HttpClient client = new HttpClient();
|
||||
try
|
||||
{
|
||||
client.start();
|
||||
ContentResponse response = client.GET("http://127.0.0.1:" + TestJettyOSGiBootCore.DEFAULT_JETTY_HTTP_PORT + "/index.html");
|
||||
assertEquals(HttpStatus.OK_200, response.getStatus());
|
||||
|
||||
String content = new String(response.getContent());
|
||||
assertTrue(content.contains("<h1>Servlet 3.1 Test WebApp</h1>"));
|
||||
|
||||
Request req = client.POST("http://127.0.0.1:" + TestJettyOSGiBootCore.DEFAULT_JETTY_HTTP_PORT + "/test");
|
||||
response = req.send();
|
||||
content = new String(response.getContent());
|
||||
assertTrue(content.contains("<p><b>Result: <span class=\"pass\">PASS</span></p>"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
client.stop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -52,7 +52,7 @@ import org.osgi.framework.BundleContext;
|
|||
@RunWith(PaxExam.class)
|
||||
public class TestJettyOSGiBootWithJsp
|
||||
{
|
||||
private static final String LOG_LEVEL = "WARN";
|
||||
private static final String LOG_LEVEL = "INFO";
|
||||
|
||||
@Inject
|
||||
BundleContext bundleContext = null;
|
||||
|
@ -73,7 +73,7 @@ public class TestJettyOSGiBootWithJsp
|
|||
options.addAll(Arrays.asList(options(systemProperty("pax.exam.logging").value("none"))));
|
||||
options.addAll(Arrays.asList(options(systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value(LOG_LEVEL))));
|
||||
options.addAll(Arrays.asList(options(systemProperty("org.eclipse.jetty.LEVEL").value(LOG_LEVEL))));
|
||||
|
||||
options.addAll(Arrays.asList(options(systemProperty("org.eclipse.jetty.annotations.LEVEL").value("DEBUG"))));
|
||||
options.addAll(jspDependencies());
|
||||
return options.toArray(new Option[options.size()]);
|
||||
}
|
||||
|
@ -106,26 +106,19 @@ public class TestJettyOSGiBootWithJsp
|
|||
public static List<Option> jspDependencies()
|
||||
{
|
||||
List<Option> res = new ArrayList<Option>();
|
||||
|
||||
//jetty jsp bundles
|
||||
res.add(mavenBundle().groupId("javax.servlet.jsp").artifactId("javax.servlet.jsp-api").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.eclipse.jetty.orbit").artifactId("javax.servlet.jsp.jstl").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.glassfish.web").artifactId("javax.servlet.jsp.jstl").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.glassfish").artifactId("javax.el").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.eclipse.jetty.orbit").artifactId("org.eclipse.jdt.core").versionAsInProject());
|
||||
res.add(mavenBundle().groupId("org.eclipse.jetty.toolchain").artifactId("jetty-jsp-fragment").versionAsInProject().noStart());
|
||||
res.add(mavenBundle().groupId("org.eclipse.jetty.osgi").artifactId("jetty-osgi-boot-jsp").versionAsInProject().noStart());
|
||||
|
||||
res.addAll(TestJettyOSGiBootCore.jspDependencies());
|
||||
//test webapp bundle
|
||||
res.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("test-jetty-webapp").classifier("webbundle").versionAsInProject());
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Ignore
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void assertAllBundlesActiveOrResolved()
|
||||
{
|
||||
TestOSGiUtil.debugBundles(bundleContext);
|
||||
TestOSGiUtil.assertAllBundlesActiveOrResolved(bundleContext);
|
||||
}
|
||||
|
||||
|
@ -142,16 +135,15 @@ public class TestJettyOSGiBootWithJsp
|
|||
@Test
|
||||
public void testJspDump() throws Exception
|
||||
{
|
||||
|
||||
HttpClient client = new HttpClient();
|
||||
try
|
||||
{
|
||||
client.start();
|
||||
ContentResponse response = client.GET("http://127.0.0.1:" + TestJettyOSGiBootCore.DEFAULT_JETTY_HTTP_PORT + "/jsp/dump.jsp");
|
||||
ContentResponse response = client.GET("http://127.0.0.1:" + TestJettyOSGiBootCore.DEFAULT_JETTY_HTTP_PORT + "/jsp/jstl.jsp");
|
||||
assertEquals(HttpStatus.OK_200, response.getStatus());
|
||||
|
||||
String content = new String(response.getContent());
|
||||
assertTrue(content.contains("<tr><th>ServletPath:</th><td>/jsp/dump.jsp</td></tr>"));
|
||||
|
||||
assertTrue(content.contains("JSTL Example"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -25,10 +25,17 @@
|
|||
</goals>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<_versionpolicy> </_versionpolicy>
|
||||
<_nouses>true</_nouses>
|
||||
<!-- Export-Package>
|
||||
org.eclipse.jetty.plus.annotation;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}",
|
||||
org.eclipse.jetty.plus.webapp;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}",
|
||||
org.eclipse.jetty.plus.jndi;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}",
|
||||
org.eclipse.jetty.plus.security;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"
|
||||
</Export-Package -->
|
||||
<Import-Package>javax.sql.*,javax.security.*,javax.naming.*,
|
||||
javax.servlet.*;version="[2.6.0,3.2)",javax.transaction.*;version="[1.1,1.3)",
|
||||
*</Import-Package>
|
||||
*
|
||||
</Import-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
@ -250,15 +250,18 @@ public class ConnectHandler extends HandlerWrapper
|
|||
channel.socket().setTcpNoDelay(true);
|
||||
channel.configureBlocking(false);
|
||||
InetSocketAddress address = new InetSocketAddress(host, port);
|
||||
channel.connect(address);
|
||||
|
||||
AsyncContext asyncContext = request.startAsync();
|
||||
asyncContext.setTimeout(0);
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Connecting to {}", address);
|
||||
|
||||
ConnectContext connectContext = new ConnectContext(request, response, asyncContext, HttpConnection.getCurrentConnection());
|
||||
selector.connect(channel, connectContext);
|
||||
if (channel.connect(address))
|
||||
selector.accept(channel, connectContext);
|
||||
else
|
||||
selector.connect(channel, connectContext);
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
|
|
|
@ -222,6 +222,7 @@ public class ProxyServletTest
|
|||
.timeout(5, TimeUnit.SECONDS)
|
||||
.send();
|
||||
|
||||
Assert.assertEquals("OK", response.getReason());
|
||||
Assert.assertEquals(200, response.getStatus());
|
||||
Assert.assertTrue(response.getHeaders().containsKey(PROXIED_HEADER));
|
||||
}
|
||||
|
|
|
@ -19,9 +19,7 @@
|
|||
|
||||
package org.eclipse.jetty.quickstart;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Collection;
|
||||
|
@ -50,7 +48,6 @@ import org.eclipse.jetty.security.authentication.FormAuthenticator;
|
|||
import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlet.FilterMapping;
|
||||
import org.eclipse.jetty.servlet.Holder;
|
||||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.servlet.ServletMapping;
|
||||
|
@ -129,7 +126,7 @@ public class QuickStartDescriptorGenerator
|
|||
out.openTag("web-app",webappAttr);
|
||||
if (_webApp.getDisplayName() != null)
|
||||
out.tag("display-name",_webApp.getDisplayName());
|
||||
|
||||
|
||||
// Set some special context parameters
|
||||
|
||||
// The location of the war file on disk
|
||||
|
@ -163,7 +160,7 @@ public class QuickStartDescriptorGenerator
|
|||
if (servlets.getFilters() != null)
|
||||
{
|
||||
for (FilterHolder holder : servlets.getFilters())
|
||||
outholder(out,md,"filter",holder);
|
||||
outholder(out,md,holder);
|
||||
}
|
||||
|
||||
if (servlets.getFilterMappings() != null)
|
||||
|
@ -199,7 +196,7 @@ public class QuickStartDescriptorGenerator
|
|||
if (servlets.getServlets() != null)
|
||||
{
|
||||
for (ServletHolder holder : servlets.getServlets())
|
||||
outholder(out,md,"servlet",holder);
|
||||
outholder(out,md,holder);
|
||||
}
|
||||
|
||||
if (servlets.getServletMappings() != null)
|
||||
|
@ -250,16 +247,37 @@ public class QuickStartDescriptorGenerator
|
|||
{
|
||||
out.openTag("security-constraint");
|
||||
|
||||
if (m.getConstraint().getAuthenticate())
|
||||
out.openTag("web-resource-collection");
|
||||
{
|
||||
out.openTag("auth-constraint");
|
||||
if (m.getConstraint().getRoles()!=null)
|
||||
for (String r : m.getConstraint().getRoles())
|
||||
out.tag("role-name",r);
|
||||
if (m.getConstraint().getName()!=null)
|
||||
out.tag("web-resource-name",m.getConstraint().getName());
|
||||
if (m.getPathSpec()!=null)
|
||||
out.tag("url-pattern",origin(md,"constraint.url."+m.getPathSpec()),m.getPathSpec());
|
||||
if (m.getMethod()!=null)
|
||||
out.tag("http-method",m.getMethod());
|
||||
|
||||
if (m.getMethodOmissions()!=null)
|
||||
for (String o:m.getMethodOmissions())
|
||||
out.tag("http-method-omission",o);
|
||||
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
if (m.getConstraint().getAuthenticate())
|
||||
{
|
||||
String[] roles = m.getConstraint().getRoles();
|
||||
if (roles!=null && roles.length>0)
|
||||
{
|
||||
out.openTag("auth-constraint");
|
||||
if (m.getConstraint().getRoles()!=null)
|
||||
for (String r : m.getConstraint().getRoles())
|
||||
out.tag("role-name",r);
|
||||
out.closeTag();
|
||||
}
|
||||
else
|
||||
out.tag("auth-constraint");
|
||||
}
|
||||
|
||||
switch (m.getConstraint().getDataConstraint())
|
||||
{
|
||||
case Constraint.DC_NONE:
|
||||
|
@ -279,22 +297,6 @@ public class QuickStartDescriptorGenerator
|
|||
|
||||
}
|
||||
|
||||
out.openTag("web-resource-collection");
|
||||
{
|
||||
if (m.getConstraint().getName()!=null)
|
||||
out.tag("web-resource-name",m.getConstraint().getName());
|
||||
if (m.getPathSpec()!=null)
|
||||
out.tag("url-pattern",origin(md,"constraint.url."+m.getPathSpec()),m.getPathSpec());
|
||||
if (m.getMethod()!=null)
|
||||
out.tag("http-method",m.getMethod());
|
||||
|
||||
if (m.getMethodOmissions()!=null)
|
||||
for (String o:m.getMethodOmissions())
|
||||
out.tag("http-method-omission",o);
|
||||
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
out.closeTag();
|
||||
|
||||
}
|
||||
|
@ -331,12 +333,6 @@ public class QuickStartDescriptorGenerator
|
|||
int maxInactiveSec = _webApp.getSessionHandler().getSessionManager().getMaxInactiveInterval();
|
||||
out.tag("session-timeout", (maxInactiveSec==0?"0":Integer.toString(maxInactiveSec/60)));
|
||||
|
||||
Set<SessionTrackingMode> modes =_webApp. getSessionHandler().getSessionManager().getEffectiveSessionTrackingModes();
|
||||
if (modes != null)
|
||||
{
|
||||
for (SessionTrackingMode mode:modes)
|
||||
out.tag("tracking-mode", mode.toString());
|
||||
}
|
||||
|
||||
//cookie-config
|
||||
SessionCookieConfig cookieConfig = _webApp.getSessionHandler().getSessionManager().getSessionCookieConfig();
|
||||
|
@ -360,6 +356,15 @@ public class QuickStartDescriptorGenerator
|
|||
out.tag("max-age", origin(md, "cookie-config.max-age"), Integer.toString(cookieConfig.getMaxAge()));
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
// tracking-modes
|
||||
Set<SessionTrackingMode> modes =_webApp. getSessionHandler().getSessionManager().getEffectiveSessionTrackingModes();
|
||||
if (modes != null)
|
||||
{
|
||||
for (SessionTrackingMode mode:modes)
|
||||
out.tag("tracking-mode", mode.toString());
|
||||
}
|
||||
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
|
@ -560,29 +565,57 @@ public class QuickStartDescriptorGenerator
|
|||
* @param holder
|
||||
* @throws IOException
|
||||
*/
|
||||
private void outholder(XmlAppendable out, MetaData md, String tag, Holder<?> holder) throws IOException
|
||||
private void outholder(XmlAppendable out, MetaData md, FilterHolder holder) throws IOException
|
||||
{
|
||||
out.openTag(tag,Collections.singletonMap("source",holder.getSource().toString()));
|
||||
if (LOG.isDebugEnabled())
|
||||
out.openTag("filter",Collections.singletonMap("source",holder.getSource().toString()));
|
||||
else
|
||||
out.openTag("filter");
|
||||
|
||||
String n = holder.getName();
|
||||
out.tag(tag + "-name",n);
|
||||
out.tag("filter-name",n);
|
||||
|
||||
String ot = n + "." + tag + ".";
|
||||
String ot = n + ".filter.";
|
||||
|
||||
if (holder instanceof FilterHolder)
|
||||
out.tag(tag + "-class",origin(md,ot + tag + "-class"),holder.getClassName());
|
||||
else if (holder instanceof ServletHolder)
|
||||
{
|
||||
ServletHolder s = (ServletHolder)holder;
|
||||
if (s.getForcedPath() != null && s.getClassName() == null)
|
||||
out.tag("jsp-file",s.getForcedPath());
|
||||
else
|
||||
out.tag(tag + "-class",origin(md,ot + tag + "-class"),s.getClassName());
|
||||
|
||||
out.tag("filter-class",origin(md,ot + "filter-class"),holder.getClassName());
|
||||
out.tag("async-supported",origin(md,ot + "async-supported"),holder.isAsyncSupported()?"true":"false");
|
||||
}
|
||||
|
||||
for (String p : holder.getInitParameters().keySet())
|
||||
{
|
||||
out.openTag("init-param",origin(md,ot + "init-param." + p))
|
||||
.tag("param-name",p)
|
||||
.tag("param-value",holder.getInitParameter(p))
|
||||
.closeTag();
|
||||
}
|
||||
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
private void outholder(XmlAppendable out, MetaData md, ServletHolder holder) throws IOException
|
||||
{
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
out.openTag("servlet",Collections.singletonMap("source",holder.getSource().toString()));
|
||||
else
|
||||
out.openTag("servlet");
|
||||
|
||||
String n = holder.getName();
|
||||
out.tag("servlet-name",n);
|
||||
|
||||
String ot = n + ".servlet.";
|
||||
|
||||
ServletHolder s = (ServletHolder)holder;
|
||||
if (s.getForcedPath() != null && s.getClassName() == null)
|
||||
out.tag("jsp-file",s.getForcedPath());
|
||||
else
|
||||
out.tag("servlet-class",origin(md,ot + "servlet-class"),s.getClassName());
|
||||
|
||||
for (String p : holder.getInitParameters().keySet())
|
||||
{
|
||||
if ("scratchdir".equalsIgnoreCase(p)) //don't preconfigure the temp dir for jsp output
|
||||
if ("jsp".equalsIgnoreCase(n) && "scratchdir".equalsIgnoreCase(p)) //don't preconfigure the temp dir for jsp output
|
||||
continue;
|
||||
out.openTag("init-param",origin(md,ot + "init-param." + p))
|
||||
.tag("param-name",p)
|
||||
|
@ -590,50 +623,46 @@ public class QuickStartDescriptorGenerator
|
|||
.closeTag();
|
||||
}
|
||||
|
||||
if (holder instanceof ServletHolder)
|
||||
if (s.getInitOrder() >= 0)
|
||||
out.tag("load-on-startup",Integer.toString(s.getInitOrder()));
|
||||
|
||||
if (!s.isEnabled())
|
||||
out.tag("enabled",origin(md,ot + "enabled"),"false");
|
||||
|
||||
out.tag("async-supported",origin(md,ot + "async-supported"),holder.isAsyncSupported()?"true":"false");
|
||||
|
||||
if (s.getRunAsRole() != null)
|
||||
out.openTag("run-as",origin(md,ot + "run-as"))
|
||||
.tag("role-name",s.getRunAsRole())
|
||||
.closeTag();
|
||||
|
||||
Map<String,String> roles = s.getRoleRefMap();
|
||||
if (roles!=null)
|
||||
{
|
||||
ServletHolder s = (ServletHolder)holder;
|
||||
if (s.getInitOrder() >= 0)
|
||||
out.tag("load-on-startup",Integer.toString(s.getInitOrder()));
|
||||
|
||||
if (s.getRunAsRole() != null)
|
||||
out.openTag("run-as",origin(md,ot + "run-as"))
|
||||
.tag("role-name",s.getRunAsRole())
|
||||
for (Map.Entry<String, String> e : roles.entrySet())
|
||||
{
|
||||
out.openTag("security-role-ref",origin(md,ot+"role-name."+e.getKey()))
|
||||
.tag("role-name",e.getKey())
|
||||
.tag("role-link",e.getValue())
|
||||
.closeTag();
|
||||
|
||||
Map<String,String> roles = s.getRoleRefMap();
|
||||
if (roles!=null)
|
||||
{
|
||||
for (Map.Entry<String, String> e : roles.entrySet())
|
||||
{
|
||||
out.openTag("security-role-ref",origin(md,ot+"role-name."+e.getKey()))
|
||||
.tag("role-name",e.getKey())
|
||||
.tag("role-link",e.getValue())
|
||||
.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
if (!s.isEnabled())
|
||||
out.tag("enabled",origin(md,ot + "enabled"),"false");
|
||||
|
||||
//multipart-config
|
||||
MultipartConfigElement multipartConfig = ((ServletHolder.Registration)s.getRegistration()).getMultipartConfig();
|
||||
if (multipartConfig != null)
|
||||
{
|
||||
out.openTag("multipart-config", origin(md, s.getName()+".servlet.multipart-config"));
|
||||
if (multipartConfig.getLocation() != null)
|
||||
out.tag("location", multipartConfig.getLocation());
|
||||
out.tag("max-file-size", Long.toString(multipartConfig.getMaxFileSize()));
|
||||
out.tag("max-request-size", Long.toString(multipartConfig.getMaxRequestSize()));
|
||||
out.tag("file-size-threshold", Long.toString(multipartConfig.getFileSizeThreshold()));
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
out.tag("async-supported",origin(md,ot + "async-supported"),holder.isAsyncSupported()?"true":"false");
|
||||
//multipart-config
|
||||
MultipartConfigElement multipartConfig = ((ServletHolder.Registration)s.getRegistration()).getMultipartConfig();
|
||||
if (multipartConfig != null)
|
||||
{
|
||||
out.openTag("multipart-config", origin(md, s.getName()+".servlet.multipart-config"));
|
||||
if (multipartConfig.getLocation() != null)
|
||||
out.tag("location", multipartConfig.getLocation());
|
||||
out.tag("max-file-size", Long.toString(multipartConfig.getMaxFileSize()));
|
||||
out.tag("max-request-size", Long.toString(multipartConfig.getMaxRequestSize()));
|
||||
out.tag("file-size-threshold", Long.toString(multipartConfig.getFileSizeThreshold()));
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||
<Arg name="server"><Ref refid="Server" /></Arg>
|
||||
<Arg name="acceptors" type="int"><Property name="http.acceptors" default="-1"/></Arg>
|
||||
<Arg name="selectors" type="int"><Property name="http.selectors" default="-1"/></Arg>
|
||||
<Arg name="factories">
|
||||
<Array type="org.eclipse.jetty.server.ConnectionFactory">
|
||||
<Item>
|
||||
|
@ -35,6 +37,8 @@
|
|||
<Set name="port"><Property name="jetty.port" default="80" /></Set>
|
||||
<Set name="idleTimeout"><Property name="http.timeout" default="30000"/></Set>
|
||||
<Set name="soLingerTime"><Property name="http.soLingerTime" default="-1"/></Set>
|
||||
<Set name="acceptorPriorityDelta"><Property name="http.acceptorPriorityDelta" default="0"/></Set>
|
||||
<Set name="selectorPriorityDelta"><Property name="http.selectorPriorityDelta" default="0"/></Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
|
|
|
@ -23,26 +23,30 @@
|
|||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||
<Arg name="server"><Ref refid="Server" /></Arg>
|
||||
<Arg name="factories">
|
||||
<Array type="org.eclipse.jetty.server.ConnectionFactory">
|
||||
<Item>
|
||||
<New class="org.eclipse.jetty.server.SslConnectionFactory">
|
||||
<Arg name="next">http/1.1</Arg>
|
||||
<Arg name="sslContextFactory"><Ref refid="sslContextFactory"/></Arg>
|
||||
</New>
|
||||
</Item>
|
||||
<Item>
|
||||
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
|
||||
<Arg name="config"><Ref refid="sslHttpConfig"/></Arg>
|
||||
</New>
|
||||
</Item>
|
||||
</Array>
|
||||
</Arg>
|
||||
<Set name="host"><Property name="jetty.host" /></Set>
|
||||
<Set name="port"><Property name="https.port" default="443" /></Set>
|
||||
<Set name="idleTimeout"><Property name="https.timeout" default="30000"/></Set>
|
||||
<Set name="soLingerTime"><Property name="https.soLingerTime" default="-1"/></Set>
|
||||
</New>
|
||||
<Arg name="acceptors" type="int"><Property name="ssl.acceptors" default="-1"/></Arg>
|
||||
<Arg name="selectors" type="int"><Property name="ssl.selectors" default="-1"/></Arg>
|
||||
<Arg name="factories">
|
||||
<Array type="org.eclipse.jetty.server.ConnectionFactory">
|
||||
<Item>
|
||||
<New class="org.eclipse.jetty.server.SslConnectionFactory">
|
||||
<Arg name="next">http/1.1</Arg>
|
||||
<Arg name="sslContextFactory"><Ref refid="sslContextFactory"/></Arg>
|
||||
</New>
|
||||
</Item>
|
||||
<Item>
|
||||
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
|
||||
<Arg name="config"><Ref refid="sslHttpConfig"/></Arg>
|
||||
</New>
|
||||
</Item>
|
||||
</Array>
|
||||
</Arg>
|
||||
<Set name="host"><Property name="jetty.host" /></Set>
|
||||
<Set name="port"><Property name="https.port" default="443" /></Set>
|
||||
<Set name="idleTimeout"><Property name="https.timeout" default="30000"/></Set>
|
||||
<Set name="soLingerTime"><Property name="https.soLingerTime" default="-1"/></Set>
|
||||
<Set name="acceptorPriorityDelta"><Property name="ssl.acceptorPriorityDelta" default="0"/></Set>
|
||||
<Set name="selectorPriorityDelta"><Property name="ssl.selectorPriorityDelta" default="0"/></Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
</Configure>
|
||||
|
|
|
@ -9,10 +9,19 @@ server
|
|||
etc/jetty-http.xml
|
||||
|
||||
[ini-template]
|
||||
## HTTP Connector Configuration
|
||||
# HTTP port to listen on
|
||||
### HTTP Connector Configuration
|
||||
|
||||
## HTTP port to listen on
|
||||
jetty.port=8080
|
||||
# HTTP idle timeout in milliseconds
|
||||
|
||||
## HTTP idle timeout in milliseconds
|
||||
http.timeout=30000
|
||||
# HTTP Socket.soLingerTime in seconds. (-1 to disable)
|
||||
|
||||
## HTTP Socket.soLingerTime in seconds. (-1 to disable)
|
||||
# http.soLingerTime=-1
|
||||
|
||||
## Parameters to control the number and priority of acceptors and selectors
|
||||
# http.selectors=1
|
||||
# http.acceptors=1
|
||||
# http.selectorPriorityDelta=0
|
||||
# http.acceptorPriorityDelta=0
|
||||
|
|
|
@ -12,24 +12,29 @@ etc/jetty-ssl.xml
|
|||
http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/plain/jetty-server/src/main/config/etc/keystore|etc/keystore
|
||||
|
||||
[ini-template]
|
||||
## SSL Keystore Configuration
|
||||
### SSL Keystore Configuration
|
||||
# define the port to use for secure redirection
|
||||
jetty.secure.port=8443
|
||||
|
||||
# Setup a demonstration keystore and truststore
|
||||
## Setup a demonstration keystore and truststore
|
||||
jetty.keystore=etc/keystore
|
||||
jetty.truststore=etc/keystore
|
||||
|
||||
# Set the demonstration passwords.
|
||||
# Note that OBF passwords are not secure, just protected from casual observation
|
||||
# See http://www.eclipse.org/jetty/documentation/current/configuring-security-secure-passwords.html
|
||||
## Set the demonstration passwords.
|
||||
## Note that OBF passwords are not secure, just protected from casual observation
|
||||
## See http://www.eclipse.org/jetty/documentation/current/configuring-security-secure-passwords.html
|
||||
jetty.keystore.password=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4
|
||||
jetty.keymanager.password=OBF:1u2u1wml1z7s1z7a1wnl1u2g
|
||||
jetty.truststore.password=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4
|
||||
|
||||
# Set the client auth behavior
|
||||
# Set to true if client certificate authentication is required
|
||||
### Set the client auth behavior
|
||||
## Set to true if client certificate authentication is required
|
||||
# jetty.ssl.needClientAuth=true
|
||||
# Set to true if client certificate authentication is desired
|
||||
## Set to true if client certificate authentication is desired
|
||||
# jetty.ssl.wantClientAuth=true
|
||||
|
||||
## Parameters to control the number and priority of acceptors and selectors
|
||||
# ssl.selectors=1
|
||||
# ssl.acceptors=1
|
||||
# ssl.selectorPriorityDelta=0
|
||||
# ssl.acceptorPriorityDelta=0
|
||||
|
|
|
@ -147,6 +147,7 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
private String _defaultProtocol;
|
||||
private ConnectionFactory _defaultConnectionFactory;
|
||||
private String _name;
|
||||
private int _acceptorPriorityDelta;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -399,6 +400,30 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
}
|
||||
}
|
||||
|
||||
@ManagedAttribute("The priority delta to apply to acceptor threads")
|
||||
public int getAcceptorPriorityDelta()
|
||||
{
|
||||
return _acceptorPriorityDelta;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Set the acceptor thread priority delta.
|
||||
* <p>This allows the acceptor thread to run at a different priority.
|
||||
* Typically this would be used to lower the priority to give preference
|
||||
* to handling previously accepted connections rather than accepting
|
||||
* new connections</p>
|
||||
* @param acceptorPriorityDelta
|
||||
*/
|
||||
public void setAcceptorPriorityDelta(int acceptorPriorityDelta)
|
||||
{
|
||||
int old=_acceptorPriorityDelta;
|
||||
_acceptorPriorityDelta = acceptorPriorityDelta;
|
||||
if (old!=acceptorPriorityDelta && isStarted())
|
||||
{
|
||||
for (Thread thread : _acceptors)
|
||||
thread.setPriority(Math.max(Thread.MIN_PRIORITY,Math.min(Thread.MAX_PRIORITY,thread.getPriority()-old+acceptorPriorityDelta)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ManagedAttribute("Protocols supported by this connector")
|
||||
|
@ -452,14 +477,18 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
@Override
|
||||
public void run()
|
||||
{
|
||||
Thread current = Thread.currentThread();
|
||||
String name=current.getName();
|
||||
final Thread thread = Thread.currentThread();
|
||||
String name=thread.getName();
|
||||
_name=String.format("%s-acceptor-%d@%x-%s",name,_acceptor,hashCode(),AbstractConnector.this.toString());
|
||||
current.setName(_name);
|
||||
thread.setName(_name);
|
||||
|
||||
int priority=thread.getPriority();
|
||||
if (_acceptorPriorityDelta!=0)
|
||||
thread.setPriority(Math.max(Thread.MIN_PRIORITY,Math.min(Thread.MAX_PRIORITY,priority+_acceptorPriorityDelta)));
|
||||
|
||||
synchronized (AbstractConnector.this)
|
||||
{
|
||||
_acceptors[_acceptor] = current;
|
||||
_acceptors[_acceptor] = thread;
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -481,7 +510,9 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
}
|
||||
finally
|
||||
{
|
||||
current.setName(name);
|
||||
thread.setName(name);
|
||||
if (_acceptorPriorityDelta!=0)
|
||||
thread.setPriority(priority);
|
||||
|
||||
synchronized (AbstractConnector.this)
|
||||
{
|
||||
|
|
|
@ -149,6 +149,26 @@ public class HttpChannel<T> implements HttpParser.RequestHandler<T>, Runnable, H
|
|||
{
|
||||
return _transport;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the idle timeout.
|
||||
* <p>This is implemented as a call to {@link EndPoint#getIdleTimeout()}, but may be
|
||||
* overridden by channels that have timeouts different from their connections.
|
||||
*/
|
||||
public long getIdleTimeout()
|
||||
{
|
||||
return _endPoint.getIdleTimeout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the idle timeout.
|
||||
* <p>This is implemented as a call to {@link EndPoint#setIdleTimeout(long), but may be
|
||||
* overridden by channels that have timeouts different from their connections.
|
||||
*/
|
||||
public void setIdleTimeout(long timeoutMs)
|
||||
{
|
||||
_endPoint.setIdleTimeout(timeoutMs);
|
||||
}
|
||||
|
||||
public ByteBufferPool getByteBufferPool()
|
||||
{
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.channels.WritePendingException;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.WriteListener;
|
||||
|
||||
|
@ -52,7 +53,14 @@ public class HttpOutput extends ServletOutputStream implements Runnable
|
|||
{
|
||||
private static Logger LOG = Log.getLogger(HttpOutput.class);
|
||||
private final HttpChannel<?> _channel;
|
||||
private final SharedBlockingCallback _writeblock=new SharedBlockingCallback();
|
||||
private final SharedBlockingCallback _writeblock=new SharedBlockingCallback()
|
||||
{
|
||||
@Override
|
||||
protected long getIdleTimeout()
|
||||
{
|
||||
return _channel.getIdleTimeout();
|
||||
}
|
||||
};
|
||||
private long _written;
|
||||
private ByteBuffer _aggregate;
|
||||
private int _bufferSize;
|
||||
|
@ -770,14 +778,15 @@ public class HttpOutput extends ServletOutputStream implements Runnable
|
|||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
switch(_state.get())
|
||||
{
|
||||
case READY:
|
||||
case CLOSED:
|
||||
// even though a write is not possible, because a close has
|
||||
// occurred, we need to call onWritePossible to tell async
|
||||
// producer that the last write completed.
|
||||
// so fall through
|
||||
case READY:
|
||||
try
|
||||
{
|
||||
_writeListener.onWritePossible();
|
||||
|
@ -788,8 +797,9 @@ public class HttpOutput extends ServletOutputStream implements Runnable
|
|||
_onError=e;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
_onError=new IllegalStateException("state="+_state.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -834,7 +844,7 @@ public class HttpOutput extends ServletOutputStream implements Runnable
|
|||
@Override
|
||||
public void onCompleteFailure(Throwable e)
|
||||
{
|
||||
_onError=e;
|
||||
_onError=e==null?new IOException():e;
|
||||
_channel.getState().onWritePossible();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.eclipse.jetty.http.HttpGenerator;
|
|||
import org.eclipse.jetty.util.Callback;
|
||||
|
||||
public interface HttpTransport
|
||||
{
|
||||
{
|
||||
void send(HttpGenerator.ResponseInfo info, ByteBuffer content, boolean lastContent, Callback callback);
|
||||
|
||||
void send(ByteBuffer content, boolean lastContent, Callback callback);
|
||||
|
|
|
@ -690,58 +690,26 @@ public class Response implements HttpServletResponse
|
|||
if (!URIUtil.hasScheme(location))
|
||||
{
|
||||
StringBuilder buf = _channel.getRequest().getRootURL();
|
||||
|
||||
if (location.startsWith("//"))
|
||||
if (location.startsWith("/"))
|
||||
{
|
||||
buf.delete(0, buf.length());
|
||||
buf.append(_channel.getRequest().getScheme());
|
||||
buf.append(":");
|
||||
buf.append(location);
|
||||
// absolute in context
|
||||
location=URIUtil.canonicalPath(location);
|
||||
}
|
||||
else if (location.startsWith("/"))
|
||||
buf.append(location);
|
||||
else
|
||||
{
|
||||
String path = _channel.getRequest().getRequestURI();
|
||||
String parent = (path.endsWith("/")) ? path : URIUtil.parentPath(path);
|
||||
location = URIUtil.addPaths(parent, location);
|
||||
if (location == null)
|
||||
throw new IllegalStateException("path cannot be above root");
|
||||
// relative to request
|
||||
String path=_channel.getRequest().getRequestURI();
|
||||
String parent=(path.endsWith("/"))?path:URIUtil.parentPath(path);
|
||||
location=URIUtil.canonicalPath(URIUtil.addPaths(parent,location));
|
||||
if (!location.startsWith("/"))
|
||||
buf.append('/');
|
||||
buf.append(location);
|
||||
}
|
||||
|
||||
location = buf.toString();
|
||||
HttpURI uri = new HttpURI(location);
|
||||
String path = uri.getDecodedPath();
|
||||
String canonical = URIUtil.canonicalPath(path);
|
||||
if (canonical == null)
|
||||
throw new IllegalArgumentException();
|
||||
if (!canonical.equals(path))
|
||||
{
|
||||
buf = _channel.getRequest().getRootURL();
|
||||
buf.append(URIUtil.encodePath(canonical));
|
||||
String param=uri.getParam();
|
||||
if (param!=null)
|
||||
{
|
||||
buf.append(';');
|
||||
buf.append(param);
|
||||
}
|
||||
String query=uri.getQuery();
|
||||
if (query!=null)
|
||||
{
|
||||
buf.append('?');
|
||||
buf.append(query);
|
||||
}
|
||||
String fragment=uri.getFragment();
|
||||
if (fragment!=null)
|
||||
{
|
||||
buf.append('#');
|
||||
buf.append(fragment);
|
||||
}
|
||||
location = buf.toString();
|
||||
}
|
||||
|
||||
if(location==null)
|
||||
throw new IllegalStateException("path cannot be above root");
|
||||
buf.append(location);
|
||||
|
||||
location=buf.toString();
|
||||
}
|
||||
|
||||
resetBuffer();
|
||||
|
|
|
@ -331,20 +331,23 @@ public class Server extends HandlerWrapper implements Attributes
|
|||
// check size of thread pool
|
||||
SizedThreadPool pool = getBean(SizedThreadPool.class);
|
||||
int max=pool==null?-1:pool.getMaxThreads();
|
||||
int needed=1;
|
||||
int selectors=0;
|
||||
int acceptors=0;
|
||||
if (mex.size()==0)
|
||||
{
|
||||
for (Connector connector : _connectors)
|
||||
{
|
||||
if (connector instanceof AbstractConnector)
|
||||
needed+=((AbstractConnector)connector).getAcceptors();
|
||||
acceptors+=((AbstractConnector)connector).getAcceptors();
|
||||
|
||||
if (connector instanceof ServerConnector)
|
||||
needed+=((ServerConnector)connector).getSelectorManager().getSelectorCount();
|
||||
selectors+=((ServerConnector)connector).getSelectorManager().getSelectorCount();
|
||||
}
|
||||
}
|
||||
|
||||
int needed=1+selectors+acceptors;
|
||||
if (max>0 && needed>max)
|
||||
throw new IllegalStateException("Insufficient max threads in ThreadPool: max="+max+" < needed="+needed);
|
||||
throw new IllegalStateException(String.format("Insufficient threads: max=%d < needed(acceptors=%d + selectors=%d + request=1)",max,acceptors,selectors));
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -113,6 +113,26 @@ public class ServerConnector extends AbstractNetworkConnector
|
|||
{
|
||||
this(server,null,null,null,acceptors,selectors,new HttpConnectionFactory());
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** HTTP Server Connection.
|
||||
* <p>Construct a ServerConnector with a private instance of {@link HttpConnectionFactory} as the only factory.</p>
|
||||
* @param server The {@link Server} this connector will accept connection for.
|
||||
* @param acceptors
|
||||
* the number of acceptor threads to use, or -1 for a default value. Acceptors accept new TCP/IP connections. If 0, then
|
||||
* the selector threads are used to accept connections.
|
||||
* @param selectors
|
||||
* the number of selector threads, or -1 for a default value. Selectors notice and schedule established connection that can make IO progress.
|
||||
* @param factories Zero or more {@link ConnectionFactory} instances used to create and configure connections.
|
||||
*/
|
||||
public ServerConnector(
|
||||
@Name("server") Server server,
|
||||
@Name("acceptors") int acceptors,
|
||||
@Name("selectors") int selectors,
|
||||
@Name("factories") ConnectionFactory... factories)
|
||||
{
|
||||
this(server,null,null,null,acceptors,selectors,factories);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Generic Server Connection with default configuration.
|
||||
|
@ -229,6 +249,29 @@ public class ServerConnector extends AbstractNetworkConnector
|
|||
return channel!=null && channel.isOpen();
|
||||
}
|
||||
|
||||
|
||||
@ManagedAttribute("The priority delta to apply to selector threads")
|
||||
public int getSelectorPriorityDelta()
|
||||
{
|
||||
return _manager.getSelectorPriorityDelta();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the selector thread priority delta to the given amount.
|
||||
* <p>This allows the selector threads to run at a different priority.
|
||||
* Typically this would be used to lower the priority to give preference
|
||||
* to handling previously accepted connections rather than accepting
|
||||
* new connections.</p>
|
||||
*
|
||||
* @param selectorPriorityDelta the amount to set the thread priority delta to
|
||||
* (may be negative)
|
||||
* @see Thread#getPriority()
|
||||
*/
|
||||
public void setSelectorPriorityDelta(int selectorPriorityDelta)
|
||||
{
|
||||
_manager.setSelectorPriorityDelta(selectorPriorityDelta);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether this connector uses a channel inherited from the JVM.
|
||||
* @see System#inheritedChannel()
|
||||
|
|
|
@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.server.HttpChannel;
|
||||
import org.eclipse.jetty.server.HttpConnection;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
|
||||
|
@ -79,17 +80,9 @@ public class IdleTimeoutHandler extends HandlerWrapper
|
|||
@Override
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||
{
|
||||
HttpConnection connection = HttpConnection.getCurrentConnection();
|
||||
final EndPoint endp = connection==null?null:connection.getEndPoint();
|
||||
|
||||
final long idle_timeout;
|
||||
if (endp==null)
|
||||
idle_timeout=-1;
|
||||
else
|
||||
{
|
||||
idle_timeout=endp.getIdleTimeout();
|
||||
endp.setIdleTimeout(_idleTimeoutMs);
|
||||
}
|
||||
final HttpChannel<?> channel = baseRequest.getHttpChannel();
|
||||
final long idle_timeout=baseRequest.getHttpChannel().getIdleTimeout();
|
||||
channel.setIdleTimeout(_idleTimeoutMs);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -97,8 +90,6 @@ public class IdleTimeoutHandler extends HandlerWrapper
|
|||
}
|
||||
finally
|
||||
{
|
||||
if (endp!=null)
|
||||
{
|
||||
if (_applyToAsync && request.isAsyncStarted())
|
||||
{
|
||||
request.getAsyncContext().addListener(new AsyncListener()
|
||||
|
@ -116,19 +107,18 @@ public class IdleTimeoutHandler extends HandlerWrapper
|
|||
@Override
|
||||
public void onError(AsyncEvent event) throws IOException
|
||||
{
|
||||
endp.setIdleTimeout(idle_timeout);
|
||||
channel.setIdleTimeout(idle_timeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete(AsyncEvent event) throws IOException
|
||||
{
|
||||
endp.setIdleTimeout(idle_timeout);
|
||||
channel.setIdleTimeout(idle_timeout);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
endp.setIdleTimeout(idle_timeout);
|
||||
}
|
||||
channel.setIdleTimeout(idle_timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -992,6 +992,8 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager
|
|||
_ownScheduler = true;
|
||||
_scheduler.start();
|
||||
}
|
||||
else if (!_scheduler.isStarted())
|
||||
throw new IllegalStateException("Shared scheduler not started");
|
||||
|
||||
setScavengeInterval(getScavengeInterval());
|
||||
}
|
||||
|
|
|
@ -476,7 +476,8 @@ public class ResponseTest
|
|||
{"l%20cation", "http://@HOST@@PORT@/path/l%20cation"},
|
||||
{"./l%20cation", "http://@HOST@@PORT@/path/l%20cation"},
|
||||
{"../l%20cation","http://@HOST@@PORT@/l%20cation"},
|
||||
{"../locati%C3%abn", "http://@HOST@@PORT@/locati%C3%ABn"},
|
||||
{"../locati%C3%abn", "http://@HOST@@PORT@/locati%C3%abn"},
|
||||
{"../other%2fplace", "http://@HOST@@PORT@/other%2fplace"},
|
||||
{"http://somehost.com/other/location","http://somehost.com/other/location"},
|
||||
};
|
||||
|
||||
|
|
|
@ -156,7 +156,6 @@ public class SPDYClient
|
|||
channel.bind(bindAddress);
|
||||
configure(channel);
|
||||
channel.configureBlocking(false);
|
||||
channel.connect(address);
|
||||
|
||||
context.put(SslClientConnectionFactory.SSL_PEER_HOST_CONTEXT_KEY, ((InetSocketAddress)address).getHostString());
|
||||
context.put(SslClientConnectionFactory.SSL_PEER_PORT_CONTEXT_KEY, ((InetSocketAddress)address).getPort());
|
||||
|
@ -164,7 +163,10 @@ public class SPDYClient
|
|||
context.put(SPDYClientConnectionFactory.SPDY_SESSION_LISTENER_CONTEXT_KEY, listener);
|
||||
context.put(SPDYClientConnectionFactory.SPDY_SESSION_PROMISE_CONTEXT_KEY, promise);
|
||||
|
||||
factory.selector.connect(channel, context);
|
||||
if (channel.connect(address))
|
||||
factory.selector.accept(channel, context);
|
||||
else
|
||||
factory.selector.connect(channel, context);
|
||||
}
|
||||
catch (IOException x)
|
||||
{
|
||||
|
|
|
@ -29,3 +29,9 @@ etc/protonego-npn.xml
|
|||
[files]
|
||||
lib/
|
||||
lib/npn/
|
||||
|
||||
[license]
|
||||
NPN is a hosted at github under the GPL v2 with ClassPath Exception.
|
||||
NPN replaces/modifies OpenJDK classes in the java.sun.security.ssl package.
|
||||
http://github.com/jetty-project/jetty-npn
|
||||
http://openjdk.java.net/legal/gplv2+ce.html
|
||||
|
|
|
@ -52,6 +52,12 @@ public class HttpChannelOverSPDY extends HttpChannel<DataInfo>
|
|||
this.stream = stream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getIdleTimeout()
|
||||
{
|
||||
return stream.getIdleTimeout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean headerComplete()
|
||||
{
|
||||
|
|
|
@ -82,9 +82,12 @@ import org.eclipse.jetty.start.config.CommandLineConfigSource;
|
|||
public class Main
|
||||
{
|
||||
private static final int EXIT_USAGE = 1;
|
||||
private static BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
|
||||
|
||||
public static String join(Collection<?> objs, String delim)
|
||||
{
|
||||
if (objs==null)
|
||||
return "";
|
||||
StringBuilder str = new StringBuilder();
|
||||
boolean needDelim = false;
|
||||
for (Object obj : objs)
|
||||
|
@ -372,6 +375,7 @@ public class Main
|
|||
StartLog.warn("ERROR: No known module for %s",name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Find any named ini file and check it follows the convention
|
||||
Path start_ini = baseHome.getBasePath("start.ini");
|
||||
|
@ -390,11 +394,57 @@ public class Main
|
|||
}
|
||||
|
||||
boolean transitive = module.isEnabled() && (module.getSources().size() == 0);
|
||||
boolean hasDefinedDefaults = module.getDefaultConfig().size() > 0;
|
||||
|
||||
// If it is not enabled or is transitive with ini template lines or toplevel and doesn't exist
|
||||
if (!module.isEnabled() || (transitive && hasDefinedDefaults) || (topLevel && !FS.exists(startd_ini) && !appendStartIni))
|
||||
boolean buildIni=false;
|
||||
if (module.isEnabled())
|
||||
{
|
||||
// is it an explicit request to create an ini file?
|
||||
if (topLevel && !FS.exists(startd_ini) && !appendStartIni)
|
||||
buildIni=true;
|
||||
|
||||
// else is it transitive
|
||||
else if (transitive)
|
||||
{
|
||||
// do we need an ini anyway?
|
||||
if (module.hasDefaultConfig() || module.hasLicense())
|
||||
buildIni=true;
|
||||
else
|
||||
StartLog.info("%-15s initialised transitively",name);
|
||||
}
|
||||
|
||||
// else must be initialized explicitly
|
||||
else
|
||||
{
|
||||
for (String source : module.getSources())
|
||||
StartLog.info("%-15s initialised in %s",name,baseHome.toShortForm(source));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buildIni=true;
|
||||
}
|
||||
|
||||
|
||||
// If we need an ini
|
||||
if (buildIni)
|
||||
{
|
||||
if (module.hasLicense())
|
||||
{
|
||||
System.err.printf("%nModule %s:%n",module.getName());
|
||||
System.err.printf(" + contains software not provided by the Eclipse Foundation!%n");
|
||||
System.err.printf(" + contains software not covered by the Eclipse Public License!%n");
|
||||
System.err.printf(" + has not been audited for compliance with its license%n");
|
||||
System.err.printf("%n");
|
||||
for (String l : module.getLicense())
|
||||
System.err.printf(" %s%n",l);
|
||||
|
||||
System.err.printf("%nProceed (y/N)? ");
|
||||
String line = input.readLine();
|
||||
|
||||
if (line==null || line.length()==0 || !line.toLowerCase().startsWith("y"))
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
|
||||
// File BufferedWriter
|
||||
BufferedWriter writer = null;
|
||||
String source = null;
|
||||
|
@ -464,14 +514,6 @@ public class Main
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (FS.exists(startd_ini))
|
||||
{
|
||||
StartLog.info("%-15s initialised in %s",name,short_startd_ini);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartLog.info("%-15s initialised transitively",name);
|
||||
}
|
||||
|
||||
// Also list other places this module is enabled
|
||||
for (String source : module.getSources())
|
||||
|
|
|
@ -103,6 +103,8 @@ public class Module
|
|||
private List<String> files;
|
||||
/** List of jvm Args */
|
||||
private List<String> jvmArgs;
|
||||
/** License lines */
|
||||
private List<String> license;
|
||||
|
||||
/** Is this Module enabled via start.jar command line, start.ini, or start.d/*.ini ? */
|
||||
private boolean enabled = false;
|
||||
|
@ -263,6 +265,16 @@ public class Module
|
|||
return jvmArgs;
|
||||
}
|
||||
|
||||
public boolean hasLicense()
|
||||
{
|
||||
return license!=null && license.size()>0;
|
||||
}
|
||||
|
||||
public List<String> getLicense()
|
||||
{
|
||||
return license;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
|
@ -283,6 +295,7 @@ public class Module
|
|||
libs = new ArrayList<>();
|
||||
files = new ArrayList<>();
|
||||
jvmArgs = new ArrayList<>();
|
||||
license = new ArrayList<>();
|
||||
|
||||
String name = basehome.toShortForm(file);
|
||||
|
||||
|
@ -356,6 +369,10 @@ public class Module
|
|||
case "LIB":
|
||||
libs.add(line);
|
||||
break;
|
||||
case "LICENSE":
|
||||
case "LICENCE":
|
||||
license.add(line);
|
||||
break;
|
||||
case "NAME":
|
||||
logicalName = line;
|
||||
break;
|
||||
|
|
|
@ -265,6 +265,12 @@ public class Modules implements Iterable<Module>
|
|||
}
|
||||
}
|
||||
|
||||
public void enable(String name) throws IOException
|
||||
{
|
||||
List<String> empty = Collections.emptyList();
|
||||
enable(name,empty);
|
||||
}
|
||||
|
||||
public void enable(String name, List<String> sources) throws IOException
|
||||
{
|
||||
if (name.contains("*"))
|
||||
|
@ -310,9 +316,14 @@ public class Modules implements Iterable<Module>
|
|||
|
||||
private void enableModule(Module module, List<String> sources) throws IOException
|
||||
{
|
||||
// Always add the sources
|
||||
if (sources != null)
|
||||
module.addSources(sources);
|
||||
|
||||
// If already enabled, nothing else to do
|
||||
if (module.isEnabled())
|
||||
{
|
||||
// already enabled, skip
|
||||
StartLog.debug("Enabled module: %s (via %s)",module.getName(),Main.join(sources,", "));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -320,10 +331,6 @@ public class Modules implements Iterable<Module>
|
|||
module.setEnabled(true);
|
||||
args.parseModule(module);
|
||||
module.expandProperties(args.getProperties());
|
||||
if (sources != null)
|
||||
{
|
||||
module.addSources(sources);
|
||||
}
|
||||
|
||||
// enable any parents that haven't been enabled (yet)
|
||||
Set<String> parentNames = new HashSet<>();
|
||||
|
@ -349,7 +356,7 @@ public class Modules implements Iterable<Module>
|
|||
}
|
||||
if (parent != null)
|
||||
{
|
||||
enableModule(parent,sources);
|
||||
enableModule(parent,null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -920,6 +920,11 @@ public class BufferUtil
|
|||
return builder.toString();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Convert Buffer to a detail debug string of pointers and content
|
||||
* @param buffer
|
||||
* @return A string showing the pointers and content of the buffer
|
||||
*/
|
||||
public static String toDetailString(ByteBuffer buffer)
|
||||
{
|
||||
if (buffer == null)
|
||||
|
@ -942,15 +947,33 @@ public class BufferUtil
|
|||
buf.append(buffer.remaining());
|
||||
buf.append("]={");
|
||||
|
||||
appendDebugString(buf,buffer);
|
||||
|
||||
buf.append("}");
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Convert buffer to a Debug String.
|
||||
* @param buffer
|
||||
* @return A string showing the escaped content of the buffer around the
|
||||
* position and limit (marked with <<< and >>>)
|
||||
*/
|
||||
public static String toDebugString(ByteBuffer buffer)
|
||||
{
|
||||
if (buffer == null)
|
||||
return "null";
|
||||
StringBuilder buf = new StringBuilder();
|
||||
appendDebugString(buf,buffer);
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
private static void appendDebugString(StringBuilder buf,ByteBuffer buffer)
|
||||
{
|
||||
for (int i = 0; i < buffer.position(); i++)
|
||||
{
|
||||
char c = (char)buffer.get(i);
|
||||
if (c >= ' ' && c <= 127)
|
||||
buf.append(c);
|
||||
else if (c == '\r' || c == '\n')
|
||||
buf.append('|');
|
||||
else
|
||||
buf.append('\ufffd');
|
||||
appendContentChar(buf,buffer.get(i));
|
||||
if (i == 16 && buffer.position() > 32)
|
||||
{
|
||||
buf.append("...");
|
||||
|
@ -960,13 +983,7 @@ public class BufferUtil
|
|||
buf.append("<<<");
|
||||
for (int i = buffer.position(); i < buffer.limit(); i++)
|
||||
{
|
||||
char c = (char)buffer.get(i);
|
||||
if (c >= ' ' && c <= 127)
|
||||
buf.append(c);
|
||||
else if (c == '\r' || c == '\n')
|
||||
buf.append('|');
|
||||
else
|
||||
buf.append('\ufffd');
|
||||
appendContentChar(buf,buffer.get(i));
|
||||
if (i == buffer.position() + 16 && buffer.limit() > buffer.position() + 32)
|
||||
{
|
||||
buf.append("...");
|
||||
|
@ -978,13 +995,7 @@ public class BufferUtil
|
|||
buffer.limit(buffer.capacity());
|
||||
for (int i = limit; i < buffer.capacity(); i++)
|
||||
{
|
||||
char c = (char)buffer.get(i);
|
||||
if (c >= ' ' && c <= 127)
|
||||
buf.append(c);
|
||||
else if (c == '\r' || c == '\n')
|
||||
buf.append('|');
|
||||
else
|
||||
buf.append('\ufffd');
|
||||
appendContentChar(buf,buffer.get(i));
|
||||
if (i == limit + 16 && buffer.capacity() > limit + 32)
|
||||
{
|
||||
buf.append("...");
|
||||
|
@ -992,11 +1003,23 @@ public class BufferUtil
|
|||
}
|
||||
}
|
||||
buffer.limit(limit);
|
||||
buf.append("}");
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
private static void appendContentChar(StringBuilder buf, byte b)
|
||||
{
|
||||
if (b == '\\')
|
||||
buf.append("\\\\");
|
||||
else if (b >= ' ')
|
||||
buf.append((char)b);
|
||||
else if (b == '\r')
|
||||
buf.append("\\r");
|
||||
else if (b == '\n')
|
||||
buf.append("\\n");
|
||||
else if (b == '\t')
|
||||
buf.append("\\t");
|
||||
else
|
||||
buf.append("\\x").append(TypeUtil.toHexString(b));
|
||||
}
|
||||
|
||||
private final static int[] decDivisors =
|
||||
{1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1};
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.eclipse.jetty.util;
|
|||
|
||||
import java.lang.ref.PhantomReference;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
|
@ -124,8 +125,8 @@ public class LeakDetector<T> extends AbstractLifeCycle implements Runnable
|
|||
@Override
|
||||
protected void doStop() throws Exception
|
||||
{
|
||||
thread.interrupt();
|
||||
super.doStop();
|
||||
thread.interrupt();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.io.IOException;
|
|||
import java.io.InterruptedIOException;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
|
@ -47,7 +48,11 @@ import org.eclipse.jetty.util.thread.NonBlockingThread;
|
|||
*/
|
||||
public class SharedBlockingCallback
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(SharedBlockingCallback.class);
|
||||
static final Logger LOG = Log.getLogger(SharedBlockingCallback.class);
|
||||
|
||||
final ReentrantLock _lock = new ReentrantLock();
|
||||
final Condition _idle = _lock.newCondition();
|
||||
final Condition _complete = _lock.newCondition();
|
||||
|
||||
|
||||
private static Throwable IDLE = new Throwable()
|
||||
|
@ -77,56 +82,64 @@ public class SharedBlockingCallback
|
|||
}
|
||||
};
|
||||
|
||||
final Blocker _blocker;
|
||||
Blocker _blocker;
|
||||
|
||||
public SharedBlockingCallback()
|
||||
{
|
||||
this(new Blocker());
|
||||
_blocker=new Blocker();
|
||||
}
|
||||
|
||||
protected SharedBlockingCallback(Blocker blocker)
|
||||
protected long getIdleTimeout()
|
||||
{
|
||||
_blocker=blocker;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public Blocker acquire() throws IOException
|
||||
{
|
||||
_blocker._lock.lock();
|
||||
_lock.lock();
|
||||
long idle = getIdleTimeout();
|
||||
try
|
||||
{
|
||||
while (_blocker._state != IDLE)
|
||||
_blocker._idle.await();
|
||||
{
|
||||
if (idle>0)
|
||||
{
|
||||
// Wait a little bit longer than the blocker might block
|
||||
if (!_idle.await(idle*2,TimeUnit.MILLISECONDS))
|
||||
throw new IOException(new TimeoutException());
|
||||
}
|
||||
else
|
||||
_idle.await();
|
||||
}
|
||||
_blocker._state = null;
|
||||
}
|
||||
catch (final InterruptedException e)
|
||||
{
|
||||
throw new InterruptedIOException()
|
||||
{
|
||||
{
|
||||
initCause(e);
|
||||
}
|
||||
};
|
||||
throw new InterruptedIOException();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_blocker._lock.unlock();
|
||||
_lock.unlock();
|
||||
}
|
||||
return _blocker;
|
||||
}
|
||||
|
||||
protected void notComplete(Blocker blocker)
|
||||
{
|
||||
LOG.warn("Blocker not complete {}",blocker);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug(new Throwable());
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** A Closeable Callback.
|
||||
* Uses the auto close mechanism to check block has been called OK.
|
||||
*/
|
||||
public static class Blocker implements Callback, Closeable
|
||||
public class Blocker implements Callback, Closeable
|
||||
{
|
||||
final ReentrantLock _lock = new ReentrantLock();
|
||||
final Condition _idle = _lock.newCondition();
|
||||
final Condition _complete = _lock.newCondition();
|
||||
Throwable _state = IDLE;
|
||||
|
||||
public Blocker()
|
||||
|
||||
protected Blocker()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -141,8 +154,8 @@ public class SharedBlockingCallback
|
|||
_state = SUCCEEDED;
|
||||
_complete.signalAll();
|
||||
}
|
||||
else if (_state == IDLE)
|
||||
throw new IllegalStateException("IDLE");
|
||||
else
|
||||
throw new IllegalStateException(_state);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -158,11 +171,17 @@ public class SharedBlockingCallback
|
|||
{
|
||||
if (_state == null)
|
||||
{
|
||||
_state = cause==null?FAILED:cause;
|
||||
if (cause==null)
|
||||
_state=FAILED;
|
||||
else if (cause instanceof BlockerTimeoutException)
|
||||
// Not this blockers timeout
|
||||
_state=new IOException(cause);
|
||||
else
|
||||
_state=cause;
|
||||
_complete.signalAll();
|
||||
}
|
||||
else if (_state == IDLE)
|
||||
throw new IllegalStateException("IDLE",cause);
|
||||
else
|
||||
throw new IllegalStateException(_state);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -183,10 +202,22 @@ public class SharedBlockingCallback
|
|||
LOG.warn("Blocking a NonBlockingThread: ",new Throwable());
|
||||
|
||||
_lock.lock();
|
||||
long idle = getIdleTimeout();
|
||||
try
|
||||
{
|
||||
while (_state == null)
|
||||
_complete.await();
|
||||
{
|
||||
if (idle>0)
|
||||
{
|
||||
// Wait a little bit longer than expected callback idle timeout
|
||||
if (!_complete.await(idle+idle/2,TimeUnit.MILLISECONDS))
|
||||
// The callback has not arrived in sufficient time.
|
||||
// We will synthesize a TimeoutException
|
||||
_state=new BlockerTimeoutException();
|
||||
}
|
||||
else
|
||||
_complete.await();
|
||||
}
|
||||
|
||||
if (_state == SUCCEEDED)
|
||||
return;
|
||||
|
@ -204,12 +235,7 @@ public class SharedBlockingCallback
|
|||
}
|
||||
catch (final InterruptedException e)
|
||||
{
|
||||
throw new InterruptedIOException()
|
||||
{
|
||||
{
|
||||
initCause(e);
|
||||
}
|
||||
};
|
||||
throw new InterruptedIOException();
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -232,17 +258,19 @@ public class SharedBlockingCallback
|
|||
if (_state == IDLE)
|
||||
throw new IllegalStateException("IDLE");
|
||||
if (_state == null)
|
||||
{
|
||||
LOG.warn("Blocker not complete {}",this);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug(new Throwable());
|
||||
}
|
||||
notComplete(this);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
_state = IDLE;
|
||||
// If the blocker timed itself out, remember the state
|
||||
if (_state instanceof BlockerTimeoutException)
|
||||
// and create a new Blocker
|
||||
_blocker=new Blocker();
|
||||
else
|
||||
// else reuse Blocker
|
||||
_state = IDLE;
|
||||
_idle.signalAll();
|
||||
_complete.signalAll();
|
||||
}
|
||||
|
@ -267,4 +295,8 @@ public class SharedBlockingCallback
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class BlockerTimeoutException extends TimeoutException
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -524,6 +524,7 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container,
|
|||
{
|
||||
if (_beans.remove(bean))
|
||||
{
|
||||
boolean wasManaged = bean.isManaged();
|
||||
|
||||
unmanage(bean);
|
||||
|
||||
|
@ -534,7 +535,7 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container,
|
|||
removeEventListener((Container.Listener)bean._bean);
|
||||
|
||||
// stop managed beans
|
||||
if (bean._managed==Managed.MANAGED && bean._bean instanceof LifeCycle)
|
||||
if (wasManaged && bean._bean instanceof LifeCycle)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -92,7 +92,7 @@ public class JarResource extends URLResource
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Returns true if the respresenetd resource exists.
|
||||
* Returns true if the represented resource exists.
|
||||
*/
|
||||
@Override
|
||||
public boolean exists()
|
||||
|
@ -118,7 +118,7 @@ public class JarResource extends URLResource
|
|||
{
|
||||
checkConnection();
|
||||
if (!_urlString.endsWith("!/"))
|
||||
return new FilterInputStream(super.getInputStream())
|
||||
return new FilterInputStream(getInputStream(false))
|
||||
{
|
||||
@Override
|
||||
public void close() throws IOException {this.in=IO.getClosedStream();}
|
||||
|
@ -129,6 +129,9 @@ public class JarResource extends URLResource
|
|||
return is;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public void copyTo(File directory)
|
||||
|
|
|
@ -197,13 +197,33 @@ public class URLResource extends Resource
|
|||
return _url.toExternalForm();
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Returns an input stream to the resource
|
||||
* Returns an input stream to the resource. The underlying
|
||||
* url connection will be nulled out to prevent re-use.
|
||||
*/
|
||||
@Override
|
||||
public synchronized InputStream getInputStream()
|
||||
throws java.io.IOException
|
||||
{
|
||||
return getInputStream (true); //backwards compatibility
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Returns an input stream to the resource, optionally nulling
|
||||
* out the underlying url connection. If the connection is not
|
||||
* nulled out, a subsequent call to getInputStream() may return
|
||||
* an existing and already in-use input stream - this depends on
|
||||
* the url protocol. Eg JarURLConnection does not reuse inputstreams.
|
||||
*
|
||||
* @param resetConnection if true the connection field is set to null
|
||||
*/
|
||||
protected synchronized InputStream getInputStream(boolean resetConnection)
|
||||
throws java.io.IOException
|
||||
{
|
||||
if (!checkConnection())
|
||||
throw new IOException( "Invalid resource");
|
||||
|
@ -220,7 +240,11 @@ public class URLResource extends Resource
|
|||
}
|
||||
finally
|
||||
{
|
||||
_connection=null;
|
||||
if (resetConnection)
|
||||
{
|
||||
_connection=null;
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Connection nulled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -479,7 +479,10 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo
|
|||
@Override
|
||||
public void dump(Appendable out, String indent) throws IOException
|
||||
{
|
||||
out.append(String.valueOf(thread.getId())).append(' ').append(thread.getName()).append(' ').append(thread.getState().toString()).append(idle ? " IDLE" : "").append('\n');
|
||||
out.append(String.valueOf(thread.getId())).append(' ').append(thread.getName()).append(' ').append(thread.getState().toString()).append(idle ? " IDLE" : "");
|
||||
if (thread.getPriority()!=Thread.NORM_PRIORITY)
|
||||
out.append(" prio="+thread.getPriority());
|
||||
out.append('\n');
|
||||
if (!idle)
|
||||
ContainerLifeCycle.dump(out, indent, Arrays.asList(trace));
|
||||
}
|
||||
|
@ -493,7 +496,8 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo
|
|||
}
|
||||
else
|
||||
{
|
||||
dump.add(thread.getId() + " " + thread.getName() + " " + thread.getState() + " @ " + (trace.length > 0 ? trace[0] : "???") + (idle ? " IDLE" : ""));
|
||||
int p=thread.getPriority();
|
||||
dump.add(thread.getId() + " " + thread.getName() + " " + thread.getState() + " @ " + (trace.length > 0 ? trace[0] : "???") + (idle ? " IDLE" : "")+ (p==Thread.NORM_PRIORITY?"":(" prio="+p)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,302 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 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.util;
|
||||
|
||||
import java.lang.management.CompilationMXBean;
|
||||
import java.lang.management.GarbageCollectorMXBean;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.MemoryMXBean;
|
||||
import java.lang.management.MemoryPoolMXBean;
|
||||
import java.lang.management.MemoryUsage;
|
||||
import java.lang.management.OperatingSystemMXBean;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class BenchmarkHelper implements Runnable
|
||||
{
|
||||
private final OperatingSystemMXBean operatingSystem;
|
||||
private final CompilationMXBean jitCompiler;
|
||||
private final MemoryMXBean heapMemory;
|
||||
private final AtomicInteger starts = new AtomicInteger();
|
||||
private final MemoryPoolMXBean youngMemoryPool;
|
||||
private final MemoryPoolMXBean survivorMemoryPool;
|
||||
private final MemoryPoolMXBean oldMemoryPool;
|
||||
private final boolean hasMemoryPools;
|
||||
private final GarbageCollectorMXBean youngCollector;
|
||||
private final GarbageCollectorMXBean oldCollector;
|
||||
private final boolean hasCollectors;
|
||||
private volatile ScheduledFuture<?> memoryPoller;
|
||||
private volatile ScheduledExecutorService scheduler;
|
||||
private volatile boolean polling;
|
||||
private volatile long lastYoungUsed;
|
||||
private volatile long startYoungCollections;
|
||||
private volatile long startYoungCollectionsTime;
|
||||
private volatile long totalYoungUsed;
|
||||
private volatile long lastSurvivorUsed;
|
||||
private volatile long totalSurvivorUsed;
|
||||
private volatile long lastOldUsed;
|
||||
private volatile long startOldCollections;
|
||||
private volatile long startOldCollectionsTime;
|
||||
private volatile long totalOldUsed;
|
||||
private volatile long startTime;
|
||||
private volatile long startProcessCPUTime;
|
||||
private volatile long startJITCTime;
|
||||
|
||||
public BenchmarkHelper()
|
||||
{
|
||||
this.operatingSystem = ManagementFactory.getOperatingSystemMXBean();
|
||||
this.jitCompiler = ManagementFactory.getCompilationMXBean();
|
||||
this.heapMemory = ManagementFactory.getMemoryMXBean();
|
||||
|
||||
List<MemoryPoolMXBean> memoryPools = ManagementFactory.getMemoryPoolMXBeans();
|
||||
MemoryPoolMXBean ymp=null;
|
||||
MemoryPoolMXBean smp=null;
|
||||
MemoryPoolMXBean omp=null;
|
||||
|
||||
for (MemoryPoolMXBean memoryPool : memoryPools)
|
||||
{
|
||||
if ("PS Eden Space".equals(memoryPool.getName()) ||
|
||||
"Par Eden Space".equals(memoryPool.getName()) ||
|
||||
"G1 Eden".equals(memoryPool.getName()))
|
||||
ymp = memoryPool;
|
||||
else if ("PS Survivor Space".equals(memoryPool.getName()) ||
|
||||
"Par Survivor Space".equals(memoryPool.getName()) ||
|
||||
"G1 Survivor".equals(memoryPool.getName()))
|
||||
smp = memoryPool;
|
||||
else if ("PS Old Gen".equals(memoryPool.getName()) ||
|
||||
"CMS Old Gen".equals(memoryPool.getName()) ||
|
||||
"G1 Old Gen".equals(memoryPool.getName()))
|
||||
omp = memoryPool;
|
||||
}
|
||||
youngMemoryPool=ymp;
|
||||
survivorMemoryPool=smp;
|
||||
oldMemoryPool=omp;
|
||||
|
||||
hasMemoryPools = youngMemoryPool != null && survivorMemoryPool != null && oldMemoryPool != null;
|
||||
|
||||
List<GarbageCollectorMXBean> garbageCollectors = ManagementFactory.getGarbageCollectorMXBeans();
|
||||
GarbageCollectorMXBean yc=null;
|
||||
GarbageCollectorMXBean oc=null;
|
||||
for (GarbageCollectorMXBean garbageCollector : garbageCollectors)
|
||||
{
|
||||
if ("PS Scavenge".equals(garbageCollector.getName()) ||
|
||||
"ParNew".equals(garbageCollector.getName()) ||
|
||||
"G1 Young Generation".equals(garbageCollector.getName()))
|
||||
yc = garbageCollector;
|
||||
else if ("PS MarkSweep".equals(garbageCollector.getName()) ||
|
||||
"ConcurrentMarkSweep".equals(garbageCollector.getName()) ||
|
||||
"G1 Old Generation".equals(garbageCollector.getName()))
|
||||
oc = garbageCollector;
|
||||
}
|
||||
youngCollector=yc;
|
||||
oldCollector=oc;
|
||||
hasCollectors = youngCollector != null && oldCollector != null;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
if (!hasMemoryPools)
|
||||
return;
|
||||
|
||||
long young = youngMemoryPool.getUsage().getUsed();
|
||||
long survivor = survivorMemoryPool.getUsage().getUsed();
|
||||
long old = oldMemoryPool.getUsage().getUsed();
|
||||
|
||||
if (!polling)
|
||||
{
|
||||
polling = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lastYoungUsed <= young)
|
||||
{
|
||||
totalYoungUsed += young - lastYoungUsed;
|
||||
}
|
||||
|
||||
if (lastSurvivorUsed <= survivor)
|
||||
{
|
||||
totalSurvivorUsed += survivor - lastSurvivorUsed;
|
||||
}
|
||||
|
||||
if (lastOldUsed <= old)
|
||||
{
|
||||
totalOldUsed += old - lastOldUsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
// May need something more here, like "how much was collected"
|
||||
}
|
||||
}
|
||||
lastYoungUsed = young;
|
||||
lastSurvivorUsed = survivor;
|
||||
lastOldUsed = old;
|
||||
}
|
||||
|
||||
public boolean startStatistics()
|
||||
{
|
||||
// Support for multiple nodes requires to ignore start requests after the first
|
||||
// but also requires that requests after the first wait until the initialization
|
||||
// is completed (otherwise node #2 may start the run while the server is GC'ing)
|
||||
synchronized (this)
|
||||
{
|
||||
if (starts.incrementAndGet() > 1)
|
||||
return false;
|
||||
|
||||
System.gc();
|
||||
System.err.println("\n========================================");
|
||||
System.err.println("Statistics Started at " + new Date());
|
||||
System.err.println("Operative System: " + operatingSystem.getName() + " " + operatingSystem.getVersion() + " " + operatingSystem.getArch());
|
||||
System.err.println("JVM : " + System.getProperty("java.vm.vendor") + " " + System.getProperty("java.vm.name") + " runtime " + System.getProperty("java.vm.version") + " " + System.getProperty("java.runtime.version"));
|
||||
System.err.println("Processors: " + operatingSystem.getAvailableProcessors());
|
||||
if (operatingSystem instanceof com.sun.management.OperatingSystemMXBean)
|
||||
{
|
||||
com.sun.management.OperatingSystemMXBean os = (com.sun.management.OperatingSystemMXBean)operatingSystem;
|
||||
long totalMemory = os.getTotalPhysicalMemorySize();
|
||||
long freeMemory = os.getFreePhysicalMemorySize();
|
||||
System.err.println("System Memory: " + percent(totalMemory - freeMemory, totalMemory) + "% used of " + gibiBytes(totalMemory) + " GiB");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.err.println("System Memory: N/A");
|
||||
}
|
||||
|
||||
MemoryUsage heapMemoryUsage = heapMemory.getHeapMemoryUsage();
|
||||
System.err.println("Used Heap Size: " + mebiBytes(heapMemoryUsage.getUsed()) + " MiB");
|
||||
System.err.println("Max Heap Size: " + mebiBytes(heapMemoryUsage.getMax()) + " MiB");
|
||||
if (hasMemoryPools)
|
||||
{
|
||||
long youngGenerationHeap = heapMemoryUsage.getMax() - oldMemoryPool.getUsage().getMax();
|
||||
System.err.println("Young Generation Heap Size: " + mebiBytes(youngGenerationHeap) + " MiB");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.err.println("Young Generation Heap Size: N/A");
|
||||
}
|
||||
System.err.println("- - - - - - - - - - - - - - - - - - - - ");
|
||||
|
||||
scheduler = Executors.newSingleThreadScheduledExecutor();
|
||||
polling = false;
|
||||
memoryPoller = scheduler.scheduleWithFixedDelay(this, 0, 250, TimeUnit.MILLISECONDS);
|
||||
|
||||
lastYoungUsed = 0;
|
||||
if (hasCollectors)
|
||||
{
|
||||
startYoungCollections = youngCollector.getCollectionCount();
|
||||
startYoungCollectionsTime = youngCollector.getCollectionTime();
|
||||
}
|
||||
totalYoungUsed = 0;
|
||||
lastSurvivorUsed = 0;
|
||||
totalSurvivorUsed = 0;
|
||||
lastOldUsed = 0;
|
||||
if (hasCollectors)
|
||||
{
|
||||
startOldCollections = oldCollector.getCollectionCount();
|
||||
startOldCollectionsTime = oldCollector.getCollectionTime();
|
||||
}
|
||||
totalOldUsed = 0;
|
||||
|
||||
startTime = System.nanoTime();
|
||||
if (operatingSystem instanceof com.sun.management.OperatingSystemMXBean)
|
||||
{
|
||||
com.sun.management.OperatingSystemMXBean os = (com.sun.management.OperatingSystemMXBean)operatingSystem;
|
||||
startProcessCPUTime = os.getProcessCpuTime();
|
||||
}
|
||||
startJITCTime = jitCompiler.getTotalCompilationTime();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean stopStatistics()
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (starts.decrementAndGet() > 0)
|
||||
return false;
|
||||
|
||||
memoryPoller.cancel(false);
|
||||
scheduler.shutdown();
|
||||
|
||||
System.err.println("- - - - - - - - - - - - - - - - - - - - ");
|
||||
System.err.println("Statistics Ended at " + new Date());
|
||||
long elapsedTime = System.nanoTime() - startTime;
|
||||
System.err.println("Elapsed time: " + TimeUnit.NANOSECONDS.toMillis(elapsedTime) + " ms");
|
||||
long elapsedJITCTime = jitCompiler.getTotalCompilationTime() - startJITCTime;
|
||||
System.err.println("\tTime in JIT compilation: " + elapsedJITCTime + " ms");
|
||||
if (hasCollectors)
|
||||
{
|
||||
long elapsedYoungCollectionsTime = youngCollector.getCollectionTime() - startYoungCollectionsTime;
|
||||
long youngCollections = youngCollector.getCollectionCount() - startYoungCollections;
|
||||
System.err.println("\tTime in Young Generation GC: " + elapsedYoungCollectionsTime + " ms (" + youngCollections + " collections)");
|
||||
long elapsedOldCollectionsTime = oldCollector.getCollectionTime() - startOldCollectionsTime;
|
||||
long oldCollections = oldCollector.getCollectionCount() - startOldCollections;
|
||||
System.err.println("\tTime in Old Generation GC: " + elapsedOldCollectionsTime + " ms (" + oldCollections + " collections)");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.err.println("\tTime in GC: N/A");
|
||||
}
|
||||
|
||||
if (hasMemoryPools)
|
||||
{
|
||||
System.err.println("Garbage Generated in Young Generation: " + mebiBytes(totalYoungUsed) + " MiB");
|
||||
System.err.println("Garbage Generated in Survivor Generation: " + mebiBytes(totalSurvivorUsed) + " MiB");
|
||||
System.err.println("Garbage Generated in Old Generation: " + mebiBytes(totalOldUsed) + " MiB");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.err.println("Garbage Generated: N/A");
|
||||
}
|
||||
|
||||
if (operatingSystem instanceof com.sun.management.OperatingSystemMXBean)
|
||||
{
|
||||
com.sun.management.OperatingSystemMXBean os = (com.sun.management.OperatingSystemMXBean)operatingSystem;
|
||||
long elapsedProcessCPUTime = os.getProcessCpuTime() - startProcessCPUTime;
|
||||
System.err.println("Average CPU Load: " + ((float)elapsedProcessCPUTime * 100 / elapsedTime) + "/" + (100 * operatingSystem.getAvailableProcessors()));
|
||||
}
|
||||
else
|
||||
{
|
||||
System.err.println("Average CPU Load: N/A");
|
||||
}
|
||||
|
||||
System.err.println("----------------------------------------\n");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public float percent(long dividend, long divisor)
|
||||
{
|
||||
return (float)dividend * 100 / divisor;
|
||||
}
|
||||
|
||||
public float mebiBytes(long bytes)
|
||||
{
|
||||
return (float)bytes / 1024 / 1024;
|
||||
}
|
||||
|
||||
public float gibiBytes(long bytes)
|
||||
{
|
||||
return (float)bytes / 1024 / 1024 / 1024;
|
||||
}
|
||||
}
|
|
@ -18,9 +18,17 @@
|
|||
|
||||
package org.eclipse.jetty.util;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.eclipse.jetty.util.SharedBlockingCallback.Blocker;
|
||||
import org.hamcrest.Matchers;
|
||||
|
@ -29,7 +37,23 @@ import org.junit.Test;
|
|||
|
||||
public class SharedBlockingCallbackTest
|
||||
{
|
||||
final SharedBlockingCallback sbcb= new SharedBlockingCallback();
|
||||
final AtomicInteger notComplete = new AtomicInteger();
|
||||
final SharedBlockingCallback sbcb= new SharedBlockingCallback()
|
||||
{
|
||||
@Override
|
||||
protected long getIdleTimeout()
|
||||
{
|
||||
return 150;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notComplete(Blocker blocker)
|
||||
{
|
||||
super.notComplete(blocker);
|
||||
notComplete.incrementAndGet();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public SharedBlockingCallbackTest()
|
||||
{
|
||||
|
@ -46,7 +70,8 @@ public class SharedBlockingCallbackTest
|
|||
start=System.currentTimeMillis();
|
||||
blocker.block();
|
||||
}
|
||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.lessThan(500L));
|
||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.lessThan(500L));
|
||||
Assert.assertEquals(0,notComplete.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -74,6 +99,7 @@ public class SharedBlockingCallbackTest
|
|||
}
|
||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.greaterThan(10L));
|
||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.lessThan(1000L));
|
||||
Assert.assertEquals(0,notComplete.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -95,7 +121,8 @@ public class SharedBlockingCallbackTest
|
|||
start=System.currentTimeMillis();
|
||||
Assert.assertEquals(ex,ee.getCause());
|
||||
}
|
||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.lessThan(100L));
|
||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.lessThan(100L));
|
||||
Assert.assertEquals(0,notComplete.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -133,6 +160,7 @@ public class SharedBlockingCallbackTest
|
|||
}
|
||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.greaterThan(10L));
|
||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.lessThan(1000L));
|
||||
Assert.assertEquals(0,notComplete.get());
|
||||
}
|
||||
|
||||
|
||||
|
@ -174,6 +202,58 @@ public class SharedBlockingCallbackTest
|
|||
blocker.succeeded();
|
||||
blocker.block();
|
||||
};
|
||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.lessThan(600L));
|
||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.lessThan(600L));
|
||||
Assert.assertEquals(0,notComplete.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBlockerClose() throws Exception
|
||||
{
|
||||
try (Blocker blocker=sbcb.acquire())
|
||||
{
|
||||
SharedBlockingCallback.LOG.info("Blocker not complete "+blocker+" warning is expected...");
|
||||
}
|
||||
|
||||
Assert.assertEquals(1,notComplete.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBlockerTimeout() throws Exception
|
||||
{
|
||||
Blocker b0=null;
|
||||
try
|
||||
{
|
||||
try (Blocker blocker=sbcb.acquire())
|
||||
{
|
||||
b0=blocker;
|
||||
Thread.sleep(400);
|
||||
blocker.block();
|
||||
}
|
||||
fail();
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
Throwable cause = e.getCause();
|
||||
assertThat(cause,instanceOf(TimeoutException.class));
|
||||
}
|
||||
|
||||
Assert.assertEquals(0,notComplete.get());
|
||||
|
||||
|
||||
try (Blocker blocker=sbcb.acquire())
|
||||
{
|
||||
assertThat(blocker,not(equalTo(b0)));
|
||||
try
|
||||
{
|
||||
b0.succeeded();
|
||||
fail();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
assertThat(e,instanceOf(IllegalStateException.class));
|
||||
assertThat(e.getCause(),instanceOf(TimeoutException.class));
|
||||
}
|
||||
blocker.succeeded();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,10 +123,14 @@ public class ContainerLifeCycleTest
|
|||
Assert.assertEquals(1,destroyed.get());
|
||||
|
||||
a0.removeBean(a1);
|
||||
Assert.assertEquals(3,started.get());
|
||||
Assert.assertEquals(3,stopped.get());
|
||||
Assert.assertEquals(1,destroyed.get());
|
||||
|
||||
a0.stop();
|
||||
a0.destroy();
|
||||
Assert.assertEquals(3,started.get());
|
||||
Assert.assertEquals(2,stopped.get());
|
||||
Assert.assertEquals(3,stopped.get());
|
||||
Assert.assertEquals(1,destroyed.get());
|
||||
|
||||
a1.stop();
|
||||
|
|
|
@ -26,8 +26,8 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.eclipse.jetty.toolchain.test.BenchmarkHelper;
|
||||
import org.eclipse.jetty.toolchain.test.annotation.Slow;
|
||||
import org.eclipse.jetty.util.BenchmarkHelper;
|
||||
import org.eclipse.jetty.util.statistic.SampleStatistic;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.After;
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.webapp;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.xml.XmlParser;
|
||||
|
||||
|
@ -35,19 +33,9 @@ public abstract class Descriptor
|
|||
_xml = xml;
|
||||
}
|
||||
|
||||
public abstract XmlParser newParser()
|
||||
throws ClassNotFoundException;
|
||||
|
||||
public abstract void ensureParser()
|
||||
throws ClassNotFoundException;
|
||||
|
||||
protected void redirect(XmlParser parser, String resource, URL source)
|
||||
{
|
||||
if (source != null)
|
||||
parser.redirectEntity(resource, source);
|
||||
}
|
||||
|
||||
|
||||
public void setValidating (boolean validating)
|
||||
{
|
||||
_validating = validating;
|
||||
|
|
|
@ -71,6 +71,17 @@ public class MetaInfConfiguration extends AbstractConfiguration
|
|||
useContainerCache = attr.booleanValue();
|
||||
|
||||
if (LOG.isDebugEnabled()) LOG.debug("{} = {}", USE_CONTAINER_METAINF_CACHE, useContainerCache);
|
||||
|
||||
//pre-emptively create empty lists for tlds, fragments and resources as context attributes
|
||||
//this signals that this class has been called. This differentiates the case where this class
|
||||
//has been called but finds no META-INF data from the case where this class was never called
|
||||
if (context.getAttribute(METAINF_TLDS) == null)
|
||||
context.setAttribute(METAINF_TLDS, new HashSet<URL>());
|
||||
if (context.getAttribute(METAINF_RESOURCES) == null)
|
||||
context.setAttribute(METAINF_RESOURCES, new HashSet<Resource>());
|
||||
if (context.getAttribute(METAINF_FRAGMENTS) == null)
|
||||
context.setAttribute(METAINF_FRAGMENTS, new HashMap<Resource, Resource>());
|
||||
|
||||
scanJars(context, context.getMetaData().getContainerResources(), useContainerCache);
|
||||
scanJars(context, context.getMetaData().getWebInfJars(), false);
|
||||
}
|
||||
|
|
|
@ -54,20 +54,23 @@ public class WebDescriptor extends Descriptor
|
|||
protected List<String> _ordering = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
public void ensureParser()
|
||||
throws ClassNotFoundException
|
||||
public void ensureParser() throws ClassNotFoundException
|
||||
{
|
||||
if (_parserSingleton == null)
|
||||
synchronized (WebDescriptor.class)
|
||||
{
|
||||
_parserSingleton = newParser();
|
||||
if (_parserSingleton == null)
|
||||
_parserSingleton = newParser(isValidating());
|
||||
}
|
||||
_parser = _parserSingleton;
|
||||
|
||||
if (_parserSingleton.isValidating()==isValidating())
|
||||
_parser = _parserSingleton;
|
||||
else
|
||||
_parser = newParser(isValidating());
|
||||
}
|
||||
|
||||
public XmlParser newParser()
|
||||
throws ClassNotFoundException
|
||||
public static XmlParser newParser(boolean validating) throws ClassNotFoundException
|
||||
{
|
||||
XmlParser xmlParser=new XmlParser()
|
||||
XmlParser xmlParser=new XmlParser(validating)
|
||||
{
|
||||
boolean mapped=false;
|
||||
|
||||
|
@ -136,56 +139,56 @@ public class WebDescriptor extends Descriptor
|
|||
if (jsp22xsd == null) jsp22xsd = Loader.getResource(Servlet.class, "javax/servlet/jsp/resources/jsp_2_2.xsd");
|
||||
if (jsp23xsd == null) jsp23xsd = Loader.getResource(Servlet.class, "javax/servlet/jsp/resources/jsp_2_3.xsd");
|
||||
}
|
||||
|
||||
redirect(this,"web-app_2_2.dtd",dtd22);
|
||||
redirect(this,"-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN",dtd22);
|
||||
redirect(this,"web.dtd",dtd23);
|
||||
redirect(this,"web-app_2_3.dtd",dtd23);
|
||||
redirect(this,"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN",dtd23);
|
||||
redirect(this,"XMLSchema.dtd",schemadtd);
|
||||
redirect(this,"http://www.w3.org/2001/XMLSchema.dtd",schemadtd);
|
||||
redirect(this,"-//W3C//DTD XMLSCHEMA 200102//EN",schemadtd);
|
||||
redirect(this,"jsp_2_0.xsd",jsp20xsd);
|
||||
redirect(this,"http://java.sun.com/xml/ns/j2ee/jsp_2_0.xsd",jsp20xsd);
|
||||
redirect(this,"http://java.sun.com/xml/ns/javaee/jsp_2_1.xsd",jsp21xsd);
|
||||
redirect(this,"jsp_2_2.xsd",jsp22xsd);
|
||||
redirect(this,"http://java.sun.com/xml/ns/javaee/jsp_2_2.xsd",jsp22xsd);
|
||||
redirect(this,"jsp_2_3.xsd",jsp23xsd);
|
||||
redirect(this,"http://xmlns.jcp.org/xml/ns/javaee/jsp_2_3.xsd",jsp23xsd);
|
||||
redirect(this,"j2ee_1_4.xsd",j2ee14xsd);
|
||||
redirect(this,"http://java.sun.com/xml/ns/j2ee/j2ee_1_4.xsd",j2ee14xsd);
|
||||
redirect(this, "http://java.sun.com/xml/ns/javaee/javaee_5.xsd",javaee5);
|
||||
redirect(this, "http://java.sun.com/xml/ns/javaee/javaee_6.xsd",javaee6);
|
||||
redirect(this, "http://xmlns.jcp.org/xml/ns/javaee/javaee_7.xsd",javaee7);
|
||||
redirect(this,"web-app_2_4.xsd",webapp24xsd);
|
||||
redirect(this,"http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd",webapp24xsd);
|
||||
redirect(this,"web-app_2_5.xsd",webapp25xsd);
|
||||
redirect(this,"http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd",webapp25xsd);
|
||||
redirect(this,"web-app_3_0.xsd",webapp30xsd);
|
||||
redirect(this,"http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd",webapp30xsd);
|
||||
redirect(this,"web-common_3_0.xsd",webcommon30xsd);
|
||||
redirect(this,"http://java.sun.com/xml/ns/javaee/web-common_3_0.xsd",webcommon30xsd);
|
||||
redirect(this,"web-fragment_3_0.xsd",webfragment30xsd);
|
||||
redirect(this,"http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd",webfragment30xsd);
|
||||
redirect(this,"web-app_3_1.xsd",webapp31xsd);
|
||||
redirect(this,"http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd",webapp31xsd);
|
||||
|
||||
redirect(this,"web-common_3_1.xsd",webcommon30xsd);
|
||||
redirect(this,"http://xmlns.jcp.org/xml/ns/javaee/web-common_3_1.xsd",webcommon31xsd);
|
||||
redirect(this,"web-fragment_3_1.xsd",webfragment30xsd);
|
||||
redirect(this,"http://xmlns.jcp.org/xml/ns/javaee/web-fragment_3_1.xsd",webfragment31xsd);
|
||||
redirect(this,"xml.xsd",xmlxsd);
|
||||
redirect(this,"http://www.w3.org/2001/xml.xsd",xmlxsd);
|
||||
redirect(this,"datatypes.dtd",datatypesdtd);
|
||||
redirect(this,"http://www.w3.org/2001/datatypes.dtd",datatypesdtd);
|
||||
redirect(this,"j2ee_web_services_client_1_1.xsd",webservice11xsd);
|
||||
redirect(this,"http://www.ibm.com/webservices/xsd/j2ee_web_services_client_1_1.xsd",webservice11xsd);
|
||||
redirect(this,"javaee_web_services_client_1_2.xsd",webservice12xsd);
|
||||
redirect(this,"http://www.ibm.com/webservices/xsd/javaee_web_services_client_1_2.xsd",webservice12xsd);
|
||||
redirect(this,"javaee_web_services_client_1_3.xsd",webservice13xsd);
|
||||
redirect(this,"http://java.sun.com/xml/ns/javaee/javaee_web_services_client_1_3.xsd",webservice13xsd);
|
||||
redirect(this,"javaee_web_services_client_1_4.xsd",webservice14xsd);
|
||||
redirect(this,"http://xmlns.jcp.org/xml/ns/javaee/javaee_web_services_client_1_4.xsd",webservice14xsd);
|
||||
redirectEntity("web-app_2_2.dtd",dtd22);
|
||||
redirectEntity("-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN",dtd22);
|
||||
redirectEntity("web.dtd",dtd23);
|
||||
redirectEntity("web-app_2_3.dtd",dtd23);
|
||||
redirectEntity("-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN",dtd23);
|
||||
redirectEntity("XMLSchema.dtd",schemadtd);
|
||||
redirectEntity("http://www.w3.org/2001/XMLSchema.dtd",schemadtd);
|
||||
redirectEntity("-//W3C//DTD XMLSCHEMA 200102//EN",schemadtd);
|
||||
redirectEntity("jsp_2_0.xsd",jsp20xsd);
|
||||
redirectEntity("http://java.sun.com/xml/ns/j2ee/jsp_2_0.xsd",jsp20xsd);
|
||||
redirectEntity("http://java.sun.com/xml/ns/javaee/jsp_2_1.xsd",jsp21xsd);
|
||||
redirectEntity("jsp_2_2.xsd",jsp22xsd);
|
||||
redirectEntity("http://java.sun.com/xml/ns/javaee/jsp_2_2.xsd",jsp22xsd);
|
||||
redirectEntity("jsp_2_3.xsd",jsp23xsd);
|
||||
redirectEntity("http://xmlns.jcp.org/xml/ns/javaee/jsp_2_3.xsd",jsp23xsd);
|
||||
redirectEntity("j2ee_1_4.xsd",j2ee14xsd);
|
||||
redirectEntity("http://java.sun.com/xml/ns/j2ee/j2ee_1_4.xsd",j2ee14xsd);
|
||||
redirectEntity( "http://java.sun.com/xml/ns/javaee/javaee_5.xsd",javaee5);
|
||||
redirectEntity( "http://java.sun.com/xml/ns/javaee/javaee_6.xsd",javaee6);
|
||||
redirectEntity( "http://xmlns.jcp.org/xml/ns/javaee/javaee_7.xsd",javaee7);
|
||||
redirectEntity("web-app_2_4.xsd",webapp24xsd);
|
||||
redirectEntity("http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd",webapp24xsd);
|
||||
redirectEntity("web-app_2_5.xsd",webapp25xsd);
|
||||
redirectEntity("http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd",webapp25xsd);
|
||||
redirectEntity("web-app_3_0.xsd",webapp30xsd);
|
||||
redirectEntity("http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd",webapp30xsd);
|
||||
redirectEntity("web-common_3_0.xsd",webcommon30xsd);
|
||||
redirectEntity("http://java.sun.com/xml/ns/javaee/web-common_3_0.xsd",webcommon30xsd);
|
||||
redirectEntity("web-fragment_3_0.xsd",webfragment30xsd);
|
||||
redirectEntity("http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd",webfragment30xsd);
|
||||
redirectEntity("web-app_3_1.xsd",webapp31xsd);
|
||||
redirectEntity("http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd",webapp31xsd);
|
||||
|
||||
redirectEntity("web-common_3_1.xsd",webcommon30xsd);
|
||||
redirectEntity("http://xmlns.jcp.org/xml/ns/javaee/web-common_3_1.xsd",webcommon31xsd);
|
||||
redirectEntity("web-fragment_3_1.xsd",webfragment30xsd);
|
||||
redirectEntity("http://xmlns.jcp.org/xml/ns/javaee/web-fragment_3_1.xsd",webfragment31xsd);
|
||||
redirectEntity("xml.xsd",xmlxsd);
|
||||
redirectEntity("http://www.w3.org/2001/xml.xsd",xmlxsd);
|
||||
redirectEntity("datatypes.dtd",datatypesdtd);
|
||||
redirectEntity("http://www.w3.org/2001/datatypes.dtd",datatypesdtd);
|
||||
redirectEntity("j2ee_web_services_client_1_1.xsd",webservice11xsd);
|
||||
redirectEntity("http://www.ibm.com/webservices/xsd/j2ee_web_services_client_1_1.xsd",webservice11xsd);
|
||||
redirectEntity("javaee_web_services_client_1_2.xsd",webservice12xsd);
|
||||
redirectEntity("http://www.ibm.com/webservices/xsd/javaee_web_services_client_1_2.xsd",webservice12xsd);
|
||||
redirectEntity("javaee_web_services_client_1_3.xsd",webservice13xsd);
|
||||
redirectEntity("http://java.sun.com/xml/ns/javaee/javaee_web_services_client_1_3.xsd",webservice13xsd);
|
||||
redirectEntity("javaee_web_services_client_1_4.xsd",webservice14xsd);
|
||||
redirectEntity("http://xmlns.jcp.org/xml/ns/javaee/javaee_web_services_client_1_4.xsd",webservice14xsd);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -248,7 +251,7 @@ public class WebDescriptor extends Descriptor
|
|||
}
|
||||
}
|
||||
|
||||
if (_majorVersion < 2 && _minorVersion < 5)
|
||||
if (_majorVersion <= 2 && _minorVersion < 5)
|
||||
_metaDataComplete = MetaDataComplete.True; // does not apply before 2.5
|
||||
else
|
||||
{
|
||||
|
@ -316,7 +319,11 @@ public class WebDescriptor extends Descriptor
|
|||
{
|
||||
_validating = validating;
|
||||
}
|
||||
|
||||
|
||||
public boolean isValidating ()
|
||||
{
|
||||
return _validating;
|
||||
}
|
||||
|
||||
public boolean isOrdered()
|
||||
{
|
||||
|
|
|
@ -175,7 +175,7 @@ public class WebInfConfiguration extends AbstractConfiguration
|
|||
// Look for extra resource
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<Resource> resources = (Set<Resource>)context.getAttribute(RESOURCE_DIRS);
|
||||
if (resources!=null)
|
||||
if (resources!=null && !resources.isEmpty())
|
||||
{
|
||||
Resource[] collection=new Resource[resources.size()+1];
|
||||
int i=0;
|
||||
|
|
|
@ -74,8 +74,14 @@ public class ConnectionManager extends ContainerLifeCycle
|
|||
|
||||
InetSocketAddress address = toSocketAddress(wsUri);
|
||||
|
||||
channel.connect(address);
|
||||
getSelector().connect(channel,this);
|
||||
if (channel.connect(address))
|
||||
{
|
||||
getSelector().accept(channel, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
getSelector().connect(channel, this);
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.eclipse.jetty.websocket.common;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.SharedBlockingCallback;
|
||||
import org.eclipse.jetty.websocket.api.WriteCallback;
|
||||
|
||||
|
@ -31,26 +32,55 @@ public class BlockingWriteCallback extends SharedBlockingCallback
|
|||
{
|
||||
public BlockingWriteCallback()
|
||||
{
|
||||
super(new WriteBlocker());
|
||||
}
|
||||
|
||||
public WriteBlocker acquireWriteBlocker() throws IOException
|
||||
{
|
||||
return (WriteBlocker)acquire();
|
||||
return new WriteBlocker(acquire());
|
||||
}
|
||||
|
||||
public static class WriteBlocker extends Blocker implements WriteCallback
|
||||
public static class WriteBlocker implements WriteCallback, Callback, AutoCloseable
|
||||
{
|
||||
Blocker blocker;
|
||||
|
||||
WriteBlocker(Blocker blocker)
|
||||
{
|
||||
this.blocker=blocker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeFailed(Throwable x)
|
||||
{
|
||||
failed(x);
|
||||
blocker.failed(x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSuccess()
|
||||
{
|
||||
succeeded();
|
||||
blocker.succeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
{
|
||||
blocker.succeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable x)
|
||||
{
|
||||
blocker.failed(x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException
|
||||
{
|
||||
blocker.close();
|
||||
}
|
||||
|
||||
public void block() throws IOException
|
||||
{
|
||||
blocker.block();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,6 +132,12 @@ public class XmlParser
|
|||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean isValidating()
|
||||
{
|
||||
return _parser.isValidating();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param name
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -540,7 +540,7 @@
|
|||
<dependency>
|
||||
<groupId>org.mortbay.jasper</groupId>
|
||||
<artifactId>apache-jsp</artifactId>
|
||||
<version>8.0.9.M1</version>
|
||||
<version>8.0.9.M3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
|
@ -47,5 +47,6 @@
|
|||
<module>test-continuation</module>
|
||||
<module>test-loginservice</module>
|
||||
<module>test-integration</module>
|
||||
<module>test-quickstart</module>
|
||||
</modules>
|
||||
</project>
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.eclipse.jetty.examples</groupId>
|
||||
<artifactId>examples-parent</artifactId>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
<artifactId>tests-parent</artifactId>
|
||||
<version>9.2.3-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>example-jetty-quickstart</artifactId>
|
||||
<name>Example :: Jetty Quick Start</name>
|
||||
<description>Jetty Quick Start Example</description>
|
||||
<artifactId>test-quickstart</artifactId>
|
||||
<name>Test :: Jetty Quick Start</name>
|
||||
<description>Jetty Quick Start Test</description>
|
||||
<url>http://www.eclipse.org/jetty</url>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-quickstart</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-webapp</artifactId>
|
||||
|
@ -36,71 +41,65 @@
|
|||
<groupId>javax.transaction</groupId>
|
||||
<artifactId>javax.transaction-api</artifactId>
|
||||
<version>1.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
<artifactId>test-mock-resources</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.orbit</groupId>
|
||||
<artifactId>javax.mail.glassfish</artifactId>
|
||||
<version>1.4.1.v201005082020</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlets</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
<artifactId>test-jndi-webapp</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>war</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
<artifactId>test-spec-webapp</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>war</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>test-jetty-webapp</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>war</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>javax-websocket-server-impl</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>websocket-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>apache-jsp</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>apache-jstl</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-test-helper</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
|
@ -43,7 +43,7 @@ public class PreconfigureJNDIWar
|
|||
|
||||
LOG.info("Preconfigured in {}ms",TimeUnit.NANOSECONDS.toMillis(System.nanoTime()-__start));
|
||||
|
||||
IO.copy(new FileInputStream("target/test-jndi-preconfigured/WEB-INF/quickstart-web.xml"),System.out);
|
||||
// IO.copy(new FileInputStream("target/test-jndi-preconfigured/WEB-INF/quickstart-web.xml"),System.out);
|
||||
}
|
||||
|
||||
}
|
|
@ -52,7 +52,7 @@ public class PreconfigureSpecWar
|
|||
|
||||
LOG.info("Preconfigured in {}ms",TimeUnit.NANOSECONDS.toMillis(System.nanoTime()-__start));
|
||||
|
||||
IO.copy(new FileInputStream("target/test-spec-preconfigured/WEB-INF/quickstart-web.xml"),System.out);
|
||||
// IO.copy(new FileInputStream("target/test-spec-preconfigured/WEB-INF/quickstart-web.xml"),System.out);
|
||||
}
|
||||
|
||||
}
|
|
@ -34,7 +34,6 @@ import org.eclipse.jetty.util.resource.Resource;
|
|||
*/
|
||||
public class PreconfigureStandardTestWar
|
||||
{
|
||||
|
||||
private static final long __start=System.nanoTime();
|
||||
private static final Logger LOG = Log.getLogger(Server.class);
|
||||
|
||||
|
@ -57,6 +56,6 @@ public class PreconfigureStandardTestWar
|
|||
|
||||
LOG.info("Preconfigured in {}ms",TimeUnit.NANOSECONDS.toMillis(System.nanoTime()-__start));
|
||||
|
||||
IO.copy(new FileInputStream("target/test-standard-preconfigured/WEB-INF/quickstart-web.xml"),System.out);
|
||||
// IO.copy(new FileInputStream("target/test-standard-preconfigured/WEB-INF/quickstart-web.xml"),System.out);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,179 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 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.quickstart;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import org.eclipse.jetty.server.NetworkConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.webapp.WebDescriptor;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
import org.eclipse.jetty.xml.XmlParser.Node;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
|
||||
public class QuickStartTest
|
||||
{
|
||||
|
||||
@Test
|
||||
public void testStandardTestWar() throws Exception
|
||||
{
|
||||
PreconfigureStandardTestWar.main(new String[]{});
|
||||
|
||||
WebDescriptor descriptor = new WebDescriptor(Resource.newResource("./target/test-standard-preconfigured/WEB-INF/quickstart-web.xml"));
|
||||
descriptor.setValidating(true);
|
||||
descriptor.parse();
|
||||
Node node = descriptor.getRoot();
|
||||
assertThat(node,Matchers.notNullValue());
|
||||
|
||||
System.setProperty("jetty.home", "target");
|
||||
|
||||
//war file or dir to start
|
||||
String war = "target/test-standard-preconfigured";
|
||||
|
||||
//optional jetty context xml file to configure the webapp
|
||||
Resource contextXml = Resource.newResource("src/test/resources/test.xml");
|
||||
|
||||
Server server = new Server(0);
|
||||
|
||||
QuickStartWebApp webapp = new QuickStartWebApp();
|
||||
webapp.setAutoPreconfigure(true);
|
||||
webapp.setWar(war);
|
||||
webapp.setContextPath("/");
|
||||
|
||||
//apply context xml file
|
||||
if (contextXml != null)
|
||||
{
|
||||
// System.err.println("Applying "+contextXml);
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXml.getURL());
|
||||
xmlConfiguration.configure(webapp);
|
||||
}
|
||||
|
||||
server.setHandler(webapp);
|
||||
|
||||
server.start();
|
||||
|
||||
URL url = new URL("http://127.0.0.1:"+server.getBean(NetworkConnector.class).getLocalPort()+"/test/dump/info");
|
||||
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
||||
assertEquals(200,connection.getResponseCode());
|
||||
assertThat(IO.toString((InputStream)connection.getContent()),Matchers.containsString("Dump Servlet"));
|
||||
|
||||
server.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpecWar() throws Exception
|
||||
{
|
||||
PreconfigureSpecWar.main(new String[]{});
|
||||
|
||||
WebDescriptor descriptor = new WebDescriptor(Resource.newResource("./target/test-spec-preconfigured/WEB-INF/quickstart-web.xml"));
|
||||
descriptor.setValidating(true);
|
||||
descriptor.parse();
|
||||
Node node = descriptor.getRoot();
|
||||
assertThat(node,Matchers.notNullValue());
|
||||
|
||||
System.setProperty("jetty.home", "target");
|
||||
|
||||
//war file or dir to start
|
||||
String war = "target/test-spec-preconfigured";
|
||||
|
||||
//optional jetty context xml file to configure the webapp
|
||||
Resource contextXml = Resource.newResource("src/test/resources/test-spec.xml");
|
||||
|
||||
Server server = new Server(0);
|
||||
|
||||
QuickStartWebApp webapp = new QuickStartWebApp();
|
||||
webapp.setAutoPreconfigure(true);
|
||||
webapp.setWar(war);
|
||||
webapp.setContextPath("/");
|
||||
|
||||
//apply context xml file
|
||||
if (contextXml != null)
|
||||
{
|
||||
// System.err.println("Applying "+contextXml);
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXml.getURL());
|
||||
xmlConfiguration.configure(webapp);
|
||||
}
|
||||
|
||||
server.setHandler(webapp);
|
||||
|
||||
server.start();
|
||||
|
||||
URL url = new URL("http://127.0.0.1:"+server.getBean(NetworkConnector.class).getLocalPort()+"/");
|
||||
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
||||
assertEquals(200,connection.getResponseCode());
|
||||
assertThat(IO.toString((InputStream)connection.getContent()),Matchers.containsString("Test Specification WebApp"));
|
||||
|
||||
server.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJNDIWar() throws Exception
|
||||
{
|
||||
PreconfigureJNDIWar.main(new String[]{});
|
||||
|
||||
WebDescriptor descriptor = new WebDescriptor(Resource.newResource("./target/test-jndi-preconfigured/WEB-INF/quickstart-web.xml"));
|
||||
descriptor.setValidating(true);
|
||||
descriptor.parse();
|
||||
Node node = descriptor.getRoot();
|
||||
assertThat(node,Matchers.notNullValue());
|
||||
|
||||
System.setProperty("jetty.home", "target");
|
||||
|
||||
//war file or dir to start
|
||||
String war = "target/test-jndi-preconfigured";
|
||||
|
||||
//optional jetty context xml file to configure the webapp
|
||||
Resource contextXml = Resource.newResource("src/test/resources/test-jndi.xml");
|
||||
|
||||
Server server = new Server(0);
|
||||
|
||||
QuickStartWebApp webapp = new QuickStartWebApp();
|
||||
webapp.setAutoPreconfigure(true);
|
||||
webapp.setWar(war);
|
||||
webapp.setContextPath("/");
|
||||
|
||||
//apply context xml file
|
||||
if (contextXml != null)
|
||||
{
|
||||
// System.err.println("Applying "+contextXml);
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXml.getURL());
|
||||
xmlConfiguration.configure(webapp);
|
||||
}
|
||||
|
||||
server.setHandler(webapp);
|
||||
|
||||
server.start();
|
||||
|
||||
URL url = new URL("http://127.0.0.1:"+server.getBean(NetworkConnector.class).getLocalPort()+"/");
|
||||
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
||||
assertEquals(200,connection.getResponseCode());
|
||||
String content=IO.toString((InputStream)connection.getContent());
|
||||
assertThat(content,Matchers.containsString("JNDI Test WebApp"));
|
||||
|
||||
server.stop();
|
||||
}
|
||||
}
|
|
@ -30,6 +30,8 @@ detected.
|
|||
<Set name="checkWelcomeFiles">true</Set>
|
||||
</Get>
|
||||
|
||||
<Set name="parentLoaderPriority">true</Set>
|
||||
|
||||
<!-- Non standard error page mapping -->
|
||||
<!--
|
||||
<Get name="errorHandler">
|
|
@ -1,6 +0,0 @@
|
|||
#
|
||||
# HTTP connector
|
||||
#
|
||||
--module=http
|
||||
jetty.port=8080
|
||||
|
|
@ -16,6 +16,51 @@
|
|||
<verbose>false</verbose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<extensions>true</extensions>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-manifest</id>
|
||||
<goals>
|
||||
<goal>manifest</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>org.eclipse.jetty.tests.test-mock-resources</Bundle-SymbolicName>
|
||||
<Bundle-Description>Mock resources used for testing </Bundle-Description>
|
||||
<Export-Package>
|
||||
com.acme;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"
|
||||
</Export-Package>
|
||||
<Import-Package>
|
||||
javax.sql,
|
||||
javax.transaction;version="1.1",
|
||||
javax.mail;version="1.4.1"
|
||||
</Import-Package>
|
||||
<_nouses>true</_nouses>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>artifact-jar</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
|
|
|
@ -16,6 +16,47 @@
|
|||
<verbose>false</verbose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>artifact-jar</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestFile>target/classes/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<extensions>true</extensions>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>bundle-manifest</id>
|
||||
<phase>process-classes</phase>
|
||||
<goals>
|
||||
<goal>manifest</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>org.eclipse.jetty.tests.test-servlet-container-initializer;singleton:=true</Bundle-SymbolicName>
|
||||
<Bundle-Description>A bundle containing a ServletContainerInitializer for testing</Bundle-Description>
|
||||
<Require-Capability>osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)"</Require-Capability>
|
||||
<Provide-Capability>osgi.serviceloader; osgi.serviceloader=javax.servlet.ServletContainerInitializer</Provide-Capability>
|
||||
<Export-Package>com.acme.initializer;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"</Export-Package>
|
||||
<_nouses>true</_nouses>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
|
@ -24,13 +65,5 @@
|
|||
<artifactId>javax.servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.orbit</groupId>
|
||||
<artifactId>javax.servlet</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
-->
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
// ========================================================================
|
||||
//
|
||||
|
||||
package com.acme;
|
||||
package com.acme.initializer;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
|
@ -16,7 +16,7 @@
|
|||
// ========================================================================
|
||||
//
|
||||
|
||||
package com.acme;
|
||||
package com.acme.initializer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
|
@ -1 +1 @@
|
|||
com.acme.FooInitializer
|
||||
com.acme.initializer.FooInitializer
|
||||
|
|
|
@ -18,6 +18,90 @@
|
|||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>src/main/assembly/config.xml</descriptor>
|
||||
<descriptor>src/main/assembly/web-bundle.xml</descriptor>
|
||||
</descriptors>
|
||||
<archive>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- also make this webapp an osgi bundle -->
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
<webResources>
|
||||
<resource>
|
||||
<directory>target</directory>
|
||||
<includes>
|
||||
<include>plugin-context.xml</include>
|
||||
</includes>
|
||||
<targetPath>META-INF</targetPath>
|
||||
</resource>
|
||||
</webResources>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<supportedProjectTypes>
|
||||
<supportedProjectType>war</supportedProjectType>
|
||||
</supportedProjectTypes>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>bundle-manifest</id>
|
||||
<phase>process-classes</phase>
|
||||
<goals>
|
||||
<goal>manifest</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>org.eclipse.jetty.tests.test-spec-webapp</Bundle-SymbolicName>
|
||||
<Bundle-Description>Test Webapp for Servlet 3.1 Features</Bundle-Description>
|
||||
<Import-Package>
|
||||
javax.servlet.jsp.*;version="[2.2.0, 3.0)",
|
||||
javax.transaction.*;version="[1.1, 2.0)",
|
||||
javax.servlet.*;version="3.0",
|
||||
javax.sql,
|
||||
org.eclipse.jetty.webapp;version="9.2",org.eclipse.jetty.plus.jndi;version="9.2",
|
||||
org.eclipse.jetty.security;version="9.2",
|
||||
com.acme;version="9.2",
|
||||
*
|
||||
</Import-Package>
|
||||
<Export-Package>com.acme.test;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"</Export-Package>
|
||||
<Web-ContextPath>/</Web-ContextPath>
|
||||
<Bundle-ClassPath>.,WEB-INF/classes,WEB-INF/lib</Bundle-ClassPath>
|
||||
<Jetty-ContextFilePath>./META-INF/plugin-context.xml</Jetty-ContextFilePath>
|
||||
<_nouses>true</_nouses>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
|
@ -65,7 +149,7 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<!-- plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.2-beta-3</version>
|
||||
|
@ -82,7 +166,7 @@
|
|||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugin -->
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
|
||||
<id>webbundle</id>
|
||||
<formats>
|
||||
<format>jar</format>
|
||||
</formats>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>${basedir}/${project.build.directory}/${project.build.finalName}/</directory>
|
||||
<outputDirectory></outputDirectory>
|
||||
<includes>
|
||||
<include>**/*.*</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue