Merge remote-tracking branch 'origin/master' into jetty-http2

Conflicts:
	VERSION.txt
	aggregates/jetty-all/pom.xml
	apache-jsp/pom.xml
	apache-jstl/pom.xml
	examples/async-rest/async-rest-jar/pom.xml
	examples/async-rest/async-rest-webapp/pom.xml
	examples/async-rest/pom.xml
	examples/embedded/pom.xml
	examples/pom.xml
	jetty-alpn/jetty-alpn-client/pom.xml
	jetty-alpn/jetty-alpn-server/pom.xml
	jetty-alpn/pom.xml
	jetty-annotations/pom.xml
	jetty-ant/pom.xml
	jetty-client/pom.xml
	jetty-continuation/pom.xml
	jetty-deploy/pom.xml
	jetty-distribution/pom.xml
	jetty-fcgi/fcgi-client/pom.xml
	jetty-fcgi/fcgi-server/pom.xml
	jetty-fcgi/pom.xml
	jetty-http-spi/pom.xml
	jetty-http/pom.xml
	jetty-io/pom.xml
	jetty-jaas/pom.xml
	jetty-jaspi/pom.xml
	jetty-jmx/pom.xml
	jetty-jndi/pom.xml
	jetty-jsp/pom.xml
	jetty-jspc-maven-plugin/pom.xml
	jetty-maven-plugin/pom.xml
	jetty-monitor/pom.xml
	jetty-nosql/pom.xml
	jetty-osgi/jetty-osgi-alpn/pom.xml
	jetty-osgi/jetty-osgi-boot-jsp/pom.xml
	jetty-osgi/jetty-osgi-boot-warurl/pom.xml
	jetty-osgi/jetty-osgi-boot/pom.xml
	jetty-osgi/jetty-osgi-httpservice/pom.xml
	jetty-osgi/jetty-osgi-npn/pom.xml
	jetty-osgi/pom.xml
	jetty-osgi/test-jetty-osgi-context/pom.xml
	jetty-osgi/test-jetty-osgi-webapp/pom.xml
	jetty-osgi/test-jetty-osgi/pom.xml
	jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWithJsp.java
	jetty-plus/pom.xml
	jetty-proxy/pom.xml
	jetty-quickstart/pom.xml
	jetty-rewrite/pom.xml
	jetty-runner/pom.xml
	jetty-security/pom.xml
	jetty-server/pom.xml
	jetty-servlet/pom.xml
	jetty-servlets/pom.xml
	jetty-spdy/pom.xml
	jetty-spdy/spdy-alpn-tests/pom.xml
	jetty-spdy/spdy-client/pom.xml
	jetty-spdy/spdy-core/pom.xml
	jetty-spdy/spdy-example-webapp/pom.xml
	jetty-spdy/spdy-http-client-transport/pom.xml
	jetty-spdy/spdy-http-common/pom.xml
	jetty-spdy/spdy-http-server/pom.xml
	jetty-spdy/spdy-npn-tests/pom.xml
	jetty-spdy/spdy-server/pom.xml
	jetty-spring/pom.xml
	jetty-start/pom.xml
	jetty-util-ajax/pom.xml
	jetty-util/pom.xml
	jetty-webapp/pom.xml
	jetty-websocket/javax-websocket-client-impl/pom.xml
	jetty-websocket/javax-websocket-server-impl/pom.xml
	jetty-websocket/pom.xml
	jetty-websocket/websocket-api/pom.xml
	jetty-websocket/websocket-client/pom.xml
	jetty-websocket/websocket-common/pom.xml
	jetty-websocket/websocket-server/pom.xml
	jetty-websocket/websocket-servlet/pom.xml
	jetty-xml/pom.xml
	pom.xml
	tests/pom.xml
	tests/test-continuation/pom.xml
	tests/test-integration/pom.xml
	tests/test-loginservice/pom.xml
	tests/test-quickstart/pom.xml
	tests/test-sessions/pom.xml
	tests/test-sessions/test-hash-sessions/pom.xml
	tests/test-sessions/test-jdbc-sessions/pom.xml
	tests/test-sessions/test-sessions-common/pom.xml
	tests/test-webapps/pom.xml
	tests/test-webapps/test-jaas-webapp/pom.xml
	tests/test-webapps/test-jetty-webapp/pom.xml
	tests/test-webapps/test-jndi-webapp/pom.xml
	tests/test-webapps/test-mock-resources/pom.xml
	tests/test-webapps/test-proxy-webapp/pom.xml
	tests/test-webapps/test-servlet-spec/pom.xml
	tests/test-webapps/test-servlet-spec/test-container-initializer/pom.xml
	tests/test-webapps/test-servlet-spec/test-spec-webapp/pom.xml
	tests/test-webapps/test-servlet-spec/test-web-fragment/pom.xml
	tests/test-webapps/test-webapp-rfc2616/pom.xml
This commit is contained in:
Greg Wilkins 2014-09-10 14:38:18 +10:00
commit 5011993ddf
45 changed files with 924 additions and 563 deletions

View File

@ -1,8 +1,39 @@
jetty-9.3.0-SNAPSHOT
jetty-9.2.3-SNAPSHOT
jetty-9.2.2-v20140723 - 23 July 2014
jetty-9.2.3.v20140905 - 05 September 2014
+ 347110 renamed class transformer methods
+ 411163 Add embedded jetty code example with JSP enabled
+ 435322 Added a idleTimeout to the SharedBlockerCallback
+ 435533 Handle 0 sized async gzip
+ 435988 ContainerLifeCycle: beans never stopped on remove
+ 436862 Update jetty-osgi to asm-5 and spifly-1.0.1
+ 438500 Odd NoClassDef errors when shutting down the jetty-maven-plugin via
the stop goal
+ 440255 ensure 500 is logged on thrown Errors
+ 441073 isEarlyEOF on HttpInput
+ 441475 org.eclipse.jetty.server.ResourceCache exceptions under high load
+ 441479 Jetty hangs due to deadlocks in session manager
+ 441649 Update to jsp and el Apache Jasper 8.0.9
+ 441756 Ssl Stackoverflow on renegotiate
+ 441897 Fixed etag handling in gzipfilter
+ 442048 fixed sendRedirect %2F encoding
+ 442383 Improved insufficient threads message
+ 442628 Update example xml file for second server instance to extract wars
+ 442642 Quickstart generates valid XML
+ 442759 Allow specific ServletContainerInitializers to be excluded
+ 442950 Embedded Jetty client requests to localhost hangs with high cpu usage
(NIO OP_CONNECT Solaris/Sparc).
+ 443049 Improved HttpParser illegal character messages
+ 443158 Fixed HttpOutput spin
+ 443172 web-fragment.xml wrongly parsed for applications running in serlvet
2.4 mode
+ 443231 java.lang.NullPointerException on scavenge scheduling when session id
manager declared before shared scheduler
+ 443262 Distinguish situation where jetty looks for tlds in META-INF but
finds none vs does not look
jetty-9.2.2.v20140723 - 23 July 2014
+ 411323 DosFilter/QoSFilter should use AsyncContext rather than
Continuations.
+ 432815 Fixed selector stop race

View File

@ -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>
</plugins>
</build>

View File

@ -37,7 +37,7 @@ lib/alpn/
[license]
ALPN is a hosted at github under the GPL v2 with ClassPath Exception.
ALPM replaces/modified OpenJDK classes in the java.sun.security.ssl package.
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

View File

@ -37,6 +37,6 @@ lib/npn/
[license]
NPN is a hosted at github under the GPL v2 with ClassPath Exception.
NPN replaces/modified OpenJDK classes in the java.sun.security.ssl package.
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

View File

@ -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.M3</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,
@ -146,7 +172,7 @@
javax.xml.parser;resolution:=optional
</Import-Package>
<_nouses>true</_nouses>
<DynamicImport-Package>org.apache.jasper.*;version="2.3"</DynamicImport-Package>
<DynamicImport-Package>org.apache.jasper.*;version="8.0.9",org.apache.el.*;version="8.0.9"</DynamicImport-Package>
</instructions>
</configuration>
</plugin>

View File

@ -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,15 +69,19 @@ 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
@ -73,18 +91,17 @@ public class ContainerTldBundleDiscoverer implements TldBundleDiscoverer
*/
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())
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.

View File

@ -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;
@ -86,9 +87,11 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
*/
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()]);
}
@ -213,7 +233,8 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
{
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,10 +276,10 @@ 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)); }
@ -269,6 +290,6 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
return null;
}
}
}*/
}

View File

@ -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());
}

View File

@ -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,

View File

@ -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.
*/

View File

@ -144,62 +144,11 @@ 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)
{
if (jettyHome == 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);
}
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;
}
}
/* ------------------------------------------------------------ */

View File

@ -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;
}
}

View File

@ -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");
}
@ -105,6 +115,23 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
}
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;
private String _defaultsDescriptor;
@ -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

View File

@ -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

View File

@ -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);

View File

@ -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.

View File

@ -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.M3</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>

View File

@ -48,6 +48,7 @@ public class TestJettyOSGiBootCore
{
private static final String LOG_LEVEL = "WARN";
// TODO these should be dynamic
public static final int DEFAULT_HTTP_PORT = 9876;
public static final int DEFAULT_SSL_PORT = 9877;
@ -91,14 +92,11 @@ 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());
res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-servlet" ).versionAsInProject().noStart());
@ -112,7 +110,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());
@ -126,6 +124,32 @@ public class TestJettyOSGiBootCore
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()
{
List<Option> res = new ArrayList<Option>();

View File

@ -112,14 +112,7 @@ public class TestJettyOSGiBootWebAppAsService
{
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

View File

@ -0,0 +1,168 @@
//
// ========================================================================
// 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-http.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_HTTP_PORT)));
options.add(systemProperty("ssl.port").value(String.valueOf(TestJettyOSGiBootCore.DEFAULT_SSL_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_HTTP_PORT);
}
@Test
public void testIndex() throws Exception
{
// TestOSGiUtil.debugBundles(bundleContext);
HttpClient client = new HttpClient();
try
{
client.start();
ContentResponse response = client.GET("http://127.0.0.1:" + TestJettyOSGiBootCore.DEFAULT_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_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();
}
}
}

View File

@ -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;
@ -72,7 +72,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()]);
}
@ -110,26 +110,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);
}
@ -151,13 +144,11 @@ public class TestJettyOSGiBootWithJsp
try
{
client.start();
ContentResponse response = client.GET("http://127.0.0.1:" + TestJettyOSGiBootCore.DEFAULT_HTTP_PORT + "/jsp/dump.jsp");
ContentResponse response = client.GET("http://127.0.0.1:" + TestJettyOSGiBootCore.DEFAULT_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
{

View File

@ -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>

View File

@ -253,7 +253,7 @@ public class Password extends Credential
{
if (arg.length != 1 && arg.length != 2)
{
System.err.println("Usage - java org.eclipse.jetty.security.Password [<user>] <password>");
System.err.println("Usage - java " + Password.class.getName() + " [<user>] <password>");
System.err.println("If the password is ?, the user will be prompted for the password");
System.exit(1);
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -568,7 +568,7 @@
<dependency>
<groupId>org.mortbay.jasper</groupId>
<artifactId>apache-jsp</artifactId>
<version>8.0.9.M2</version>
<version>8.0.9.M3</version>
</dependency>
<dependency>

View File

@ -19,6 +19,33 @@
<verbose>false</verbose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<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>
</plugins>
</build>
<dependencies>

View File

@ -19,6 +19,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>
@ -27,13 +68,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>

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package com.acme;
package com.acme.initializer;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package com.acme;
package com.acme.initializer;
import java.util.ArrayList;
import java.util.Set;

View File

@ -21,6 +21,89 @@
<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>
<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>
@ -68,7 +151,7 @@
</execution>
</executions>
</plugin>
<plugin>
<!-- plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-3</version>
@ -85,7 +168,7 @@
</configuration>
</execution>
</executions>
</plugin>
</plugin -->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>

View File

@ -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>

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package com.acme;
package com.acme.test;
import javax.annotation.Resource;
import javax.servlet.ServletContextAttributeEvent;

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package com.acme;
package com.acme.test;
import java.io.IOException;
import java.util.ArrayList;
@ -110,7 +110,7 @@ public class AnnotationTest extends HttpServlet
try
{
InitialContext ic = new InitialContext();
envLookupResult = "java:comp/env/com.acme.AnnotationTest/maxAmount="+ic.lookup("java:comp/env/com.acme.AnnotationTest/maxAmount");
envLookupResult = "java:comp/env/com.acme.test.AnnotationTest/maxAmount="+ic.lookup("java:comp/env/com.acme.test.AnnotationTest/maxAmount");
}
catch (Exception e)
{
@ -131,7 +131,7 @@ public class AnnotationTest extends HttpServlet
try
{
InitialContext ic = new InitialContext();
envLookupResult3 = "java:comp/env/com.acme.AnnotationTest/avgAmount="+ic.lookup("java:comp/env/com.acme.AnnotationTest/avgAmount");
envLookupResult3 = "java:comp/env/com.acme.test.AnnotationTest/avgAmount="+ic.lookup("java:comp/env/com.acme.test.AnnotationTest/avgAmount");
}
catch (Exception e)
{
@ -143,7 +143,7 @@ public class AnnotationTest extends HttpServlet
try
{
InitialContext ic = new InitialContext();
dsLookupResult = "java:comp/env/com.acme.AnnotationTest/myDatasource="+ic.lookup("java:comp/env/com.acme.AnnotationTest/myDatasource");
dsLookupResult = "java:comp/env/com.acme.test.AnnotationTest/myDatasource="+ic.lookup("java:comp/env/com.acme.test.AnnotationTest/myDatasource");
}
catch (Exception e)
{
@ -154,7 +154,7 @@ public class AnnotationTest extends HttpServlet
try
{
InitialContext ic = new InitialContext();
txLookupResult = "java:comp/env/com.acme.AnnotationTest/myUserTransaction="+ic.lookup("java:comp/env/com.acme.AnnotationTest/myUserTransaction");
txLookupResult = "java:comp/env/com.acme.test.AnnotationTest/myUserTransaction="+ic.lookup("java:comp/env/com.acme.test.AnnotationTest/myUserTransaction");
}
catch (Exception e)
{
@ -209,14 +209,14 @@ public class AnnotationTest extends HttpServlet
__HandlesTypes = Arrays.asList( "javax.servlet.GenericServlet",
"javax.servlet.http.HttpServlet",
"com.acme.AsyncListenerServlet",
"com.acme.AnnotationTest",
"com.acme.RoleAnnotationTest",
"com.acme.MultiPartTest",
"com.acme.FragmentServlet",
"com.acme.TestListener",
"com.acme.SecuredServlet",
"com.acme.Bar");
"com.acme.test.AsyncListenerServlet",
"com.acme.test.AnnotationTest",
"com.acme.test.RoleAnnotationTest",
"com.acme.test.MultiPartTest",
"com.acme.fragment.FragmentServlet",
"com.acme.test.TestListener",
"com.acme.test.SecuredServlet",
"com.acme.test.Bar");
out.println("<h2>@ContainerInitializer</h2>");
out.println("<pre>");
out.println("@HandlesTypes({javax.servlet.Servlet.class, Foo.class})");

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package com.acme;
package com.acme.test;
import java.io.IOException;
import java.io.PrintWriter;

View File

@ -16,12 +16,12 @@
// ========================================================================
//
package com.acme;
package com.acme.test;
public class Bar {
@Foo(2)
@com.acme.initializer.Foo(2)
public void someMethod () {
}

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package com.acme;
package com.acme.test;
import java.io.IOException;
import java.util.Collection;

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package com.acme;
package com.acme.test;
import java.io.IOException;

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package com.acme;
package com.acme.test;
import java.io.IOException;
import java.io.PrintWriter;

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package com.acme;
package com.acme.test;
import java.util.EventListener;
import javax.annotation.PostConstruct;
@ -38,7 +38,7 @@ import javax.servlet.http.HttpSessionIdListener;
import javax.servlet.http.HttpSessionListener;
@Foo(1)
@com.acme.initializer.Foo(1)
@WebListener
public class TestListener implements HttpSessionListener, HttpSessionAttributeListener, HttpSessionActivationListener, ServletContextListener, ServletContextAttributeListener, ServletRequestListener, ServletRequestAttributeListener
{

View File

@ -1,3 +0,0 @@
Manifest-Version: 1.0
Class-Path:

View File

@ -9,7 +9,7 @@
<display-name>Test Annotations WebApp</display-name>
<listener>
<listener-class>com.acme.TestListener</listener-class>
<listener-class>com.acme.test.TestListener</listener-class>
</listener>
@ -25,7 +25,7 @@
<servlet>
<servlet-name>RoleAnnotationTest</servlet-name>
<servlet-class>com.acme.RoleAnnotationTest</servlet-class>
<servlet-class>com.acme.test.RoleAnnotationTest</servlet-class>
<load-on-startup>1</load-on-startup>
<security-role-ref>
<role-name>manager</role-name>
@ -40,7 +40,7 @@
<servlet>
<servlet-name>Multi</servlet-name>
<servlet-class>com.acme.MultiPartTest</servlet-class>
<servlet-class>com.acme.test.MultiPartTest</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
@ -50,7 +50,7 @@
</servlet-mapping>
<env-entry>
<env-entry-name>com.acme.AnnotationTest/avgAmount</env-entry-name>
<env-entry-name>com.acme.test.AnnotationTest/avgAmount</env-entry-name>
<env-entry-type>java.lang.Double</env-entry-type>
<env-entry-value>1.25</env-entry-value>
</env-entry>

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package com.acme;
package com.acme.fragment;
import java.io.IOException;

View File

@ -14,7 +14,7 @@
<servlet>
<servlet-name>AnnotationTest</servlet-name>
<servlet-class>com.acme.AnnotationTest</servlet-class>
<servlet-class>com.acme.test.AnnotationTest</servlet-class>
<init-param>
<param-name>extra1</param-name><param-value>123</param-value>
</init-param>
@ -25,7 +25,7 @@
<servlet>
<servlet-name>Fragment</servlet-name>
<servlet-class>com.acme.FragmentServlet</servlet-class>
<servlet-class>com.acme.fragment.FragmentServlet</servlet-class>
</servlet>
<servlet-mapping>