Merge remote-tracking branch 'origin/jetty-10.0.x' into jetty-10.0.x-1743-refactor-maven-plugin-redux
Signed-off-by: Jan Bartel <janb@webtide.com>
This commit is contained in:
commit
60d20c8808
|
@ -11,7 +11,7 @@ pipeline {
|
||||||
agent { node { label 'linux' } }
|
agent { node { label 'linux' } }
|
||||||
options { timeout(time: 120, unit: 'MINUTES') }
|
options { timeout(time: 120, unit: 'MINUTES') }
|
||||||
steps {
|
steps {
|
||||||
mavenBuild("jdk11", "-Pautobahn -Pmongodb install", "maven3", false)
|
mavenBuild("jdk11", "-Pmongodb install", "maven3", true) // -Pautobahn
|
||||||
// Collect up the jacoco execution results (only on main build)
|
// Collect up the jacoco execution results (only on main build)
|
||||||
jacoco inclusionPattern: '**/org/eclipse/jetty/**/*.class',
|
jacoco inclusionPattern: '**/org/eclipse/jetty/**/*.class',
|
||||||
exclusionPattern: '' +
|
exclusionPattern: '' +
|
||||||
|
@ -35,16 +35,7 @@ pipeline {
|
||||||
execPattern: '**/target/jacoco.exec',
|
execPattern: '**/target/jacoco.exec',
|
||||||
classPattern: '**/target/classes',
|
classPattern: '**/target/classes',
|
||||||
sourcePattern: '**/src/main/java'
|
sourcePattern: '**/src/main/java'
|
||||||
warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'Java']]
|
junit testResults: '**/target/surefire-reports/*.xml,**/target/autobahntestsuite-reports/*.xml'
|
||||||
maven_invoker reportsFilenamePattern: "**/target/invoker-reports/BUILD*.xml", invokerBuildDir: "**/target/it"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage("Build / Test - JDK11") {
|
|
||||||
agent { node { label 'linux' } }
|
|
||||||
options { timeout(time: 120, unit: 'MINUTES') }
|
|
||||||
steps {
|
|
||||||
mavenBuild("jdk11", "-Pmongodb install", "maven3", false)
|
|
||||||
warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'Java']]
|
warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'Java']]
|
||||||
maven_invoker reportsFilenamePattern: "**/target/invoker-reports/BUILD*.xml", invokerBuildDir: "**/target/it"
|
maven_invoker reportsFilenamePattern: "**/target/invoker-reports/BUILD*.xml", invokerBuildDir: "**/target/it"
|
||||||
}
|
}
|
||||||
|
@ -54,7 +45,7 @@ pipeline {
|
||||||
agent { node { label 'linux' } }
|
agent { node { label 'linux' } }
|
||||||
options { timeout(time: 120, unit: 'MINUTES') }
|
options { timeout(time: 120, unit: 'MINUTES') }
|
||||||
steps {
|
steps {
|
||||||
mavenBuild("jdk12", "-Pmongodb install", "maven3", false)
|
mavenBuild("jdk12", "-Pmongodb install", "maven3", true)
|
||||||
warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'Java']]
|
warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'Java']]
|
||||||
maven_invoker reportsFilenamePattern: "**/target/invoker-reports/BUILD*.xml", invokerBuildDir: "**/target/it"
|
maven_invoker reportsFilenamePattern: "**/target/invoker-reports/BUILD*.xml", invokerBuildDir: "**/target/it"
|
||||||
}
|
}
|
||||||
|
@ -68,11 +59,56 @@ pipeline {
|
||||||
warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'JavaDoc'], [parserName: 'Java']]
|
warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'JavaDoc'], [parserName: 'Java']]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stage("Checkstyle ") {
|
||||||
|
agent { node { label 'linux' } }
|
||||||
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
|
steps {
|
||||||
|
mavenBuild("jdk11", "install checkstyle:check -DskipTests", "maven3", true)
|
||||||
|
recordIssues(
|
||||||
|
enabledForFailure: true, aggregatingResults: true,
|
||||||
|
tools: [java(), checkStyle(pattern: '**/target/checkstyle-result.xml', reportEncoding: 'UTF-8')]
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
failure {
|
||||||
|
slackNotif()
|
||||||
|
}
|
||||||
|
unstable {
|
||||||
|
slackNotif()
|
||||||
|
}
|
||||||
|
fixed {
|
||||||
|
slackNotif()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def slackNotif() {
|
||||||
|
script {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ( env.BRANCH_NAME == 'jetty-10.0.x' || env.BRANCH_NAME == 'jetty-9.4.x' )
|
||||||
|
{
|
||||||
|
//BUILD_USER = currentBuild.rawBuild.getCause(Cause.UserIdCause).getUserId()
|
||||||
|
// by ${BUILD_USER}
|
||||||
|
COLOR_MAP = ['SUCCESS': 'good', 'FAILURE': 'danger', 'UNSTABLE': 'danger', 'ABORTED': 'danger']
|
||||||
|
slackSend channel: '#jenkins',
|
||||||
|
color: COLOR_MAP[currentBuild.currentResult],
|
||||||
|
message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} - ${env.BUILD_URL}"
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace()
|
||||||
|
echo "skip failure slack notification: " + e.getMessage()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To other developers, if you are using this method above, please use the following syntax.
|
* To other developers, if you are using this method above, please use the following syntax.
|
||||||
*
|
*
|
||||||
|
|
|
@ -38,12 +38,12 @@ node("linux") {
|
||||||
// jmh run
|
// jmh run
|
||||||
node( 'jmh-build-node' ) {
|
node( 'jmh-build-node' ) {
|
||||||
stage("jmh-run") {
|
stage("jmh-run") {
|
||||||
timeout( time: 180, unit: 'MINUTES' ) {
|
timeout( time: 210, unit: 'MINUTES' ) {
|
||||||
withEnv( ["JAVA_HOME=${tool "$jdk"}"] ) {
|
withEnv( ["JAVA_HOME=${tool "$jdk"}"] ) {
|
||||||
unstash name: 'perf-tests'
|
unstash name: 'perf-tests'
|
||||||
sh "rm -rf jmh_results"
|
sh "rm -rf jmh_results"
|
||||||
sh "mkdir jmh_results"
|
sh "mkdir jmh_results"
|
||||||
sh "${env.JAVA_HOME}/bin/java -jar $jmhJarPath -rff jmh_results/jmh_result.json -rf json -foe true"
|
sh "${env.JAVA_HOME}/bin/java -jar $jmhJarPath -rff jmh_results/jmh_result.json -rf json -foe true -i 3 -t 3 -wi 3"
|
||||||
jmhReport 'jmh_results/jmh_result.json'
|
jmhReport 'jmh_results/jmh_result.json'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
44
VERSION.txt
44
VERSION.txt
|
@ -1,10 +1,52 @@
|
||||||
jetty-10.0.0-SNAPSHOT
|
jetty-10.0.0-SNAPSHOT
|
||||||
|
|
||||||
|
jetty-9.4.19.v20190610 - 10 June 2019
|
||||||
|
+ 2909 Remove B64Code
|
||||||
|
+ 3332 jetty-maven-plugin - transitive dependencies not loaded from
|
||||||
|
"target/classes"
|
||||||
|
+ 3498 WebSocket Session.suspend() now suspends incoming frames instead of
|
||||||
|
reads
|
||||||
|
+ 3534 Use System nanoTime, not currentTimeMillis for IdleTimeout
|
||||||
|
+ 3550 Server becomes unresponsive after sitting idle from a load spike
|
||||||
|
+ 3562 InetAccessHandler should be able to apply to a certain port or
|
||||||
|
connector
|
||||||
|
+ 3568 Make UserStore able to be started/stopped with its LoginService
|
||||||
|
+ 3583 jetty-maven plugin in multi-module-project does not use files from
|
||||||
|
/target/test-classes folder of dependent projects
|
||||||
|
+ 3605 IdleTimeout with Jetty HTTP/2 and InputStreamResponseListener
|
||||||
|
+ 3608 Reply with 400 Bad request to malformed WebSocket handshake
|
||||||
|
+ 3616 Backport WebSocket SessionTracker from Jetty 10
|
||||||
|
+ 3620 Use of `throwUnavailableOnStartupException=true` does not stop Server
|
||||||
|
in jetty-home
|
||||||
|
+ 3627 Only renew session id when spnego authentication is fully complete
|
||||||
|
+ 3628 NPE in QueuedThreadPool.getReservedThreads()
|
||||||
|
+ 3630 X-Forwarded-For missing last hextet for ipv6
|
||||||
|
+ 3633 endpointIdentificationAlgorithm enabled by default
|
||||||
|
jetty-ssl-context.xml
|
||||||
|
+ 3653 access control exception if programmatic security manager is used
|
||||||
|
+ 3655 Spaces missing on Cookies generated via RFC6265
|
||||||
|
+ 3663 Remove deprecation of HttpClient replacement methods in WebSocketClient
|
||||||
|
+ 3680 Bom manages non-existent infinispan-remote and infinispan-embedded
|
||||||
|
dependencies due to config classifier
|
||||||
|
+ 3683 Multipart file not deleted when client aborts upload
|
||||||
|
+ 3690 Upgrade to asm 7.1
|
||||||
|
+ 3713 Emit warning when invoking deprecated method in Jetty XML
|
||||||
|
+ 3715 Improve Log.condensePackage performance
|
||||||
|
+ 3722 HttpSessionListener.sessionDestroyed should be able to access webapp
|
||||||
|
classes
|
||||||
|
+ 3726 Remove OSGi export uses of servlet-api from jetty-util
|
||||||
|
+ 3729 Make creation of java:comp/env threadsafe
|
||||||
|
+ 3743 Update XmlConfiguration usage in Jetty to always use Constructors that
|
||||||
|
provide Location information
|
||||||
|
+ 3748 @Resource field not injected in Jetty Demo
|
||||||
|
+ 3750 NPE in WebSocketClient.toString()
|
||||||
|
+ 3751 Modern Configure DTD / FPI is used inconsistently
|
||||||
|
|
||||||
jetty-9.4.18.v20190429 - 29 April 2019
|
jetty-9.4.18.v20190429 - 29 April 2019
|
||||||
+ 3476 IllegalStateException in WebSocket ConnectionState
|
+ 3476 IllegalStateException in WebSocket ConnectionState
|
||||||
+ 3550 Server becomes unresponsive after sitting idle from a load spike
|
+ 3550 Server becomes unresponsive after sitting idle from a load spike
|
||||||
+ 3563 Update to apache jasper 8.5.40
|
+ 3563 Update to apache jasper 8.5.40
|
||||||
+ 3573 Update jetty-bom for new infinispan artifacts.
|
+ 3573 Update jetty-bom for new infinispan artifacts
|
||||||
+ 3582 HeapByteBuffer cleared unexpected
|
+ 3582 HeapByteBuffer cleared unexpected
|
||||||
+ 3597 Session persistence broken from 9.4.13+
|
+ 3597 Session persistence broken from 9.4.13+
|
||||||
+ 3609 Fix infinispan start module dependencies
|
+ 3609 Fix infinispan start module dependencies
|
||||||
|
|
|
@ -188,7 +188,7 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||||
<artifactId>websocket-client</artifactId>
|
<artifactId>jetty-websocket-client</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- http/2 support -->
|
<!-- http/2 support -->
|
||||||
|
|
|
@ -63,8 +63,7 @@
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<archive>
|
<archive>
|
||||||
<manifest>
|
<manifest></manifest>
|
||||||
</manifest>
|
|
||||||
<manifestEntries>
|
<manifestEntries>
|
||||||
<mode>development</mode>
|
<mode>development</mode>
|
||||||
<url>http://eclipse.org/jetty</url>
|
<url>http://eclipse.org/jetty</url>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-project</artifactId>
|
<artifactId>jetty-project</artifactId>
|
||||||
|
@ -24,11 +23,9 @@
|
||||||
<instructions>
|
<instructions>
|
||||||
<Bundle-Description>Jetty-specific ServletContainerInitializer for Jasper</Bundle-Description>
|
<Bundle-Description>Jetty-specific ServletContainerInitializer for Jasper</Bundle-Description>
|
||||||
<Export-Package>
|
<Export-Package>
|
||||||
org.eclipse.jetty.apache.jsp.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}",
|
org.eclipse.jetty.apache.jsp.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}", org.eclipse.jetty.jsp.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"
|
||||||
org.eclipse.jetty.jsp.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"
|
|
||||||
</Export-Package>
|
</Export-Package>
|
||||||
<Require-Capability>osgi.extender;
|
<Require-Capability>osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)";resolution:=optional
|
||||||
filter:="(osgi.extender=osgi.serviceloader.registrar)";resolution:=optional
|
|
||||||
</Require-Capability>
|
</Require-Capability>
|
||||||
<Provide-Capability>
|
<Provide-Capability>
|
||||||
osgi.serviceloader;osgi.serviceloader=javax.servlet.ServletContainerInitializer,osgi.serviceloader;osgi.serviceloader=org.apache.juli.logging.Log
|
osgi.serviceloader;osgi.serviceloader=javax.servlet.ServletContainerInitializer,osgi.serviceloader;osgi.serviceloader=org.apache.juli.logging.Log
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.net.URL;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
import org.apache.jasper.servlet.JasperInitializer;
|
import org.apache.jasper.servlet.JasperInitializer;
|
||||||
|
@ -38,6 +37,7 @@ import org.xml.sax.SAXException;
|
||||||
public class JettyJasperInitializer extends JasperInitializer
|
public class JettyJasperInitializer extends JasperInitializer
|
||||||
{
|
{
|
||||||
private static final Log LOG = LogFactory.getLog(JasperInitializer.class);
|
private static final Log LOG = LogFactory.getLog(JasperInitializer.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NullTldScanner
|
* NullTldScanner
|
||||||
*
|
*
|
||||||
|
@ -47,10 +47,7 @@ public class JettyJasperInitializer extends JasperInitializer
|
||||||
private final class NullTldScanner extends TldScanner
|
private final class NullTldScanner extends TldScanner
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param context
|
*
|
||||||
* @param namespaceAware
|
|
||||||
* @param validation
|
|
||||||
* @param blockExternal
|
|
||||||
*/
|
*/
|
||||||
private NullTldScanner(ServletContext context, boolean namespaceAware, boolean validation, boolean blockExternal)
|
private NullTldScanner(ServletContext context, boolean namespaceAware, boolean validation, boolean blockExternal)
|
||||||
{
|
{
|
||||||
|
@ -93,20 +90,23 @@ public class JettyJasperInitializer extends JasperInitializer
|
||||||
public TldScanner newTldScanner(ServletContext context, boolean namespaceAware, boolean validate, boolean blockExternal)
|
public TldScanner newTldScanner(ServletContext context, boolean namespaceAware, boolean validate, boolean blockExternal)
|
||||||
{
|
{
|
||||||
String tmp = context.getInitParameter("org.eclipse.jetty.jsp.precompiled");
|
String tmp = context.getInitParameter("org.eclipse.jetty.jsp.precompiled");
|
||||||
if (tmp!=null && !tmp.equals("") && Boolean.valueOf(tmp))
|
if (tmp != null && !tmp.equals("") && Boolean.valueOf(tmp))
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled()) LOG.debug("Jsp precompilation detected");
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Jsp precompilation detected");
|
||||||
return new NullTldScanner(context, namespaceAware, validate, blockExternal);
|
return new NullTldScanner(context, namespaceAware, validate, blockExternal);
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<URL> tldUrls = (Collection<URL>)context.getAttribute("org.eclipse.jetty.tlds");
|
Collection<URL> tldUrls = (Collection<URL>)context.getAttribute("org.eclipse.jetty.tlds");
|
||||||
if (tldUrls != null)
|
if (tldUrls != null)
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled()) LOG.debug("Tld pre-scan detected");
|
if (LOG.isDebugEnabled())
|
||||||
return new JettyTldPreScanned(context,namespaceAware,validate,blockExternal,tldUrls);
|
LOG.debug("Tld pre-scan detected");
|
||||||
|
return new JettyTldPreScanned(context, namespaceAware, validate, blockExternal, tldUrls);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOG.isDebugEnabled()) LOG.debug("Defaulting to jasper tld scanning");
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Defaulting to jasper tld scanning");
|
||||||
return super.newTldScanner(context, namespaceAware, validate, blockExternal);
|
return super.newTldScanner(context, namespaceAware, validate, blockExternal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,10 @@
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
package org.eclipse.jetty.apache.jsp;
|
package org.eclipse.jetty.apache.jsp;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
import org.apache.jasper.servlet.TldPreScanned;
|
import org.apache.jasper.servlet.TldPreScanned;
|
||||||
|
@ -39,7 +37,6 @@ import org.apache.tomcat.util.descriptor.tld.TldResourcePath;
|
||||||
* may be in the reactor at the same time as a webapp being run with the
|
* may be in the reactor at the same time as a webapp being run with the
|
||||||
* plugin. That means that the tlds will be used from their location in
|
* plugin. That means that the tlds will be used from their location in
|
||||||
* the file system, rather than from their assembled jar.
|
* the file system, rather than from their assembled jar.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class JettyTldPreScanned extends TldPreScanned
|
public class JettyTldPreScanned extends TldPreScanned
|
||||||
{
|
{
|
||||||
|
@ -65,7 +62,7 @@ public class JettyTldPreScanned extends TldPreScanned
|
||||||
int a = str.indexOf("jar:");
|
int a = str.indexOf("jar:");
|
||||||
int b = str.indexOf("META-INF");
|
int b = str.indexOf("META-INF");
|
||||||
if (b < 0)
|
if (b < 0)
|
||||||
throw new IllegalStateException("Bad tld url: "+str);
|
throw new IllegalStateException("Bad tld url: " + str);
|
||||||
|
|
||||||
String path = str.substring(b);
|
String path = str.substring(b);
|
||||||
if (a >= 0)
|
if (a >= 0)
|
||||||
|
@ -95,5 +92,4 @@ public class JettyTldPreScanned extends TldPreScanned
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,14 +30,14 @@ public class JuliLog implements org.apache.juli.logging.Log
|
||||||
|
|
||||||
public JuliLog()
|
public JuliLog()
|
||||||
{
|
{
|
||||||
_logger=org.eclipse.jetty.util.log.Log.getRootLogger();
|
_logger = org.eclipse.jetty.util.log.Log.getRootLogger();
|
||||||
_stdErrLog=(_logger instanceof org.eclipse.jetty.util.log.StdErrLog) ? (org.eclipse.jetty.util.log.StdErrLog)_logger:null;
|
_stdErrLog = (_logger instanceof org.eclipse.jetty.util.log.StdErrLog) ? (org.eclipse.jetty.util.log.StdErrLog)_logger : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JuliLog(String name)
|
public JuliLog(String name)
|
||||||
{
|
{
|
||||||
_logger=org.eclipse.jetty.util.log.Log.getLogger(name);
|
_logger = org.eclipse.jetty.util.log.Log.getLogger(name);
|
||||||
_stdErrLog=(_logger instanceof org.eclipse.jetty.util.log.StdErrLog) ? (org.eclipse.jetty.util.log.StdErrLog)_logger:null;
|
_stdErrLog = (_logger instanceof org.eclipse.jetty.util.log.StdErrLog) ? (org.eclipse.jetty.util.log.StdErrLog)_logger : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,31 +49,31 @@ public class JuliLog implements org.apache.juli.logging.Log
|
||||||
@Override
|
@Override
|
||||||
public boolean isErrorEnabled()
|
public boolean isErrorEnabled()
|
||||||
{
|
{
|
||||||
return _stdErrLog==null?true:_stdErrLog.getLevel()<=org.eclipse.jetty.util.log.StdErrLog.LEVEL_WARN;
|
return _stdErrLog == null ? true : _stdErrLog.getLevel() <= org.eclipse.jetty.util.log.StdErrLog.LEVEL_WARN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFatalEnabled()
|
public boolean isFatalEnabled()
|
||||||
{
|
{
|
||||||
return _stdErrLog==null?true:_stdErrLog.getLevel()<=org.eclipse.jetty.util.log.StdErrLog.LEVEL_WARN;
|
return _stdErrLog == null ? true : _stdErrLog.getLevel() <= org.eclipse.jetty.util.log.StdErrLog.LEVEL_WARN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInfoEnabled()
|
public boolean isInfoEnabled()
|
||||||
{
|
{
|
||||||
return _stdErrLog==null?true:_stdErrLog.getLevel()<=org.eclipse.jetty.util.log.StdErrLog.LEVEL_INFO;
|
return _stdErrLog == null ? true : _stdErrLog.getLevel() <= org.eclipse.jetty.util.log.StdErrLog.LEVEL_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTraceEnabled()
|
public boolean isTraceEnabled()
|
||||||
{
|
{
|
||||||
return _stdErrLog==null?true:_stdErrLog.getLevel()<=org.eclipse.jetty.util.log.StdErrLog.LEVEL_DEBUG;
|
return _stdErrLog == null ? true : _stdErrLog.getLevel() <= org.eclipse.jetty.util.log.StdErrLog.LEVEL_DEBUG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWarnEnabled()
|
public boolean isWarnEnabled()
|
||||||
{
|
{
|
||||||
return _stdErrLog==null?true:_stdErrLog.getLevel()<=org.eclipse.jetty.util.log.StdErrLog.LEVEL_WARN;
|
return _stdErrLog == null ? true : _stdErrLog.getLevel() <= org.eclipse.jetty.util.log.StdErrLog.LEVEL_WARN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -82,16 +82,16 @@ public class JuliLog implements org.apache.juli.logging.Log
|
||||||
if (message instanceof String)
|
if (message instanceof String)
|
||||||
_logger.debug((String)message);
|
_logger.debug((String)message);
|
||||||
else
|
else
|
||||||
_logger.debug("{}",message);
|
_logger.debug("{}", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void trace(Object message, Throwable t)
|
public void trace(Object message, Throwable t)
|
||||||
{
|
{
|
||||||
if (message instanceof String)
|
if (message instanceof String)
|
||||||
_logger.debug((String)message,t);
|
_logger.debug((String)message, t);
|
||||||
else
|
else
|
||||||
_logger.debug("{}",message,t);
|
_logger.debug("{}", message, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -100,16 +100,16 @@ public class JuliLog implements org.apache.juli.logging.Log
|
||||||
if (message instanceof String)
|
if (message instanceof String)
|
||||||
_logger.debug((String)message);
|
_logger.debug((String)message);
|
||||||
else
|
else
|
||||||
_logger.debug("{}",message);
|
_logger.debug("{}", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void debug(Object message, Throwable t)
|
public void debug(Object message, Throwable t)
|
||||||
{
|
{
|
||||||
if (message instanceof String)
|
if (message instanceof String)
|
||||||
_logger.debug((String)message,t);
|
_logger.debug((String)message, t);
|
||||||
else
|
else
|
||||||
_logger.debug("{}",message,t);
|
_logger.debug("{}", message, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -118,16 +118,16 @@ public class JuliLog implements org.apache.juli.logging.Log
|
||||||
if (message instanceof String)
|
if (message instanceof String)
|
||||||
_logger.info((String)message);
|
_logger.info((String)message);
|
||||||
else
|
else
|
||||||
_logger.info("{}",message);
|
_logger.info("{}", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void info(Object message, Throwable t)
|
public void info(Object message, Throwable t)
|
||||||
{
|
{
|
||||||
if (message instanceof String)
|
if (message instanceof String)
|
||||||
_logger.info((String)message,t);
|
_logger.info((String)message, t);
|
||||||
else
|
else
|
||||||
_logger.info("{}",message,t);
|
_logger.info("{}", message, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -136,16 +136,16 @@ public class JuliLog implements org.apache.juli.logging.Log
|
||||||
if (message instanceof String)
|
if (message instanceof String)
|
||||||
_logger.warn((String)message);
|
_logger.warn((String)message);
|
||||||
else
|
else
|
||||||
_logger.warn("{}",message);
|
_logger.warn("{}", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void warn(Object message, Throwable t)
|
public void warn(Object message, Throwable t)
|
||||||
{
|
{
|
||||||
if (message instanceof String)
|
if (message instanceof String)
|
||||||
_logger.warn((String)message,t);
|
_logger.warn((String)message, t);
|
||||||
else
|
else
|
||||||
_logger.warn("{}",message,t);
|
_logger.warn("{}", message, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -154,16 +154,16 @@ public class JuliLog implements org.apache.juli.logging.Log
|
||||||
if (message instanceof String)
|
if (message instanceof String)
|
||||||
_logger.warn((String)message);
|
_logger.warn((String)message);
|
||||||
else
|
else
|
||||||
_logger.warn("{}",message);
|
_logger.warn("{}", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void error(Object message, Throwable t)
|
public void error(Object message, Throwable t)
|
||||||
{
|
{
|
||||||
if (message instanceof String)
|
if (message instanceof String)
|
||||||
_logger.warn((String)message,t);
|
_logger.warn((String)message, t);
|
||||||
else
|
else
|
||||||
_logger.warn("{}",message,t);
|
_logger.warn("{}", message, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -172,16 +172,16 @@ public class JuliLog implements org.apache.juli.logging.Log
|
||||||
if (message instanceof String)
|
if (message instanceof String)
|
||||||
_logger.warn((String)message);
|
_logger.warn((String)message);
|
||||||
else
|
else
|
||||||
_logger.warn("{}",message);
|
_logger.warn("{}", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fatal(Object message, Throwable t)
|
public void fatal(Object message, Throwable t)
|
||||||
{
|
{
|
||||||
if (message instanceof String)
|
if (message instanceof String)
|
||||||
_logger.warn((String)message,t);
|
_logger.warn((String)message, t);
|
||||||
else
|
else
|
||||||
_logger.warn("{}",message,t);
|
_logger.warn("{}", message, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
import javax.servlet.RequestDispatcher;
|
import javax.servlet.RequestDispatcher;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -30,7 +29,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.jasper.servlet.JspServlet;
|
import org.apache.jasper.servlet.JspServlet;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JettyJspServlet
|
* JettyJspServlet
|
||||||
*
|
*
|
||||||
|
@ -46,10 +44,6 @@ public class JettyJspServlet extends JspServlet
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -5387857473125086791L;
|
private static final long serialVersionUID = -5387857473125086791L;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
|
public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
|
||||||
{
|
{
|
||||||
|
@ -59,16 +53,16 @@ public class JettyJspServlet extends JspServlet
|
||||||
else
|
else
|
||||||
throw new ServletException("Request not HttpServletRequest");
|
throw new ServletException("Request not HttpServletRequest");
|
||||||
|
|
||||||
String servletPath=null;
|
String servletPath = null;
|
||||||
String pathInfo=null;
|
String pathInfo = null;
|
||||||
if (request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI)!=null)
|
if (request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI) != null)
|
||||||
{
|
{
|
||||||
servletPath=(String)request.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH);
|
servletPath = (String)request.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH);
|
||||||
pathInfo=(String)request.getAttribute(RequestDispatcher.INCLUDE_PATH_INFO);
|
pathInfo = (String)request.getAttribute(RequestDispatcher.INCLUDE_PATH_INFO);
|
||||||
if (servletPath==null)
|
if (servletPath == null)
|
||||||
{
|
{
|
||||||
servletPath=request.getServletPath();
|
servletPath = request.getServletPath();
|
||||||
pathInfo=request.getPathInfo();
|
pathInfo = request.getPathInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -77,7 +71,7 @@ public class JettyJspServlet extends JspServlet
|
||||||
pathInfo = request.getPathInfo();
|
pathInfo = request.getPathInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
String pathInContext = addPaths(servletPath,pathInfo);
|
String pathInContext = addPaths(servletPath, pathInfo);
|
||||||
|
|
||||||
String jspFile = getInitParameter("jspFile");
|
String jspFile = getInitParameter("jspFile");
|
||||||
|
|
||||||
|
@ -122,9 +116,9 @@ public class JettyJspServlet extends JspServlet
|
||||||
if (servletPath.isEmpty())
|
if (servletPath.isEmpty())
|
||||||
return pathInfo;
|
return pathInfo;
|
||||||
|
|
||||||
if (pathInfo==null)
|
if (pathInfo == null)
|
||||||
return servletPath;
|
return servletPath;
|
||||||
|
|
||||||
return servletPath+pathInfo;
|
return servletPath + pathInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -72,11 +71,10 @@ public class TestJettyJspServlet
|
||||||
resp.setContentType("html/text");
|
resp.setContentType("html/text");
|
||||||
resp.getOutputStream().println("This.Is.The.Default.");
|
resp.getOutputStream().println("This.Is.The.Default.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp () throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
JspFactory.setDefaultFactory(new JspFactoryImpl());
|
JspFactory.setDefaultFactory(new JspFactoryImpl());
|
||||||
_dir = MavenTestingUtils.getTestResourceDir("base");
|
_dir = MavenTestingUtils.getTestResourceDir("base");
|
||||||
|
@ -88,7 +86,7 @@ public class TestJettyJspServlet
|
||||||
_tester.getContext().setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
|
_tester.getContext().setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
|
||||||
ServletHolder dfltHolder = new ServletHolder();
|
ServletHolder dfltHolder = new ServletHolder();
|
||||||
dfltHolder.setName("default");
|
dfltHolder.setName("default");
|
||||||
dfltHolder.setHeldClass( DfltServlet.class);
|
dfltHolder.setHeldClass(DfltServlet.class);
|
||||||
_tester.getContext().addServlet(dfltHolder, "/");
|
_tester.getContext().addServlet(dfltHolder, "/");
|
||||||
|
|
||||||
_tester.start();
|
_tester.start();
|
||||||
|
@ -105,7 +103,7 @@ public class TestJettyJspServlet
|
||||||
public void testWithJsp() throws Exception
|
public void testWithJsp() throws Exception
|
||||||
{
|
{
|
||||||
//test that an ordinary jsp is served by jsp servlet
|
//test that an ordinary jsp is served by jsp servlet
|
||||||
String request = "" +
|
String request =
|
||||||
"GET /context/foo.jsp HTTP/1.1\r\n" +
|
"GET /context/foo.jsp HTTP/1.1\r\n" +
|
||||||
"Host: localhost\r\n" +
|
"Host: localhost\r\n" +
|
||||||
"Connection: close\r\n" +
|
"Connection: close\r\n" +
|
||||||
|
@ -116,12 +114,11 @@ public class TestJettyJspServlet
|
||||||
assertThat(response.toString(), response.getContent(), not(containsString("This.Is.The.Default.")));
|
assertThat(response.toString(), response.getContent(), not(containsString("This.Is.The.Default.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithDirectory() throws Exception
|
public void testWithDirectory() throws Exception
|
||||||
{
|
{
|
||||||
//test that a dir is served by the default servlet
|
//test that a dir is served by the default servlet
|
||||||
String request = "" +
|
String request =
|
||||||
"GET /context/dir HTTP/1.1\r\n" +
|
"GET /context/dir HTTP/1.1\r\n" +
|
||||||
"Host: localhost\r\n" +
|
"Host: localhost\r\n" +
|
||||||
"Connection: close\r\n" +
|
"Connection: close\r\n" +
|
||||||
|
|
|
@ -16,11 +16,8 @@
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
package org.eclipse.jetty.jsp;
|
package org.eclipse.jetty.jsp;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -34,10 +31,12 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TestJettyTldPreScanned
|
* TestJettyTldPreScanned
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class TestJettyTldPreScanned
|
public class TestJettyTldPreScanned
|
||||||
{
|
{
|
||||||
|
@ -53,15 +52,15 @@ public class TestJettyTldPreScanned
|
||||||
File tld = MavenTestingUtils.getTestResourceFile("META-INF/foo-taglib.tld");
|
File tld = MavenTestingUtils.getTestResourceFile("META-INF/foo-taglib.tld");
|
||||||
|
|
||||||
List<URL> list = new ArrayList<>();
|
List<URL> list = new ArrayList<>();
|
||||||
list.add(new URL("jar:"+jar.toURI().toURL().toString()+"!/META-INF/bar-taglib.tld"));
|
list.add(new URL("jar:" + jar.toURI().toURL().toString() + "!/META-INF/bar-taglib.tld"));
|
||||||
list.add(tld.toURI().toURL());
|
list.add(tld.toURI().toURL());
|
||||||
|
|
||||||
JettyTldPreScanned preScanned = new JettyTldPreScanned(new ServletContextHandler().getServletContext(),false,false,false,list);
|
JettyTldPreScanned preScanned = new JettyTldPreScanned(new ServletContextHandler().getServletContext(), false, false, false, list);
|
||||||
preScanned.scanJars();
|
preScanned.scanJars();
|
||||||
Map<TldResourcePath, TaglibXml> map = preScanned.getTldResourcePathTaglibXmlMap();
|
Map<TldResourcePath, TaglibXml> map = preScanned.getTldResourcePathTaglibXmlMap();
|
||||||
assertNotNull(map);
|
assertNotNull(map);
|
||||||
assertEquals(2, map.size());
|
assertEquals(2, map.size());
|
||||||
for (TldResourcePath p: map.keySet())
|
for (TldResourcePath p : map.keySet())
|
||||||
{
|
{
|
||||||
URL u = p.getUrl();
|
URL u = p.getUrl();
|
||||||
TaglibXml tlx = map.get(p);
|
TaglibXml tlx = map.get(p);
|
||||||
|
@ -70,5 +69,4 @@ public class TestJettyTldPreScanned
|
||||||
fail("unknown tag");
|
fail("unknown tag");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,11 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.jsp;
|
package org.eclipse.jetty.jsp;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
|
|
||||||
import org.eclipse.jetty.servlet.ServletHolder;
|
import org.eclipse.jetty.servlet.ServletHolder;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
public class TestJspFileNameToClass
|
public class TestJspFileNameToClass
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -33,7 +32,6 @@ public class TestJspFileNameToClass
|
||||||
ServletHolder h = new ServletHolder();
|
ServletHolder h = new ServletHolder();
|
||||||
h.setName("test");
|
h.setName("test");
|
||||||
|
|
||||||
|
|
||||||
assertEquals(null, h.getClassNameForJsp(null));
|
assertEquals(null, h.getClassNameForJsp(null));
|
||||||
|
|
||||||
assertEquals(null, h.getClassNameForJsp(""));
|
assertEquals(null, h.getClassNameForJsp(""));
|
||||||
|
@ -56,5 +54,4 @@ public class TestJspFileNameToClass
|
||||||
|
|
||||||
assertEquals("org.apache.jsp.a.b.c.blah_jsp", h.getClassNameForJsp("a/b/c/blah.jsp"));
|
assertEquals("org.apache.jsp.a.b.c.blah_jsp", h.getClassNameForJsp("a/b/c/blah.jsp"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,6 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.jstl;
|
package org.eclipse.jetty.jstl;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.containsString;
|
|
||||||
import static org.hamcrest.Matchers.is;
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -37,7 +33,6 @@ import org.eclipse.jetty.toolchain.test.FS;
|
||||||
import org.eclipse.jetty.toolchain.test.IO;
|
import org.eclipse.jetty.toolchain.test.IO;
|
||||||
import org.eclipse.jetty.toolchain.test.JAR;
|
import org.eclipse.jetty.toolchain.test.JAR;
|
||||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||||
import org.eclipse.jetty.webapp.Configuration;
|
|
||||||
import org.eclipse.jetty.webapp.Configurations;
|
import org.eclipse.jetty.webapp.Configurations;
|
||||||
import org.eclipse.jetty.webapp.JettyWebXmlConfiguration;
|
import org.eclipse.jetty.webapp.JettyWebXmlConfiguration;
|
||||||
import org.eclipse.jetty.webapp.WebAppContext;
|
import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
|
@ -45,6 +40,10 @@ import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
public class JspIncludeTest
|
public class JspIncludeTest
|
||||||
{
|
{
|
||||||
private static Server server;
|
private static Server server;
|
||||||
|
@ -69,7 +68,7 @@ public class JspIncludeTest
|
||||||
JAR.create(testTagLibDir, new File(libDir, "testtaglib.jar"));
|
JAR.create(testTagLibDir, new File(libDir, "testtaglib.jar"));
|
||||||
|
|
||||||
// Configure WebAppContext
|
// Configure WebAppContext
|
||||||
Configurations.setServerDefault(server).add(new JettyWebXmlConfiguration(),new AnnotationConfiguration());
|
Configurations.setServerDefault(server).add(new JettyWebXmlConfiguration(), new AnnotationConfiguration());
|
||||||
|
|
||||||
WebAppContext context = new WebAppContext();
|
WebAppContext context = new WebAppContext();
|
||||||
context.setContextPath("/");
|
context.setContextPath("/");
|
||||||
|
@ -111,7 +110,7 @@ public class JspIncludeTest
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
connection = (HttpURLConnection) uri.toURL().openConnection();
|
connection = (HttpURLConnection)uri.toURL().openConnection();
|
||||||
connection.connect();
|
connection.connect();
|
||||||
if (HttpURLConnection.HTTP_OK != connection.getResponseCode())
|
if (HttpURLConnection.HTTP_OK != connection.getResponseCode())
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,18 +18,12 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.jstl;
|
package org.eclipse.jetty.jstl;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.containsString;
|
|
||||||
import static org.hamcrest.Matchers.is;
|
|
||||||
import static org.hamcrest.Matchers.not;
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import javax.servlet.jsp.JspException;
|
import javax.servlet.jsp.JspException;
|
||||||
|
|
||||||
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
||||||
|
@ -39,12 +33,16 @@ import org.eclipse.jetty.toolchain.test.FS;
|
||||||
import org.eclipse.jetty.toolchain.test.JAR;
|
import org.eclipse.jetty.toolchain.test.JAR;
|
||||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||||
import org.eclipse.jetty.util.IO;
|
import org.eclipse.jetty.util.IO;
|
||||||
import org.eclipse.jetty.webapp.Configuration;
|
|
||||||
import org.eclipse.jetty.webapp.WebAppContext;
|
import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
import org.junit.jupiter.api.AfterAll;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
import static org.hamcrest.Matchers.not;
|
||||||
|
|
||||||
public class JstlTest
|
public class JstlTest
|
||||||
{
|
{
|
||||||
private static Server server;
|
private static Server server;
|
||||||
|
@ -66,7 +64,7 @@ public class JstlTest
|
||||||
File libDir = new File(testWebAppDir, "WEB-INF/lib");
|
File libDir = new File(testWebAppDir, "WEB-INF/lib");
|
||||||
FS.ensureDirExists(libDir);
|
FS.ensureDirExists(libDir);
|
||||||
File testTagLibDir = MavenTestingUtils.getProjectDir("src/test/taglibjar");
|
File testTagLibDir = MavenTestingUtils.getProjectDir("src/test/taglibjar");
|
||||||
JAR.create(testTagLibDir,new File(libDir, "testtaglib.jar"));
|
JAR.create(testTagLibDir, new File(libDir, "testtaglib.jar"));
|
||||||
|
|
||||||
// Configure WebAppCont
|
// Configure WebAppCont
|
||||||
WebAppContext context = new WebAppContext();
|
WebAppContext context = new WebAppContext();
|
||||||
|
@ -74,11 +72,10 @@ public class JstlTest
|
||||||
|
|
||||||
File scratchDir = MavenTestingUtils.getTargetFile("tests/" + JstlTest.class.getSimpleName() + "-scratch");
|
File scratchDir = MavenTestingUtils.getTargetFile("tests/" + JstlTest.class.getSimpleName() + "-scratch");
|
||||||
FS.ensureEmpty(scratchDir);
|
FS.ensureEmpty(scratchDir);
|
||||||
JspConfig.init(context,testWebAppDir.toURI(),scratchDir);
|
JspConfig.init(context, testWebAppDir.toURI(), scratchDir);
|
||||||
|
|
||||||
context.addConfiguration(new AnnotationConfiguration());
|
context.addConfiguration(new AnnotationConfiguration());
|
||||||
|
|
||||||
|
|
||||||
server.setHandler(context);
|
server.setHandler(context);
|
||||||
|
|
||||||
// Start Server
|
// Start Server
|
||||||
|
@ -91,7 +88,7 @@ public class JstlTest
|
||||||
host = "localhost";
|
host = "localhost";
|
||||||
}
|
}
|
||||||
int port = connector.getLocalPort();
|
int port = connector.getLocalPort();
|
||||||
baseUri = new URI(String.format("http://%s:%d/",host,port));
|
baseUri = new URI(String.format("http://%s:%d/", host, port));
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterAll
|
@AfterAll
|
||||||
|
@ -104,9 +101,9 @@ public class JstlTest
|
||||||
@Test
|
@Test
|
||||||
public void testUrlsBasic() throws IOException
|
public void testUrlsBasic() throws IOException
|
||||||
{
|
{
|
||||||
HttpURLConnection http = (HttpURLConnection) baseUri.resolve("/urls.jsp").toURL().openConnection();
|
HttpURLConnection http = (HttpURLConnection)baseUri.resolve("/urls.jsp").toURL().openConnection();
|
||||||
assertThat("http response", http.getResponseCode(), is(200));
|
assertThat("http response", http.getResponseCode(), is(200));
|
||||||
try(InputStream input = http.getInputStream())
|
try (InputStream input = http.getInputStream())
|
||||||
{
|
{
|
||||||
String resp = IO.toString(input, StandardCharsets.UTF_8);
|
String resp = IO.toString(input, StandardCharsets.UTF_8);
|
||||||
assertThat("Response should be JSP processed", resp, not(containsString("<c:url")));
|
assertThat("Response should be JSP processed", resp, not(containsString("<c:url")));
|
||||||
|
@ -118,9 +115,9 @@ public class JstlTest
|
||||||
@Test
|
@Test
|
||||||
public void testCatchBasic() throws IOException
|
public void testCatchBasic() throws IOException
|
||||||
{
|
{
|
||||||
HttpURLConnection http = (HttpURLConnection) baseUri.resolve("/catch-basic.jsp").toURL().openConnection();
|
HttpURLConnection http = (HttpURLConnection)baseUri.resolve("/catch-basic.jsp").toURL().openConnection();
|
||||||
assertThat("http response", http.getResponseCode(), is(200));
|
assertThat("http response", http.getResponseCode(), is(200));
|
||||||
try(InputStream input = http.getInputStream())
|
try (InputStream input = http.getInputStream())
|
||||||
{
|
{
|
||||||
String resp = IO.toString(input, StandardCharsets.UTF_8);
|
String resp = IO.toString(input, StandardCharsets.UTF_8);
|
||||||
assertThat("Response should be JSP processed", resp, not(containsString("<c:catch")));
|
assertThat("Response should be JSP processed", resp, not(containsString("<c:catch")));
|
||||||
|
@ -132,9 +129,9 @@ public class JstlTest
|
||||||
@Test
|
@Test
|
||||||
public void testCatchTaglib() throws IOException
|
public void testCatchTaglib() throws IOException
|
||||||
{
|
{
|
||||||
HttpURLConnection http = (HttpURLConnection) baseUri.resolve("/catch-taglib.jsp").toURL().openConnection();
|
HttpURLConnection http = (HttpURLConnection)baseUri.resolve("/catch-taglib.jsp").toURL().openConnection();
|
||||||
assertThat("http response", http.getResponseCode(), is(200));
|
assertThat("http response", http.getResponseCode(), is(200));
|
||||||
try(InputStream input = http.getInputStream())
|
try (InputStream input = http.getInputStream())
|
||||||
{
|
{
|
||||||
String resp = IO.toString(input, StandardCharsets.UTF_8);
|
String resp = IO.toString(input, StandardCharsets.UTF_8);
|
||||||
assertThat("Response should be JSP processed", resp, not(containsString("<c:catch>")));
|
assertThat("Response should be JSP processed", resp, not(containsString("<c:catch>")));
|
||||||
|
|
|
@ -0,0 +1,354 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<profiles version="16">
|
||||||
|
<profile kind="CodeFormatterProfile" name="Jetty" version="16">
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_logical_operator" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation" value="common_lines"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement" value="common_lines"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration" value="common_lines"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.align_with_spaces" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="1"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement" value="common_lines"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_logical_operator" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line" value="one_line_never"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="next_line"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="128"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_method_body_on_one_line" value="one_line_never"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line" value="one_line_never"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="next_line"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line" value="one_line_never"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line" value="one_line_never"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause" value="common_lines"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_additive_operator" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_relational_operator" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line" value="one_line_never"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_shift_operator" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="next_line"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="next_line"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="next_line"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="18"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_parameters" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_loops" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_relational_operator" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="32"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation" value="common_lines"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_additive_operator" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="80"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_module_statements" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line" value="one_line_never"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="next_line"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="next_line"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain" value="48"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_additive_operator" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_shift_operator" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines" value="2147483647"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="next_line"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="83"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause" value="common_lines"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_code_block_on_one_line" value="one_line_never"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="1"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assignment_operator" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="next_line"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration" value="common_lines"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line" value="one_line_never"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_arguments" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_logical_operator" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_relational_operator" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.indent_tag_description" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="18"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_string_concatenation" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="next_line_on_wrap"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_logical_operator" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_shift_operator" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration" value="common_lines"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_shift_operator" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line" value="one_line_never"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="next_line"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="next_line"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header" value="0"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_additive_operator" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_relational_operator" value="insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_string_concatenation" value="false"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="128"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
|
@ -0,0 +1,531 @@
|
||||||
|
<code_scheme name="Jetty-StyleChecked" version="173">
|
||||||
|
<option name="AUTODETECT_INDENTS" value="false" />
|
||||||
|
<option name="LINE_SEPARATOR" value="
" />
|
||||||
|
<option name="RIGHT_MARGIN" value="128" />
|
||||||
|
<AndroidXmlCodeStyleSettings>
|
||||||
|
<option name="USE_CUSTOM_SETTINGS" value="true" />
|
||||||
|
</AndroidXmlCodeStyleSettings>
|
||||||
|
<HTMLCodeStyleSettings>
|
||||||
|
<option name="HTML_ATTRIBUTE_WRAP" value="0" />
|
||||||
|
</HTMLCodeStyleSettings>
|
||||||
|
<JavaCodeStyleSettings>
|
||||||
|
<option name="FIELD_NAME_PREFIX" value="_" />
|
||||||
|
<option name="USE_EXTERNAL_ANNOTATIONS" value="true" />
|
||||||
|
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
|
||||||
|
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
|
||||||
|
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
|
||||||
|
<value />
|
||||||
|
</option>
|
||||||
|
<option name="IMPORT_LAYOUT_TABLE">
|
||||||
|
<value>
|
||||||
|
<package name="java" withSubpackages="true" static="false" />
|
||||||
|
<package name="javax" withSubpackages="true" static="false" />
|
||||||
|
<emptyLine />
|
||||||
|
<package name="" withSubpackages="true" static="false" />
|
||||||
|
<emptyLine />
|
||||||
|
<package name="" withSubpackages="true" static="true" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="JD_ALIGN_PARAM_COMMENTS" value="false" />
|
||||||
|
<option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false" />
|
||||||
|
<option name="JD_P_AT_EMPTY_LINES" value="false" />
|
||||||
|
<option name="JD_KEEP_EMPTY_PARAMETER" value="false" />
|
||||||
|
<option name="JD_KEEP_EMPTY_EXCEPTION" value="false" />
|
||||||
|
<option name="JD_KEEP_EMPTY_RETURN" value="false" />
|
||||||
|
<option name="JD_PRESERVE_LINE_FEEDS" value="true" />
|
||||||
|
</JavaCodeStyleSettings>
|
||||||
|
<MarkdownNavigatorCodeStyleSettings>
|
||||||
|
<option name="RIGHT_MARGIN" value="72" />
|
||||||
|
</MarkdownNavigatorCodeStyleSettings>
|
||||||
|
<XML>
|
||||||
|
<option name="XML_ATTRIBUTE_WRAP" value="0" />
|
||||||
|
<option name="XML_TEXT_WRAP" value="0" />
|
||||||
|
<option name="XML_KEEP_LINE_BREAKS" value="false" />
|
||||||
|
<option name="XML_KEEP_LINE_BREAKS_IN_TEXT" value="false" />
|
||||||
|
<option name="XML_KEEP_BLANK_LINES" value="1" />
|
||||||
|
<option name="XML_ALIGN_ATTRIBUTES" value="false" />
|
||||||
|
<option name="XML_SPACE_INSIDE_EMPTY_TAG" value="true" />
|
||||||
|
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
||||||
|
</XML>
|
||||||
|
<codeStyleSettings language="Groovy">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="JAVA">
|
||||||
|
<option name="RIGHT_MARGIN" value="128" />
|
||||||
|
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
|
||||||
|
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
|
||||||
|
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
|
||||||
|
<option name="KEEP_BLANK_LINES_BETWEEN_PACKAGE_DECLARATION_AND_HEADER" value="1" />
|
||||||
|
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
|
||||||
|
<option name="BRACE_STYLE" value="2" />
|
||||||
|
<option name="CLASS_BRACE_STYLE" value="2" />
|
||||||
|
<option name="METHOD_BRACE_STYLE" value="2" />
|
||||||
|
<option name="LAMBDA_BRACE_STYLE" value="2" />
|
||||||
|
<option name="ELSE_ON_NEW_LINE" value="true" />
|
||||||
|
<option name="WHILE_ON_NEW_LINE" value="true" />
|
||||||
|
<option name="CATCH_ON_NEW_LINE" value="true" />
|
||||||
|
<option name="FINALLY_ON_NEW_LINE" value="true" />
|
||||||
|
<option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
|
||||||
|
<option name="SPACE_AFTER_TYPE_CAST" value="false" />
|
||||||
|
<option name="RESOURCE_LIST_WRAP" value="2" />
|
||||||
|
<option name="KEEP_SIMPLE_LAMBDAS_IN_ONE_LINE" value="true" />
|
||||||
|
<option name="KEEP_SIMPLE_CLASSES_IN_ONE_LINE" value="true" />
|
||||||
|
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
|
||||||
|
<option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
|
||||||
|
<option name="ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE" value="true" />
|
||||||
|
<option name="DOWHILE_BRACE_FORCE" value="3" />
|
||||||
|
<option name="WHILE_BRACE_FORCE" value="3" />
|
||||||
|
<option name="FOR_BRACE_FORCE" value="3" />
|
||||||
|
<indentOptions>
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
</indentOptions>
|
||||||
|
<arrangement>
|
||||||
|
<rules>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<ENUM>true</ENUM>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<FIELD>true</FIELD>
|
||||||
|
<FINAL>true</FINAL>
|
||||||
|
<PUBLIC>true</PUBLIC>
|
||||||
|
<STATIC>true</STATIC>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<FIELD>true</FIELD>
|
||||||
|
<FINAL>true</FINAL>
|
||||||
|
<PROTECTED>true</PROTECTED>
|
||||||
|
<STATIC>true</STATIC>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<FIELD>true</FIELD>
|
||||||
|
<FINAL>true</FINAL>
|
||||||
|
<PACKAGE_PRIVATE>true</PACKAGE_PRIVATE>
|
||||||
|
<STATIC>true</STATIC>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<FIELD>true</FIELD>
|
||||||
|
<FINAL>true</FINAL>
|
||||||
|
<PRIVATE>true</PRIVATE>
|
||||||
|
<STATIC>true</STATIC>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<FIELD>true</FIELD>
|
||||||
|
<PUBLIC>true</PUBLIC>
|
||||||
|
<STATIC>true</STATIC>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<FIELD>true</FIELD>
|
||||||
|
<PROTECTED>true</PROTECTED>
|
||||||
|
<STATIC>true</STATIC>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<FIELD>true</FIELD>
|
||||||
|
<PACKAGE_PRIVATE>true</PACKAGE_PRIVATE>
|
||||||
|
<STATIC>true</STATIC>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<FIELD>true</FIELD>
|
||||||
|
<PRIVATE>true</PRIVATE>
|
||||||
|
<STATIC>true</STATIC>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<INITIALIZER_BLOCK>true</INITIALIZER_BLOCK>
|
||||||
|
<STATIC>true</STATIC>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<FIELD>true</FIELD>
|
||||||
|
<FINAL>true</FINAL>
|
||||||
|
<PUBLIC>true</PUBLIC>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<FIELD>true</FIELD>
|
||||||
|
<FINAL>true</FINAL>
|
||||||
|
<PROTECTED>true</PROTECTED>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<FIELD>true</FIELD>
|
||||||
|
<FINAL>true</FINAL>
|
||||||
|
<PACKAGE_PRIVATE>true</PACKAGE_PRIVATE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<FIELD>true</FIELD>
|
||||||
|
<FINAL>true</FINAL>
|
||||||
|
<PRIVATE>true</PRIVATE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<FIELD>true</FIELD>
|
||||||
|
<PUBLIC>true</PUBLIC>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<FIELD>true</FIELD>
|
||||||
|
<PROTECTED>true</PROTECTED>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<FIELD>true</FIELD>
|
||||||
|
<PACKAGE_PRIVATE>true</PACKAGE_PRIVATE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<FIELD>true</FIELD>
|
||||||
|
<PRIVATE>true</PRIVATE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<FIELD>true</FIELD>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<INITIALIZER_BLOCK>true</INITIALIZER_BLOCK>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<CONSTRUCTOR>true</CONSTRUCTOR>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<METHOD>true</METHOD>
|
||||||
|
<STATIC>true</STATIC>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<METHOD>true</METHOD>
|
||||||
|
<PUBLIC>true</PUBLIC>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<METHOD>true</METHOD>
|
||||||
|
<PROTECTED>true</PROTECTED>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<METHOD>true</METHOD>
|
||||||
|
<PRIVATE>true</PRIVATE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<INTERFACE>true</INTERFACE>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<CLASS>true</CLASS>
|
||||||
|
<STATIC>true</STATIC>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<CLASS>true</CLASS>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
</rules>
|
||||||
|
</arrangement>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="XML">
|
||||||
|
<option name="RIGHT_MARGIN" value="256" />
|
||||||
|
<option name="FORCE_REARRANGE_MODE" value="1" />
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
</indentOptions>
|
||||||
|
<arrangement>
|
||||||
|
<rules>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>xmlns:android</NAME>
|
||||||
|
<XML_NAMESPACE>Namespace:</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>xmlns:.*</NAME>
|
||||||
|
<XML_NAMESPACE>Namespace:</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:id</NAME>
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:name</NAME>
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>name</NAME>
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>style</NAME>
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:layout_width</NAME>
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:layout_height</NAME>
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:layout_.*</NAME>
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:width</NAME>
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:height</NAME>
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
</rules>
|
||||||
|
</arrangement>
|
||||||
|
</codeStyleSettings>
|
||||||
|
</code_scheme>
|
|
@ -0,0 +1,28 @@
|
||||||
|
<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</groupId>
|
||||||
|
<artifactId>jetty-project</artifactId>
|
||||||
|
<version>10.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>build-resources</artifactId>
|
||||||
|
<version>10.0.0-SNAPSHOT</version>
|
||||||
|
<name>Jetty :: Build Resources</name>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
|
<version>2.8.2</version>
|
||||||
|
<configuration>
|
||||||
|
<!-- we would prefer not deploy it but we need as it's not discovered as part of reactor
|
||||||
|
as it's a dependency of a plugin
|
||||||
|
<skip>true</skip>
|
||||||
|
-->
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,291 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE module PUBLIC
|
||||||
|
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||||
|
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Checkstyle configuration that checks the Jetty coding conventions.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<module name = "Checker">
|
||||||
|
<property name="charset" value="UTF-8"/>
|
||||||
|
|
||||||
|
<property name="severity" value="warning"/>
|
||||||
|
|
||||||
|
<property name="fileExtensions" value="java"/>
|
||||||
|
|
||||||
|
<!-- reference to suppressions filter for both eclipse and intellij checkstyle plugins -->
|
||||||
|
<module name="SuppressionFilter">
|
||||||
|
<property name="file" value="${checkstyle.suppressions.file}"/>
|
||||||
|
<property name="optional" value="true"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Excludes all 'module-info.java' files -->
|
||||||
|
<!-- See https://checkstyle.org/config_filefilters.html -->
|
||||||
|
<module name="BeforeExecutionExclusionFileFilter">
|
||||||
|
<property name="fileNamePattern" value="module\-info\.java$"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Checks for whitespace -->
|
||||||
|
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
|
||||||
|
<module name="FileTabCharacter">
|
||||||
|
<property name="eachLine" value="true"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<module name="TreeWalker">
|
||||||
|
<!--
|
||||||
|
Eclipse Jetty Specific.
|
||||||
|
===========================================================================================
|
||||||
|
-->
|
||||||
|
|
||||||
|
<module name="SuppressionCommentFilter">
|
||||||
|
<property name="offCommentFormat" value="@checkstyle-disable-check : ([\w\|]+)"/>
|
||||||
|
<property name="onCommentFormat" value="@checkstyle-enable-check : ([\w\|]+)"/>
|
||||||
|
<property name="checkFormat" value="$1"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Check abbreviations(consecutive capital letters) length in identifier name -->
|
||||||
|
<module name="AbbreviationAsWordInName">
|
||||||
|
<property name="ignoreFinal" value="true"/>
|
||||||
|
<property name="allowedAbbreviations" value="ALPN, ASCII, AWT, CRLDP, CRLF, FCGI, GZIP, HTTP, HTTPS, ID, IP, ISO8859, JAAS, JDBC, JMXRMI, JNDI, JPMS, JSON, JSTL, LDAP, PROXY, RFC, SPNEGO, URI, URL, UTF8, XML"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Location of Annotations -->
|
||||||
|
<module name="AnnotationLocation">
|
||||||
|
<property name="allowSamelineSingleParameterlessAnnotation" value="false"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Catch Parameter Name Format -->
|
||||||
|
<module name="CatchParameterName">
|
||||||
|
<property name="format" value="^(e|t|x|ex|th|e2|[a-z][a-z][a-zA-Z0-9]+)$"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Class Type Parameter Name Format -->
|
||||||
|
<module name="ClassTypeParameterName">
|
||||||
|
<property name="format" value="^[A-Z][A-Z0-9]*$"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Import Line Ordering -->
|
||||||
|
<module name="CustomImportOrder">
|
||||||
|
<property name="sortImportsInGroupAlphabetically" value="true"/>
|
||||||
|
<property name="separateLineBetweenGroups" value="true"/>
|
||||||
|
<property name="customImportOrderRules" value="STANDARD_JAVA_PACKAGE###THIRD_PARTY_PACKAGE###STATIC"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- do not allow empty blocks in: try, finally, if, else, or switch -->
|
||||||
|
<module name="EmptyBlock">
|
||||||
|
<property name="option" value="TEXT"/>
|
||||||
|
<property name="tokens"
|
||||||
|
value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- enforce empty line after specified tokens -->
|
||||||
|
<module name="EmptyLineSeparator">
|
||||||
|
<property name="allowNoEmptyLineBetweenFields" value="true"/>
|
||||||
|
<property name="allowMultipleEmptyLines" value="false"/>
|
||||||
|
<property name="tokens"
|
||||||
|
value="PACKAGE_DEF, IMPORT, STATIC_IMPORT, CLASS_DEF, INTERFACE_DEF, ENUM_DEF,
|
||||||
|
STATIC_INIT, INSTANCE_INIT, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Indentation Rules -->
|
||||||
|
<module name="Indentation">
|
||||||
|
<property name="throwsIndent" value="0"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Interface Type Parameter Name -->
|
||||||
|
<module name="InterfaceTypeParameterName">
|
||||||
|
<property name="format" value="^[A-Z][A-Z0-9]*$"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- left curly brace must be on new line -->
|
||||||
|
<module name="LeftCurly">
|
||||||
|
<property name="option" value="nl"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Method Type Parameter Name -->
|
||||||
|
<module name="MethodTypeParameterName">
|
||||||
|
<property name="format" value="^[A-Z][A-Z0-9]*$"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Member Name Format -->
|
||||||
|
<module name="MemberName">
|
||||||
|
<property name="format" value="^[_a-z][a-zA-Z0-9]*$"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- require braces is disabled - we don't enforce that in Jetty
|
||||||
|
<module name="NeedBraces">
|
||||||
|
<property name="allowSingleLineStatement" value="true"/>
|
||||||
|
</module>
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- No Whitespace After specific tokens -->
|
||||||
|
<module name="NoWhitespaceAfter">
|
||||||
|
<property name="tokens" value="ARRAY_INIT, AT, INC, DEC, UNARY_MINUS, UNARY_PLUS, BNOT, LNOT, DOT, ARRAY_DECLARATOR, INDEX_OP, TYPECAST"/>
|
||||||
|
<property name="allowLineBreaks" value="true"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- No Whitespace Before specific tokens -->
|
||||||
|
<module name="NoWhitespaceBefore">
|
||||||
|
<property name="tokens"
|
||||||
|
value="COMMA, SEMI, POST_INC, POST_DEC, DOT, ELLIPSIS, METHOD_REF"/>
|
||||||
|
<property name="allowLineBreaks" value="true"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- allowed wrapping for operators -->
|
||||||
|
<module name="OperatorWrap">
|
||||||
|
<property name="id" value="OperatorWrapNextLine"/>
|
||||||
|
<property name="tokens" value="QUESTION, COLON"/>
|
||||||
|
<property name="option" value="nl"/>
|
||||||
|
</module>
|
||||||
|
<module name="OperatorWrap">
|
||||||
|
<property name="id" value="OperatorWrapSameLine"/>
|
||||||
|
<property name="tokens" value="EQUAL, NOT_EQUAL, DIV, PLUS, MINUS, STAR, MOD, SR, BSR, GE, GT, SL, LE, LT, BXOR, BOR, LOR, BAND, LAND, TYPE_EXTENSION_AND, LITERAL_INSTANCEOF"/>
|
||||||
|
<property name="option" value="eol"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- ensure we don't have legacy comments that confuse javadoc tooling -->
|
||||||
|
<module name="Regexp">
|
||||||
|
<property name="id" value="LegacyMethodSeparators"/>
|
||||||
|
<property name="format" value="/\*\s*[=*-]*\s*\*/"/>
|
||||||
|
<property name="illegalPattern" value="true"/>
|
||||||
|
<property name="ignoreComments" value="false"/>
|
||||||
|
<property name="message" value="Legacy Method Separators"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- right curly brace must be on new line -->
|
||||||
|
<module name="RightCurly">
|
||||||
|
<property name="option" value="alone_or_singleline"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Various Wrapping of ".", ",", "...", "[]", and method ref New Lines -->
|
||||||
|
<module name="SeparatorWrap">
|
||||||
|
<property name="id" value="SeparatorWrapNextLine"/>
|
||||||
|
<property name="tokens" value="DOT"/>
|
||||||
|
<property name="option" value="nl"/>
|
||||||
|
</module>
|
||||||
|
<module name="SeparatorWrap">
|
||||||
|
<property name="id" value="SeparatorWrapSameLine"/>
|
||||||
|
<property name="tokens" value="COMMA, ELLIPSIS, ARRAY_DECLARATOR, METHOD_REF"/>
|
||||||
|
<property name="option" value="eol"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- checks that a token is followed by whitespace -->
|
||||||
|
<module name="WhitespaceAround">
|
||||||
|
<property name="allowEmptyConstructors" value="true"/>
|
||||||
|
<property name="allowEmptyLambdas" value="true"/>
|
||||||
|
<property name="allowEmptyMethods" value="true"/>
|
||||||
|
<property name="allowEmptyTypes" value="true"/>
|
||||||
|
<property name="allowEmptyLoops" value="true"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Checks based on common Open Source specific recommendations.
|
||||||
|
===========================================================================================
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- limit use of unicode escape sequences (eg "\u20ac") in mainline code. -->
|
||||||
|
<module name="AvoidEscapedUnicodeCharacters">
|
||||||
|
<!-- allow control characters to use unicode escape sequences -->
|
||||||
|
<property name="allowEscapesForControlCharacters" value="true"/>
|
||||||
|
<!-- allow unicode escape sequences if also followed by tail comments -->
|
||||||
|
<property name="allowByTailComment" value="true"/>
|
||||||
|
<!-- allow use of non-printable escape sequences -->
|
||||||
|
<property name="allowNonPrintableEscapes" value="true"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- not allowing star import lines -->
|
||||||
|
<module name="AvoidStarImport"/>
|
||||||
|
|
||||||
|
<!-- if you have an empty catch block, name the caught exception "ignored" -->
|
||||||
|
<module name="EmptyCatchBlock">
|
||||||
|
<property name="exceptionVariableName" value="ignored"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- if a switch statement contains java code, but lacks fall through comment its an error -->
|
||||||
|
<module name="FallThrough"/>
|
||||||
|
|
||||||
|
<!-- reject unicode or octal values in mainline code -->
|
||||||
|
<module name="IllegalTokenText">
|
||||||
|
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
|
||||||
|
<property name="format"
|
||||||
|
value="\\u00(09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
|
||||||
|
<property name="message"
|
||||||
|
value="Consider using special escape sequence instead of octal value or Unicode escaped value."/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- all switch statements should have "default" label declared -->
|
||||||
|
<module name="MissingSwitchDefault"/>
|
||||||
|
|
||||||
|
<!-- prevent line wrapping of import / package statements -->
|
||||||
|
<module name="NoLineWrap"/>
|
||||||
|
|
||||||
|
<!-- only 1 top level class defined per java file -->
|
||||||
|
<module name="OneTopLevelClass"/>
|
||||||
|
|
||||||
|
<!-- Filename and Classname match -->
|
||||||
|
<module name="OuterTypeFilename"/>
|
||||||
|
|
||||||
|
<!-- Checks that overload methods are grouped together -->
|
||||||
|
<module name="OverloadMethodsDeclarationOrder"/>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Checks based on the Java Language Specification recommendations.
|
||||||
|
https://docs.oracle.com/javase/specs/jls/se8/html/index.html
|
||||||
|
===========================================================================================
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- array type style -->
|
||||||
|
<!-- int[] foo; // OK
|
||||||
|
int foo[]; // BAD -->
|
||||||
|
<module name="ArrayTypeStyle" />
|
||||||
|
|
||||||
|
<!-- Whitespace around Generics (angle brackets) follow convention -->
|
||||||
|
<module name="GenericWhitespace" />
|
||||||
|
|
||||||
|
<!-- Lambda Parameter Name Format -->
|
||||||
|
<module name="LambdaParameterName" />
|
||||||
|
|
||||||
|
<!-- Local Parameter Name Format -->
|
||||||
|
<module name="LocalVariableName" />
|
||||||
|
|
||||||
|
<!-- Method Name Format -->
|
||||||
|
<module name="MethodName" />
|
||||||
|
|
||||||
|
<!-- Checks the padding between the identifier of a method definition, constructor definition,
|
||||||
|
method call, or constructor invocation: nospace -->
|
||||||
|
<module name="MethodParamPad"/>
|
||||||
|
|
||||||
|
<!-- ensure that modifiers follow suggested order -->
|
||||||
|
<module name="ModifierOrder"/>
|
||||||
|
|
||||||
|
<!-- only 1 variable declaration per line -->
|
||||||
|
<module name="MultipleVariableDeclarations"/>
|
||||||
|
|
||||||
|
<!-- No Object.finalize() use -->
|
||||||
|
<module name="NoFinalizer"/>
|
||||||
|
|
||||||
|
<!-- checks that there is only one statement per line -->
|
||||||
|
<module name="OneStatementPerLine"/>
|
||||||
|
|
||||||
|
<!-- package name JLS rules -->
|
||||||
|
<module name="PackageName" />
|
||||||
|
|
||||||
|
<!-- Parameter Name Format -->
|
||||||
|
<module name="ParameterName" />
|
||||||
|
|
||||||
|
<!-- the policy on the padding of parentheses: nospace -->
|
||||||
|
<module name="ParenPad"/>
|
||||||
|
|
||||||
|
<!-- Type Name format -->
|
||||||
|
<module name="TypeName" />
|
||||||
|
|
||||||
|
<!-- checks that long constants are defined with an upper ell. That is 'L' and not 'l' -->
|
||||||
|
<module name="UpperEll"/>
|
||||||
|
<!-- TODO: look for float / double version of above -->
|
||||||
|
|
||||||
|
<!-- Checks the distance between declaration of variable and its first usage -->
|
||||||
|
<module name="VariableDeclarationUsageDistance"/>
|
||||||
|
|
||||||
|
</module>
|
||||||
|
</module>
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<!DOCTYPE suppressions PUBLIC
|
||||||
|
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
|
||||||
|
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
|
||||||
|
|
||||||
|
<suppressions>
|
||||||
|
<!-- all /target/ directories -->
|
||||||
|
<suppress checks=".*" files="[/\\]target[/\\]generated-sources[/\\]" />
|
||||||
|
|
||||||
|
<!-- General JUnit Test Cases -->
|
||||||
|
<suppress checks="AbbreviationAsWordInNameCheck"
|
||||||
|
files="[/\\]src[/\\]test[/\\]java[/\\]" />
|
||||||
|
<suppress checks="AvoidEscapedUnicodeCharactersCheck"
|
||||||
|
files="[/\\]src[/\\]test[/\\]java[/\\]" />
|
||||||
|
<suppress checks="LocalVariableNameCheck"
|
||||||
|
files="[/\\]src[/\\]test[/\\]java[/\\]" />
|
||||||
|
<suppress checks="MethodNameCheck"
|
||||||
|
files="[/\\]src[/\\]test[/\\]java[/\\]" />
|
||||||
|
<suppress checks="TypeNameCheck"
|
||||||
|
files="[/\\]src[/\\]test[/\\]java[/\\]" />
|
||||||
|
|
||||||
|
<!-- jetty-jmh specific -->
|
||||||
|
<suppress checks="AbbreviationAsWordInNameCheck"
|
||||||
|
files="[/\\]jetty-jmh[/\\]src[/\\]main[/\\]java[/\\]" />
|
||||||
|
<suppress checks="AvoidEscapedUnicodeCharactersCheck"
|
||||||
|
files="[/\\]jetty-jmh[/\\]src[/\\]main[/\\]java[/\\]" />
|
||||||
|
<suppress checks="LocalVariableNameCheck"
|
||||||
|
files="[/\\]jetty-jmh[/\\]src[/\\]main[/\\]java[/\\]" />
|
||||||
|
<suppress checks="MethodNameCheck"
|
||||||
|
files="[/\\]jetty-jmh[/\\]src[/\\]main[/\\]java[/\\]" />
|
||||||
|
<suppress checks="TypeNameCheck"
|
||||||
|
files="[/\\]jetty-jmh[/\\]src[/\\]main[/\\]java[/\\]" />
|
||||||
|
|
||||||
|
</suppressions>
|
|
@ -1,5 +1,4 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>example-async-rest</artifactId>
|
<artifactId>example-async-rest</artifactId>
|
||||||
|
|
|
@ -24,7 +24,6 @@ import java.math.RoundingMode;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
import javax.servlet.ServletConfig;
|
import javax.servlet.ServletConfig;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
|
@ -43,18 +42,18 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
*/
|
*/
|
||||||
public class AbstractRestServlet extends HttpServlet
|
public class AbstractRestServlet extends HttpServlet
|
||||||
{
|
{
|
||||||
protected final static String __DEFAULT_APPID = "Webtide81-adf4-4f0a-ad58-d91e41bbe85";
|
protected static final String __DEFAULT_APPID = "Webtide81-adf4-4f0a-ad58-d91e41bbe85";
|
||||||
protected final static String STYLE =
|
protected static final String STYLE =
|
||||||
"<style type='text/css'>"+
|
"<style type='text/css'>" +
|
||||||
" img.thumb:hover {height:50px}"+
|
" img.thumb:hover {height:50px}" +
|
||||||
" img.thumb {vertical-align:text-top}"+
|
" img.thumb {vertical-align:text-top}" +
|
||||||
" span.red {color: #ff0000}"+
|
" span.red {color: #ff0000}" +
|
||||||
" span.green {color: #00ff00}"+
|
" span.green {color: #00ff00}" +
|
||||||
" iframe {border: 0px}"+
|
" iframe {border: 0px}" +
|
||||||
"</style>";
|
"</style>";
|
||||||
|
|
||||||
protected final static String ITEMS_PARAM = "items";
|
protected static final String ITEMS_PARAM = "items";
|
||||||
protected final static String APPID_PARAM = "appid";
|
protected static final String APPID_PARAM = "appid";
|
||||||
|
|
||||||
protected String _appid;
|
protected String _appid;
|
||||||
|
|
||||||
|
@ -67,12 +66,25 @@ public class AbstractRestServlet extends HttpServlet
|
||||||
_appid = servletConfig.getInitParameter(APPID_PARAM);
|
_appid = servletConfig.getInitParameter(APPID_PARAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: consider using StringUtil.sanitizeFileSystemName instead of this?
|
||||||
public static String sanitize(String s)
|
// might introduce jetty-util dependency though
|
||||||
|
public static String sanitize(String str)
|
||||||
{
|
{
|
||||||
if (s==null)
|
if (str == null)
|
||||||
return null;
|
return null;
|
||||||
return s.replace("<","?").replace("&","?").replace("\n","?");
|
|
||||||
|
char[] chars = str.toCharArray();
|
||||||
|
int len = chars.length;
|
||||||
|
for (int i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
char c = chars[i];
|
||||||
|
if ((c <= 0x1F) || // control characters
|
||||||
|
(c == '<') || (c == '&'))
|
||||||
|
{
|
||||||
|
chars[i] = '?';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return String.valueOf(chars);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String restURL(String item)
|
protected String restURL(String item)
|
||||||
|
@ -81,15 +93,15 @@ public class AbstractRestServlet extends HttpServlet
|
||||||
{
|
{
|
||||||
return ("http://open.api.ebay.com/shopping?MaxEntries=3&appid=" + _appid +
|
return ("http://open.api.ebay.com/shopping?MaxEntries=3&appid=" + _appid +
|
||||||
"&version=573&siteid=0&callname=FindItems&responseencoding=JSON&QueryKeywords=" +
|
"&version=573&siteid=0&callname=FindItems&responseencoding=JSON&QueryKeywords=" +
|
||||||
URLEncoder.encode(item,"UTF-8"));
|
URLEncoder.encode(item, "UTF-8"));
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String generateThumbs(Queue<Map<String,String>> results)
|
protected String generateThumbs(Queue<Map<String, String>> results)
|
||||||
{
|
{
|
||||||
StringBuilder thumbs = new StringBuilder();
|
StringBuilder thumbs = new StringBuilder();
|
||||||
for (Map<String, String> m : results)
|
for (Map<String, String> m : results)
|
||||||
|
@ -97,10 +109,10 @@ public class AbstractRestServlet extends HttpServlet
|
||||||
if (!m.containsKey("GalleryURL"))
|
if (!m.containsKey("GalleryURL"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
thumbs.append("<a href=\""+m.get("ViewItemURLForNaturalSearch")+"\">");
|
thumbs.append("<a href=\"" + m.get("ViewItemURLForNaturalSearch") + "\">");
|
||||||
thumbs.append("<img class='thumb' border='1px' height='25px'"+
|
thumbs.append("<img class='thumb' border='1px' height='25px'" +
|
||||||
" src='"+m.get("GalleryURL")+"'"+
|
" src='" + m.get("GalleryURL") + "'" +
|
||||||
" title='"+m.get("Title")+"'"+
|
" title='" + m.get("Title") + "'" +
|
||||||
"/>");
|
"/>");
|
||||||
thumbs.append("</a> ");
|
thumbs.append("</a> ");
|
||||||
}
|
}
|
||||||
|
@ -110,14 +122,14 @@ public class AbstractRestServlet extends HttpServlet
|
||||||
protected String ms(long nano)
|
protected String ms(long nano)
|
||||||
{
|
{
|
||||||
BigDecimal dec = new BigDecimal(nano);
|
BigDecimal dec = new BigDecimal(nano);
|
||||||
return dec.divide(new BigDecimal(1000000L)).setScale(1,RoundingMode.UP).toString();
|
return dec.divide(new BigDecimal(1000000L)).setScale(1, RoundingMode.UP).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int width(long nano)
|
protected int width(long nano)
|
||||||
{
|
{
|
||||||
int w=(int)((nano+999999L)/5000000L);
|
int w = (int)((nano + 999999L) / 5000000L);
|
||||||
if (w==0)
|
if (w == 0)
|
||||||
w=2;
|
w = 2;
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,5 +138,4 @@ public class AbstractRestServlet extends HttpServlet
|
||||||
{
|
{
|
||||||
doGet(request, response);
|
doGet(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ import java.util.Map;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import javax.servlet.AsyncContext;
|
import javax.servlet.AsyncContext;
|
||||||
import javax.servlet.ServletConfig;
|
import javax.servlet.ServletConfig;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
|
@ -52,9 +51,9 @@ import org.eclipse.jetty.util.ajax.JSON;
|
||||||
*/
|
*/
|
||||||
public class AsyncRestServlet extends AbstractRestServlet
|
public class AsyncRestServlet extends AbstractRestServlet
|
||||||
{
|
{
|
||||||
final static String RESULTS_ATTR = "org.eclipse.jetty.demo.client";
|
static final String RESULTS_ATTR = "org.eclipse.jetty.demo.client";
|
||||||
final static String DURATION_ATTR = "org.eclipse.jetty.demo.duration";
|
static final String DURATION_ATTR = "org.eclipse.jetty.demo.duration";
|
||||||
final static String START_ATTR = "org.eclispe.jetty.demo.start";
|
static final String START_ATTR = "org.eclispe.jetty.demo.start";
|
||||||
|
|
||||||
HttpClient _client;
|
HttpClient _client;
|
||||||
|
|
||||||
|
@ -78,17 +77,17 @@ public class AsyncRestServlet extends AbstractRestServlet
|
||||||
@Override
|
@Override
|
||||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
||||||
{
|
{
|
||||||
Long start=System.nanoTime();
|
Long start = System.nanoTime();
|
||||||
|
|
||||||
// Do we have results yet?
|
// Do we have results yet?
|
||||||
Queue<Map<String, String>> results = (Queue<Map<String, String>>) request.getAttribute(RESULTS_ATTR);
|
Queue<Map<String, String>> results = (Queue<Map<String, String>>)request.getAttribute(RESULTS_ATTR);
|
||||||
|
|
||||||
// If no results, this must be the first dispatch, so send the REST request(s)
|
// If no results, this must be the first dispatch, so send the REST request(s)
|
||||||
if (results==null)
|
if (results == null)
|
||||||
{
|
{
|
||||||
// define results data structures
|
// define results data structures
|
||||||
final Queue<Map<String, String>> resultsQueue = new ConcurrentLinkedQueue<>();
|
final Queue<Map<String, String>> resultsQueue = new ConcurrentLinkedQueue<>();
|
||||||
request.setAttribute(RESULTS_ATTR, results=resultsQueue);
|
request.setAttribute(RESULTS_ATTR, results = resultsQueue);
|
||||||
|
|
||||||
// suspend the request
|
// suspend the request
|
||||||
// This is done before scheduling async handling to avoid race of
|
// This is done before scheduling async handling to avoid race of
|
||||||
|
@ -97,24 +96,25 @@ public class AsyncRestServlet extends AbstractRestServlet
|
||||||
async.setTimeout(30000);
|
async.setTimeout(30000);
|
||||||
|
|
||||||
// extract keywords to search for
|
// extract keywords to search for
|
||||||
String[] keywords=sanitize(request.getParameter(ITEMS_PARAM)).split(",");
|
String[] keywords = sanitize(request.getParameter(ITEMS_PARAM)).split(",");
|
||||||
final AtomicInteger outstanding=new AtomicInteger(keywords.length);
|
final AtomicInteger outstanding = new AtomicInteger(keywords.length);
|
||||||
|
|
||||||
// Send request each keyword
|
// Send request each keyword
|
||||||
for (final String item:keywords)
|
for (final String item : keywords)
|
||||||
{
|
{
|
||||||
_client.newRequest(restURL(item)).method(HttpMethod.GET).send(
|
_client.newRequest(restURL(item)).method(HttpMethod.GET).send(
|
||||||
new AsyncRestRequest()
|
new AsyncRestRequest()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
void onAuctionFound(Map<String,String> auction)
|
void onAuctionFound(Map<String, String> auction)
|
||||||
{
|
{
|
||||||
resultsQueue.add(auction);
|
resultsQueue.add(auction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void onComplete()
|
void onComplete()
|
||||||
{
|
{
|
||||||
if (outstanding.decrementAndGet()<=0)
|
if (outstanding.decrementAndGet() <= 0)
|
||||||
async.dispatch();
|
async.dispatch();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -130,7 +130,7 @@ public class AsyncRestServlet extends AbstractRestServlet
|
||||||
// We have results!
|
// We have results!
|
||||||
|
|
||||||
// Generate the response
|
// Generate the response
|
||||||
String thumbs = generateThumbs(results);
|
final String thumbs = generateThumbs(results);
|
||||||
|
|
||||||
response.setContentType("text/html");
|
response.setContentType("text/html");
|
||||||
PrintWriter out = response.getWriter();
|
PrintWriter out = response.getWriter();
|
||||||
|
@ -138,23 +138,23 @@ public class AsyncRestServlet extends AbstractRestServlet
|
||||||
out.println(STYLE);
|
out.println(STYLE);
|
||||||
out.println("</head><body><small>");
|
out.println("</head><body><small>");
|
||||||
|
|
||||||
long initial = (Long) request.getAttribute(DURATION_ATTR);
|
long initial = (Long)request.getAttribute(DURATION_ATTR);
|
||||||
long start0 = (Long) request.getAttribute(START_ATTR);
|
long start0 = (Long)request.getAttribute(START_ATTR);
|
||||||
|
|
||||||
long now = System.nanoTime();
|
long now = System.nanoTime();
|
||||||
long total=now-start0;
|
long total = now - start0;
|
||||||
long generate=now-start;
|
long generate = now - start;
|
||||||
long thread=initial+generate;
|
long thread = initial + generate;
|
||||||
|
|
||||||
out.print("<b>Asynchronous: "+sanitize(request.getParameter(ITEMS_PARAM))+"</b><br/>");
|
out.print("<b>Asynchronous: " + sanitize(request.getParameter(ITEMS_PARAM)) + "</b><br/>");
|
||||||
out.print("Total Time: "+ms(total)+"ms<br/>");
|
out.print("Total Time: " + ms(total) + "ms<br/>");
|
||||||
|
|
||||||
out.print("Thread held (<span class='red'>red</span>): "+ms(thread)+"ms (" + ms(initial) + " initial + " + ms(generate) + " generate )<br/>");
|
out.print("Thread held (<span class='red'>red</span>): " + ms(thread) + "ms (" + ms(initial) + " initial + " + ms(generate) + " generate )<br/>");
|
||||||
out.print("Async wait (<span class='green'>green</span>): "+ms(total-thread)+"ms<br/>");
|
out.print("Async wait (<span class='green'>green</span>): " + ms(total - thread) + "ms<br/>");
|
||||||
|
|
||||||
out.println("<img border='0px' src='asyncrest/red.png' height='20px' width='"+width(initial)+"px'>"+
|
out.println("<img border='0px' src='asyncrest/red.png' height='20px' width='" + width(initial) + "px'>" +
|
||||||
"<img border='0px' src='asyncrest/green.png' height='20px' width='"+width(total-thread)+"px'>"+
|
"<img border='0px' src='asyncrest/green.png' height='20px' width='" + width(total - thread) + "px'>" +
|
||||||
"<img border='0px' src='asyncrest/red.png' height='20px' width='"+width(generate)+"px'>");
|
"<img border='0px' src='asyncrest/red.png' height='20px' width='" + width(generate) + "px'>");
|
||||||
|
|
||||||
out.println("<hr />");
|
out.println("<hr />");
|
||||||
out.println(thumbs);
|
out.println(thumbs);
|
||||||
|
@ -175,27 +175,29 @@ public class AsyncRestServlet extends AbstractRestServlet
|
||||||
public void onContent(Response response, ByteBuffer content)
|
public void onContent(Response response, ByteBuffer content)
|
||||||
{
|
{
|
||||||
byte[] bytes = BufferUtil.toArray(content);
|
byte[] bytes = BufferUtil.toArray(content);
|
||||||
_content.append(bytes,0,bytes.length);
|
_content.append(bytes, 0, bytes.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(Result result)
|
public void onComplete(Result result)
|
||||||
{
|
{
|
||||||
// extract auctions from the results
|
// extract auctions from the results
|
||||||
Map<String,?> query = (Map<String,?>) JSON.parse(_content.toString());
|
Map<String, ?> query = (Map<String, ?>)JSON.parse(_content.toString());
|
||||||
Object[] auctions = (Object[]) query.get("Item");
|
Object[] auctions = (Object[])query.get("Item");
|
||||||
if (auctions != null)
|
if (auctions != null)
|
||||||
{
|
{
|
||||||
for (Object o : auctions)
|
for (Object o : auctions)
|
||||||
onAuctionFound((Map<String,String>)o);
|
{
|
||||||
|
onAuctionFound((Map<String, String>)o);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onComplete();
|
onComplete();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract void onAuctionFound(Map<String,String> details);
|
|
||||||
abstract void onComplete();
|
abstract void onComplete();
|
||||||
|
|
||||||
|
abstract void onAuctionFound(Map<String, String> details);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,7 +27,6 @@ import java.net.URL;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -43,11 +42,10 @@ public class SerialRestServlet extends AbstractRestServlet
|
||||||
@Override
|
@Override
|
||||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
||||||
{
|
{
|
||||||
long start = System.nanoTime();
|
final long start = System.nanoTime();
|
||||||
|
|
||||||
|
String[] keywords = sanitize(request.getParameter(ITEMS_PARAM)).split(",");
|
||||||
String[] keywords=sanitize(request.getParameter(ITEMS_PARAM)).split(",");
|
Queue<Map<String, String>> results = new LinkedList<Map<String, String>>();
|
||||||
Queue<Map<String,String>> results = new LinkedList<Map<String,String>>();
|
|
||||||
|
|
||||||
// make all requests serially
|
// make all requests serially
|
||||||
for (String itemName : keywords)
|
for (String itemName : keywords)
|
||||||
|
@ -58,17 +56,18 @@ public class SerialRestServlet extends AbstractRestServlet
|
||||||
connection.setRequestMethod("GET");
|
connection.setRequestMethod("GET");
|
||||||
|
|
||||||
Map query = (Map)JSON.parse(new BufferedReader(new InputStreamReader(connection.getInputStream())));
|
Map query = (Map)JSON.parse(new BufferedReader(new InputStreamReader(connection.getInputStream())));
|
||||||
Object[] auctions = (Object[]) query.get("Item");
|
Object[] auctions = (Object[])query.get("Item");
|
||||||
if (auctions != null)
|
if (auctions != null)
|
||||||
{
|
{
|
||||||
for (Object o : auctions)
|
for (Object o : auctions)
|
||||||
results.add((Map) o);
|
{
|
||||||
|
results.add((Map)o);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Generate the response
|
// Generate the response
|
||||||
String thumbs=generateThumbs(results);
|
final String thumbs = generateThumbs(results);
|
||||||
|
|
||||||
response.setContentType("text/html");
|
response.setContentType("text/html");
|
||||||
PrintWriter out = response.getWriter();
|
PrintWriter out = response.getWriter();
|
||||||
|
@ -77,22 +76,19 @@ public class SerialRestServlet extends AbstractRestServlet
|
||||||
out.println("</head><body><small>");
|
out.println("</head><body><small>");
|
||||||
|
|
||||||
long now = System.nanoTime();
|
long now = System.nanoTime();
|
||||||
long total=now-start;
|
long total = now - start;
|
||||||
|
|
||||||
out.print("<b>Blocking: "+sanitize(request.getParameter(ITEMS_PARAM))+"</b><br/>");
|
out.print("<b>Blocking: " + sanitize(request.getParameter(ITEMS_PARAM)) + "</b><br/>");
|
||||||
out.print("Total Time: "+ms(total)+"ms<br/>");
|
out.print("Total Time: " + ms(total) + "ms<br/>");
|
||||||
out.print("Thread held (<span class='red'>red</span>): "+ms(total)+"ms<br/>");
|
out.print("Thread held (<span class='red'>red</span>): " + ms(total) + "ms<br/>");
|
||||||
|
|
||||||
out.println("<img border='0px' src='asyncrest/red.png' height='20px' width='"+width(total)+"px'>");
|
out.println("<img border='0px' src='asyncrest/red.png' height='20px' width='" + width(total) + "px'>");
|
||||||
|
|
||||||
out.println("<hr />");
|
out.println("<hr />");
|
||||||
out.println(thumbs);
|
out.println(thumbs);
|
||||||
out.println("</small>");
|
out.println("</small>");
|
||||||
out.println("</body></html>");
|
out.println("</body></html>");
|
||||||
out.close();
|
out.close();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,5 +100,4 @@ public class SerialRestServlet extends AbstractRestServlet
|
||||||
{
|
{
|
||||||
doGet(request, response);
|
doGet(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>example-async-rest</artifactId>
|
<artifactId>example-async-rest</artifactId>
|
||||||
|
|
|
@ -18,15 +18,13 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.example.asyncrest;
|
package org.eclipse.jetty.example.asyncrest;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.Server;
|
|
||||||
import org.eclipse.jetty.webapp.ClassMatcher;
|
|
||||||
import org.eclipse.jetty.webapp.WebAppContext;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServlet;
|
|
||||||
import java.nio.file.FileSystems;
|
import java.nio.file.FileSystems;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.server.Server;
|
||||||
|
import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
|
|
||||||
public class AsyncRestServer
|
public class AsyncRestServer
|
||||||
{
|
{
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
|
@ -34,7 +32,7 @@ public class AsyncRestServer
|
||||||
{
|
{
|
||||||
// Find the async-reset webapp based on common IDE working directories
|
// Find the async-reset webapp based on common IDE working directories
|
||||||
// TODO import webapp as maven artifact
|
// TODO import webapp as maven artifact
|
||||||
Path home = FileSystems.getDefault().getPath(System.getProperty("jetty.home",".")).toAbsolutePath();
|
Path home = FileSystems.getDefault().getPath(System.getProperty("jetty.home", ".")).toAbsolutePath();
|
||||||
Path war = home.resolve("../async-rest-webapp/target/async-rest/");
|
Path war = home.resolve("../async-rest-webapp/target/async-rest/");
|
||||||
if (!Files.exists(war))
|
if (!Files.exists(war))
|
||||||
war = home.resolve("examples/async-rest/async-rest-webapp/target/async-rest/");
|
war = home.resolve("examples/async-rest/async-rest-webapp/target/async-rest/");
|
||||||
|
@ -42,7 +40,7 @@ public class AsyncRestServer
|
||||||
throw new IllegalArgumentException("Cannot find async-rest webapp");
|
throw new IllegalArgumentException("Cannot find async-rest webapp");
|
||||||
|
|
||||||
// Build a demo server
|
// Build a demo server
|
||||||
Server server = new Server(Integer.getInteger("jetty.http.port",8080).intValue());
|
Server server = new Server(Integer.getInteger("jetty.http.port", 8080).intValue());
|
||||||
WebAppContext webapp = new WebAppContext();
|
WebAppContext webapp = new WebAppContext();
|
||||||
webapp.setContextPath("/");
|
webapp.setContextPath("/");
|
||||||
webapp.setWar(war.toAbsolutePath().toString());
|
webapp.setWar(war.toAbsolutePath().toString());
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>example-async-rest</artifactId>
|
<artifactId>example-async-rest</artifactId>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_9_3.dtd">
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
This is the jetty specific web application configuration file. When starting
|
This is the jetty specific web application configuration file. When starting
|
||||||
|
@ -9,7 +9,7 @@ org.eclipse.jetty.servlet.WebApplicationContext object
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
|
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
|
||||||
<Get class="org.eclipse.jetty.util.log.Log" name="rootLogger">
|
<Get name="servletContext">
|
||||||
<Call name="warn"><Arg>async-rest webapp is deployed. DO NOT USE IN PRODUCTION!</Arg></Call>
|
<Call name="log"><Arg>The async-rest webapp is deployed. DO NOT USE IN PRODUCTION!</Arg><Arg></Arg></Call>
|
||||||
</Get>
|
</Get>
|
||||||
</Configure>
|
</Configure>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.jetty.examples</groupId>
|
<groupId>org.eclipse.jetty.examples</groupId>
|
||||||
<artifactId>examples-parent</artifactId>
|
<artifactId>examples-parent</artifactId>
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.embedded;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import javax.servlet.AsyncContext;
|
import javax.servlet.AsyncContext;
|
||||||
import javax.servlet.ReadListener;
|
import javax.servlet.ReadListener;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
|
@ -31,7 +30,6 @@ import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
|
||||||
public class AsyncEchoServlet extends HttpServlet
|
public class AsyncEchoServlet extends HttpServlet
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -100,13 +98,13 @@ public class AsyncEchoServlet extends HttpServlet
|
||||||
break;
|
break;
|
||||||
|
|
||||||
int read = input.read(buffer);
|
int read = input.read(buffer);
|
||||||
if (read<0)
|
if (read < 0)
|
||||||
{
|
{
|
||||||
if (complete.compareAndSet(false,true))
|
if (complete.compareAndSet(false, true))
|
||||||
asyncContext.complete();
|
asyncContext.complete();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (read>0)
|
else if (read > 0)
|
||||||
{
|
{
|
||||||
output.write(buffer, 0, read);
|
output.write(buffer, 0, read);
|
||||||
}
|
}
|
||||||
|
@ -116,7 +114,7 @@ public class AsyncEchoServlet extends HttpServlet
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable failure)
|
public void onError(Throwable failure)
|
||||||
{
|
{
|
||||||
new Throwable("onError",failure).printStackTrace();
|
new Throwable("onError", failure).printStackTrace();
|
||||||
asyncContext.complete();
|
asyncContext.complete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,6 @@ package org.eclipse.jetty.embedded;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
@ -30,9 +28,8 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
public class DumpServlet extends HttpServlet
|
public class DumpServlet extends HttpServlet
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected void doGet( HttpServletRequest request,
|
protected void doGet(HttpServletRequest request,
|
||||||
HttpServletResponse response ) throws ServletException,
|
HttpServletResponse response) throws IOException
|
||||||
IOException
|
|
||||||
{
|
{
|
||||||
response.setContentType("text/html");
|
response.setContentType("text/html");
|
||||||
response.setStatus(HttpServletResponse.SC_OK);
|
response.setStatus(HttpServletResponse.SC_OK);
|
||||||
|
@ -51,8 +48,7 @@ public class DumpServlet extends HttpServlet
|
||||||
String r = request.getParameter("resource");
|
String r = request.getParameter("resource");
|
||||||
if (r != null)
|
if (r != null)
|
||||||
{
|
{
|
||||||
out.println("resource(" + r + ")="
|
out.println("resource(" + r + ")=" + getServletContext().getResource(r));
|
||||||
+ getServletContext().getResource(r));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out.println("</pre>");
|
out.println("</pre>");
|
||||||
|
|
|
@ -28,13 +28,13 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||||
|
|
||||||
public class ExampleServer
|
public class ExampleServer
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
Server server = new Server();
|
Server server = new Server();
|
||||||
|
|
||||||
ServerConnector connector = new ServerConnector(server);
|
ServerConnector connector = new ServerConnector(server);
|
||||||
connector.setPort(8080);
|
connector.setPort(8080);
|
||||||
server.setConnectors(new Connector[] { connector });
|
server.setConnectors(new Connector[]{connector});
|
||||||
|
|
||||||
ServletContextHandler context = new ServletContextHandler();
|
ServletContextHandler context = new ServletContextHandler();
|
||||||
context.setContextPath("/");
|
context.setContextPath("/");
|
||||||
|
@ -42,7 +42,7 @@ public class ExampleServer
|
||||||
context.addServlet(AsyncEchoServlet.class, "/echo/*");
|
context.addServlet(AsyncEchoServlet.class, "/echo/*");
|
||||||
|
|
||||||
HandlerCollection handlers = new HandlerCollection();
|
HandlerCollection handlers = new HandlerCollection();
|
||||||
handlers.setHandlers(new Handler[] { context, new DefaultHandler() });
|
handlers.setHandlers(new Handler[]{context, new DefaultHandler()});
|
||||||
server.setHandler(handlers);
|
server.setHandler(handlers);
|
||||||
|
|
||||||
server.start();
|
server.start();
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.eclipse.jetty.xml.XmlConfiguration;
|
||||||
*/
|
*/
|
||||||
public class ExampleServerXml
|
public class ExampleServerXml
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
// Find Jetty XML (in classpath) that configures and starts Server.
|
// Find Jetty XML (in classpath) that configures and starts Server.
|
||||||
Resource serverXml = Resource.newSystemResource("exampleserver.xml");
|
Resource serverXml = Resource.newSystemResource("exampleserver.xml");
|
||||||
|
|
|
@ -58,14 +58,15 @@ import org.eclipse.jetty.util.resource.Resource;
|
||||||
*/
|
*/
|
||||||
public class FastFileServer
|
public class FastFileServer
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
Server server = new Server(8080);
|
Server server = new Server(8080);
|
||||||
|
|
||||||
HandlerList handlers = new HandlerList();
|
HandlerList handlers = new HandlerList();
|
||||||
handlers.setHandlers(new Handler[] {
|
handlers.setHandlers(new Handler[]{
|
||||||
new FastFileHandler(new File(System.getProperty("user.dir"))),
|
new FastFileHandler(new File(System.getProperty("user.dir"))),
|
||||||
new DefaultHandler() });
|
new DefaultHandler()
|
||||||
|
});
|
||||||
server.setHandler(handlers);
|
server.setHandler(handlers);
|
||||||
|
|
||||||
server.start();
|
server.start();
|
||||||
|
@ -77,16 +78,16 @@ public class FastFileServer
|
||||||
private final MimeTypes mimeTypes = new MimeTypes();
|
private final MimeTypes mimeTypes = new MimeTypes();
|
||||||
private final File dir;
|
private final File dir;
|
||||||
|
|
||||||
private FastFileHandler( File dir )
|
private FastFileHandler(File dir)
|
||||||
{
|
{
|
||||||
this.dir = dir;
|
this.dir = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle( String target,
|
public void handle(String target,
|
||||||
Request baseRequest,
|
Request baseRequest,
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
HttpServletResponse response ) throws IOException,
|
HttpServletResponse response) throws IOException,
|
||||||
ServletException
|
ServletException
|
||||||
{
|
{
|
||||||
// define small medium and large.
|
// define small medium and large.
|
||||||
|
@ -110,7 +111,7 @@ public class FastFileServer
|
||||||
{
|
{
|
||||||
if (!request.getPathInfo().endsWith(URIUtil.SLASH))
|
if (!request.getPathInfo().endsWith(URIUtil.SLASH))
|
||||||
{
|
{
|
||||||
response.sendRedirect(response.encodeRedirectURL(request.getRequestURI()+URIUtil.SLASH));
|
response.sendRedirect(response.encodeRedirectURL(request.getRequestURI() + URIUtil.SLASH));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String listing = Resource.newResource(file).getListHTML(
|
String listing = Resource.newResource(file).getListHTML(
|
||||||
|
@ -134,7 +135,7 @@ public class FastFileServer
|
||||||
if (file.length() < SMALL)
|
if (file.length() < SMALL)
|
||||||
{
|
{
|
||||||
// need to caste to Jetty output stream for best API
|
// need to caste to Jetty output stream for best API
|
||||||
((HttpOutput) response.getOutputStream())
|
((HttpOutput)response.getOutputStream())
|
||||||
.sendContent(FileChannel.open(file.toPath(),
|
.sendContent(FileChannel.open(file.toPath(),
|
||||||
StandardOpenOption.READ));
|
StandardOpenOption.READ));
|
||||||
return;
|
return;
|
||||||
|
@ -153,7 +154,7 @@ public class FastFileServer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failed( Throwable x )
|
public void failed(Throwable x)
|
||||||
{
|
{
|
||||||
// log error and complete async response;
|
// log error and complete async response;
|
||||||
x.printStackTrace();
|
x.printStackTrace();
|
||||||
|
@ -165,7 +166,7 @@ public class FastFileServer
|
||||||
if (file.length() < MEDIUM)
|
if (file.length() < MEDIUM)
|
||||||
{
|
{
|
||||||
// the file channel is closed by the async send
|
// the file channel is closed by the async send
|
||||||
((HttpOutput) response.getOutputStream())
|
((HttpOutput)response.getOutputStream())
|
||||||
.sendContent(FileChannel.open(file.toPath(),
|
.sendContent(FileChannel.open(file.toPath(),
|
||||||
StandardOpenOption.READ), completionCB);
|
StandardOpenOption.READ), completionCB);
|
||||||
return;
|
return;
|
||||||
|
@ -176,7 +177,7 @@ public class FastFileServer
|
||||||
// can be hard to GC on some JVMs. But for this example we will
|
// can be hard to GC on some JVMs. But for this example we will
|
||||||
// create a new buffer per file
|
// create a new buffer per file
|
||||||
ByteBuffer buffer;
|
ByteBuffer buffer;
|
||||||
try ( RandomAccessFile raf = new RandomAccessFile(file, "r"); )
|
try (RandomAccessFile raf = new RandomAccessFile(file, "r");)
|
||||||
{
|
{
|
||||||
buffer = raf.getChannel().map(MapMode.READ_ONLY, 0,
|
buffer = raf.getChannel().map(MapMode.READ_ONLY, 0,
|
||||||
raf.length());
|
raf.length());
|
||||||
|
@ -188,7 +189,7 @@ public class FastFileServer
|
||||||
|
|
||||||
// send the content as a buffer with a callback to complete the
|
// send the content as a buffer with a callback to complete the
|
||||||
// async request need to caste to Jetty output stream for best API
|
// async request need to caste to Jetty output stream for best API
|
||||||
((HttpOutput) response.getOutputStream()).sendContent(buffer,
|
((HttpOutput)response.getOutputStream()).sendContent(buffer,
|
||||||
completionCB);
|
completionCB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,21 +35,21 @@ public class FileServer
|
||||||
// Create a basic Jetty server object that will listen on port 8080. Note that if you set this to port 0
|
// Create a basic Jetty server object that will listen on port 8080. Note that if you set this to port 0
|
||||||
// then a randomly available port will be assigned that you can either look in the logs for the port,
|
// then a randomly available port will be assigned that you can either look in the logs for the port,
|
||||||
// or programmatically obtain it for use in test cases.
|
// or programmatically obtain it for use in test cases.
|
||||||
Server server = new Server(8080);
|
final Server server = new Server(8080);
|
||||||
|
|
||||||
// Create the ResourceHandler. It is the object that will actually handle the request for a given file. It is
|
// Create the ResourceHandler. It is the object that will actually handle the request for a given file. It is
|
||||||
// a Jetty Handler object so it is suitable for chaining with other handlers as you will see in other examples.
|
// a Jetty Handler object so it is suitable for chaining with other handlers as you will see in other examples.
|
||||||
ResourceHandler resource_handler = new ResourceHandler();
|
ResourceHandler resourceHandler = new ResourceHandler();
|
||||||
|
|
||||||
// Configure the ResourceHandler. Setting the resource base indicates where the files should be served out of.
|
// Configure the ResourceHandler. Setting the resource base indicates where the files should be served out of.
|
||||||
// In this example it is the current directory but it can be configured to anything that the jvm has access to.
|
// In this example it is the current directory but it can be configured to anything that the jvm has access to.
|
||||||
resource_handler.setDirectoriesListed(true);
|
resourceHandler.setDirectoriesListed(true);
|
||||||
resource_handler.setWelcomeFiles(new String[]{ "index.html" });
|
resourceHandler.setWelcomeFiles(new String[]{"index.html"});
|
||||||
resource_handler.setResourceBase(".");
|
resourceHandler.setResourceBase(".");
|
||||||
|
|
||||||
// Add the ResourceHandler to the server.
|
// Add the ResourceHandler to the server.
|
||||||
HandlerList handlers = new HandlerList();
|
HandlerList handlers = new HandlerList();
|
||||||
handlers.setHandlers(new Handler[] { resource_handler, new DefaultHandler() });
|
handlers.setHandlers(new Handler[]{resourceHandler, new DefaultHandler()});
|
||||||
server.setHandler(handlers);
|
server.setHandler(handlers);
|
||||||
|
|
||||||
// Start things up! By using the server.join() the server thread will join with the current thread.
|
// Start things up! By using the server.join() the server thread will join with the current thread.
|
||||||
|
|
|
@ -34,12 +34,11 @@ import org.eclipse.jetty.xml.XmlConfiguration;
|
||||||
*/
|
*/
|
||||||
public class FileServerXml
|
public class FileServerXml
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
Resource fileserverXml = Resource.newSystemResource("fileserver.xml");
|
Resource fileServerXml = Resource.newSystemResource("fileserver.xml");
|
||||||
XmlConfiguration configuration = new XmlConfiguration(
|
XmlConfiguration configuration = new XmlConfiguration(fileServerXml);
|
||||||
fileserverXml.getInputStream());
|
Server server = (Server)configuration.configure();
|
||||||
Server server = (Server) configuration.configure();
|
|
||||||
server.start();
|
server.start();
|
||||||
server.join();
|
server.join();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.embedded;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
@ -38,22 +37,22 @@ public class HelloHandler extends AbstractHandler
|
||||||
this("Hello World");
|
this("Hello World");
|
||||||
}
|
}
|
||||||
|
|
||||||
public HelloHandler( String greeting )
|
public HelloHandler(String greeting)
|
||||||
{
|
{
|
||||||
this(greeting, null);
|
this(greeting, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HelloHandler( String greeting, String body )
|
public HelloHandler(String greeting, String body)
|
||||||
{
|
{
|
||||||
this.greeting = greeting;
|
this.greeting = greeting;
|
||||||
this.body = body;
|
this.body = body;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle( String target,
|
public void handle(String target,
|
||||||
Request baseRequest,
|
Request baseRequest,
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
HttpServletResponse response ) throws IOException,
|
HttpServletResponse response) throws IOException,
|
||||||
ServletException
|
ServletException
|
||||||
{
|
{
|
||||||
response.setContentType("text/html; charset=utf-8");
|
response.setContentType("text/html; charset=utf-8");
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
package org.eclipse.jetty.embedded;
|
package org.eclipse.jetty.embedded;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -35,14 +34,14 @@ public class HelloServlet extends HttpServlet
|
||||||
this("Hello");
|
this("Hello");
|
||||||
}
|
}
|
||||||
|
|
||||||
public HelloServlet( String greeting )
|
public HelloServlet(String greeting)
|
||||||
{
|
{
|
||||||
this.greeting = greeting;
|
this.greeting = greeting;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doGet( HttpServletRequest request,
|
protected void doGet(HttpServletRequest request,
|
||||||
HttpServletResponse response ) throws ServletException,
|
HttpServletResponse response) throws ServletException,
|
||||||
IOException
|
IOException
|
||||||
{
|
{
|
||||||
response.setContentType("text/html");
|
response.setContentType("text/html");
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.embedded;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -30,16 +29,18 @@ import javax.servlet.http.HttpSession;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class HelloSessionServlet extends HttpServlet
|
public class HelloSessionServlet extends HttpServlet
|
||||||
{
|
{
|
||||||
public HelloSessionServlet() {}
|
public HelloSessionServlet()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doGet( HttpServletRequest request,
|
protected void doGet(HttpServletRequest request,
|
||||||
HttpServletResponse response ) throws ServletException,
|
HttpServletResponse response) throws ServletException,
|
||||||
IOException
|
IOException
|
||||||
{
|
{
|
||||||
response.setContentType("text/html");
|
response.setContentType("text/html");
|
||||||
response.setStatus(HttpServletResponse.SC_OK);
|
response.setStatus(HttpServletResponse.SC_OK);
|
||||||
response.addHeader("Cache-Control","no-cache");
|
response.addHeader("Cache-Control", "no-cache");
|
||||||
|
|
||||||
HttpSession session = request.getSession();
|
HttpSession session = request.getSession();
|
||||||
String message;
|
String message;
|
||||||
|
@ -73,12 +74,10 @@ public class HelloSessionServlet extends HttpServlet
|
||||||
out.println("<h1>" + greeting + " from HelloSessionServlet</h1>");
|
out.println("<h1>" + greeting + " from HelloSessionServlet</h1>");
|
||||||
out.println("<p>" + message + "</p>");
|
out.println("<p>" + message + "</p>");
|
||||||
out.println("<pre>");
|
out.println("<pre>");
|
||||||
out.println("session.getId() = " +session.getId());
|
out.println("session.getId() = " + session.getId());
|
||||||
out.println("session.isNew() = " +session.isNew());
|
out.println("session.isNew() = " + session.isNew());
|
||||||
out.println("</pre>");
|
out.println("</pre>");
|
||||||
out.println("<p>" + link + "</p>");
|
out.println("<p>" + link + "</p>");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
package org.eclipse.jetty.embedded;
|
package org.eclipse.jetty.embedded;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
@ -31,10 +30,10 @@ import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||||
public class HelloWorld extends AbstractHandler
|
public class HelloWorld extends AbstractHandler
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void handle( String target,
|
public void handle(String target,
|
||||||
Request baseRequest,
|
Request baseRequest,
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
HttpServletResponse response ) throws IOException,
|
HttpServletResponse response) throws IOException,
|
||||||
ServletException
|
ServletException
|
||||||
{
|
{
|
||||||
// Declare response encoding and types
|
// Declare response encoding and types
|
||||||
|
@ -50,7 +49,7 @@ public class HelloWorld extends AbstractHandler
|
||||||
baseRequest.setHandled(true);
|
baseRequest.setHandled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
Server server = new Server(8080);
|
Server server = new Server(8080);
|
||||||
server.setHandler(new HelloWorld());
|
server.setHandler(new HelloWorld());
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
package org.eclipse.jetty.embedded;
|
package org.eclipse.jetty.embedded;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -27,7 +26,6 @@ import java.util.Date;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.servlet.DispatcherType;
|
import javax.servlet.DispatcherType;
|
||||||
import javax.servlet.Filter;
|
import javax.servlet.Filter;
|
||||||
import javax.servlet.FilterChain;
|
import javax.servlet.FilterChain;
|
||||||
|
@ -70,57 +68,57 @@ public class Http2Server
|
||||||
ManagementFactory.getPlatformMBeanServer());
|
ManagementFactory.getPlatformMBeanServer());
|
||||||
server.addBean(mbContainer);
|
server.addBean(mbContainer);
|
||||||
|
|
||||||
ServletContextHandler context = new ServletContextHandler(server, "/",ServletContextHandler.SESSIONS);
|
ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS);
|
||||||
String docroot = "src/main/resources/docroot";
|
String docroot = "src/main/resources/docroot";
|
||||||
if (!new File(docroot).exists())
|
if (!new File(docroot).exists())
|
||||||
docroot = "examples/embedded/src/main/resources/docroot";
|
docroot = "examples/embedded/src/main/resources/docroot";
|
||||||
context.setResourceBase(docroot);
|
context.setResourceBase(docroot);
|
||||||
context.addFilter(PushCacheFilter.class,"/*",EnumSet.of(DispatcherType.REQUEST));
|
context.addFilter(PushCacheFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
|
||||||
// context.addFilter(PushSessionCacheFilter.class,"/*",EnumSet.of(DispatcherType.REQUEST));
|
// context.addFilter(PushSessionCacheFilter.class,"/*",EnumSet.of(DispatcherType.REQUEST));
|
||||||
context.addFilter(PushedTilesFilter.class,"/*",EnumSet.of(DispatcherType.REQUEST));
|
context.addFilter(PushedTilesFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
|
||||||
context.addServlet(new ServletHolder(servlet), "/test/*");
|
context.addServlet(new ServletHolder(servlet), "/test/*");
|
||||||
context.addServlet(DefaultServlet.class, "/").setInitParameter("maxCacheSize","81920");
|
context.addServlet(DefaultServlet.class, "/").setInitParameter("maxCacheSize", "81920");
|
||||||
server.setHandler(context);
|
server.setHandler(context);
|
||||||
|
|
||||||
// HTTP Configuration
|
// HTTP Configuration
|
||||||
HttpConfiguration http_config = new HttpConfiguration();
|
HttpConfiguration httpConfig = new HttpConfiguration();
|
||||||
http_config.setSecureScheme("https");
|
httpConfig.setSecureScheme("https");
|
||||||
http_config.setSecurePort(8443);
|
httpConfig.setSecurePort(8443);
|
||||||
http_config.setSendXPoweredBy(true);
|
httpConfig.setSendXPoweredBy(true);
|
||||||
http_config.setSendServerVersion(true);
|
httpConfig.setSendServerVersion(true);
|
||||||
|
|
||||||
// HTTP Connector
|
// HTTP Connector
|
||||||
ServerConnector http = new ServerConnector(server,new HttpConnectionFactory(http_config), new HTTP2CServerConnectionFactory(http_config));
|
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig), new HTTP2CServerConnectionFactory(httpConfig));
|
||||||
http.setPort(8080);
|
http.setPort(8080);
|
||||||
server.addConnector(http);
|
server.addConnector(http);
|
||||||
|
|
||||||
// SSL Context Factory for HTTPS and HTTP/2
|
// SSL Context Factory for HTTPS and HTTP/2
|
||||||
String jetty_distro = System.getProperty("jetty.distro","../../jetty-distribution/target/distribution");
|
String jettyDistro = System.getProperty("jetty.distro", "../../jetty-distribution/target/distribution");
|
||||||
if (!new File(jetty_distro).exists())
|
if (!new File(jettyDistro).exists())
|
||||||
jetty_distro = "jetty-distribution/target/distribution";
|
jettyDistro = "jetty-distribution/target/distribution";
|
||||||
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
|
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
|
||||||
sslContextFactory.setKeyStorePath(jetty_distro + "/demo-base/etc/keystore");
|
sslContextFactory.setKeyStorePath(jettyDistro + "/demo-base/etc/keystore");
|
||||||
sslContextFactory.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
|
sslContextFactory.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
|
||||||
sslContextFactory.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");
|
sslContextFactory.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");
|
||||||
sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR);
|
sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR);
|
||||||
// sslContextFactory.setProvider("Conscrypt");
|
// sslContextFactory.setProvider("Conscrypt");
|
||||||
|
|
||||||
// HTTPS Configuration
|
// HTTPS Configuration
|
||||||
HttpConfiguration https_config = new HttpConfiguration(http_config);
|
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
|
||||||
https_config.addCustomizer(new SecureRequestCustomizer());
|
httpsConfig.addCustomizer(new SecureRequestCustomizer());
|
||||||
|
|
||||||
// HTTP/2 Connection Factory
|
// HTTP/2 Connection Factory
|
||||||
HTTP2ServerConnectionFactory h2 = new HTTP2ServerConnectionFactory(https_config);
|
HTTP2ServerConnectionFactory h2 = new HTTP2ServerConnectionFactory(httpsConfig);
|
||||||
|
|
||||||
ALPNServerConnectionFactory alpn = new ALPNServerConnectionFactory();
|
ALPNServerConnectionFactory alpn = new ALPNServerConnectionFactory();
|
||||||
alpn.setDefaultProtocol(http.getDefaultProtocol());
|
alpn.setDefaultProtocol(http.getDefaultProtocol());
|
||||||
|
|
||||||
// SSL Connection Factory
|
// SSL Connection Factory
|
||||||
SslConnectionFactory ssl = new SslConnectionFactory(sslContextFactory,alpn.getProtocol());
|
SslConnectionFactory ssl = new SslConnectionFactory(sslContextFactory, alpn.getProtocol());
|
||||||
|
|
||||||
// HTTP/2 Connector
|
// HTTP/2 Connector
|
||||||
ServerConnector http2Connector =
|
ServerConnector http2Connector =
|
||||||
new ServerConnector(server,ssl,alpn,h2,new HttpConnectionFactory(https_config));
|
new ServerConnector(server, ssl, alpn, h2, new HttpConnectionFactory(httpsConfig));
|
||||||
http2Connector.setPort(8443);
|
http2Connector.setPort(8443);
|
||||||
server.addConnector(http2Connector);
|
server.addConnector(http2Connector);
|
||||||
|
|
||||||
|
@ -140,14 +138,14 @@ public class Http2Server
|
||||||
{
|
{
|
||||||
Request baseRequest = Request.getBaseRequest(request);
|
Request baseRequest = Request.getBaseRequest(request);
|
||||||
|
|
||||||
if (baseRequest.isPush() && baseRequest.getRequestURI().contains("tiles") )
|
if (baseRequest.isPush() && baseRequest.getRequestURI().contains("tiles"))
|
||||||
{
|
{
|
||||||
String uri = baseRequest.getRequestURI().replace("tiles","pushed").substring(baseRequest.getContextPath().length());
|
String uri = baseRequest.getRequestURI().replace("tiles", "pushed").substring(baseRequest.getContextPath().length());
|
||||||
request.getRequestDispatcher(uri).forward(request,response);
|
request.getRequestDispatcher(uri).forward(request, response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
chain.doFilter(request,response);
|
chain.doFilter(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -163,20 +161,20 @@ public class Http2Server
|
||||||
@Override
|
@Override
|
||||||
protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException
|
protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException
|
||||||
{
|
{
|
||||||
String code=request.getParameter("code");
|
String code = request.getParameter("code");
|
||||||
if (code!=null)
|
if (code != null)
|
||||||
response.setStatus(Integer.parseInt(code));
|
response.setStatus(Integer.parseInt(code));
|
||||||
|
|
||||||
HttpSession session = request.getSession(true);
|
HttpSession session = request.getSession(true);
|
||||||
if (session.isNew())
|
if (session.isNew())
|
||||||
response.addCookie(new Cookie("bigcookie",
|
response.addCookie(new Cookie("bigcookie",
|
||||||
"This is a test cookies that was created on "+new Date()+" and is used by the jetty http/2 test servlet."));
|
"This is a test cookies that was created on " + new Date() + " and is used by the jetty http/2 test servlet."));
|
||||||
response.setHeader("Custom","Value");
|
response.setHeader("Custom", "Value");
|
||||||
response.setContentType("text/plain");
|
response.setContentType("text/plain");
|
||||||
String content = "Hello from Jetty using "+request.getProtocol() +"\n";
|
String content = "Hello from Jetty using " + request.getProtocol() + "\n";
|
||||||
content+="uri="+request.getRequestURI()+"\n";
|
content += "uri=" + request.getRequestURI() + "\n";
|
||||||
content+="session="+session.getId()+(session.isNew()?"(New)\n":"\n");
|
content += "session=" + session.getId() + (session.isNew() ? "(New)\n" : "\n");
|
||||||
content+="date="+new Date()+"\n";
|
content += "date=" + new Date() + "\n";
|
||||||
|
|
||||||
content += Optional.ofNullable(request.getCookies())
|
content += Optional.ofNullable(request.getCookies())
|
||||||
.stream()
|
.stream()
|
||||||
|
|
|
@ -28,12 +28,13 @@ import org.eclipse.jetty.servlet.ServletHolder;
|
||||||
import org.eclipse.jetty.util.resource.Resource;
|
import org.eclipse.jetty.util.resource.Resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class JarServer
|
public class JarServer
|
||||||
{
|
{
|
||||||
public static void main(String[] args) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
Server server = new Server(8080);
|
final Server server = new Server(8080);
|
||||||
|
|
||||||
ServletContextHandler context = new ServletContextHandler();
|
ServletContextHandler context = new ServletContextHandler();
|
||||||
Resource.setDefaultUseCaches(true);
|
Resource.setDefaultUseCaches(true);
|
||||||
|
@ -42,7 +43,7 @@ public class JarServer
|
||||||
context.addServlet(new ServletHolder(new DefaultServlet()), "/");
|
context.addServlet(new ServletHolder(new DefaultServlet()), "/");
|
||||||
|
|
||||||
HandlerList handlers = new HandlerList();
|
HandlerList handlers = new HandlerList();
|
||||||
handlers.setHandlers(new Handler[] { context, new DefaultHandler() });
|
handlers.setHandlers(new Handler[]{context, new DefaultHandler()});
|
||||||
server.setHandler(handlers);
|
server.setHandler(handlers);
|
||||||
|
|
||||||
server.start();
|
server.start();
|
||||||
|
|
|
@ -0,0 +1,109 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2019 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.embedded;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.util.StringUtil;
|
||||||
|
import org.eclipse.jetty.util.log.Log;
|
||||||
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A utility test class to locate a Jetty Distribution for testing purposes by searching:
|
||||||
|
* <ul>
|
||||||
|
* <li>The <code>jetty.home</code> system property</li>
|
||||||
|
* <li>The <code>JETTY_HOME</code> environment variable</li>
|
||||||
|
* <li>The working directory hierarchy with subdirectory <code>jetty-distribution/target/home</code></li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
public class JettyDistribution
|
||||||
|
{
|
||||||
|
private static final Logger LOG = Log.getLogger(JettyDistribution.class);
|
||||||
|
public static final Path DISTRIBUTION;
|
||||||
|
|
||||||
|
static
|
||||||
|
{
|
||||||
|
Path distro = asJettyDistribution(System.getProperty("jetty.home"));
|
||||||
|
if (distro == null)
|
||||||
|
distro = asJettyDistribution(System.getenv().get("JETTY_HOME"));
|
||||||
|
|
||||||
|
if (distro == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Path working = new File(".").getAbsoluteFile().getCanonicalFile().toPath();
|
||||||
|
while (distro == null && working != null)
|
||||||
|
{
|
||||||
|
distro = asJettyDistribution(working.resolve("jetty-distribution/target/distribution").toString());
|
||||||
|
working = working.getParent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Throwable th)
|
||||||
|
{
|
||||||
|
LOG.warn(th);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DISTRIBUTION = distro;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Path asJettyDistribution(String test)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (StringUtil.isBlank(test))
|
||||||
|
{
|
||||||
|
LOG.info("asJettyDistribution {} is blank", test);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
File dir = new File(test);
|
||||||
|
if (!dir.exists() || !dir.isDirectory())
|
||||||
|
{
|
||||||
|
LOG.info("asJettyDistribution {} is not a directory", test);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
File demoBase = new File(dir, "demo-base");
|
||||||
|
if (!demoBase.exists() || !demoBase.isDirectory())
|
||||||
|
{
|
||||||
|
LOG.info("asJettyDistribution {} has no demo-base", test);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG.info("asJettyDistribution {}", dir);
|
||||||
|
return dir.getAbsoluteFile().getCanonicalFile().toPath();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOG.ignore(e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Path resolve(String path)
|
||||||
|
{
|
||||||
|
return DISTRIBUTION.resolve(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String... arg)
|
||||||
|
{
|
||||||
|
System.err.println("Jetty Distribution is " + DISTRIBUTION);
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,7 +19,6 @@
|
||||||
package org.eclipse.jetty.embedded;
|
package org.eclipse.jetty.embedded;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
|
|
||||||
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
||||||
|
@ -30,7 +29,9 @@ import org.eclipse.jetty.http.HttpVersion;
|
||||||
import org.eclipse.jetty.jmx.MBeanContainer;
|
import org.eclipse.jetty.jmx.MBeanContainer;
|
||||||
import org.eclipse.jetty.plus.webapp.EnvConfiguration;
|
import org.eclipse.jetty.plus.webapp.EnvConfiguration;
|
||||||
import org.eclipse.jetty.plus.webapp.PlusConfiguration;
|
import org.eclipse.jetty.plus.webapp.PlusConfiguration;
|
||||||
|
import org.eclipse.jetty.rewrite.handler.MsieSslRule;
|
||||||
import org.eclipse.jetty.rewrite.handler.RewriteHandler;
|
import org.eclipse.jetty.rewrite.handler.RewriteHandler;
|
||||||
|
import org.eclipse.jetty.rewrite.handler.ValidUrlRule;
|
||||||
import org.eclipse.jetty.security.HashLoginService;
|
import org.eclipse.jetty.security.HashLoginService;
|
||||||
import org.eclipse.jetty.server.AsyncRequestLogWriter;
|
import org.eclipse.jetty.server.AsyncRequestLogWriter;
|
||||||
import org.eclipse.jetty.server.CustomRequestLog;
|
import org.eclipse.jetty.server.CustomRequestLog;
|
||||||
|
@ -58,37 +59,23 @@ import org.eclipse.jetty.webapp.Configurations;
|
||||||
*/
|
*/
|
||||||
public class LikeJettyXml
|
public class LikeJettyXml
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
// Path to as-built jetty-distribution directory
|
// Path to as-built jetty-distribution directory
|
||||||
String jettyHomeBuild = "jetty-distribution/target/distribution";
|
String jettyHomeBuild = JettyDistribution.DISTRIBUTION.toString();
|
||||||
|
|
||||||
// Find jetty home and base directories
|
// Find jetty home and base directories
|
||||||
String homePath = System.getProperty("jetty.home", jettyHomeBuild);
|
String homePath = System.getProperty("jetty.home", jettyHomeBuild);
|
||||||
File start_jar = new File(homePath,"start.jar");
|
|
||||||
if (!start_jar.exists())
|
|
||||||
{
|
|
||||||
homePath = jettyHomeBuild = "jetty-distribution/target/distribution";
|
|
||||||
start_jar = new File(homePath,"start.jar");
|
|
||||||
if (!start_jar.exists())
|
|
||||||
throw new FileNotFoundException(start_jar.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
File homeDir = new File(homePath);
|
File homeDir = new File(homePath);
|
||||||
|
|
||||||
String basePath = System.getProperty("jetty.base", homeDir + "/demo-base");
|
String basePath = System.getProperty("jetty.base", homeDir + "/demo-base");
|
||||||
File baseDir = new File(basePath);
|
File baseDir = new File(basePath);
|
||||||
if(!baseDir.exists())
|
|
||||||
{
|
|
||||||
throw new FileNotFoundException(baseDir.getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure jetty.home and jetty.base system properties
|
// Configure jetty.home and jetty.base system properties
|
||||||
String jetty_home = homeDir.getAbsolutePath();
|
String jettyHome = homeDir.getAbsolutePath();
|
||||||
String jetty_base = baseDir.getAbsolutePath();
|
String jettyBase = baseDir.getAbsolutePath();
|
||||||
System.setProperty("jetty.home", jetty_home);
|
System.setProperty("jetty.home", jettyHome);
|
||||||
System.setProperty("jetty.base", jetty_base);
|
System.setProperty("jetty.base", jettyBase);
|
||||||
|
|
||||||
|
|
||||||
// === jetty.xml ===
|
// === jetty.xml ===
|
||||||
// Setup Threadpool
|
// Setup Threadpool
|
||||||
|
@ -99,27 +86,27 @@ public class LikeJettyXml
|
||||||
Server server = new Server(threadPool);
|
Server server = new Server(threadPool);
|
||||||
|
|
||||||
// Scheduler
|
// Scheduler
|
||||||
server.addBean(new ScheduledExecutorScheduler(null,false));
|
server.addBean(new ScheduledExecutorScheduler(null, false));
|
||||||
|
|
||||||
// HTTP Configuration
|
// HTTP Configuration
|
||||||
HttpConfiguration http_config = new HttpConfiguration();
|
HttpConfiguration httpConfig = new HttpConfiguration();
|
||||||
http_config.setSecureScheme("https");
|
httpConfig.setSecureScheme("https");
|
||||||
http_config.setSecurePort(8443);
|
httpConfig.setSecurePort(8443);
|
||||||
http_config.setOutputBufferSize(32768);
|
httpConfig.setOutputBufferSize(32768);
|
||||||
http_config.setRequestHeaderSize(8192);
|
httpConfig.setRequestHeaderSize(8192);
|
||||||
http_config.setResponseHeaderSize(8192);
|
httpConfig.setResponseHeaderSize(8192);
|
||||||
http_config.setSendServerVersion(true);
|
httpConfig.setSendServerVersion(true);
|
||||||
http_config.setSendDateHeader(false);
|
httpConfig.setSendDateHeader(false);
|
||||||
// httpConfig.addCustomizer(new ForwardedRequestCustomizer());
|
// httpConfig.addCustomizer(new ForwardedRequestCustomizer());
|
||||||
|
|
||||||
// Handler Structure
|
// Handler Structure
|
||||||
HandlerCollection handlers = new HandlerCollection();
|
HandlerCollection handlers = new HandlerCollection();
|
||||||
ContextHandlerCollection contexts = new ContextHandlerCollection();
|
ContextHandlerCollection contexts = new ContextHandlerCollection();
|
||||||
handlers.setHandlers(new Handler[] { contexts, new DefaultHandler() });
|
handlers.setHandlers(new Handler[]{contexts, new DefaultHandler()});
|
||||||
server.setHandler(handlers);
|
server.setHandler(handlers);
|
||||||
|
|
||||||
// Extra options
|
// Extra options
|
||||||
server.setDumpAfterStart(false);
|
server.setDumpAfterStart(true);
|
||||||
server.setDumpBeforeStop(false);
|
server.setDumpBeforeStop(false);
|
||||||
server.setStopAtShutdown(true);
|
server.setStopAtShutdown(true);
|
||||||
|
|
||||||
|
@ -128,22 +115,20 @@ public class LikeJettyXml
|
||||||
ManagementFactory.getPlatformMBeanServer());
|
ManagementFactory.getPlatformMBeanServer());
|
||||||
server.addBean(mbContainer);
|
server.addBean(mbContainer);
|
||||||
|
|
||||||
|
|
||||||
// === jetty-http.xml ===
|
// === jetty-http.xml ===
|
||||||
ServerConnector http = new ServerConnector(server,
|
ServerConnector http = new ServerConnector(server,
|
||||||
new HttpConnectionFactory(http_config));
|
new HttpConnectionFactory(httpConfig));
|
||||||
http.setPort(8080);
|
http.setPort(8080);
|
||||||
http.setIdleTimeout(30000);
|
http.setIdleTimeout(30000);
|
||||||
server.addConnector(http);
|
server.addConnector(http);
|
||||||
|
|
||||||
|
|
||||||
// === jetty-https.xml ===
|
// === jetty-https.xml ===
|
||||||
// SSL Context Factory
|
// SSL Context Factory
|
||||||
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
|
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
|
||||||
sslContextFactory.setKeyStorePath(jetty_home + "/../../../jetty-server/src/test/config/etc/keystore");
|
sslContextFactory.setKeyStorePath(jettyHome + "/../../../jetty-server/src/test/config/etc/keystore");
|
||||||
sslContextFactory.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
|
sslContextFactory.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
|
||||||
sslContextFactory.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");
|
sslContextFactory.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");
|
||||||
sslContextFactory.setTrustStorePath(jetty_home + "/../../../jetty-server/src/test/config/etc/keystore");
|
sslContextFactory.setTrustStorePath(jettyHome + "/../../../jetty-server/src/test/config/etc/keystore");
|
||||||
sslContextFactory.setTrustStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
|
sslContextFactory.setTrustStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
|
||||||
sslContextFactory.setExcludeCipherSuites("SSL_RSA_WITH_DES_CBC_SHA",
|
sslContextFactory.setExcludeCipherSuites("SSL_RSA_WITH_DES_CBC_SHA",
|
||||||
"SSL_DHE_RSA_WITH_DES_CBC_SHA", "SSL_DHE_DSS_WITH_DES_CBC_SHA",
|
"SSL_DHE_RSA_WITH_DES_CBC_SHA", "SSL_DHE_DSS_WITH_DES_CBC_SHA",
|
||||||
|
@ -153,17 +138,16 @@ public class LikeJettyXml
|
||||||
"SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA");
|
"SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA");
|
||||||
|
|
||||||
// SSL HTTP Configuration
|
// SSL HTTP Configuration
|
||||||
HttpConfiguration https_config = new HttpConfiguration(http_config);
|
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
|
||||||
https_config.addCustomizer(new SecureRequestCustomizer());
|
httpsConfig.addCustomizer(new SecureRequestCustomizer());
|
||||||
|
|
||||||
// SSL Connector
|
// SSL Connector
|
||||||
ServerConnector sslConnector = new ServerConnector(server,
|
ServerConnector sslConnector = new ServerConnector(server,
|
||||||
new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
|
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
|
||||||
new HttpConnectionFactory(https_config));
|
new HttpConnectionFactory(httpsConfig));
|
||||||
sslConnector.setPort(8443);
|
sslConnector.setPort(8443);
|
||||||
server.addConnector(sslConnector);
|
server.addConnector(sslConnector);
|
||||||
|
|
||||||
|
|
||||||
// === jetty-deploy.xml ===
|
// === jetty-deploy.xml ===
|
||||||
DeploymentManager deployer = new DeploymentManager();
|
DeploymentManager deployer = new DeploymentManager();
|
||||||
//DebugListener debug = new DebugListener(System.out,true,true,true);
|
//DebugListener debug = new DebugListener(System.out,true,true,true);
|
||||||
|
@ -174,14 +158,14 @@ public class LikeJettyXml
|
||||||
"org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
|
"org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
|
||||||
".*/jetty-servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$");
|
".*/jetty-servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$");
|
||||||
|
|
||||||
WebAppProvider webapp_provider = new WebAppProvider();
|
WebAppProvider webAppProvider = new WebAppProvider();
|
||||||
webapp_provider.setMonitoredDirName(jetty_base + "/webapps");
|
webAppProvider.setMonitoredDirName(jettyBase + "/webapps");
|
||||||
webapp_provider.setDefaultsDescriptor(jetty_home + "/etc/webdefault.xml");
|
webAppProvider.setDefaultsDescriptor(jettyHome + "/etc/webdefault.xml");
|
||||||
webapp_provider.setScanInterval(1);
|
webAppProvider.setScanInterval(1);
|
||||||
webapp_provider.setExtractWars(true);
|
webAppProvider.setExtractWars(true);
|
||||||
webapp_provider.setConfigurationManager(new PropertiesConfigurationManager());
|
webAppProvider.setConfigurationManager(new PropertiesConfigurationManager());
|
||||||
|
|
||||||
deployer.addAppProvider(webapp_provider);
|
deployer.addAppProvider(webAppProvider);
|
||||||
server.addBean(deployer);
|
server.addBean(deployer);
|
||||||
|
|
||||||
// === setup jetty plus ==
|
// === setup jetty plus ==
|
||||||
|
@ -197,18 +181,19 @@ public class LikeJettyXml
|
||||||
RewriteHandler rewrite = new RewriteHandler();
|
RewriteHandler rewrite = new RewriteHandler();
|
||||||
rewrite.setHandler(server.getHandler());
|
rewrite.setHandler(server.getHandler());
|
||||||
server.setHandler(rewrite);
|
server.setHandler(rewrite);
|
||||||
|
rewrite.addRule(new MsieSslRule());
|
||||||
|
rewrite.addRule(new ValidUrlRule());
|
||||||
|
|
||||||
// === jetty-requestlog.xml ===
|
// === jetty-requestlog.xml ===
|
||||||
AsyncRequestLogWriter logWriter = new AsyncRequestLogWriter(jetty_home + "/logs/yyyy_mm_dd.request.log");
|
AsyncRequestLogWriter logWriter = new AsyncRequestLogWriter(jettyHome + "/logs/yyyy_mm_dd.request.log");
|
||||||
CustomRequestLog requestLog = new CustomRequestLog(logWriter, CustomRequestLog.EXTENDED_NCSA_FORMAT + " \"%C\"");
|
|
||||||
logWriter.setFilenameDateFormat("yyyy_MM_dd");
|
logWriter.setFilenameDateFormat("yyyy_MM_dd");
|
||||||
logWriter.setRetainDays(90);
|
logWriter.setRetainDays(90);
|
||||||
logWriter.setTimeZone("GMT");
|
logWriter.setTimeZone("GMT");
|
||||||
|
CustomRequestLog requestLog = new CustomRequestLog(logWriter, CustomRequestLog.EXTENDED_NCSA_FORMAT + " \"%C\"");
|
||||||
server.setRequestLog(requestLog);
|
server.setRequestLog(requestLog);
|
||||||
|
|
||||||
|
|
||||||
// === jetty-lowresources.xml ===
|
// === jetty-lowresources.xml ===
|
||||||
LowResourceMonitor lowResourcesMonitor=new LowResourceMonitor(server);
|
LowResourceMonitor lowResourcesMonitor = new LowResourceMonitor(server);
|
||||||
lowResourcesMonitor.setPeriod(1000);
|
lowResourcesMonitor.setPeriod(1000);
|
||||||
lowResourcesMonitor.setLowResourcesIdleTimeout(200);
|
lowResourcesMonitor.setLowResourcesIdleTimeout(200);
|
||||||
lowResourcesMonitor.setMonitorThreads(true);
|
lowResourcesMonitor.setMonitorThreads(true);
|
||||||
|
@ -216,17 +201,15 @@ public class LikeJettyXml
|
||||||
lowResourcesMonitor.setMaxLowResourcesTime(5000);
|
lowResourcesMonitor.setMaxLowResourcesTime(5000);
|
||||||
server.addBean(lowResourcesMonitor);
|
server.addBean(lowResourcesMonitor);
|
||||||
|
|
||||||
|
|
||||||
// === test-realm.xml ===
|
// === test-realm.xml ===
|
||||||
HashLoginService login = new HashLoginService();
|
HashLoginService login = new HashLoginService();
|
||||||
login.setName("Test Realm");
|
login.setName("Test Realm");
|
||||||
login.setConfig(jetty_base + "/etc/realm.properties");
|
login.setConfig(jettyBase + "/etc/realm.properties");
|
||||||
login.setHotReload(false);
|
login.setHotReload(false);
|
||||||
server.addBean(login);
|
server.addBean(login);
|
||||||
|
|
||||||
// Start the server
|
// Start the server
|
||||||
server.start();
|
server.start();
|
||||||
server.dumpStdErr();
|
|
||||||
server.join();
|
server.join();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||||
*/
|
*/
|
||||||
public class ManyConnectors
|
public class ManyConnectors
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
// Since this example shows off SSL configuration, we need a keystore
|
// Since this example shows off SSL configuration, we need a keystore
|
||||||
// with the appropriate key. These lookup of jetty.home is purely a hack
|
// with the appropriate key. These lookup of jetty.home is purely a hack
|
||||||
|
@ -65,10 +65,10 @@ public class ManyConnectors
|
||||||
// <code>http</code> of course, as the default for secured http is
|
// <code>http</code> of course, as the default for secured http is
|
||||||
// <code>https</code> but we show setting the scheme to show it can be
|
// <code>https</code> but we show setting the scheme to show it can be
|
||||||
// done. The port for secured communication is also set here.
|
// done. The port for secured communication is also set here.
|
||||||
HttpConfiguration http_config = new HttpConfiguration();
|
HttpConfiguration httpConfig = new HttpConfiguration();
|
||||||
http_config.setSecureScheme("https");
|
httpConfig.setSecureScheme("https");
|
||||||
http_config.setSecurePort(8443);
|
httpConfig.setSecurePort(8443);
|
||||||
http_config.setOutputBufferSize(32768);
|
httpConfig.setOutputBufferSize(32768);
|
||||||
|
|
||||||
// HTTP connector
|
// HTTP connector
|
||||||
// The first server connector we create is the one for http, passing in
|
// The first server connector we create is the one for http, passing in
|
||||||
|
@ -76,7 +76,7 @@ public class ManyConnectors
|
||||||
// the output buffer size, etc. We also set the port (8080) and
|
// the output buffer size, etc. We also set the port (8080) and
|
||||||
// configure an idle timeout.
|
// configure an idle timeout.
|
||||||
ServerConnector http = new ServerConnector(server,
|
ServerConnector http = new ServerConnector(server,
|
||||||
new HttpConnectionFactory(http_config));
|
new HttpConnectionFactory(httpConfig));
|
||||||
http.setPort(8080);
|
http.setPort(8080);
|
||||||
http.setIdleTimeout(30000);
|
http.setIdleTimeout(30000);
|
||||||
|
|
||||||
|
@ -105,19 +105,19 @@ public class ManyConnectors
|
||||||
// SecureRequestCustomizer which is how a new connector is able to
|
// SecureRequestCustomizer which is how a new connector is able to
|
||||||
// resolve the https connection before handing control over to the Jetty
|
// resolve the https connection before handing control over to the Jetty
|
||||||
// Server.
|
// Server.
|
||||||
HttpConfiguration https_config = new HttpConfiguration(http_config);
|
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
|
||||||
SecureRequestCustomizer src = new SecureRequestCustomizer();
|
SecureRequestCustomizer src = new SecureRequestCustomizer();
|
||||||
src.setStsMaxAge(2000);
|
src.setStsMaxAge(2000);
|
||||||
src.setStsIncludeSubDomains(true);
|
src.setStsIncludeSubDomains(true);
|
||||||
https_config.addCustomizer(src);
|
httpsConfig.addCustomizer(src);
|
||||||
|
|
||||||
// HTTPS connector
|
// HTTPS connector
|
||||||
// We create a second ServerConnector, passing in the http configuration
|
// We create a second ServerConnector, passing in the http configuration
|
||||||
// we just made along with the previously created ssl context factory.
|
// we just made along with the previously created ssl context factory.
|
||||||
// Next we set the port and a longer idle timeout.
|
// Next we set the port and a longer idle timeout.
|
||||||
ServerConnector https = new ServerConnector(server,
|
ServerConnector https = new ServerConnector(server,
|
||||||
new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
|
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
|
||||||
new HttpConnectionFactory(https_config));
|
new HttpConnectionFactory(httpsConfig));
|
||||||
https.setPort(8443);
|
https.setPort(8443);
|
||||||
https.setIdleTimeout(500000);
|
https.setIdleTimeout(500000);
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ public class ManyConnectors
|
||||||
// has something to pass requests off to.
|
// has something to pass requests off to.
|
||||||
|
|
||||||
// Set the connectors
|
// Set the connectors
|
||||||
server.setConnectors(new Connector[] { http, https });
|
server.setConnectors(new Connector[]{http, https});
|
||||||
|
|
||||||
// Set a handler
|
// Set a handler
|
||||||
server.setHandler(new HelloHandler());
|
server.setHandler(new HelloHandler());
|
||||||
|
|
|
@ -25,9 +25,9 @@ import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||||
|
|
||||||
public class ManyContexts
|
public class ManyContexts
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
Server server = new Server(8080);
|
final Server server = new Server(8080);
|
||||||
|
|
||||||
ContextHandler context = new ContextHandler("/");
|
ContextHandler context = new ContextHandler("/");
|
||||||
context.setContextPath("/");
|
context.setContextPath("/");
|
||||||
|
@ -40,12 +40,14 @@ public class ManyContexts
|
||||||
contextIT.setHandler(new HelloHandler("Bongiorno"));
|
contextIT.setHandler(new HelloHandler("Bongiorno"));
|
||||||
|
|
||||||
ContextHandler contextV = new ContextHandler("/");
|
ContextHandler contextV = new ContextHandler("/");
|
||||||
contextV.setVirtualHosts(new String[] { "127.0.0.2" });
|
contextV.setVirtualHosts(new String[]{"127.0.0.2"});
|
||||||
contextV.setHandler(new HelloHandler("Virtual Hello"));
|
contextV.setHandler(new HelloHandler("Virtual Hello"));
|
||||||
|
|
||||||
ContextHandlerCollection contexts = new ContextHandlerCollection();
|
ContextHandlerCollection contexts = new ContextHandlerCollection();
|
||||||
contexts.setHandlers(new Handler[] { context, contextFR, contextIT,
|
contexts.setHandlers(new Handler[]{
|
||||||
contextV });
|
context, contextFR, contextIT,
|
||||||
|
contextV
|
||||||
|
});
|
||||||
|
|
||||||
server.setHandler(contexts);
|
server.setHandler(contexts);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.eclipse.jetty.embedded;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
@ -72,10 +71,10 @@ public class ManyHandlers
|
||||||
public static class ParamHandler extends AbstractHandler
|
public static class ParamHandler extends AbstractHandler
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void handle( String target,
|
public void handle(String target,
|
||||||
Request baseRequest,
|
Request baseRequest,
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
HttpServletResponse response ) throws IOException,
|
HttpServletResponse response) throws IOException,
|
||||||
ServletException
|
ServletException
|
||||||
{
|
{
|
||||||
Map<String, String[]> params = request.getParameterMap();
|
Map<String, String[]> params = request.getParameterMap();
|
||||||
|
@ -94,10 +93,10 @@ public class ManyHandlers
|
||||||
public static class WelcomeWrapHandler extends HandlerWrapper
|
public static class WelcomeWrapHandler extends HandlerWrapper
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void handle( String target,
|
public void handle(String target,
|
||||||
Request baseRequest,
|
Request baseRequest,
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
HttpServletResponse response ) throws IOException,
|
HttpServletResponse response) throws IOException,
|
||||||
ServletException
|
ServletException
|
||||||
{
|
{
|
||||||
request.setAttribute("welcome", "Hello");
|
request.setAttribute("welcome", "Hello");
|
||||||
|
@ -105,15 +104,15 @@ public class ManyHandlers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
Server server = new Server(8080);
|
final Server server = new Server(8080);
|
||||||
|
|
||||||
// create the handlers
|
// create the handlers
|
||||||
Handler param = new ParamHandler();
|
final Handler param = new ParamHandler();
|
||||||
HandlerWrapper wrapper = new WelcomeWrapHandler();
|
final HandlerWrapper wrapper = new WelcomeWrapHandler();
|
||||||
Handler hello = new HelloHandler();
|
final Handler hello = new HelloHandler();
|
||||||
Handler dft = new DefaultHandler();
|
final Handler dft = new DefaultHandler();
|
||||||
|
|
||||||
// configure request logging
|
// configure request logging
|
||||||
File requestLogFile = File.createTempFile("demo", "log");
|
File requestLogFile = File.createTempFile("demo", "log");
|
||||||
|
@ -126,8 +125,8 @@ public class ManyHandlers
|
||||||
|
|
||||||
// link them all together
|
// link them all together
|
||||||
wrapper.setHandler(hello);
|
wrapper.setHandler(hello);
|
||||||
list.setHandlers(new Handler[] { param, new GzipHandler() });
|
list.setHandlers(new Handler[]{param, new GzipHandler()});
|
||||||
handlers.setHandlers(new Handler[] { list, dft });
|
handlers.setHandlers(new Handler[]{list, dft});
|
||||||
|
|
||||||
server.setHandler(handlers);
|
server.setHandler(handlers);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.eclipse.jetty.servlet.ServletHolder;
|
||||||
|
|
||||||
public class ManyServletContexts
|
public class ManyServletContexts
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
Server server = new Server(8080);
|
Server server = new Server(8080);
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
package org.eclipse.jetty.embedded;
|
package org.eclipse.jetty.embedded;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -30,7 +29,7 @@ import org.eclipse.jetty.servlet.ServletHandler;
|
||||||
|
|
||||||
public class MinimalServlets
|
public class MinimalServlets
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
// Create a basic jetty server object that will listen on port 8080.
|
// Create a basic jetty server object that will listen on port 8080.
|
||||||
// Note that if you set this to port 0 then a randomly available port
|
// Note that if you set this to port 0 then a randomly available port
|
||||||
|
@ -66,8 +65,8 @@ public class MinimalServlets
|
||||||
public static class HelloServlet extends HttpServlet
|
public static class HelloServlet extends HttpServlet
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected void doGet( HttpServletRequest request,
|
protected void doGet(HttpServletRequest request,
|
||||||
HttpServletResponse response ) throws ServletException,
|
HttpServletResponse response) throws ServletException,
|
||||||
IOException
|
IOException
|
||||||
{
|
{
|
||||||
response.setContentType("text/html");
|
response.setContentType("text/html");
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.eclipse.jetty.server.ServerConnector;
|
||||||
*/
|
*/
|
||||||
public class OneConnector
|
public class OneConnector
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
// The Server
|
// The Server
|
||||||
Server server = new Server();
|
Server server = new Server();
|
||||||
|
|
|
@ -23,18 +23,18 @@ import org.eclipse.jetty.server.handler.ContextHandler;
|
||||||
|
|
||||||
public class OneContext
|
public class OneContext
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
Server server = new Server( 8080 );
|
Server server = new Server(8080);
|
||||||
|
|
||||||
// Add a single handler on context "/hello"
|
// Add a single handler on context "/hello"
|
||||||
ContextHandler context = new ContextHandler();
|
ContextHandler context = new ContextHandler();
|
||||||
context.setContextPath( "/hello" );
|
context.setContextPath("/hello");
|
||||||
context.setHandler( new HelloHandler() );
|
context.setHandler(new HelloHandler());
|
||||||
|
|
||||||
// Can be accessed using http://localhost:8080/hello
|
// Can be accessed using http://localhost:8080/hello
|
||||||
|
|
||||||
server.setHandler( context );
|
server.setHandler(context);
|
||||||
|
|
||||||
// Start the server
|
// Start the server
|
||||||
server.start();
|
server.start();
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.eclipse.jetty.server.Server;
|
||||||
|
|
||||||
public class OneHandler
|
public class OneHandler
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
Server server = new Server(8080);
|
Server server = new Server(8080);
|
||||||
server.setHandler(new HelloHandler());
|
server.setHandler(new HelloHandler());
|
||||||
|
|
|
@ -18,11 +18,8 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.embedded;
|
package org.eclipse.jetty.embedded;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.Server;
|
import java.io.IOException;
|
||||||
import org.eclipse.jetty.servlet.DefaultServlet;
|
import java.util.EnumSet;
|
||||||
import org.eclipse.jetty.servlet.ListenerHolder;
|
|
||||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
|
||||||
|
|
||||||
import javax.servlet.DispatcherType;
|
import javax.servlet.DispatcherType;
|
||||||
import javax.servlet.Filter;
|
import javax.servlet.Filter;
|
||||||
import javax.servlet.FilterChain;
|
import javax.servlet.FilterChain;
|
||||||
|
@ -34,12 +31,15 @@ import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.ServletRequestEvent;
|
import javax.servlet.ServletRequestEvent;
|
||||||
import javax.servlet.ServletRequestListener;
|
import javax.servlet.ServletRequestListener;
|
||||||
import javax.servlet.ServletResponse;
|
import javax.servlet.ServletResponse;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.EnumSet;
|
import org.eclipse.jetty.server.Server;
|
||||||
|
import org.eclipse.jetty.servlet.DefaultServlet;
|
||||||
|
import org.eclipse.jetty.servlet.ListenerHolder;
|
||||||
|
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||||
|
|
||||||
public class OneServletContext
|
public class OneServletContext
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
Server server = new Server(8080);
|
Server server = new Server(8080);
|
||||||
|
|
||||||
|
@ -56,9 +56,9 @@ public class OneServletContext
|
||||||
context.addServlet(HelloServlet.class, "/hello/*");
|
context.addServlet(HelloServlet.class, "/hello/*");
|
||||||
context.addServlet(DefaultServlet.class, "/");
|
context.addServlet(DefaultServlet.class, "/");
|
||||||
|
|
||||||
context.addFilter(TestFilter.class,"/*", EnumSet.of(DispatcherType.REQUEST));
|
context.addFilter(TestFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
|
||||||
context.addFilter(TestFilter.class,"/test", EnumSet.of(DispatcherType.REQUEST,DispatcherType.ASYNC));
|
context.addFilter(TestFilter.class, "/test", EnumSet.of(DispatcherType.REQUEST, DispatcherType.ASYNC));
|
||||||
context.addFilter(TestFilter.class,"*.test", EnumSet.of(DispatcherType.REQUEST,DispatcherType.INCLUDE,DispatcherType.FORWARD));
|
context.addFilter(TestFilter.class, "*.test", EnumSet.of(DispatcherType.REQUEST, DispatcherType.INCLUDE, DispatcherType.FORWARD));
|
||||||
|
|
||||||
context.getServletHandler().addListener(new ListenerHolder(InitListener.class));
|
context.getServletHandler().addListener(new ListenerHolder(InitListener.class));
|
||||||
context.getServletHandler().addListener(new ListenerHolder(RequestListener.class));
|
context.getServletHandler().addListener(new ListenerHolder(RequestListener.class));
|
||||||
|
@ -68,7 +68,6 @@ public class OneServletContext
|
||||||
server.join();
|
server.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class TestFilter implements Filter
|
public static class TestFilter implements Filter
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -103,7 +102,6 @@ public class OneServletContext
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class RequestListener implements ServletRequestListener
|
public static class RequestListener implements ServletRequestListener
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||||
|
|
||||||
public class OneServletContextJmxStats
|
public class OneServletContextJmxStats
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
Server server = new Server(8080);
|
Server server = new Server(8080);
|
||||||
// Add JMX tracking to Server
|
// Add JMX tracking to Server
|
||||||
|
|
|
@ -25,7 +25,6 @@ import org.eclipse.jetty.server.session.SessionCache;
|
||||||
import org.eclipse.jetty.server.session.SessionHandler;
|
import org.eclipse.jetty.server.session.SessionHandler;
|
||||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||||
|
|
||||||
|
|
||||||
public class OneServletContextWithSession
|
public class OneServletContextWithSession
|
||||||
{
|
{
|
||||||
public static void main(String[] args) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
|
|
||||||
public class OneWebApp
|
public class OneWebApp
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
// Create a basic jetty server object that will listen on port 8080.
|
// Create a basic jetty server object that will listen on port 8080.
|
||||||
// Note that if you set this to port 0 then a randomly available port
|
// Note that if you set this to port 0 then a randomly available port
|
||||||
|
@ -50,12 +50,7 @@ public class OneWebApp
|
||||||
// PlusConfiguration) to choosing where the webapp will unpack itself.
|
// PlusConfiguration) to choosing where the webapp will unpack itself.
|
||||||
WebAppContext webapp = new WebAppContext();
|
WebAppContext webapp = new WebAppContext();
|
||||||
webapp.setContextPath("/");
|
webapp.setContextPath("/");
|
||||||
File warFile = new File("../../tests/test-jmx/jmx-webapp/target/jmx-webapp");
|
File warFile = JettyDistribution.resolve("demo-base/webapps/async-rest.war").toFile();
|
||||||
if (!warFile.exists())
|
|
||||||
warFile = new File("tests/test-jmx/jmx-webapp/target/jmx-webapp");
|
|
||||||
if (!warFile.exists())
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
|
|
||||||
webapp.setWar(warFile.getAbsolutePath());
|
webapp.setWar(warFile.getAbsolutePath());
|
||||||
|
|
||||||
// A WebAppContext is a ContextHandler as well so it needs to be set to
|
// A WebAppContext is a ContextHandler as well so it needs to be set to
|
||||||
|
|
|
@ -29,19 +29,19 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
|
|
||||||
public class OneWebAppWithJsp
|
public class OneWebAppWithJsp
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
// Create a basic jetty server object that will listen on port 8080.
|
// Create a basic jetty server object that will listen on port 8080.
|
||||||
// Note that if you set this to port 0 then
|
// Note that if you set this to port 0 then
|
||||||
// a randomly available port will be assigned that you can either look
|
// a randomly available port will be assigned that you can either look
|
||||||
// in the logs for the port,
|
// in the logs for the port,
|
||||||
// or programmatically obtain it for use in test cases.
|
// or programmatically obtain it for use in test cases.
|
||||||
Server server = new Server( 8080 );
|
Server server = new Server(8080);
|
||||||
|
|
||||||
// Setup JMX
|
// Setup JMX
|
||||||
MBeanContainer mbContainer = new MBeanContainer(
|
MBeanContainer mbContainer = new MBeanContainer(
|
||||||
ManagementFactory.getPlatformMBeanServer() );
|
ManagementFactory.getPlatformMBeanServer());
|
||||||
server.addBean( mbContainer );
|
server.addBean(mbContainer);
|
||||||
|
|
||||||
// The WebAppContext is the entity that controls the environment in
|
// The WebAppContext is the entity that controls the environment in
|
||||||
// which a web application lives and
|
// which a web application lives and
|
||||||
|
@ -53,18 +53,16 @@ public class OneWebAppWithJsp
|
||||||
// the webapp (through
|
// the webapp (through
|
||||||
// PlusConfiguration) to choosing where the webapp will unpack itself.
|
// PlusConfiguration) to choosing where the webapp will unpack itself.
|
||||||
WebAppContext webapp = new WebAppContext();
|
WebAppContext webapp = new WebAppContext();
|
||||||
webapp.setContextPath( "/" );
|
webapp.setContextPath("/");
|
||||||
File warFile = new File(
|
File warFile = new File(
|
||||||
"jetty-distribution/target/distribution/demo-base/webapps/test.war" );
|
"jetty-distribution/target/distribution/demo-base/webapps/test.war");
|
||||||
if (!warFile.exists())
|
if (!warFile.exists())
|
||||||
{
|
{
|
||||||
throw new RuntimeException( "Unable to find WAR File: "
|
throw new RuntimeException("Unable to find WAR File: " + warFile.getAbsolutePath());
|
||||||
+ warFile.getAbsolutePath() );
|
|
||||||
}
|
}
|
||||||
webapp.setWar( warFile.getAbsolutePath() );
|
webapp.setWar(warFile.getAbsolutePath());
|
||||||
webapp.setExtractWAR(true);
|
webapp.setExtractWAR(true);
|
||||||
|
|
||||||
|
|
||||||
// This webapp will use jsps and jstl. We need to enable the
|
// This webapp will use jsps and jstl. We need to enable the
|
||||||
// AnnotationConfiguration in order to correctly
|
// AnnotationConfiguration in order to correctly
|
||||||
// set up the jsp container
|
// set up the jsp container
|
||||||
|
@ -76,12 +74,12 @@ public class OneWebAppWithJsp
|
||||||
// scan for them instead.
|
// scan for them instead.
|
||||||
webapp.setAttribute(
|
webapp.setAttribute(
|
||||||
"org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
|
"org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
|
||||||
".*/jetty-servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$" );
|
".*/jetty-servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$");
|
||||||
|
|
||||||
// A WebAppContext is a ContextHandler as well so it needs to be set to
|
// A WebAppContext is a ContextHandler as well so it needs to be set to
|
||||||
// the server so it is aware of where to
|
// the server so it is aware of where to
|
||||||
// send the appropriate requests.
|
// send the appropriate requests.
|
||||||
server.setHandler( webapp );
|
server.setHandler(webapp);
|
||||||
|
|
||||||
// Configure a LoginService.
|
// Configure a LoginService.
|
||||||
// Since this example is for our test webapp, we need to setup a
|
// Since this example is for our test webapp, we need to setup a
|
||||||
|
@ -92,9 +90,9 @@ public class OneWebAppWithJsp
|
||||||
// can be started and stopped according to the lifecycle of the server
|
// can be started and stopped according to the lifecycle of the server
|
||||||
// itself.
|
// itself.
|
||||||
HashLoginService loginService = new HashLoginService();
|
HashLoginService loginService = new HashLoginService();
|
||||||
loginService.setName( "Test Realm" );
|
loginService.setName("Test Realm");
|
||||||
loginService.setConfig( "examples/embedded/src/test/resources/realm.properties" );
|
loginService.setConfig("examples/embedded/src/test/resources/realm.properties");
|
||||||
server.addBean( loginService );
|
server.addBean(loginService);
|
||||||
|
|
||||||
// Start things up!
|
// Start things up!
|
||||||
server.start();
|
server.start();
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.eclipse.jetty.servlet.ServletHolder;
|
||||||
|
|
||||||
public class ProxyServer
|
public class ProxyServer
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
Server server = new Server();
|
Server server = new Server();
|
||||||
ServerConnector connector = new ServerConnector(server);
|
ServerConnector connector = new ServerConnector(server);
|
||||||
|
@ -47,5 +47,4 @@ public class ProxyServer
|
||||||
|
|
||||||
server.start();
|
server.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,16 +28,16 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||||
|
|
||||||
public class RewriteServer
|
public class RewriteServer
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
Server server = new Server(8080);
|
Server server = new Server(8080);
|
||||||
|
|
||||||
HttpConfiguration config=server.getConnectors()[0].getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration();
|
HttpConfiguration config = server.getConnectors()[0].getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration();
|
||||||
|
|
||||||
RewriteCustomizer rewrite = new RewriteCustomizer();
|
RewriteCustomizer rewrite = new RewriteCustomizer();
|
||||||
config.addCustomizer(rewrite);
|
config.addCustomizer(rewrite);
|
||||||
rewrite.addRule(new CompactPathRule());
|
rewrite.addRule(new CompactPathRule());
|
||||||
rewrite.addRule(new RewriteRegexRule("(.*)foo(.*)","$1FOO$2"));
|
rewrite.addRule(new RewriteRegexRule("(.*)foo(.*)", "$1FOO$2"));
|
||||||
|
|
||||||
ServletContextHandler context = new ServletContextHandler(
|
ServletContextHandler context = new ServletContextHandler(
|
||||||
ServletContextHandler.SESSIONS);
|
ServletContextHandler.SESSIONS);
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.eclipse.jetty.util.security.Constraint;
|
||||||
|
|
||||||
public class SecuredHelloHandler
|
public class SecuredHelloHandler
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
// Create a basic jetty server object that will listen on port 8080.
|
// Create a basic jetty server object that will listen on port 8080.
|
||||||
// Note that if you set this to port 0 then a randomly available port
|
// Note that if you set this to port 0 then a randomly available port
|
||||||
|
@ -65,7 +65,7 @@ public class SecuredHelloHandler
|
||||||
Constraint constraint = new Constraint();
|
Constraint constraint = new Constraint();
|
||||||
constraint.setName("auth");
|
constraint.setName("auth");
|
||||||
constraint.setAuthenticate(true);
|
constraint.setAuthenticate(true);
|
||||||
constraint.setRoles(new String[] { "user", "admin" });
|
constraint.setRoles(new String[]{"user", "admin"});
|
||||||
|
|
||||||
// Binds a url pattern with the previously created constraint. The roles
|
// Binds a url pattern with the previously created constraint. The roles
|
||||||
// for this constraing mapping are mined from the Constraint itself
|
// for this constraing mapping are mined from the Constraint itself
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.io.File;
|
||||||
|
|
||||||
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
||||||
import org.eclipse.jetty.plus.jndi.EnvEntry;
|
import org.eclipse.jetty.plus.jndi.EnvEntry;
|
||||||
|
import org.eclipse.jetty.plus.jndi.NamingDump;
|
||||||
import org.eclipse.jetty.plus.jndi.Resource;
|
import org.eclipse.jetty.plus.jndi.Resource;
|
||||||
import org.eclipse.jetty.plus.jndi.Transaction;
|
import org.eclipse.jetty.plus.jndi.Transaction;
|
||||||
import org.eclipse.jetty.plus.webapp.EnvConfiguration;
|
import org.eclipse.jetty.plus.webapp.EnvConfiguration;
|
||||||
|
@ -35,21 +36,19 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
*/
|
*/
|
||||||
public class ServerWithAnnotations
|
public class ServerWithAnnotations
|
||||||
{
|
{
|
||||||
public static final void main( String args[] ) throws Exception
|
public static final void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
// Create the server
|
// Create the server
|
||||||
Server server = new Server(8080);
|
final Server server = new Server(8080);
|
||||||
|
|
||||||
|
|
||||||
// Create a WebApp
|
// Create a WebApp
|
||||||
WebAppContext webapp = new WebAppContext();
|
WebAppContext webapp = new WebAppContext();
|
||||||
|
|
||||||
// Enable parsing of jndi-related parts of web.xml and jetty-env.xml
|
// Enable parsing of jndi-related parts of web.xml and jetty-env.xml
|
||||||
webapp.addConfiguration(new EnvConfiguration(),new PlusConfiguration(),new AnnotationConfiguration());
|
webapp.addConfiguration(new EnvConfiguration(), new PlusConfiguration(), new AnnotationConfiguration());
|
||||||
|
|
||||||
webapp.setContextPath("/");
|
webapp.setContextPath("/");
|
||||||
File warFile = new File(
|
File warFile = JettyDistribution.resolve("demo-base/webapps/test-spec.war").toFile();
|
||||||
"jetty-distribution/target/distribution/demo-base/webapps/test.war");
|
|
||||||
webapp.setWar(warFile.getAbsolutePath());
|
webapp.setWar(warFile.getAbsolutePath());
|
||||||
webapp.setAttribute(
|
webapp.setAttribute(
|
||||||
"org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
|
"org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
|
||||||
|
@ -61,10 +60,14 @@ public class ServerWithAnnotations
|
||||||
new Transaction(new com.acme.MockUserTransaction());
|
new Transaction(new com.acme.MockUserTransaction());
|
||||||
|
|
||||||
// Define an env entry with webapp scope.
|
// Define an env entry with webapp scope.
|
||||||
new EnvEntry(webapp, "maxAmount", 100D, true);
|
// THIS ENTRY IS OVERRIDEN BY THE ENTRY IN jetty-env.xml
|
||||||
|
new EnvEntry(webapp, "maxAmount", 100d, true);
|
||||||
|
|
||||||
// Register a mock DataSource scoped to the webapp
|
// Register a mock DataSource scoped to the webapp
|
||||||
new Resource(webapp, "jdbc/mydatasource", new com.acme.MockDataSource());
|
new Resource(server, "jdbc/mydatasource", new com.acme.MockDataSource());
|
||||||
|
|
||||||
|
// Add JNDI context to server for dump
|
||||||
|
server.addBean(new NamingDump());
|
||||||
|
|
||||||
// Configure a LoginService
|
// Configure a LoginService
|
||||||
HashLoginService loginService = new HashLoginService();
|
HashLoginService loginService = new HashLoginService();
|
||||||
|
@ -76,5 +79,4 @@ public class ServerWithAnnotations
|
||||||
server.dumpStdErr();
|
server.dumpStdErr();
|
||||||
server.join();
|
server.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
package org.eclipse.jetty.embedded;
|
package org.eclipse.jetty.embedded;
|
||||||
|
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
|
|
||||||
import javax.management.remote.JMXServiceURL;
|
import javax.management.remote.JMXServiceURL;
|
||||||
|
|
||||||
import org.eclipse.jetty.jmx.ConnectorServer;
|
import org.eclipse.jetty.jmx.ConnectorServer;
|
||||||
|
@ -31,7 +30,7 @@ import org.eclipse.jetty.server.Server;
|
||||||
*/
|
*/
|
||||||
public class ServerWithJMX
|
public class ServerWithJMX
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
// === jetty-jmx.xml ===
|
// === jetty-jmx.xml ===
|
||||||
MBeanContainer mbContainer = new MBeanContainer(
|
MBeanContainer mbContainer = new MBeanContainer(
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
*/
|
*/
|
||||||
public class ServerWithJNDI
|
public class ServerWithJNDI
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
// Create the server
|
// Create the server
|
||||||
|
@ -46,7 +46,7 @@ public class ServerWithJNDI
|
||||||
server.setHandler(webapp);
|
server.setHandler(webapp);
|
||||||
|
|
||||||
// Enable parsing of jndi-related parts of web.xml and jetty-env.xml
|
// Enable parsing of jndi-related parts of web.xml and jetty-env.xml
|
||||||
webapp.addConfiguration(new EnvConfiguration(),new PlusConfiguration());
|
webapp.addConfiguration(new EnvConfiguration(), new PlusConfiguration());
|
||||||
|
|
||||||
// Register new transaction manager in JNDI
|
// Register new transaction manager in JNDI
|
||||||
// At runtime, the webapp accesses this as java:comp/UserTransaction
|
// At runtime, the webapp accesses this as java:comp/UserTransaction
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.eclipse.jetty.server.Server;
|
||||||
*/
|
*/
|
||||||
public class SimplestServer
|
public class SimplestServer
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
Server server = new Server(8080);
|
Server server = new Server(8080);
|
||||||
server.start();
|
server.start();
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.eclipse.jetty.util.resource.Resource;
|
||||||
*/
|
*/
|
||||||
public class SplitFileServer
|
public class SplitFileServer
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
// Create the Server object and a corresponding ServerConnector and then
|
// Create the Server object and a corresponding ServerConnector and then
|
||||||
// set the port for the connector. In this example the server will
|
// set the port for the connector. In this example the server will
|
||||||
|
@ -47,7 +47,7 @@ public class SplitFileServer
|
||||||
Server server = new Server();
|
Server server = new Server();
|
||||||
ServerConnector connector = new ServerConnector(server);
|
ServerConnector connector = new ServerConnector(server);
|
||||||
connector.setPort(8090);
|
connector.setPort(8090);
|
||||||
server.setConnectors(new Connector[] { connector });
|
server.setConnectors(new Connector[]{connector});
|
||||||
|
|
||||||
// Create a Context Handler and ResourceHandler. The ContextHandler is
|
// Create a Context Handler and ResourceHandler. The ContextHandler is
|
||||||
// getting set to "/" path but this could be anything you like for
|
// getting set to "/" path but this could be anything you like for
|
||||||
|
@ -77,7 +77,7 @@ public class SplitFileServer
|
||||||
// This will let jetty process urls against the declared contexts in
|
// This will let jetty process urls against the declared contexts in
|
||||||
// order to match up content.
|
// order to match up content.
|
||||||
ContextHandlerCollection contexts = new ContextHandlerCollection();
|
ContextHandlerCollection contexts = new ContextHandlerCollection();
|
||||||
contexts.setHandlers(new Handler[] { context0, context1 });
|
contexts.setHandlers(new Handler[]{context0, context1});
|
||||||
|
|
||||||
server.setHandler(contexts);
|
server.setHandler(contexts);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.embedded;
|
||||||
|
|
||||||
import javax.websocket.OnMessage;
|
import javax.websocket.OnMessage;
|
||||||
import javax.websocket.Session;
|
import javax.websocket.Session;
|
||||||
import javax.websocket.server.ServerContainer;
|
|
||||||
import javax.websocket.server.ServerEndpoint;
|
import javax.websocket.server.ServerEndpoint;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
|
@ -41,34 +40,31 @@ public class WebSocketJsrServer
|
||||||
public static class EchoJsrSocket
|
public static class EchoJsrSocket
|
||||||
{
|
{
|
||||||
@OnMessage
|
@OnMessage
|
||||||
public void onMessage( Session session, String message )
|
public void onMessage(Session session, String message)
|
||||||
{
|
{
|
||||||
session.getAsyncRemote().sendText(message);
|
session.getAsyncRemote().sendText(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
Server server = new Server(8080);
|
final Server server = new Server(8080);
|
||||||
|
|
||||||
HandlerList handlers = new HandlerList();
|
HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
ServletContextHandler context = new ServletContextHandler(
|
ServletContextHandler contextHandler = new ServletContextHandler(
|
||||||
ServletContextHandler.SESSIONS);
|
ServletContextHandler.SESSIONS);
|
||||||
context.setContextPath("/");
|
contextHandler.setContextPath("/");
|
||||||
handlers.addHandler(context);
|
handlers.addHandler(contextHandler);
|
||||||
handlers.addHandler(new DefaultHandler());
|
handlers.addHandler(new DefaultHandler());
|
||||||
server.setHandler(handlers);
|
server.setHandler(handlers);
|
||||||
|
|
||||||
// Enable javax.websocket configuration for the context
|
// Enable javax.websocket configuration for the context
|
||||||
ServerContainer wsContainer = JavaxWebSocketServletContainerInitializer
|
JavaxWebSocketServletContainerInitializer.configure(contextHandler, (context, container) ->
|
||||||
.configureContext(context);
|
container.addEndpoint(EchoJsrSocket.class));
|
||||||
|
|
||||||
// Add your websockets to the container
|
|
||||||
wsContainer.addEndpoint(EchoJsrSocket.class);
|
|
||||||
|
|
||||||
server.start();
|
server.start();
|
||||||
context.dumpStdErr();
|
contextHandler.dumpStdErr();
|
||||||
server.join();
|
server.join();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||||
import org.eclipse.jetty.servlet.ServletHolder;
|
import org.eclipse.jetty.servlet.ServletHolder;
|
||||||
import org.eclipse.jetty.websocket.api.Session;
|
import org.eclipse.jetty.websocket.api.Session;
|
||||||
|
import org.eclipse.jetty.websocket.api.WriteCallback;
|
||||||
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
|
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
|
||||||
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
|
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
|
||||||
import org.eclipse.jetty.websocket.server.JettyWebSocketServlet;
|
import org.eclipse.jetty.websocket.server.JettyWebSocketServlet;
|
||||||
|
@ -41,9 +42,9 @@ public class WebSocketServer
|
||||||
public static class EchoSocket
|
public static class EchoSocket
|
||||||
{
|
{
|
||||||
@OnWebSocketMessage
|
@OnWebSocketMessage
|
||||||
public void onMessage( Session session, String message )
|
public void onMessage(Session session, String message)
|
||||||
{
|
{
|
||||||
session.getRemote().sendStringByFuture(message);
|
session.getRemote().sendString(message, WriteCallback.NOOP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,11 +57,11 @@ public class WebSocketServer
|
||||||
@Override
|
@Override
|
||||||
public void configure(JettyWebSocketServletFactory factory)
|
public void configure(JettyWebSocketServletFactory factory)
|
||||||
{
|
{
|
||||||
factory.addMapping(factory.parsePathSpec("/"), (req,res)->new EchoSocket());
|
factory.addMapping("/", (req, res) -> new EchoSocket());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main( String[] args ) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
Server server = new Server(8080);
|
Server server = new Server(8080);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_9_3.dtd">
|
||||||
|
|
||||||
<Configure id="ExampleServer" class="org.eclipse.jetty.server.Server">
|
<Configure id="ExampleServer" class="org.eclipse.jetty.server.Server">
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_9_3.dtd">
|
||||||
|
|
||||||
<Configure id="FileServer" class="org.eclipse.jetty.server.Server">
|
<Configure id="FileServer" class="org.eclipse.jetty.server.Server">
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_9_3.dtd">
|
||||||
|
|
||||||
<Configure id="OtherServer" class="org.eclipse.jetty.server.Server">
|
<Configure id="OtherServer" class="org.eclipse.jetty.server.Server">
|
||||||
<Set name="handler">
|
<Set name="handler">
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class TestXml
|
||||||
{
|
{
|
||||||
public static void main(String[] args) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
System.setProperty("jetty.home","../jetty-distribution/target/distribution");
|
System.setProperty("jetty.home", "../jetty-distribution/target/distribution");
|
||||||
XmlConfiguration.main("../jetty-jmx/src/main/config/etc/jetty-jmx.xml",
|
XmlConfiguration.main("../jetty-jmx/src/main/config/etc/jetty-jmx.xml",
|
||||||
"../jetty-server/src/main/config/etc/jetty.xml");
|
"../jetty-server/src/main/config/etc/jetty.xml");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-project</artifactId>
|
<artifactId>jetty-project</artifactId>
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.eclipse.jetty.alpn.client;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import javax.net.ssl.SSLEngine;
|
import javax.net.ssl.SSLEngine;
|
||||||
|
|
||||||
import org.eclipse.jetty.io.ClientConnectionFactory;
|
import org.eclipse.jetty.io.ClientConnectionFactory;
|
||||||
|
|
|
@ -24,7 +24,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.ServiceLoader;
|
import java.util.ServiceLoader;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import javax.net.ssl.SSLEngine;
|
import javax.net.ssl.SSLEngine;
|
||||||
|
|
||||||
import org.eclipse.jetty.io.ClientConnectionFactory;
|
import org.eclipse.jetty.io.ClientConnectionFactory;
|
||||||
|
@ -55,14 +54,14 @@ public class ALPNClientConnectionFactory extends NegotiatingClientConnectionFact
|
||||||
IllegalStateException failure = new IllegalStateException("No Client ALPNProcessors!");
|
IllegalStateException failure = new IllegalStateException("No Client ALPNProcessors!");
|
||||||
|
|
||||||
// Use a for loop on iterator so load exceptions can be caught and ignored
|
// Use a for loop on iterator so load exceptions can be caught and ignored
|
||||||
for (Iterator<Client> i = ServiceLoader.load(Client.class).iterator(); i.hasNext();)
|
for (Iterator<Client> i = ServiceLoader.load(Client.class).iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
Client processor;
|
Client processor;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
processor = i.next();
|
processor = i.next();
|
||||||
}
|
}
|
||||||
catch(Throwable x)
|
catch (Throwable x)
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug(x);
|
LOG.debug(x);
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<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/xsd/maven-4.0.0.xsd">
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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/xsd/maven-4.0.0.xsd">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-alpn-parent</artifactId>
|
<artifactId>jetty-alpn-parent</artifactId>
|
||||||
|
@ -84,8 +83,7 @@
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<argLine>
|
<argLine>
|
||||||
@{argLine} ${jetty.surefire.argLine}
|
@{argLine} ${jetty.surefire.argLine} --add-reads org.eclipse.jetty.alpn.conscrypt.server=org.eclipse.jetty.server
|
||||||
--add-reads org.eclipse.jetty.alpn.conscrypt.server=org.eclipse.jetty.server
|
|
||||||
</argLine>
|
</argLine>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -76,7 +76,6 @@ public class ConscryptServerALPNProcessor implements ALPNProcessor.Server
|
||||||
{
|
{
|
||||||
private final ALPNServerConnection alpnConnection;
|
private final ALPNServerConnection alpnConnection;
|
||||||
|
|
||||||
|
|
||||||
private ALPNCallback(ALPNServerConnection connection)
|
private ALPNCallback(ALPNServerConnection connection)
|
||||||
{
|
{
|
||||||
alpnConnection = connection;
|
alpnConnection = connection;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<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/xsd/maven-4.0.0.xsd">
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
package org.eclipse.jetty.alpn.java.client;
|
package org.eclipse.jetty.alpn.java.client;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.net.ssl.SSLEngine;
|
import javax.net.ssl.SSLEngine;
|
||||||
import javax.net.ssl.SSLParameters;
|
import javax.net.ssl.SSLParameters;
|
||||||
|
|
||||||
|
@ -39,15 +38,15 @@ public class JDK9ClientALPNProcessor implements ALPNProcessor.Client
|
||||||
@Override
|
@Override
|
||||||
public void init()
|
public void init()
|
||||||
{
|
{
|
||||||
if (JavaVersion.VERSION.getPlatform()<9)
|
if (JavaVersion.VERSION.getPlatform() < 9)
|
||||||
throw new IllegalStateException(this + " not applicable for java "+JavaVersion.VERSION);
|
throw new IllegalStateException(this + " not applicable for java " + JavaVersion.VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean appliesTo(SSLEngine sslEngine)
|
public boolean appliesTo(SSLEngine sslEngine)
|
||||||
{
|
{
|
||||||
Module module = sslEngine.getClass().getModule();
|
Module module = sslEngine.getClass().getModule();
|
||||||
return module!=null && "java.base".equals(module.getName());
|
return module != null && "java.base".equals(module.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<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/xsd/maven-4.0.0.xsd">
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-alpn-parent</artifactId>
|
<artifactId>jetty-alpn-parent</artifactId>
|
||||||
|
@ -22,8 +20,7 @@
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<argLine>
|
<argLine>
|
||||||
@{argLine} ${jetty.surefire.argLine}
|
@{argLine} ${jetty.surefire.argLine} --add-reads org.eclipse.jetty.alpn.java.server=org.eclipse.jetty.server
|
||||||
--add-reads org.eclipse.jetty.alpn.java.server=org.eclipse.jetty.server
|
|
||||||
</argLine>
|
</argLine>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.alpn.java.server;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
import javax.net.ssl.SSLEngine;
|
import javax.net.ssl.SSLEngine;
|
||||||
|
|
||||||
import org.eclipse.jetty.alpn.server.ALPNServerConnection;
|
import org.eclipse.jetty.alpn.server.ALPNServerConnection;
|
||||||
|
@ -39,15 +38,15 @@ public class JDK9ServerALPNProcessor implements ALPNProcessor.Server, SslHandsha
|
||||||
@Override
|
@Override
|
||||||
public void init()
|
public void init()
|
||||||
{
|
{
|
||||||
if (JavaVersion.VERSION.getPlatform()<9)
|
if (JavaVersion.VERSION.getPlatform() < 9)
|
||||||
throw new IllegalStateException(this + " not applicable for java "+JavaVersion.VERSION);
|
throw new IllegalStateException(this + " not applicable for java " + JavaVersion.VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean appliesTo(SSLEngine sslEngine)
|
public boolean appliesTo(SSLEngine sslEngine)
|
||||||
{
|
{
|
||||||
Module module = sslEngine.getClass().getModule();
|
Module module = sslEngine.getClass().getModule();
|
||||||
return module!=null && "java.base".equals(module.getName());
|
return module != null && "java.base".equals(module.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,7 +55,7 @@ public class JDK9ServerALPNProcessor implements ALPNProcessor.Server, SslHandsha
|
||||||
sslEngine.setHandshakeApplicationProtocolSelector(new ALPNCallback((ALPNServerConnection)connection));
|
sslEngine.setHandshakeApplicationProtocolSelector(new ALPNCallback((ALPNServerConnection)connection));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ALPNCallback implements BiFunction<SSLEngine,List<String>,String>, SslHandshakeListener
|
private final class ALPNCallback implements BiFunction<SSLEngine, List<String>, String>, SslHandshakeListener
|
||||||
{
|
{
|
||||||
private final ALPNServerConnection alpnConnection;
|
private final ALPNServerConnection alpnConnection;
|
||||||
|
|
||||||
|
@ -81,7 +80,7 @@ public class JDK9ServerALPNProcessor implements ALPNProcessor.Server, SslHandsha
|
||||||
String protocol = alpnConnection.getProtocol();
|
String protocol = alpnConnection.getProtocol();
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("TLS handshake succeeded, protocol={} for {}", protocol, alpnConnection);
|
LOG.debug("TLS handshake succeeded, protocol={} for {}", protocol, alpnConnection);
|
||||||
if (protocol ==null)
|
if (protocol == null)
|
||||||
alpnConnection.unsupported();
|
alpnConnection.unsupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.SSLParameters;
|
import javax.net.ssl.SSLParameters;
|
||||||
import javax.net.ssl.SSLSocket;
|
import javax.net.ssl.SSLSocket;
|
||||||
|
@ -105,7 +104,7 @@ public class JDK9ALPNTest
|
||||||
client.startHandshake();
|
client.startHandshake();
|
||||||
|
|
||||||
OutputStream output = client.getOutputStream();
|
OutputStream output = client.getOutputStream();
|
||||||
output.write(("" +
|
output.write((
|
||||||
"GET / HTTP/1.1\r\n" +
|
"GET / HTTP/1.1\r\n" +
|
||||||
"Host: localhost\r\n" +
|
"Host: localhost\r\n" +
|
||||||
"Connection: close\r\n" +
|
"Connection: close\r\n" +
|
||||||
|
@ -150,7 +149,7 @@ public class JDK9ALPNTest
|
||||||
client.startHandshake();
|
client.startHandshake();
|
||||||
|
|
||||||
OutputStream output = client.getOutputStream();
|
OutputStream output = client.getOutputStream();
|
||||||
output.write(("" +
|
output.write((
|
||||||
"GET / HTTP/1.1\r\n" +
|
"GET / HTTP/1.1\r\n" +
|
||||||
"Host: localhost\r\n" +
|
"Host: localhost\r\n" +
|
||||||
"Connection: close\r\n" +
|
"Connection: close\r\n" +
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">
|
||||||
|
|
||||||
<Configure id="sslConnector" class="org.eclipse.jetty.server.ServerConnector">
|
<Configure id="sslConnector" class="org.eclipse.jetty.server.ServerConnector">
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
<Arg>
|
<Arg>
|
||||||
<New id="alpn" class="org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory">
|
<New id="alpn" class="org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory">
|
||||||
<Arg name="protocols" type="String"><Property name="jetty.alpn.protocols" default="" /></Arg>
|
<Arg name="protocols" type="String"><Property name="jetty.alpn.protocols" default="" /></Arg>
|
||||||
<Set name="defaultProtocol"><Property name="jetty.alpn.defaultProtocol" /></Set>
|
<Set name="defaultProtocol" property="jetty.alpn.defaultProtocol"/>
|
||||||
</New>
|
</New>
|
||||||
</Arg>
|
</Arg>
|
||||||
</Call>
|
</Call>
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
DO NOT EDIT - See: https://www.eclipse.org/jetty/documentation/current/startup-modules.html
|
||||||
|
|
||||||
|
[depend]
|
||||||
|
alpn-impl/alpn-9
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.alpn.server;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.net.ssl.SSLEngine;
|
import javax.net.ssl.SSLEngine;
|
||||||
import javax.net.ssl.SSLSession;
|
import javax.net.ssl.SSLSession;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ServiceLoader;
|
import java.util.ServiceLoader;
|
||||||
|
|
||||||
import javax.net.ssl.SSLEngine;
|
import javax.net.ssl.SSLEngine;
|
||||||
|
|
||||||
import org.eclipse.jetty.io.AbstractConnection;
|
import org.eclipse.jetty.io.AbstractConnection;
|
||||||
|
@ -52,14 +51,14 @@ public class ALPNServerConnectionFactory extends NegotiatingServerConnectionFact
|
||||||
|
|
||||||
IllegalStateException failure = new IllegalStateException("No Server ALPNProcessors!");
|
IllegalStateException failure = new IllegalStateException("No Server ALPNProcessors!");
|
||||||
// Use a for loop on iterator so load exceptions can be caught and ignored
|
// Use a for loop on iterator so load exceptions can be caught and ignored
|
||||||
for (Iterator<Server> i = ServiceLoader.load(Server.class).iterator(); i.hasNext();)
|
for (Iterator<Server> i = ServiceLoader.load(Server.class).iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
Server processor;
|
Server processor;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
processor = i.next();
|
processor = i.next();
|
||||||
}
|
}
|
||||||
catch(Throwable x)
|
catch (Throwable x)
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug(x);
|
LOG.debug(x);
|
||||||
|
@ -108,7 +107,7 @@ public class ALPNServerConnectionFactory extends NegotiatingServerConnectionFact
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("No ALPNProcessor: {} {}",engine,endPoint);
|
LOG.debug("No ALPNProcessor: {} {}", engine, endPoint);
|
||||||
throw new IllegalStateException("Connection rejected: No ALPN Processor for " + engine.getClass().getName() + " from " + processors);
|
throw new IllegalStateException("Connection rejected: No ALPN Processor for " + engine.getClass().getName() + " from " + processors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<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">
|
||||||
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>
|
<parent>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-project</artifactId>
|
<artifactId>jetty-project</artifactId>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-project</artifactId>
|
<artifactId>jetty-project</artifactId>
|
||||||
|
@ -21,8 +20,7 @@
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<argLine>
|
<argLine>
|
||||||
@{argLine} ${jetty.surefire.argLine}
|
@{argLine} ${jetty.surefire.argLine} --add-opens org.eclipse.jetty.annotations/org.eclipse.jetty.annotations.resources=org.eclipse.jetty.plus
|
||||||
--add-opens org.eclipse.jetty.annotations/org.eclipse.jetty.annotations.resources=org.eclipse.jetty.plus
|
|
||||||
</argLine>
|
</argLine>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
@ -33,9 +31,7 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<instructions>
|
<instructions>
|
||||||
<Import-Package>org.objectweb.asm;version="5",*</Import-Package>
|
<Import-Package>org.objectweb.asm;version="5",*</Import-Package>
|
||||||
<Require-Capability>osgi.serviceloader;
|
<Require-Capability>osgi.serviceloader; filter:="(osgi.serviceloader=javax.servlet.ServletContainerInitializer)";resolution:=optional;cardinality:=multiple, osgi.extender; filter:="(osgi.extender=osgi.serviceloader.processor)";resolution:=optional
|
||||||
filter:="(osgi.serviceloader=javax.servlet.ServletContainerInitializer)";resolution:=optional;cardinality:=multiple,
|
|
||||||
osgi.extender; filter:="(osgi.extender=osgi.serviceloader.processor)";resolution:=optional
|
|
||||||
</Require-Capability>
|
</Require-Capability>
|
||||||
</instructions>
|
</instructions>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -26,22 +26,18 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
* DiscoverableAnnotationHandler
|
* DiscoverableAnnotationHandler
|
||||||
*
|
*
|
||||||
* Base class for handling the discovery of an annotation.
|
* Base class for handling the discovery of an annotation.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractDiscoverableAnnotationHandler extends AbstractHandler
|
public abstract class AbstractDiscoverableAnnotationHandler extends AbstractHandler
|
||||||
{
|
{
|
||||||
protected WebAppContext _context;
|
protected WebAppContext _context;
|
||||||
|
|
||||||
|
|
||||||
public AbstractDiscoverableAnnotationHandler(WebAppContext context)
|
public AbstractDiscoverableAnnotationHandler(WebAppContext context)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addAnnotation(DiscoveredAnnotation a)
|
||||||
public void addAnnotation (DiscoveredAnnotation a)
|
|
||||||
{
|
{
|
||||||
_context.getMetaData().addDiscoveredAnnotation(a);
|
_context.getMetaData().addDiscoveredAnnotation(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
public static final String MULTI_THREADED = "org.eclipse.jetty.annotations.multiThreaded";
|
public static final String MULTI_THREADED = "org.eclipse.jetty.annotations.multiThreaded";
|
||||||
public static final String MAX_SCAN_WAIT = "org.eclipse.jetty.annotations.maxWait";
|
public static final String MAX_SCAN_WAIT = "org.eclipse.jetty.annotations.maxWait";
|
||||||
|
|
||||||
|
|
||||||
public static final int DEFAULT_MAX_SCAN_WAIT = 60; /* time in sec */
|
public static final int DEFAULT_MAX_SCAN_WAIT = 60; /* time in sec */
|
||||||
public static final boolean DEFAULT_MULTI_THREADED = true;
|
public static final boolean DEFAULT_MULTI_THREADED = true;
|
||||||
|
|
||||||
|
@ -107,19 +106,18 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
* TimeStatistic
|
* TimeStatistic
|
||||||
*
|
*
|
||||||
* Simple class to capture elapsed time of an operation.
|
* Simple class to capture elapsed time of an operation.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class TimeStatistic
|
public class TimeStatistic
|
||||||
{
|
{
|
||||||
public long _start = 0;
|
public long _start = 0;
|
||||||
public long _end = 0;
|
public long _end = 0;
|
||||||
|
|
||||||
public void start ()
|
public void start()
|
||||||
{
|
{
|
||||||
_start = System.nanoTime();
|
_start = System.nanoTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void end ()
|
public void end()
|
||||||
{
|
{
|
||||||
_end = System.nanoTime();
|
_end = System.nanoTime();
|
||||||
}
|
}
|
||||||
|
@ -129,23 +127,21 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
return _start;
|
return _start;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getEnd ()
|
public long getEnd()
|
||||||
{
|
{
|
||||||
return _end;
|
return _end;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getElapsed ()
|
public long getElapsed()
|
||||||
{
|
{
|
||||||
return (_end > _start?(_end-_start):0);
|
return (_end > _start ? (_end - _start) : 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ParserTask
|
* ParserTask
|
||||||
*
|
*
|
||||||
* Task to executing scanning of a resource for annotations.
|
* Task to executing scanning of a resource for annotations.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ParserTask implements Callable<Void>
|
public class ParserTask implements Callable<Void>
|
||||||
{
|
{
|
||||||
|
@ -155,7 +151,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
protected final Resource _resource;
|
protected final Resource _resource;
|
||||||
protected TimeStatistic _stat;
|
protected TimeStatistic _stat;
|
||||||
|
|
||||||
public ParserTask (AnnotationParser parser, Set<? extends Handler>handlers, Resource resource)
|
public ParserTask(AnnotationParser parser, Set<? extends Handler> handlers, Resource resource)
|
||||||
{
|
{
|
||||||
_parser = parser;
|
_parser = parser;
|
||||||
_handlers = handlers;
|
_handlers = handlers;
|
||||||
|
@ -190,7 +186,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ServletContainerInitializerOrdering
|
* ServletContainerInitializerOrdering
|
||||||
*
|
*
|
||||||
|
@ -205,7 +200,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
private Integer _star = null;
|
private Integer _star = null;
|
||||||
private String _ordering = null;
|
private String _ordering = null;
|
||||||
|
|
||||||
public ServletContainerInitializerOrdering (String ordering)
|
public ServletContainerInitializerOrdering(String ordering)
|
||||||
{
|
{
|
||||||
if (ordering != null)
|
if (ordering != null)
|
||||||
{
|
{
|
||||||
|
@ -213,17 +208,16 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
|
|
||||||
String[] tmp = StringUtil.csvSplit(ordering);
|
String[] tmp = StringUtil.csvSplit(ordering);
|
||||||
|
|
||||||
for (int i=0; i<tmp.length; i++)
|
for (int i = 0; i < tmp.length; i++)
|
||||||
{
|
{
|
||||||
String s = tmp[i].trim();
|
String s = tmp[i].trim();
|
||||||
_indexMap.put(s, i);
|
_indexMap.put(s, i);
|
||||||
if ("*".equals(s))
|
if ("*".equals(s))
|
||||||
{
|
{
|
||||||
if (_star != null)
|
if (_star != null)
|
||||||
throw new IllegalArgumentException("Duplicate wildcards in ServletContainerInitializer ordering "+ordering);
|
throw new IllegalArgumentException("Duplicate wildcards in ServletContainerInitializer ordering " + ordering);
|
||||||
_star = i;
|
_star = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,17 +243,18 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
/**
|
/**
|
||||||
* @return true if the ordering contains a single value of "*"
|
* @return true if the ordering contains a single value of "*"
|
||||||
*/
|
*/
|
||||||
public boolean isDefaultOrder ()
|
public boolean isDefaultOrder()
|
||||||
{
|
{
|
||||||
return (getSize() == 1 && hasWildcard());
|
return (getSize() == 1 && hasWildcard());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the order index of the given classname
|
* Get the order index of the given classname
|
||||||
|
*
|
||||||
* @param name the classname to look up
|
* @param name the classname to look up
|
||||||
* @return the index of the class name (or -1 if not found)
|
* @return the index of the class name (or -1 if not found)
|
||||||
*/
|
*/
|
||||||
public int getIndexOf (String name)
|
public int getIndexOf(String name)
|
||||||
{
|
{
|
||||||
Integer i = _indexMap.get(name);
|
Integer i = _indexMap.get(name);
|
||||||
if (i == null)
|
if (i == null)
|
||||||
|
@ -269,6 +264,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of elements of the ordering
|
* Get the number of elements of the ordering
|
||||||
|
*
|
||||||
* @return the size of the index
|
* @return the size of the index
|
||||||
*/
|
*/
|
||||||
public int getSize()
|
public int getSize()
|
||||||
|
@ -285,22 +281,20 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ServletContainerInitializerComparator
|
* ServletContainerInitializerComparator
|
||||||
*
|
*
|
||||||
* Comparator impl that orders a set of ServletContainerInitializers according to the
|
* Comparator impl that orders a set of ServletContainerInitializers according to the
|
||||||
* list of classnames (optionally containing a "*" wildcard character) established in a
|
* list of classnames (optionally containing a "*" wildcard character) established in a
|
||||||
* ServletContainerInitializerOrdering.
|
* ServletContainerInitializerOrdering.
|
||||||
|
*
|
||||||
* @see ServletContainerInitializerOrdering
|
* @see ServletContainerInitializerOrdering
|
||||||
*/
|
*/
|
||||||
public class ServletContainerInitializerComparator implements Comparator<ServletContainerInitializer>
|
public class ServletContainerInitializerComparator implements Comparator<ServletContainerInitializer>
|
||||||
{
|
{
|
||||||
private ServletContainerInitializerOrdering _ordering;
|
private ServletContainerInitializerOrdering _ordering;
|
||||||
|
|
||||||
|
public ServletContainerInitializerComparator(ServletContainerInitializerOrdering ordering)
|
||||||
public ServletContainerInitializerComparator (ServletContainerInitializerOrdering ordering)
|
|
||||||
{
|
{
|
||||||
_ordering = ordering;
|
_ordering = ordering;
|
||||||
}
|
}
|
||||||
|
@ -308,8 +302,8 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
@Override
|
@Override
|
||||||
public int compare(ServletContainerInitializer sci1, ServletContainerInitializer sci2)
|
public int compare(ServletContainerInitializer sci1, ServletContainerInitializer sci2)
|
||||||
{
|
{
|
||||||
String c1 = (sci1 != null? sci1.getClass().getName() : null);
|
String c1 = (sci1 != null ? sci1.getClass().getName() : null);
|
||||||
String c2 = (sci2 != null? sci2.getClass().getName() : null);
|
String c2 = (sci2 != null ? sci2.getClass().getName() : null);
|
||||||
|
|
||||||
if (c1 == null && c2 == null)
|
if (c1 == null && c2 == null)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -329,7 +323,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
public void preConfigure(final WebAppContext context) throws Exception
|
public void preConfigure(final WebAppContext context) throws Exception
|
||||||
{
|
{
|
||||||
String tmp = (String)context.getAttribute(SERVLET_CONTAINER_INITIALIZER_EXCLUSION_PATTERN);
|
String tmp = (String)context.getAttribute(SERVLET_CONTAINER_INITIALIZER_EXCLUSION_PATTERN);
|
||||||
_sciExcludePattern = (tmp==null?null:Pattern.compile(tmp));
|
_sciExcludePattern = (tmp == null ? null : Pattern.compile(tmp));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDiscoverableAnnotationHandler(AbstractDiscoverableAnnotationHandler handler)
|
public void addDiscoverableAnnotationHandler(AbstractDiscoverableAnnotationHandler handler)
|
||||||
|
@ -366,14 +360,15 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
// Resolve container initializers
|
// Resolve container initializers
|
||||||
List<ContainerInitializer> initializers =
|
List<ContainerInitializer> initializers =
|
||||||
(List<ContainerInitializer>)context.getAttribute(AnnotationConfiguration.CONTAINER_INITIALIZERS);
|
(List<ContainerInitializer>)context.getAttribute(AnnotationConfiguration.CONTAINER_INITIALIZERS);
|
||||||
if (initializers != null && initializers.size()>0)
|
if (initializers != null && initializers.size() > 0)
|
||||||
{
|
{
|
||||||
Map<String, Set<String>> map = ( Map<String, Set<String>>) context.getAttribute(AnnotationConfiguration.CLASS_INHERITANCE_MAP);
|
Map<String, Set<String>> map = (Map<String, Set<String>>)context.getAttribute(AnnotationConfiguration.CLASS_INHERITANCE_MAP);
|
||||||
for (ContainerInitializer i : initializers)
|
for (ContainerInitializer i : initializers)
|
||||||
i.resolveClasses(context,map);
|
{
|
||||||
|
i.resolveClasses(context, map);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.jetty.webapp.AbstractConfiguration#postConfigure(org.eclipse.jetty.webapp.WebAppContext)
|
* @see org.eclipse.jetty.webapp.AbstractConfiguration#postConfigure(org.eclipse.jetty.webapp.WebAppContext)
|
||||||
|
@ -417,27 +412,22 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
super.postConfigure(context);
|
super.postConfigure(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform scanning of classes for annotations
|
* Perform scanning of classes for annotations
|
||||||
*
|
*
|
||||||
* @param context the context for the scan
|
* @param context the context for the scan
|
||||||
* @throws Exception if unable to scan
|
* @throws Exception if unable to scan
|
||||||
*/
|
*/
|
||||||
protected void scanForAnnotations (WebAppContext context)
|
protected void scanForAnnotations(WebAppContext context)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
int javaPlatform = 0;
|
int javaPlatform = 0;
|
||||||
Object target = context.getAttribute(JavaVersion.JAVA_TARGET_PLATFORM);
|
Object target = context.getAttribute(JavaVersion.JAVA_TARGET_PLATFORM);
|
||||||
if (target!=null)
|
if (target != null)
|
||||||
javaPlatform = Integer.parseInt(target.toString());
|
javaPlatform = Integer.parseInt(target.toString());
|
||||||
AnnotationParser parser = createAnnotationParser(javaPlatform);
|
AnnotationParser parser = createAnnotationParser(javaPlatform);
|
||||||
_parserTasks = new ArrayList<ParserTask>();
|
_parserTasks = new ArrayList<ParserTask>();
|
||||||
|
|
||||||
long start = 0;
|
|
||||||
|
|
||||||
|
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Annotation scanning commencing: webxml={}, metadatacomplete={}, configurationDiscovered={}, multiThreaded={}, maxScanWait={}",
|
LOG.debug("Annotation scanning commencing: webxml={}, metadatacomplete={}, configurationDiscovered={}, multiThreaded={}, maxScanWait={}",
|
||||||
context.getServletContext().getEffectiveMajorVersion(),
|
context.getServletContext().getEffectiveMajorVersion(),
|
||||||
|
@ -446,7 +436,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
isUseMultiThreading(context),
|
isUseMultiThreading(context),
|
||||||
getMaxScanWait(context));
|
getMaxScanWait(context));
|
||||||
|
|
||||||
|
|
||||||
parseContainerPath(context, parser);
|
parseContainerPath(context, parser);
|
||||||
//email from Rajiv Mordani jsrs 315 7 April 2010
|
//email from Rajiv Mordani jsrs 315 7 April 2010
|
||||||
// If there is a <others/> then the ordering should be
|
// If there is a <others/> then the ordering should be
|
||||||
|
@ -454,16 +443,16 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
// In case there is no others then it is
|
// In case there is no others then it is
|
||||||
// WEB-INF/classes + order of the elements.
|
// WEB-INF/classes + order of the elements.
|
||||||
parseWebInfClasses(context, parser);
|
parseWebInfClasses(context, parser);
|
||||||
parseWebInfLib (context, parser);
|
parseWebInfLib(context, parser);
|
||||||
|
|
||||||
start = System.nanoTime();
|
long start = System.nanoTime();
|
||||||
|
|
||||||
//execute scan, either effectively synchronously (1 thread only), or asynchronously (limited by number of processors available)
|
//execute scan, either effectively synchronously (1 thread only), or asynchronously (limited by number of processors available)
|
||||||
final Semaphore task_limit = (isUseMultiThreading(context)? new Semaphore(ProcessorUtils.availableProcessors()):new Semaphore( 1));
|
final Semaphore task_limit = (isUseMultiThreading(context) ? new Semaphore(ProcessorUtils.availableProcessors()) : new Semaphore(1));
|
||||||
final CountDownLatch latch = new CountDownLatch(_parserTasks.size());
|
final CountDownLatch latch = new CountDownLatch(_parserTasks.size());
|
||||||
final MultiException me = new MultiException();
|
final MultiException me = new MultiException();
|
||||||
|
|
||||||
for (final ParserTask p:_parserTasks)
|
for (final ParserTask p : _parserTasks)
|
||||||
{
|
{
|
||||||
task_limit.acquire();
|
task_limit.acquire();
|
||||||
context.getServer().getThreadPool().execute(new Runnable()
|
context.getServer().getThreadPool().execute(new Runnable()
|
||||||
|
@ -489,19 +478,21 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean timeout = !latch.await(getMaxScanWait(context), TimeUnit.SECONDS);
|
boolean timeout = !latch.await(getMaxScanWait(context), TimeUnit.SECONDS);
|
||||||
long elapsedMs = TimeUnit.MILLISECONDS.convert(System.nanoTime()-start, TimeUnit.NANOSECONDS);
|
long elapsedMs = TimeUnit.MILLISECONDS.convert(System.nanoTime() - start, TimeUnit.NANOSECONDS);
|
||||||
|
|
||||||
LOG.info("Scanning elapsed time={}ms",elapsedMs);
|
LOG.info("Scanning elapsed time={}ms", elapsedMs);
|
||||||
|
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
{
|
{
|
||||||
for (ParserTask p:_parserTasks)
|
for (ParserTask p : _parserTasks)
|
||||||
|
{
|
||||||
LOG.debug("Scanned {} in {}ms", p.getResource(), TimeUnit.MILLISECONDS.convert(p.getStatistic().getElapsed(), TimeUnit.NANOSECONDS));
|
LOG.debug("Scanned {} in {}ms", p.getResource(), TimeUnit.MILLISECONDS.convert(p.getStatistic().getElapsed(), TimeUnit.NANOSECONDS));
|
||||||
|
}
|
||||||
|
|
||||||
LOG.debug("Scanned {} container path jars, {} WEB-INF/lib jars, {} WEB-INF/classes dirs in {}ms for context {}",
|
LOG.debug("Scanned {} container path jars, {} WEB-INF/lib jars, {} WEB-INF/classes dirs in {}ms for context {}",
|
||||||
(_containerPathStats==null?-1:_containerPathStats.getTotal()),
|
(_containerPathStats == null ? -1 : _containerPathStats.getTotal()),
|
||||||
(_webInfLibStats==null?-1:_webInfLibStats.getTotal()),
|
(_webInfLibStats == null ? -1 : _webInfLibStats.getTotal()),
|
||||||
(_webInfClassesStats==null?-1:_webInfClassesStats.getTotal()),
|
(_webInfClassesStats == null ? -1 : _webInfClassesStats.getTotal()),
|
||||||
elapsedMs,
|
elapsedMs,
|
||||||
context);
|
context);
|
||||||
}
|
}
|
||||||
|
@ -511,8 +502,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
me.ifExceptionThrow();
|
me.ifExceptionThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param javaPlatform The java platform to scan for.
|
* @param javaPlatform The java platform to scan for.
|
||||||
* @return a new AnnotationParser. This method can be overridden to use a different implementation of
|
* @return a new AnnotationParser. This method can be overridden to use a different implementation of
|
||||||
|
@ -525,6 +514,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if we should use multiple threads to scan for annotations or not
|
* Check if we should use multiple threads to scan for annotations or not
|
||||||
|
*
|
||||||
* @param context the context of the multi threaded setting
|
* @param context the context of the multi threaded setting
|
||||||
* @return true if multi threading is enabled on the context, server, or via a System property.
|
* @return true if multi threading is enabled on the context, server, or via a System property.
|
||||||
* @see #MULTI_THREADED
|
* @see #MULTI_THREADED
|
||||||
|
@ -547,8 +537,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
return Boolean.parseBoolean(System.getProperty(MULTI_THREADED, Boolean.toString(DEFAULT_MULTI_THREADED)));
|
return Boolean.parseBoolean(System.getProperty(MULTI_THREADED, Boolean.toString(DEFAULT_MULTI_THREADED)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Work out how long we should wait for the async scanning to occur.
|
* Work out how long we should wait for the async scanning to occur.
|
||||||
*
|
*
|
||||||
|
@ -556,7 +544,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
* @return the max scan wait setting on the context, or server, or via a System property.
|
* @return the max scan wait setting on the context, or server, or via a System property.
|
||||||
* @see #MAX_SCAN_WAIT
|
* @see #MAX_SCAN_WAIT
|
||||||
*/
|
*/
|
||||||
protected int getMaxScanWait (WebAppContext context)
|
protected int getMaxScanWait(WebAppContext context)
|
||||||
{
|
{
|
||||||
//try context attribute to get max time in sec to wait for scan completion
|
//try context attribute to get max time in sec to wait for scan completion
|
||||||
Object o = context.getAttribute(MAX_SCAN_WAIT);
|
Object o = context.getAttribute(MAX_SCAN_WAIT);
|
||||||
|
@ -583,7 +571,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
context.getObjectFactory().addDecorator(new AnnotationDecorator(context));
|
context.getObjectFactory().addDecorator(new AnnotationDecorator(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createServletContainerInitializerAnnotationHandlers (WebAppContext context, List<ServletContainerInitializer> scis)
|
public void createServletContainerInitializerAnnotationHandlers(WebAppContext context, List<ServletContainerInitializer> scis)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
if (scis == null || scis.isEmpty())
|
if (scis == null || scis.isEmpty())
|
||||||
|
@ -603,7 +591,10 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
if (classes != null)
|
if (classes != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (LOG.isDebugEnabled()){LOG.debug("HandlesTypes {} on initializer {}",Arrays.asList(classes),service.getClass());}
|
if (LOG.isDebugEnabled())
|
||||||
|
{
|
||||||
|
LOG.debug("HandlesTypes {} on initializer {}", Arrays.asList(classes), service.getClass());
|
||||||
|
}
|
||||||
|
|
||||||
initializer = new ContainerInitializer(service, classes);
|
initializer = new ContainerInitializer(service, classes);
|
||||||
|
|
||||||
|
@ -617,13 +608,14 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
_classInheritanceHandler = new ClassInheritanceHandler(map);
|
_classInheritanceHandler = new ClassInheritanceHandler(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Class<?> c: classes)
|
for (Class<?> c : classes)
|
||||||
{
|
{
|
||||||
//The value of one of the HandlesTypes classes is actually an Annotation itself so
|
//The value of one of the HandlesTypes classes is actually an Annotation itself so
|
||||||
//register a handler for it
|
//register a handler for it
|
||||||
if (c.isAnnotation())
|
if (c.isAnnotation())
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled()) LOG.debug("Registering annotation handler for "+c.getName());
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Registering annotation handler for " + c.getName());
|
||||||
_containerInitializerAnnotationHandlers.add(new ContainerInitializerAnnotationHandler(initializer, c));
|
_containerInitializerAnnotationHandlers.add(new ContainerInitializerAnnotationHandler(initializer, c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -631,19 +623,20 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
initializer = new ContainerInitializer(service, null);
|
initializer = new ContainerInitializer(service, null);
|
||||||
if (LOG.isDebugEnabled()) LOG.debug("No classes in HandlesTypes on initializer "+service.getClass());
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("No classes in HandlesTypes on initializer " + service.getClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
initializer = new ContainerInitializer(service, null);
|
initializer = new ContainerInitializer(service, null);
|
||||||
if (LOG.isDebugEnabled()) LOG.debug("No HandlesTypes annotation on initializer "+service.getClass());
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("No HandlesTypes annotation on initializer " + service.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
initializers.add(initializer);
|
initializers.add(initializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//add a bean to the context which will call the servletcontainerinitializers when appropriate
|
//add a bean to the context which will call the servletcontainerinitializers when appropriate
|
||||||
ServletContainerInitializersStarter starter = (ServletContainerInitializersStarter)context.getAttribute(CONTAINER_INITIALIZER_STARTER);
|
ServletContainerInitializersStarter starter = (ServletContainerInitializersStarter)context.getAttribute(CONTAINER_INITIALIZER_STARTER);
|
||||||
if (starter != null)
|
if (starter != null)
|
||||||
|
@ -653,7 +646,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
context.addBean(starter, true);
|
context.addBean(starter, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Resource getJarFor (ServletContainerInitializer service)
|
public Resource getJarFor(ServletContainerInitializer service)
|
||||||
throws MalformedURLException, IOException
|
throws MalformedURLException, IOException
|
||||||
{
|
{
|
||||||
URI uri = TypeUtil.getLocationOfClass(service.getClass());
|
URI uri = TypeUtil.getLocationOfClass(service.getClass());
|
||||||
|
@ -672,7 +665,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
* @return true if excluded
|
* @return true if excluded
|
||||||
* @throws Exception if unable to determine exclusion
|
* @throws Exception if unable to determine exclusion
|
||||||
*/
|
*/
|
||||||
public boolean isFromExcludedJar (WebAppContext context, ServletContainerInitializer sci, Resource sciResource)
|
public boolean isFromExcludedJar(WebAppContext context, ServletContainerInitializer sci, Resource sciResource)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
if (sci == null)
|
if (sci == null)
|
||||||
|
@ -734,7 +727,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("{}Excluded {} found={}",found?"!":"",sci,found);
|
LOG.debug("{}Excluded {} found={}", found ? "!" : "", sci, found);
|
||||||
return !found;
|
return !found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -753,11 +746,10 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
|
|
||||||
//test if name of class matches the regex
|
//test if name of class matches the regex
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Checking {} against containerInitializerExclusionPattern",sci.getClass().getName());
|
LOG.debug("Checking {} against containerInitializerExclusionPattern", sci.getClass().getName());
|
||||||
return _sciExcludePattern.matcher(sci.getClass().getName()).matches();
|
return _sciExcludePattern.matcher(sci.getClass().getName()).matches();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if the ServletContainerInitializer is from the container classpath
|
* Test if the ServletContainerInitializer is from the container classpath
|
||||||
*
|
*
|
||||||
|
@ -765,7 +757,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
* @param sci the ServletContainerIntializer
|
* @param sci the ServletContainerIntializer
|
||||||
* @return true if ServletContainerIntializer is from container classpath
|
* @return true if ServletContainerIntializer is from container classpath
|
||||||
*/
|
*/
|
||||||
public boolean isFromContainerClassPath (WebAppContext context, ServletContainerInitializer sci)
|
public boolean isFromContainerClassPath(WebAppContext context, ServletContainerInitializer sci)
|
||||||
{
|
{
|
||||||
if (sci == null)
|
if (sci == null)
|
||||||
return false;
|
return false;
|
||||||
|
@ -773,7 +765,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
ClassLoader sciLoader = sci.getClass().getClassLoader();
|
ClassLoader sciLoader = sci.getClass().getClassLoader();
|
||||||
|
|
||||||
//if loaded by bootstrap loader, then its the container classpath
|
//if loaded by bootstrap loader, then its the container classpath
|
||||||
if ( sciLoader == null)
|
if (sciLoader == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
//if there is no context classloader, then its the container classpath
|
//if there is no context classloader, then its the container classpath
|
||||||
|
@ -799,7 +791,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
* @param sci a Resource representing the SCI
|
* @param sci a Resource representing the SCI
|
||||||
* @return true if the sci Resource is inside a WEB-INF/classes directory, false otherwise
|
* @return true if the sci Resource is inside a WEB-INF/classes directory, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isFromWebInfClasses (WebAppContext context, Resource sci)
|
public boolean isFromWebInfClasses(WebAppContext context, Resource sci)
|
||||||
{
|
{
|
||||||
for (Resource dir : context.getMetaData().getWebInfClassesDirs())
|
for (Resource dir : context.getMetaData().getWebInfClassesDirs())
|
||||||
{
|
{
|
||||||
|
@ -813,11 +805,12 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get SCIs that are not excluded from consideration
|
* Get SCIs that are not excluded from consideration
|
||||||
|
*
|
||||||
* @param context the web app context
|
* @param context the web app context
|
||||||
* @return the list of non-excluded servlet container initializers
|
* @return the list of non-excluded servlet container initializers
|
||||||
* @throws Exception if unable to get list
|
* @throws Exception if unable to get list
|
||||||
*/
|
*/
|
||||||
public List<ServletContainerInitializer> getNonExcludedInitializers (WebAppContext context)
|
public List<ServletContainerInitializer> getNonExcludedInitializers(WebAppContext context)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
ArrayList<ServletContainerInitializer> nonExcludedInitializers = new ArrayList<ServletContainerInitializer>();
|
ArrayList<ServletContainerInitializer> nonExcludedInitializers = new ArrayList<ServletContainerInitializer>();
|
||||||
|
@ -828,25 +821,25 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
start = System.nanoTime();
|
start = System.nanoTime();
|
||||||
ServiceLoader<ServletContainerInitializer> loader = ServiceLoader.load(ServletContainerInitializer.class);
|
ServiceLoader<ServletContainerInitializer> loader = ServiceLoader.load(ServletContainerInitializer.class);
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Service loaders found in {}ms", (TimeUnit.MILLISECONDS.convert((System.nanoTime()-start), TimeUnit.NANOSECONDS)));
|
LOG.debug("Service loaders found in {}ms", (TimeUnit.MILLISECONDS.convert((System.nanoTime() - start), TimeUnit.NANOSECONDS)));
|
||||||
|
|
||||||
Map<ServletContainerInitializer,Resource> sciResourceMap = new HashMap<ServletContainerInitializer,Resource>();
|
Map<ServletContainerInitializer, Resource> sciResourceMap = new HashMap<ServletContainerInitializer, Resource>();
|
||||||
ServletContainerInitializerOrdering initializerOrdering = getInitializerOrdering(context);
|
ServletContainerInitializerOrdering initializerOrdering = getInitializerOrdering(context);
|
||||||
|
|
||||||
//Get initial set of SCIs that aren't from excluded jars or excluded by the containerExclusionPattern, or excluded
|
//Get initial set of SCIs that aren't from excluded jars or excluded by the containerExclusionPattern, or excluded
|
||||||
//because containerInitializerOrdering omits it
|
//because containerInitializerOrdering omits it
|
||||||
Iterator<ServletContainerInitializer> iter = loader.iterator();
|
Iterator<ServletContainerInitializer> iter = loader.iterator();
|
||||||
while(iter.hasNext())
|
while (iter.hasNext())
|
||||||
{
|
{
|
||||||
ServletContainerInitializer sci;
|
ServletContainerInitializer sci;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
sci=iter.next();
|
sci = iter.next();
|
||||||
}
|
}
|
||||||
catch(Error e)
|
catch (Error e)
|
||||||
{
|
{
|
||||||
// Probably a SCI discovered on the system classpath that is hidden by the context classloader
|
// Probably a SCI discovered on the system classpath that is hidden by the context classloader
|
||||||
LOG.info("Error: "+e.getMessage()+" for "+context);
|
LOG.info("Error: " + e.getMessage() + " for " + context);
|
||||||
LOG.debug(e);
|
LOG.debug(e);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -868,8 +861,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
|
|
||||||
//check containerInitializerOrdering doesn't exclude it
|
//check containerInitializerOrdering doesn't exclude it
|
||||||
String name = sci.getClass().getName();
|
String name = sci.getClass().getName();
|
||||||
if (initializerOrdering != null
|
if (initializerOrdering != null && (!initializerOrdering.hasWildcard() && initializerOrdering.getIndexOf(name) < 0))
|
||||||
&& (!initializerOrdering.hasWildcard() && initializerOrdering.getIndexOf(name) < 0))
|
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("{} is excluded by ordering", sci);
|
LOG.debug("{} is excluded by ordering", sci);
|
||||||
|
@ -883,7 +875,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
if (initializerOrdering != null && !initializerOrdering.isDefaultOrder())
|
if (initializerOrdering != null && !initializerOrdering.isDefaultOrder())
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Ordering ServletContainerInitializers with "+initializerOrdering);
|
LOG.debug("Ordering ServletContainerInitializers with " + initializerOrdering);
|
||||||
|
|
||||||
//There is an ordering that is not just "*".
|
//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
|
//Arrange ServletContainerInitializers according to the ordering of classnames given, irrespective of coming from container or webapp classpaths
|
||||||
|
@ -898,9 +890,9 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
|
|
||||||
//First add in all SCIs that can't be excluded
|
//First add in all SCIs that can't be excluded
|
||||||
int lastContainerSCI = -1;
|
int lastContainerSCI = -1;
|
||||||
for (Map.Entry<ServletContainerInitializer, Resource> entry:sciResourceMap.entrySet())
|
for (Map.Entry<ServletContainerInitializer, Resource> entry : sciResourceMap.entrySet())
|
||||||
{
|
{
|
||||||
if (entry.getKey().getClass().getClassLoader()==context.getClassLoader().getParent())
|
if (entry.getKey().getClass().getClassLoader() == context.getClassLoader().getParent())
|
||||||
{
|
{
|
||||||
nonExcludedInitializers.add(++lastContainerSCI, entry.getKey()); //add all container SCIs before any webapp SCIs
|
nonExcludedInitializers.add(++lastContainerSCI, entry.getKey()); //add all container SCIs before any webapp SCIs
|
||||||
}
|
}
|
||||||
|
@ -921,8 +913,10 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
}
|
}
|
||||||
|
|
||||||
//throw out the ones we've already accounted for
|
//throw out the ones we've already accounted for
|
||||||
for (ServletContainerInitializer s:nonExcludedInitializers)
|
for (ServletContainerInitializer s : nonExcludedInitializers)
|
||||||
|
{
|
||||||
sciResourceMap.remove(s);
|
sciResourceMap.remove(s);
|
||||||
|
}
|
||||||
|
|
||||||
if (context.getMetaData().getOrdering() == null)
|
if (context.getMetaData().getOrdering() == null)
|
||||||
{
|
{
|
||||||
|
@ -934,12 +928,12 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Ordering ServletContainerInitializers with ordering {}",context.getMetaData().getOrdering());
|
LOG.debug("Ordering ServletContainerInitializers with ordering {}", context.getMetaData().getOrdering());
|
||||||
|
|
||||||
//add SCIs 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 (Resource webInfJar : context.getMetaData().getOrderedWebInfJars())
|
||||||
{
|
{
|
||||||
for (Map.Entry<ServletContainerInitializer, Resource> entry:sciResourceMap.entrySet())
|
for (Map.Entry<ServletContainerInitializer, Resource> entry : sciResourceMap.entrySet())
|
||||||
{
|
{
|
||||||
if (webInfJar.equals(entry.getValue()))
|
if (webInfJar.equals(entry.getValue()))
|
||||||
nonExcludedInitializers.add(entry.getKey());
|
nonExcludedInitializers.add(entry.getKey());
|
||||||
|
@ -969,22 +963,23 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
|
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
{
|
{
|
||||||
int i=0;
|
int i = 0;
|
||||||
for (ServletContainerInitializer sci:nonExcludedInitializers)
|
for (ServletContainerInitializer sci : nonExcludedInitializers)
|
||||||
LOG.debug("ServletContainerInitializer: {} {} from {}",(++i), sci.getClass().getName(), sciResourceMap.get(sci));
|
{
|
||||||
|
LOG.debug("ServletContainerInitializer: {} {} from {}", (++i), sci.getClass().getName(), sciResourceMap.get(sci));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nonExcludedInitializers;
|
return nonExcludedInitializers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Jetty-specific extension that allows an ordering to be applied across ALL ServletContainerInitializers.
|
* Jetty-specific extension that allows an ordering to be applied across ALL ServletContainerInitializers.
|
||||||
*
|
*
|
||||||
* @param context the context for the initializer ordering configuration
|
* @param context the context for the initializer ordering configuration
|
||||||
* @return the ordering of the ServletContainerIntializer's
|
* @return the ordering of the ServletContainerIntializer's
|
||||||
*/
|
*/
|
||||||
public ServletContainerInitializerOrdering getInitializerOrdering (WebAppContext context)
|
public ServletContainerInitializerOrdering getInitializerOrdering(WebAppContext context)
|
||||||
{
|
{
|
||||||
if (context == null)
|
if (context == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -996,7 +991,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
return new ServletContainerInitializerOrdering(tmp);
|
return new ServletContainerInitializerOrdering(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan jars on container path.
|
* Scan jars on container path.
|
||||||
*
|
*
|
||||||
|
@ -1004,7 +998,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
* @param parser the parser to scan with
|
* @param parser the parser to scan with
|
||||||
* @throws Exception if unable to scan
|
* @throws Exception if unable to scan
|
||||||
*/
|
*/
|
||||||
public void parseContainerPath (final WebAppContext context, final AnnotationParser parser) throws Exception
|
public void parseContainerPath(final WebAppContext context, final AnnotationParser parser) throws Exception
|
||||||
{
|
{
|
||||||
//always parse for discoverable annotations as well as class hierarchy and servletcontainerinitializer related annotations
|
//always parse for discoverable annotations as well as class hierarchy and servletcontainerinitializer related annotations
|
||||||
final Set<Handler> handlers = new HashSet<Handler>();
|
final Set<Handler> handlers = new HashSet<Handler>();
|
||||||
|
@ -1032,7 +1026,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan jars in WEB-INF/lib
|
* Scan jars in WEB-INF/lib
|
||||||
*
|
*
|
||||||
|
@ -1040,7 +1033,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
* @param parser the annotation parser to use
|
* @param parser the annotation parser to use
|
||||||
* @throws Exception if unable to scan and/or parse
|
* @throws Exception if unable to scan and/or parse
|
||||||
*/
|
*/
|
||||||
public void parseWebInfLib (final WebAppContext context, final AnnotationParser parser) throws Exception
|
public void parseWebInfLib(final WebAppContext context, final AnnotationParser parser) throws Exception
|
||||||
{
|
{
|
||||||
List<FragmentDescriptor> frags = context.getMetaData().getFragments();
|
List<FragmentDescriptor> frags = context.getMetaData().getFragments();
|
||||||
|
|
||||||
|
@ -1089,8 +1082,8 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
|
|
||||||
if (_parserTasks != null)
|
if (_parserTasks != null)
|
||||||
{
|
{
|
||||||
ParserTask task = new ParserTask(parser, handlers,r);
|
ParserTask task = new ParserTask(parser, handlers, r);
|
||||||
_parserTasks.add (task);
|
_parserTasks.add(task);
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
{
|
{
|
||||||
_webInfLibStats.increment();
|
_webInfLibStats.increment();
|
||||||
|
@ -1101,7 +1094,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan classes in WEB-INF/classes
|
* Scan classes in WEB-INF/classes
|
||||||
*
|
*
|
||||||
|
@ -1109,7 +1101,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
* @param parser the annotation parser to use
|
* @param parser the annotation parser to use
|
||||||
* @throws Exception if unable to scan and/or parse
|
* @throws Exception if unable to scan and/or parse
|
||||||
*/
|
*/
|
||||||
public void parseWebInfClasses (final WebAppContext context, final AnnotationParser parser)
|
public void parseWebInfClasses(final WebAppContext context, final AnnotationParser parser)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
Set<Handler> handlers = new HashSet<Handler>();
|
Set<Handler> handlers = new HashSet<Handler>();
|
||||||
|
@ -1136,8 +1128,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the web-fragment.xml from a jar
|
* Get the web-fragment.xml from a jar
|
||||||
*
|
*
|
||||||
|
@ -1146,15 +1136,15 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
* @return true if the fragment if found, or null of not found
|
* @return true if the fragment if found, or null of not found
|
||||||
* @throws Exception if unable to determine the the fragment contains
|
* @throws Exception if unable to determine the the fragment contains
|
||||||
*/
|
*/
|
||||||
public FragmentDescriptor getFragmentFromJar (Resource jar, List<FragmentDescriptor> frags)
|
public FragmentDescriptor getFragmentFromJar(Resource jar, List<FragmentDescriptor> frags)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
//check if the jar has a web-fragment.xml
|
//check if the jar has a web-fragment.xml
|
||||||
FragmentDescriptor d = null;
|
FragmentDescriptor d = null;
|
||||||
for (FragmentDescriptor frag: frags)
|
for (FragmentDescriptor frag : frags)
|
||||||
{
|
{
|
||||||
Resource fragResource = frag.getResource(); //eg jar:file:///a/b/c/foo.jar!/META-INF/web-fragment.xml
|
Resource fragResource = frag.getResource(); //eg jar:file:///a/b/c/foo.jar!/META-INF/web-fragment.xml
|
||||||
if (Resource.isContainedIn(fragResource,jar))
|
if (Resource.isContainedIn(fragResource, jar))
|
||||||
{
|
{
|
||||||
d = frag;
|
d = frag;
|
||||||
break;
|
break;
|
||||||
|
@ -1163,9 +1153,9 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMetaDataComplete (WebDescriptor d)
|
public boolean isMetaDataComplete(WebDescriptor d)
|
||||||
{
|
{
|
||||||
return (d!=null && d.getMetaDataComplete() == MetaDataComplete.True);
|
return (d != null && d.getMetaDataComplete() == MetaDataComplete.True);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ClassInheritanceMap extends ConcurrentHashMap<String, Set<String>>
|
public static class ClassInheritanceMap extends ConcurrentHashMap<String, Set<String>>
|
||||||
|
@ -1174,9 +1164,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return String.format("ClassInheritanceMap@%x{size=%d}",hashCode(),size());
|
return String.format("ClassInheritanceMap@%x{size=%d}", hashCode(), size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class AnnotationDecorator implements Decorator
|
||||||
registerHandlers(context);
|
registerHandlers(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerHandlers (WebAppContext context)
|
public void registerHandlers(WebAppContext context)
|
||||||
{
|
{
|
||||||
_introspector.registerHandler(new ResourceAnnotationHandler(context));
|
_introspector.registerHandler(new ResourceAnnotationHandler(context));
|
||||||
_introspector.registerHandler(new ResourcesAnnotationHandler(context));
|
_introspector.registerHandler(new ResourcesAnnotationHandler(context));
|
||||||
|
@ -54,9 +54,10 @@ public class AnnotationDecorator implements Decorator
|
||||||
* <li> PreDestroy </li>
|
* <li> PreDestroy </li>
|
||||||
* <li> ServletSecurity? </li>
|
* <li> ServletSecurity? </li>
|
||||||
* </ul>
|
* </ul>
|
||||||
|
*
|
||||||
* @param o the object ot introspect
|
* @param o the object ot introspect
|
||||||
*/
|
*/
|
||||||
protected void introspect (Object o)
|
protected void introspect(Object o)
|
||||||
{
|
{
|
||||||
_introspector.introspect(o.getClass());
|
_introspector.introspect(o.getClass());
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,17 +19,19 @@
|
||||||
package org.eclipse.jetty.annotations;
|
package org.eclipse.jetty.annotations;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AnnotationIntrospector
|
* AnnotationIntrospector
|
||||||
*
|
* Introspects a class to find various types of
|
||||||
*
|
* annotations as defined by the servlet specification.
|
||||||
*/
|
*/
|
||||||
public class AnnotationIntrospector
|
public class AnnotationIntrospector
|
||||||
{
|
{
|
||||||
protected List<IntrospectableAnnotationHandler> _handlers = new ArrayList<IntrospectableAnnotationHandler>();
|
private final Set<Class<?>> _introspectedClasses = new HashSet<>();
|
||||||
|
private final List<IntrospectableAnnotationHandler> _handlers = new ArrayList<IntrospectableAnnotationHandler>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IntrospectableAnnotationHandler
|
* IntrospectableAnnotationHandler
|
||||||
|
@ -41,21 +43,18 @@ public class AnnotationIntrospector
|
||||||
public void handle(Class<?> clazz);
|
public void handle(Class<?> clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractIntrospectableAnnotationHandler
|
* AbstractIntrospectableAnnotationHandler
|
||||||
*
|
*
|
||||||
* Base class for handlers that introspect a class to find a particular annotation.
|
* Base class for handlers that introspect a class to find a particular annotation.
|
||||||
* A handler can optionally introspect the parent hierarchy of a class.
|
* A handler can optionally introspect the parent hierarchy of a class.
|
||||||
*/
|
*/
|
||||||
public static abstract class AbstractIntrospectableAnnotationHandler implements IntrospectableAnnotationHandler
|
public abstract static class AbstractIntrospectableAnnotationHandler implements IntrospectableAnnotationHandler
|
||||||
{
|
{
|
||||||
private boolean _introspectAncestors;
|
private boolean _introspectAncestors;
|
||||||
|
|
||||||
public abstract void doHandle(Class<?> clazz);
|
public abstract void doHandle(Class<?> clazz);
|
||||||
|
|
||||||
|
|
||||||
public AbstractIntrospectableAnnotationHandler(boolean introspectAncestors)
|
public AbstractIntrospectableAnnotationHandler(boolean introspectAncestors)
|
||||||
{
|
{
|
||||||
_introspectAncestors = introspectAncestors;
|
_introspectAncestors = introspectAncestors;
|
||||||
|
@ -67,7 +66,7 @@ public class AnnotationIntrospector
|
||||||
Class<?> c = clazz;
|
Class<?> c = clazz;
|
||||||
|
|
||||||
//process the whole inheritance hierarchy for the class
|
//process the whole inheritance hierarchy for the class
|
||||||
while (c!=null && (!c.equals(Object.class)))
|
while (c != null && (!c.equals(Object.class)))
|
||||||
{
|
{
|
||||||
doHandle(c);
|
doHandle(c);
|
||||||
if (!_introspectAncestors)
|
if (!_introspectAncestors)
|
||||||
|
@ -78,19 +77,29 @@ public class AnnotationIntrospector
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerHandler (IntrospectableAnnotationHandler handler)
|
public void registerHandler(IntrospectableAnnotationHandler handler)
|
||||||
{
|
{
|
||||||
_handlers.add(handler);
|
_handlers.add(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void introspect (Class<?> clazz)
|
public void introspect(Class<?> clazz)
|
||||||
{
|
{
|
||||||
if (_handlers == null)
|
if (_handlers == null)
|
||||||
return;
|
return;
|
||||||
if (clazz == null)
|
if (clazz == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (IntrospectableAnnotationHandler handler:_handlers)
|
synchronized (_introspectedClasses)
|
||||||
|
{
|
||||||
|
//Synchronize on the set of already introspected classes.
|
||||||
|
//This ensures that only 1 thread can be introspecting, and that
|
||||||
|
//thread must have fully finished generating the products of
|
||||||
|
//introspection before another thread is allowed in.
|
||||||
|
//We remember the classes that we have introspected to avoid
|
||||||
|
//reprocessing the same class.
|
||||||
|
if (_introspectedClasses.add(clazz))
|
||||||
|
{
|
||||||
|
for (IntrospectableAnnotationHandler handler : _handlers)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -105,6 +114,7 @@ public class AnnotationIntrospector
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@ import org.eclipse.jetty.util.Loader;
|
||||||
import org.eclipse.jetty.util.ManifestUtils;
|
import org.eclipse.jetty.util.ManifestUtils;
|
||||||
import org.eclipse.jetty.util.MultiException;
|
import org.eclipse.jetty.util.MultiException;
|
||||||
import org.eclipse.jetty.util.MultiReleaseJarFile;
|
import org.eclipse.jetty.util.MultiReleaseJarFile;
|
||||||
|
import org.eclipse.jetty.util.StringUtil;
|
||||||
|
import org.eclipse.jetty.util.TypeUtil;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
import org.eclipse.jetty.util.resource.Resource;
|
import org.eclipse.jetty.util.resource.Resource;
|
||||||
|
@ -80,9 +82,10 @@ public class AnnotationParser
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine the runtime version of asm.
|
* Determine the runtime version of asm.
|
||||||
|
*
|
||||||
* @return the org.objectweb.asm.Opcode matching the runtime version of asm.
|
* @return the org.objectweb.asm.Opcode matching the runtime version of asm.
|
||||||
*/
|
*/
|
||||||
public static int asmVersion ()
|
public static int asmVersion()
|
||||||
{
|
{
|
||||||
int asmVersion = ASM_OPCODE_VERSION;
|
int asmVersion = ASM_OPCODE_VERSION;
|
||||||
String version = ManifestUtils.getVersion(Opcodes.class).orElse(null);
|
String version = ManifestUtils.getVersion(Opcodes.class).orElse(null);
|
||||||
|
@ -139,18 +142,18 @@ public class AnnotationParser
|
||||||
* @param name the internal name
|
* @param name the internal name
|
||||||
* @return the simple name
|
* @return the simple name
|
||||||
*/
|
*/
|
||||||
public static String normalize (String name)
|
public static String normalize(String name)
|
||||||
{
|
{
|
||||||
if (name==null)
|
if (name == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (name.startsWith("L") && name.endsWith(";"))
|
if (name.startsWith("L") && name.endsWith(";"))
|
||||||
name = name.substring(1, name.length()-1);
|
name = name.substring(1, name.length() - 1);
|
||||||
|
|
||||||
if (name.endsWith(".class"))
|
if (name.endsWith(".class"))
|
||||||
name = name.substring(0, name.length()-".class".length());
|
name = name.substring(0, name.length() - ".class".length());
|
||||||
|
|
||||||
return name.replace('/', '.');
|
return StringUtil.replace(name, '/', '.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -159,14 +162,16 @@ public class AnnotationParser
|
||||||
* @param list the list of internal names
|
* @param list the list of internal names
|
||||||
* @return the list of simple names
|
* @return the list of simple names
|
||||||
*/
|
*/
|
||||||
public static String[] normalize (String[] list)
|
public static String[] normalize(String[] list)
|
||||||
{
|
{
|
||||||
if (list == null)
|
if (list == null)
|
||||||
return null;
|
return null;
|
||||||
String[] normalList = new String[list.length];
|
String[] normalList = new String[list.length];
|
||||||
int i=0;
|
int i = 0;
|
||||||
for (String s : list)
|
for (String s : list)
|
||||||
|
{
|
||||||
normalList[i++] = normalize(s);
|
normalList[i++] = normalize(s);
|
||||||
|
}
|
||||||
return normalList;
|
return normalList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,17 +350,22 @@ public class AnnotationParser
|
||||||
public static interface Handler
|
public static interface Handler
|
||||||
{
|
{
|
||||||
public void handle(ClassInfo classInfo);
|
public void handle(ClassInfo classInfo);
|
||||||
|
|
||||||
public void handle(MethodInfo methodInfo);
|
public void handle(MethodInfo methodInfo);
|
||||||
public void handle (FieldInfo fieldInfo);
|
|
||||||
public void handle (ClassInfo info, String annotationName);
|
public void handle(FieldInfo fieldInfo);
|
||||||
public void handle (MethodInfo info, String annotationName);
|
|
||||||
public void handle (FieldInfo info, String annotationName);
|
public void handle(ClassInfo info, String annotationName);
|
||||||
|
|
||||||
|
public void handle(MethodInfo info, String annotationName);
|
||||||
|
|
||||||
|
public void handle(FieldInfo info, String annotationName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience base class to provide no-ops for all Handler methods.
|
* Convenience base class to provide no-ops for all Handler methods.
|
||||||
*/
|
*/
|
||||||
public static abstract class AbstractHandler implements Handler
|
public abstract static class AbstractHandler implements Handler
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void handle(ClassInfo classInfo)
|
public void handle(ClassInfo classInfo)
|
||||||
|
@ -407,7 +417,7 @@ public class AnnotationParser
|
||||||
{
|
{
|
||||||
super(asmVersion);
|
super(asmVersion);
|
||||||
_handlers = handlers;
|
_handlers = handlers;
|
||||||
_mi = new MethodInfo(classInfo, name, access, methodDesc,signature, exceptions);
|
_mi = new MethodInfo(classInfo, name, access, methodDesc, signature, exceptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -417,8 +427,10 @@ public class AnnotationParser
|
||||||
public AnnotationVisitor visitAnnotation(String desc, boolean visible)
|
public AnnotationVisitor visitAnnotation(String desc, boolean visible)
|
||||||
{
|
{
|
||||||
String annotationName = normalize(desc);
|
String annotationName = normalize(desc);
|
||||||
for (Handler h:_handlers)
|
for (Handler h : _handlers)
|
||||||
|
{
|
||||||
h.handle(_mi, annotationName);
|
h.handle(_mi, annotationName);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -454,7 +466,9 @@ public class AnnotationParser
|
||||||
{
|
{
|
||||||
String annotationName = normalize(desc);
|
String annotationName = normalize(desc);
|
||||||
for (Handler h : _handlers)
|
for (Handler h : _handlers)
|
||||||
|
{
|
||||||
h.handle(_fieldInfo, annotationName);
|
h.handle(_fieldInfo, annotationName);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -479,7 +493,7 @@ public class AnnotationParser
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit (final int version,
|
public void visit(final int version,
|
||||||
final int access,
|
final int access,
|
||||||
final String name,
|
final String name,
|
||||||
final String signature,
|
final String signature,
|
||||||
|
@ -487,19 +501,23 @@ public class AnnotationParser
|
||||||
final String[] interfaces)
|
final String[] interfaces)
|
||||||
{
|
{
|
||||||
_ci = new ClassInfo(_containingResource, normalize(name), version, access, signature, normalize(superName), normalize(interfaces));
|
_ci = new ClassInfo(_containingResource, normalize(name), version, access, signature, normalize(superName), normalize(interfaces));
|
||||||
for (Handler h:_handlers)
|
for (Handler h : _handlers)
|
||||||
|
{
|
||||||
h.handle(_ci);
|
h.handle(_ci);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Visit an annotation on a Class
|
* Visit an annotation on a Class
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AnnotationVisitor visitAnnotation (String desc, boolean visible)
|
public AnnotationVisitor visitAnnotation(String desc, boolean visible)
|
||||||
{
|
{
|
||||||
String annotationName = normalize(desc);
|
String annotationName = normalize(desc);
|
||||||
for (Handler h : _handlers)
|
for (Handler h : _handlers)
|
||||||
|
{
|
||||||
h.handle(_ci, annotationName);
|
h.handle(_ci, annotationName);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,7 +525,7 @@ public class AnnotationParser
|
||||||
* Visit a method to extract its annotations
|
* Visit a method to extract its annotations
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MethodVisitor visitMethod (final int access,
|
public MethodVisitor visitMethod(final int access,
|
||||||
final String name,
|
final String name,
|
||||||
final String methodDesc,
|
final String methodDesc,
|
||||||
final String signature,
|
final String signature,
|
||||||
|
@ -520,7 +538,7 @@ public class AnnotationParser
|
||||||
* Visit a field to extract its annotations
|
* Visit a field to extract its annotations
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public FieldVisitor visitField (final int access,
|
public FieldVisitor visitField(final int access,
|
||||||
final String fieldName,
|
final String fieldName,
|
||||||
final String fieldType,
|
final String fieldType,
|
||||||
final String signature,
|
final String signature,
|
||||||
|
@ -541,18 +559,17 @@ public class AnnotationParser
|
||||||
public AnnotationParser(int javaPlatform)
|
public AnnotationParser(int javaPlatform)
|
||||||
{
|
{
|
||||||
_asmVersion = asmVersion();
|
_asmVersion = asmVersion();
|
||||||
if (javaPlatform==0)
|
if (javaPlatform == 0)
|
||||||
javaPlatform = JavaVersion.VERSION.getPlatform();
|
javaPlatform = JavaVersion.VERSION.getPlatform();
|
||||||
_javaPlatform = javaPlatform;
|
_javaPlatform = javaPlatform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public AnnotationParser(int javaPlatform, int asmVersion)
|
public AnnotationParser(int javaPlatform, int asmVersion)
|
||||||
{
|
{
|
||||||
if (javaPlatform==0)
|
if (javaPlatform == 0)
|
||||||
javaPlatform = JavaVersion.VERSION.getPlatform();
|
javaPlatform = JavaVersion.VERSION.getPlatform();
|
||||||
_javaPlatform = javaPlatform;
|
_javaPlatform = javaPlatform;
|
||||||
if (asmVersion==0)
|
if (asmVersion == 0)
|
||||||
asmVersion = ASM_OPCODE_VERSION;
|
asmVersion = ASM_OPCODE_VERSION;
|
||||||
_asmVersion = asmVersion;
|
_asmVersion = asmVersion;
|
||||||
}
|
}
|
||||||
|
@ -563,7 +580,7 @@ public class AnnotationParser
|
||||||
* @param classname the name of the class
|
* @param classname the name of the class
|
||||||
* @param location the fully qualified location of the class
|
* @param location the fully qualified location of the class
|
||||||
*/
|
*/
|
||||||
public void addParsedClass (String classname, Resource location)
|
public void addParsedClass(String classname, Resource location)
|
||||||
{
|
{
|
||||||
Resource existing = _parsedClassNames.putIfAbsent(classname, location);
|
Resource existing = _parsedClassNames.putIfAbsent(classname, location);
|
||||||
if (existing != null)
|
if (existing != null)
|
||||||
|
@ -577,18 +594,17 @@ public class AnnotationParser
|
||||||
* @param className the class name to parse
|
* @param className the class name to parse
|
||||||
* @throws Exception if unable to parse
|
* @throws Exception if unable to parse
|
||||||
*/
|
*/
|
||||||
public void parse (Set<? extends Handler> handlers, String className) throws Exception
|
public void parse(Set<? extends Handler> handlers, String className) throws Exception
|
||||||
{
|
{
|
||||||
if (className == null)
|
if (className == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String tmp = className;
|
String classRef = TypeUtil.toClassReference(className);
|
||||||
className = className.replace('.', '/')+".class";
|
URL resource = Loader.getResource(classRef);
|
||||||
URL resource = Loader.getResource(className);
|
if (resource != null)
|
||||||
if (resource!= null)
|
|
||||||
{
|
{
|
||||||
Resource r = Resource.newResource(resource);
|
Resource r = Resource.newResource(resource);
|
||||||
addParsedClass(tmp, r);
|
addParsedClass(className, r);
|
||||||
try (InputStream is = r.getInputStream())
|
try (InputStream is = r.getInputStream())
|
||||||
{
|
{
|
||||||
scanClass(handlers, null, is);
|
scanClass(handlers, null, is);
|
||||||
|
@ -604,14 +620,14 @@ public class AnnotationParser
|
||||||
* @param visitSuperClasses if true, also visit super classes for parse
|
* @param visitSuperClasses if true, also visit super classes for parse
|
||||||
* @throws Exception if unable to parse class
|
* @throws Exception if unable to parse class
|
||||||
*/
|
*/
|
||||||
public void parse (Set<? extends Handler> handlers, Class<?> clazz, boolean visitSuperClasses) throws Exception
|
public void parse(Set<? extends Handler> handlers, Class<?> clazz, boolean visitSuperClasses) throws Exception
|
||||||
{
|
{
|
||||||
Class<?> cz = clazz;
|
Class<?> cz = clazz;
|
||||||
while (cz != Object.class)
|
while (cz != Object.class)
|
||||||
{
|
{
|
||||||
String nameAsResource = cz.getName().replace('.', '/')+".class";
|
String nameAsResource = TypeUtil.toClassReference(cz);
|
||||||
URL resource = Loader.getResource(nameAsResource);
|
URL resource = Loader.getResource(nameAsResource);
|
||||||
if (resource!= null)
|
if (resource != null)
|
||||||
{
|
{
|
||||||
Resource r = Resource.newResource(resource);
|
Resource r = Resource.newResource(resource);
|
||||||
addParsedClass(clazz.getName(), r);
|
addParsedClass(clazz.getName(), r);
|
||||||
|
@ -635,7 +651,7 @@ public class AnnotationParser
|
||||||
* @param classNames the class name
|
* @param classNames the class name
|
||||||
* @throws Exception if unable to parse
|
* @throws Exception if unable to parse
|
||||||
*/
|
*/
|
||||||
public void parse (Set<? extends Handler> handlers, String[] classNames) throws Exception
|
public void parse(Set<? extends Handler> handlers, String[] classNames) throws Exception
|
||||||
{
|
{
|
||||||
if (classNames == null)
|
if (classNames == null)
|
||||||
return;
|
return;
|
||||||
|
@ -650,21 +666,20 @@ public class AnnotationParser
|
||||||
* @param classNames the class names
|
* @param classNames the class names
|
||||||
* @throws Exception if unable to parse
|
* @throws Exception if unable to parse
|
||||||
*/
|
*/
|
||||||
public void parse (Set<? extends Handler> handlers, List<String> classNames) throws Exception
|
public void parse(Set<? extends Handler> handlers, List<String> classNames) throws Exception
|
||||||
{
|
{
|
||||||
MultiException me = new MultiException();
|
MultiException me = new MultiException();
|
||||||
|
|
||||||
for (String s:classNames)
|
for (String className : classNames)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String name = s;
|
String classRef = TypeUtil.toClassReference(className);
|
||||||
s = s.replace('.', '/')+".class";
|
URL resource = Loader.getResource(classRef);
|
||||||
URL resource = Loader.getResource(s);
|
if (resource != null)
|
||||||
if (resource!= null)
|
|
||||||
{
|
{
|
||||||
Resource r = Resource.newResource(resource);
|
Resource r = Resource.newResource(resource);
|
||||||
addParsedClass(name, r);
|
addParsedClass(className, r);
|
||||||
try (InputStream is = r.getInputStream())
|
try (InputStream is = r.getInputStream())
|
||||||
{
|
{
|
||||||
scanClass(handlers, null, is);
|
scanClass(handlers, null, is);
|
||||||
|
@ -673,71 +688,12 @@ public class AnnotationParser
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
me.add(new RuntimeException("Error scanning class "+s, e));
|
me.add(new RuntimeException("Error scanning class " + className, e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
me.ifExceptionThrow();
|
me.ifExceptionThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse all classes in a directory
|
|
||||||
*
|
|
||||||
* @param handlers the set of handlers to look for classes in
|
|
||||||
* @param root the resource directory to look for classes
|
|
||||||
* @throws Exception if unable to parse
|
|
||||||
*/
|
|
||||||
protected void parseDir (Set<? extends Handler> handlers, Resource root) throws Exception
|
|
||||||
{
|
|
||||||
if (!root.isDirectory() || !root.exists() || root.getName().startsWith("."))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("Scanning dir {}", root);
|
|
||||||
|
|
||||||
File rootFile = root.getFile();
|
|
||||||
|
|
||||||
MultiException me = new MultiException();
|
|
||||||
Collection<Resource> resources = root.getAllResources();
|
|
||||||
if (resources != null)
|
|
||||||
{
|
|
||||||
for (Resource r:resources)
|
|
||||||
{
|
|
||||||
if (r.isDirectory())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
File file = r.getFile();
|
|
||||||
if (isValidClassFileName((file==null?null:file.getName())))
|
|
||||||
{
|
|
||||||
Path classpath = rootFile.toPath().relativize(file.toPath());
|
|
||||||
String str = classpath.toString();
|
|
||||||
str = str.substring(0, str.lastIndexOf(".class")).replace('/', '.').replace('\\', '.');
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("Scanning class {}", r);
|
|
||||||
addParsedClass(str, r);
|
|
||||||
try (InputStream is=r.getInputStream())
|
|
||||||
{
|
|
||||||
scanClass(handlers, Resource.newResource(file.getParentFile()), is);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
if (LOG.isDebugEnabled()) LOG.debug("Error scanning file "+file, ex);
|
|
||||||
me.add(new RuntimeException("Error scanning file "+file,ex));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (LOG.isDebugEnabled()) LOG.debug("Skipping scan on invalid file {}", file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
me.ifExceptionThrow();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse classes in the supplied uris.
|
* Parse classes in the supplied uris.
|
||||||
*
|
*
|
||||||
|
@ -745,14 +701,14 @@ public class AnnotationParser
|
||||||
* @param uris the uris for the jars
|
* @param uris the uris for the jars
|
||||||
* @throws Exception if unable to parse
|
* @throws Exception if unable to parse
|
||||||
*/
|
*/
|
||||||
public void parse (final Set<? extends Handler> handlers, final URI[] uris) throws Exception
|
public void parse(final Set<? extends Handler> handlers, final URI[] uris) throws Exception
|
||||||
{
|
{
|
||||||
if (uris==null)
|
if (uris == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MultiException me = new MultiException();
|
MultiException me = new MultiException();
|
||||||
|
|
||||||
for (URI uri:uris)
|
for (URI uri : uris)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -760,7 +716,7 @@ public class AnnotationParser
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
me.add(new RuntimeException("Problem parsing classes from "+ uri, e));
|
me.add(new RuntimeException("Problem parsing classes from " + uri, e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
me.ifExceptionThrow();
|
me.ifExceptionThrow();
|
||||||
|
@ -773,12 +729,12 @@ public class AnnotationParser
|
||||||
* @param uri the uri for the jar
|
* @param uri the uri for the jar
|
||||||
* @throws Exception if unable to parse
|
* @throws Exception if unable to parse
|
||||||
*/
|
*/
|
||||||
public void parse (final Set<? extends Handler> handlers, URI uri) throws Exception
|
public void parse(final Set<? extends Handler> handlers, URI uri) throws Exception
|
||||||
{
|
{
|
||||||
if (uri == null)
|
if (uri == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
parse (handlers, Resource.newResource(uri));
|
parse(handlers, Resource.newResource(uri));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -788,7 +744,7 @@ public class AnnotationParser
|
||||||
* @param r the resource to parse
|
* @param r the resource to parse
|
||||||
* @throws Exception if unable to parse
|
* @throws Exception if unable to parse
|
||||||
*/
|
*/
|
||||||
public void parse (final Set<? extends Handler> handlers, Resource r) throws Exception
|
public void parse(final Set<? extends Handler> handlers, Resource r) throws Exception
|
||||||
{
|
{
|
||||||
if (r == null)
|
if (r == null)
|
||||||
return;
|
return;
|
||||||
|
@ -808,14 +764,77 @@ public class AnnotationParser
|
||||||
|
|
||||||
if (fullname.endsWith(".class"))
|
if (fullname.endsWith(".class"))
|
||||||
{
|
{
|
||||||
try (InputStream is=r.getInputStream())
|
try (InputStream is = r.getInputStream())
|
||||||
{
|
{
|
||||||
scanClass(handlers, null, is);
|
scanClass(handlers, null, is);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOG.isDebugEnabled()) LOG.warn("Resource not scannable for classes: {}", r);
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.warn("Resource not scannable for classes: {}", r);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse all classes in a directory
|
||||||
|
*
|
||||||
|
* @param handlers the set of handlers to look for classes in
|
||||||
|
* @param root the resource directory to look for classes
|
||||||
|
* @throws Exception if unable to parse
|
||||||
|
*/
|
||||||
|
protected void parseDir(Set<? extends Handler> handlers, Resource root) throws Exception
|
||||||
|
{
|
||||||
|
if (!root.isDirectory() || !root.exists() || root.getName().startsWith("."))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Scanning dir {}", root);
|
||||||
|
|
||||||
|
File rootFile = root.getFile();
|
||||||
|
|
||||||
|
MultiException me = new MultiException();
|
||||||
|
Collection<Resource> resources = root.getAllResources();
|
||||||
|
if (resources != null)
|
||||||
|
{
|
||||||
|
for (Resource r : resources)
|
||||||
|
{
|
||||||
|
if (r.isDirectory())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
File file = r.getFile();
|
||||||
|
if (isValidClassFileName((file == null ? null : file.getName())))
|
||||||
|
{
|
||||||
|
Path classpath = rootFile.toPath().relativize(file.toPath());
|
||||||
|
String str = classpath.toString();
|
||||||
|
str = str.substring(0, str.lastIndexOf(".class"));
|
||||||
|
str = StringUtil.replace(str, File.separatorChar, '.');
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Scanning class {}", r);
|
||||||
|
addParsedClass(str, r);
|
||||||
|
try (InputStream is = r.getInputStream())
|
||||||
|
{
|
||||||
|
scanClass(handlers, Resource.newResource(file.getParentFile()), is);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Error scanning file " + file, ex);
|
||||||
|
me.add(new RuntimeException("Error scanning file " + file, ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Skipping scan on invalid file {}", file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
me.ifExceptionThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -825,7 +844,7 @@ public class AnnotationParser
|
||||||
* @param jarResource the jar resource to parse
|
* @param jarResource the jar resource to parse
|
||||||
* @throws Exception if unable to parse
|
* @throws Exception if unable to parse
|
||||||
*/
|
*/
|
||||||
protected void parseJar (Set<? extends Handler> handlers, Resource jarResource) throws Exception
|
protected void parseJar(Set<? extends Handler> handlers, Resource jarResource) throws Exception
|
||||||
{
|
{
|
||||||
if (jarResource == null)
|
if (jarResource == null)
|
||||||
return;
|
return;
|
||||||
|
@ -836,9 +855,9 @@ public class AnnotationParser
|
||||||
LOG.debug("Scanning jar {}", jarResource);
|
LOG.debug("Scanning jar {}", jarResource);
|
||||||
|
|
||||||
MultiException me = new MultiException();
|
MultiException me = new MultiException();
|
||||||
try (MultiReleaseJarFile jarFile = new MultiReleaseJarFile(jarResource.getFile(),_javaPlatform,false))
|
try (MultiReleaseJarFile jarFile = new MultiReleaseJarFile(jarResource.getFile(), _javaPlatform, false))
|
||||||
{
|
{
|
||||||
jarFile.stream().forEach(e->
|
jarFile.stream().forEach(e ->
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -862,7 +881,7 @@ public class AnnotationParser
|
||||||
* @param jar the jar file
|
* @param jar the jar file
|
||||||
* @throws Exception if unable to parse
|
* @throws Exception if unable to parse
|
||||||
*/
|
*/
|
||||||
protected void parseJarEntry (Set<? extends Handler> handlers, Resource jar, MultiReleaseJarFile.VersionedJarEntry entry)
|
protected void parseJarEntry(Set<? extends Handler> handlers, Resource jar, MultiReleaseJarFile.VersionedJarEntry entry)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
if (jar == null || entry == null)
|
if (jar == null || entry == null)
|
||||||
|
@ -877,8 +896,8 @@ public class AnnotationParser
|
||||||
//check file is a valid class file name
|
//check file is a valid class file name
|
||||||
if (isValidClassFileName(name) && isValidClassFilePath(name))
|
if (isValidClassFileName(name) && isValidClassFilePath(name))
|
||||||
{
|
{
|
||||||
String shortName = name.replace('/', '.').substring(0,name.length()-6);
|
String shortName = StringUtil.replace(name, '/', '.').substring(0, name.length() - 6);
|
||||||
addParsedClass(shortName, Resource.newResource("jar:"+jar.getURI()+"!/"+entry.getNameInJar()));
|
addParsedClass(shortName, Resource.newResource("jar:" + jar.getURI() + "!/" + entry.getNameInJar()));
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Scanning class from jar {}!/{}", jar, entry);
|
LOG.debug("Scanning class from jar {}!/{}", jar, entry);
|
||||||
try (InputStream is = entry.getInputStream())
|
try (InputStream is = entry.getInputStream())
|
||||||
|
@ -896,16 +915,16 @@ public class AnnotationParser
|
||||||
* @param is the input stream to parse
|
* @param is the input stream to parse
|
||||||
* @throws IOException if unable to parse
|
* @throws IOException if unable to parse
|
||||||
*/
|
*/
|
||||||
protected void scanClass (Set<? extends Handler> handlers, Resource containingResource, InputStream is) throws IOException
|
protected void scanClass(Set<? extends Handler> handlers, Resource containingResource, InputStream is) throws IOException
|
||||||
{
|
{
|
||||||
ClassReader reader = new ClassReader(is);
|
ClassReader reader = new ClassReader(is);
|
||||||
reader.accept(new MyClassVisitor(handlers, containingResource, _asmVersion), ClassReader.SKIP_CODE|ClassReader.SKIP_DEBUG|ClassReader.SKIP_FRAMES);
|
reader.accept(new MyClassVisitor(handlers, containingResource, _asmVersion), ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove any parsed class names.
|
* Remove any parsed class names.
|
||||||
*/
|
*/
|
||||||
public void resetParsedClasses ()
|
public void resetParsedClasses()
|
||||||
{
|
{
|
||||||
_parsedClassNames.clear();
|
_parsedClassNames.clear();
|
||||||
}
|
}
|
||||||
|
@ -918,36 +937,40 @@ public class AnnotationParser
|
||||||
* <li> it isn't a dot file or in a hidden directory </li>
|
* <li> it isn't a dot file or in a hidden directory </li>
|
||||||
* <li> the name of the class at least begins with a valid identifier for a class name </li>
|
* <li> the name of the class at least begins with a valid identifier for a class name </li>
|
||||||
* </ul>
|
* </ul>
|
||||||
|
*
|
||||||
* @param name the class file name
|
* @param name the class file name
|
||||||
* @return whether the class file name is valid
|
* @return whether the class file name is valid
|
||||||
*/
|
*/
|
||||||
private boolean isValidClassFileName (String name)
|
private boolean isValidClassFileName(String name)
|
||||||
{
|
{
|
||||||
//no name cannot be valid
|
//no name cannot be valid
|
||||||
if (name == null || name.length()==0)
|
if (name == null || name.length() == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//skip anything that is not a class file
|
//skip anything that is not a class file
|
||||||
String lc = name.toLowerCase(Locale.ENGLISH);
|
String lc = name.toLowerCase(Locale.ENGLISH);
|
||||||
if (!lc.endsWith(".class"))
|
if (!lc.endsWith(".class"))
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled()) LOG.debug("Not a class: {}",name);
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Not a class: {}", name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lc.equals("module-info.class"))
|
if (lc.equals("module-info.class"))
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled()) LOG.debug("Skipping module-info.class");
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Skipping module-info.class");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//skip any classfiles that are not a valid java identifier
|
//skip any classfiles that are not a valid java identifier
|
||||||
int c0 = 0;
|
int c0 = 0;
|
||||||
int ldir = name.lastIndexOf('/', name.length()-6);
|
int ldir = name.lastIndexOf('/', name.length() - 6);
|
||||||
c0 = (ldir > -1 ? ldir+1 : c0);
|
c0 = (ldir > -1 ? ldir + 1 : c0);
|
||||||
if (!Character.isJavaIdentifierStart(name.charAt(c0)))
|
if (!Character.isJavaIdentifierStart(name.charAt(c0)))
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled()) LOG.debug("Not a java identifier: {}",name);
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Not a java identifier: {}", name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -960,16 +983,17 @@ public class AnnotationParser
|
||||||
* @param path the class file path
|
* @param path the class file path
|
||||||
* @return whether the class file path is valid
|
* @return whether the class file path is valid
|
||||||
*/
|
*/
|
||||||
private boolean isValidClassFilePath (String path)
|
private boolean isValidClassFilePath(String path)
|
||||||
{
|
{
|
||||||
//no path is not valid
|
//no path is not valid
|
||||||
if (path == null || path.length()==0)
|
if (path == null || path.length() == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// skip any classfiles that are in a hidden directory
|
// skip any classfiles that are in a hidden directory
|
||||||
if (path.startsWith(".") || path.contains("/."))
|
if (path.startsWith(".") || path.contains("/."))
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled()) LOG.debug("Contains hidden dirs: " + path);
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Contains hidden dirs: " + path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@ public class ClassInheritanceHandler extends AbstractHandler
|
||||||
|
|
||||||
Map<String, Set<String>> _inheritanceMap;
|
Map<String, Set<String>> _inheritanceMap;
|
||||||
|
|
||||||
|
|
||||||
public ClassInheritanceHandler(Map<String, Set<String>> map)
|
public ClassInheritanceHandler(Map<String, Set<String>> map)
|
||||||
{
|
{
|
||||||
_inheritanceMap = map;
|
_inheritanceMap = map;
|
||||||
|
@ -53,7 +52,7 @@ public class ClassInheritanceHandler extends AbstractHandler
|
||||||
if ("java.lang.Object".equals(classInfo.getClassName()))
|
if ("java.lang.Object".equals(classInfo.getClassName()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i=0; classInfo.getInterfaces() != null && i < classInfo.getInterfaces().length;i++)
|
for (int i = 0; classInfo.getInterfaces() != null && i < classInfo.getInterfaces().length; i++)
|
||||||
{
|
{
|
||||||
addToInheritanceMap(classInfo.getInterfaces()[i], classInfo.getClassName());
|
addToInheritanceMap(classInfo.getInterfaces()[i], classInfo.getClassName());
|
||||||
}
|
}
|
||||||
|
@ -69,7 +68,7 @@ public class ClassInheritanceHandler extends AbstractHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToInheritanceMap (String interfaceOrSuperClassName, String implementingOrExtendingClassName)
|
private void addToInheritanceMap(String interfaceOrSuperClassName, String implementingOrExtendingClassName)
|
||||||
{
|
{
|
||||||
|
|
||||||
//As it is likely that the interfaceOrSuperClassName is already in the map, try getting it first
|
//As it is likely that the interfaceOrSuperClassName is already in the map, try getting it first
|
||||||
|
|
|
@ -16,10 +16,8 @@
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
package org.eclipse.jetty.annotations;
|
package org.eclipse.jetty.annotations;
|
||||||
|
|
||||||
|
|
||||||
import org.eclipse.jetty.annotations.AnnotationParser.AbstractHandler;
|
import org.eclipse.jetty.annotations.AnnotationParser.AbstractHandler;
|
||||||
import org.eclipse.jetty.annotations.AnnotationParser.ClassInfo;
|
import org.eclipse.jetty.annotations.AnnotationParser.ClassInfo;
|
||||||
import org.eclipse.jetty.annotations.AnnotationParser.FieldInfo;
|
import org.eclipse.jetty.annotations.AnnotationParser.FieldInfo;
|
||||||
|
@ -38,7 +36,7 @@ public class ContainerInitializerAnnotationHandler extends AbstractHandler
|
||||||
final ContainerInitializer _initializer;
|
final ContainerInitializer _initializer;
|
||||||
final Class _annotation;
|
final Class _annotation;
|
||||||
|
|
||||||
public ContainerInitializerAnnotationHandler (ContainerInitializer initializer, Class annotation)
|
public ContainerInitializerAnnotationHandler(ContainerInitializer initializer, Class annotation)
|
||||||
{
|
{
|
||||||
_initializer = initializer;
|
_initializer = initializer;
|
||||||
_annotation = annotation;
|
_annotation = annotation;
|
||||||
|
@ -84,7 +82,6 @@ public class ContainerInitializerAnnotationHandler extends AbstractHandler
|
||||||
_initializer.addAnnotatedTypeName(info.getClassInfo().getClassName());
|
_initializer.addAnnotatedTypeName(info.getClassInfo().getClassName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ContainerInitializer getContainerInitializer()
|
public ContainerInitializer getContainerInitializer()
|
||||||
{
|
{
|
||||||
return _initializer;
|
return _initializer;
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.annotations;
|
package org.eclipse.jetty.annotations;
|
||||||
|
|
||||||
|
|
||||||
import javax.annotation.security.DeclareRoles;
|
import javax.annotation.security.DeclareRoles;
|
||||||
import javax.servlet.Servlet;
|
import javax.servlet.Servlet;
|
||||||
|
|
||||||
|
@ -44,7 +43,6 @@ public class DeclareRolesAnnotationHandler extends AbstractIntrospectableAnnotat
|
||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler#doHandle(java.lang.Class)
|
* @see org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler#doHandle(java.lang.Class)
|
||||||
*/
|
*/
|
||||||
|
@ -60,7 +58,7 @@ public class DeclareRolesAnnotationHandler extends AbstractIntrospectableAnnotat
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeclareRoles declareRoles = (DeclareRoles) clazz.getAnnotation(DeclareRoles.class);
|
DeclareRoles declareRoles = (DeclareRoles)clazz.getAnnotation(DeclareRoles.class);
|
||||||
if (declareRoles == null)
|
if (declareRoles == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -68,9 +66,10 @@ public class DeclareRolesAnnotationHandler extends AbstractIntrospectableAnnotat
|
||||||
|
|
||||||
if (roles != null && roles.length > 0)
|
if (roles != null && roles.length > 0)
|
||||||
{
|
{
|
||||||
for (String r:roles)
|
for (String r : roles)
|
||||||
|
{
|
||||||
((ConstraintSecurityHandler)_context.getSecurityHandler()).addRole(r);
|
((ConstraintSecurityHandler)_context.getSecurityHandler()).addRole(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,6 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MultiPartConfigAnnotationHandler
|
* MultiPartConfigAnnotationHandler
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class MultiPartConfigAnnotationHandler extends AbstractIntrospectableAnnotationHandler
|
public class MultiPartConfigAnnotationHandler extends AbstractIntrospectableAnnotationHandler
|
||||||
{
|
{
|
||||||
|
@ -43,6 +41,7 @@ public class MultiPartConfigAnnotationHandler extends AbstractIntrospectableAnno
|
||||||
super(false);
|
super(false);
|
||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler#doHandle(java.lang.Class)
|
* @see org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler#doHandle(java.lang.Class)
|
||||||
*/
|
*/
|
||||||
|
@ -52,7 +51,7 @@ public class MultiPartConfigAnnotationHandler extends AbstractIntrospectableAnno
|
||||||
if (!Servlet.class.isAssignableFrom(clazz))
|
if (!Servlet.class.isAssignableFrom(clazz))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MultipartConfig multi = (MultipartConfig) clazz.getAnnotation(MultipartConfig.class);
|
MultipartConfig multi = (MultipartConfig)clazz.getAnnotation(MultipartConfig.class);
|
||||||
if (multi == null)
|
if (multi == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -62,35 +61,16 @@ public class MultiPartConfigAnnotationHandler extends AbstractIntrospectableAnno
|
||||||
//How to identify the correct Servlet? If the Servlet has no WebServlet annotation on it, does it mean that this MultipartConfig
|
//How to identify the correct Servlet? If the Servlet has no WebServlet annotation on it, does it mean that this MultipartConfig
|
||||||
//annotation applies to all declared instances in web.xml/programmatically?
|
//annotation applies to all declared instances in web.xml/programmatically?
|
||||||
//Assuming TRUE for now.
|
//Assuming TRUE for now.
|
||||||
|
for (ServletHolder holder : _context.getServletHandler().getServlets(clazz))
|
||||||
ServletHolder holder = getServletHolderForClass(clazz);
|
|
||||||
if (holder != null)
|
|
||||||
{
|
{
|
||||||
Descriptor d = metaData.getOriginDescriptor(holder.getName()+".servlet.multipart-config");
|
Descriptor d = metaData.getOriginDescriptor(holder.getName() + ".servlet.multipart-config");
|
||||||
//if a descriptor has already set the value for multipart config, do not
|
//if a descriptor has already set the value for multipart config, do not
|
||||||
//let the annotation override it
|
//let the annotation override it
|
||||||
if (d == null)
|
if (d == null)
|
||||||
{
|
{
|
||||||
metaData.setOrigin(holder.getName()+".servlet.multipart-config",multi,clazz);
|
metaData.setOrigin(holder.getName() + ".servlet.multipart-config", multi, clazz);
|
||||||
holder.getRegistration().setMultipartConfig(new MultipartConfigElement(multi));
|
holder.getRegistration().setMultipartConfig(new MultipartConfigElement(multi));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServletHolder getServletHolderForClass (Class clazz)
|
|
||||||
{
|
|
||||||
ServletHolder holder = null;
|
|
||||||
ServletHolder[] holders = _context.getServletHandler().getServlets();
|
|
||||||
if (holders != null)
|
|
||||||
{
|
|
||||||
for (ServletHolder h : holders)
|
|
||||||
{
|
|
||||||
if (h.getClassName() != null && h.getClassName().equals(clazz.getName()))
|
|
||||||
{
|
|
||||||
holder = h;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return holder;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.annotations;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
import org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler;
|
import org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler;
|
||||||
|
@ -34,13 +33,12 @@ public class PostConstructAnnotationHandler extends AbstractIntrospectableAnnota
|
||||||
{
|
{
|
||||||
protected WebAppContext _context;
|
protected WebAppContext _context;
|
||||||
|
|
||||||
public PostConstructAnnotationHandler (WebAppContext wac)
|
public PostConstructAnnotationHandler(WebAppContext wac)
|
||||||
{
|
{
|
||||||
super(true);
|
super(true);
|
||||||
_context = wac;
|
_context = wac;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doHandle(Class clazz)
|
public void doHandle(Class clazz)
|
||||||
{
|
{
|
||||||
|
@ -48,19 +46,19 @@ public class PostConstructAnnotationHandler extends AbstractIntrospectableAnnota
|
||||||
if (supportsPostConstruct(clazz))
|
if (supportsPostConstruct(clazz))
|
||||||
{
|
{
|
||||||
Method[] methods = clazz.getDeclaredMethods();
|
Method[] methods = clazz.getDeclaredMethods();
|
||||||
for (int i=0; i<methods.length; i++)
|
for (int i = 0; i < methods.length; i++)
|
||||||
{
|
{
|
||||||
Method m = (Method)methods[i];
|
Method m = (Method)methods[i];
|
||||||
if (m.isAnnotationPresent(PostConstruct.class))
|
if (m.isAnnotationPresent(PostConstruct.class))
|
||||||
{
|
{
|
||||||
if (m.getParameterCount() != 0)
|
if (m.getParameterCount() != 0)
|
||||||
throw new IllegalStateException(m+" has parameters");
|
throw new IllegalStateException(m + " has parameters");
|
||||||
if (m.getReturnType() != Void.TYPE)
|
if (m.getReturnType() != Void.TYPE)
|
||||||
throw new IllegalStateException(m+" is not void");
|
throw new IllegalStateException(m + " is not void");
|
||||||
if (m.getExceptionTypes().length != 0)
|
if (m.getExceptionTypes().length != 0)
|
||||||
throw new IllegalStateException(m+" throws checked exceptions");
|
throw new IllegalStateException(m + " throws checked exceptions");
|
||||||
if (Modifier.isStatic(m.getModifiers()))
|
if (Modifier.isStatic(m.getModifiers()))
|
||||||
throw new IllegalStateException(m+" is static");
|
throw new IllegalStateException(m + " is static");
|
||||||
|
|
||||||
//ServletSpec 3.0 p80 If web.xml declares even one post-construct then all post-constructs
|
//ServletSpec 3.0 p80 If web.xml declares even one post-construct then all post-constructs
|
||||||
//in fragments must be ignored. Otherwise, they are additive.
|
//in fragments must be ignored. Otherwise, they are additive.
|
||||||
|
@ -72,13 +70,12 @@ public class PostConstructAnnotationHandler extends AbstractIntrospectableAnnota
|
||||||
origin == Origin.WebOverride))
|
origin == Origin.WebOverride))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PostConstructCallback callback = new PostConstructCallback();
|
PostConstructCallback callback = new PostConstructCallback(clazz, m.getName());
|
||||||
callback.setTarget(clazz.getName(), m.getName());
|
|
||||||
LifeCycleCallbackCollection lifecycles = (LifeCycleCallbackCollection)_context.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION);
|
LifeCycleCallbackCollection lifecycles = (LifeCycleCallbackCollection)_context.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION);
|
||||||
if (lifecycles == null)
|
if (lifecycles == null)
|
||||||
{
|
{
|
||||||
lifecycles = new LifeCycleCallbackCollection();
|
lifecycles = new LifeCycleCallbackCollection();
|
||||||
_context.setAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION,lifecycles);
|
_context.setAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION, lifecycles);
|
||||||
}
|
}
|
||||||
lifecycles.add(callback);
|
lifecycles.add(callback);
|
||||||
}
|
}
|
||||||
|
@ -88,10 +85,11 @@ public class PostConstructAnnotationHandler extends AbstractIntrospectableAnnota
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the given class is permitted to have PostConstruct annotation.
|
* Check if the given class is permitted to have PostConstruct annotation.
|
||||||
|
*
|
||||||
* @param c the class
|
* @param c the class
|
||||||
* @return true if the spec permits the class to have PostConstruct, false otherwise
|
* @return true if the spec permits the class to have PostConstruct, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean supportsPostConstruct (Class c)
|
public boolean supportsPostConstruct(Class c)
|
||||||
{
|
{
|
||||||
if (javax.servlet.Servlet.class.isAssignableFrom(c) ||
|
if (javax.servlet.Servlet.class.isAssignableFrom(c) ||
|
||||||
javax.servlet.Filter.class.isAssignableFrom(c) ||
|
javax.servlet.Filter.class.isAssignableFrom(c) ||
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.annotations;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
|
|
||||||
import javax.annotation.PreDestroy;
|
import javax.annotation.PreDestroy;
|
||||||
|
|
||||||
import org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler;
|
import org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler;
|
||||||
|
@ -34,7 +33,7 @@ public class PreDestroyAnnotationHandler extends AbstractIntrospectableAnnotatio
|
||||||
{
|
{
|
||||||
WebAppContext _context;
|
WebAppContext _context;
|
||||||
|
|
||||||
public PreDestroyAnnotationHandler (WebAppContext wac)
|
public PreDestroyAnnotationHandler(WebAppContext wac)
|
||||||
{
|
{
|
||||||
super(true);
|
super(true);
|
||||||
_context = wac;
|
_context = wac;
|
||||||
|
@ -47,19 +46,19 @@ public class PreDestroyAnnotationHandler extends AbstractIntrospectableAnnotatio
|
||||||
if (supportsPreDestroy(clazz))
|
if (supportsPreDestroy(clazz))
|
||||||
{
|
{
|
||||||
Method[] methods = clazz.getDeclaredMethods();
|
Method[] methods = clazz.getDeclaredMethods();
|
||||||
for (int i=0; i<methods.length; i++)
|
for (int i = 0; i < methods.length; i++)
|
||||||
{
|
{
|
||||||
Method m = (Method)methods[i];
|
Method m = (Method)methods[i];
|
||||||
if (m.isAnnotationPresent(PreDestroy.class))
|
if (m.isAnnotationPresent(PreDestroy.class))
|
||||||
{
|
{
|
||||||
if (m.getParameterCount() != 0)
|
if (m.getParameterCount() != 0)
|
||||||
throw new IllegalStateException(m+" has parameters");
|
throw new IllegalStateException(m + " has parameters");
|
||||||
if (m.getReturnType() != Void.TYPE)
|
if (m.getReturnType() != Void.TYPE)
|
||||||
throw new IllegalStateException(m+" is not void");
|
throw new IllegalStateException(m + " is not void");
|
||||||
if (m.getExceptionTypes().length != 0)
|
if (m.getExceptionTypes().length != 0)
|
||||||
throw new IllegalStateException(m+" throws checked exceptions");
|
throw new IllegalStateException(m + " throws checked exceptions");
|
||||||
if (Modifier.isStatic(m.getModifiers()))
|
if (Modifier.isStatic(m.getModifiers()))
|
||||||
throw new IllegalStateException(m+" is static");
|
throw new IllegalStateException(m + " is static");
|
||||||
|
|
||||||
//ServletSpec 3.0 p80 If web.xml declares even one predestroy then all predestroys
|
//ServletSpec 3.0 p80 If web.xml declares even one predestroy then all predestroys
|
||||||
//in fragments must be ignored. Otherwise, they are additive.
|
//in fragments must be ignored. Otherwise, they are additive.
|
||||||
|
@ -71,8 +70,7 @@ public class PreDestroyAnnotationHandler extends AbstractIntrospectableAnnotatio
|
||||||
origin == Origin.WebOverride))
|
origin == Origin.WebOverride))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PreDestroyCallback callback = new PreDestroyCallback();
|
PreDestroyCallback callback = new PreDestroyCallback(clazz, m.getName());
|
||||||
callback.setTarget(clazz.getName(), m.getName());
|
|
||||||
|
|
||||||
LifeCycleCallbackCollection lifecycles = (LifeCycleCallbackCollection)_context.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION);
|
LifeCycleCallbackCollection lifecycles = (LifeCycleCallbackCollection)_context.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION);
|
||||||
if (lifecycles == null)
|
if (lifecycles == null)
|
||||||
|
@ -89,10 +87,11 @@ public class PreDestroyAnnotationHandler extends AbstractIntrospectableAnnotatio
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the spec permits the given class to use the PreDestroy annotation.
|
* Check if the spec permits the given class to use the PreDestroy annotation.
|
||||||
|
*
|
||||||
* @param c the class
|
* @param c the class
|
||||||
* @return true if permitted, false otherwise
|
* @return true if permitted, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean supportsPreDestroy (Class c)
|
public boolean supportsPreDestroy(Class c)
|
||||||
{
|
{
|
||||||
if (javax.servlet.Servlet.class.isAssignableFrom(c) ||
|
if (javax.servlet.Servlet.class.isAssignableFrom(c) ||
|
||||||
javax.servlet.Filter.class.isAssignableFrom(c) ||
|
javax.servlet.Filter.class.isAssignableFrom(c) ||
|
||||||
|
|
|
@ -24,7 +24,6 @@ import java.lang.reflect.Modifier;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.naming.InitialContext;
|
import javax.naming.InitialContext;
|
||||||
import javax.naming.NameNotFoundException;
|
import javax.naming.NameNotFoundException;
|
||||||
|
@ -43,19 +42,20 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||||
private static final Logger LOG = Log.getLogger(ResourceAnnotationHandler.class);
|
private static final Logger LOG = Log.getLogger(ResourceAnnotationHandler.class);
|
||||||
|
|
||||||
protected static final List<Class<?>> ENV_ENTRY_TYPES =
|
protected static final List<Class<?>> ENV_ENTRY_TYPES =
|
||||||
Arrays.asList(new Class[] {String.class, Character.class, Integer.class, Boolean.class, Double.class, Byte.class, Short.class, Long.class, Float.class});
|
Arrays.asList(new Class[]
|
||||||
|
{
|
||||||
|
String.class, Character.class, Integer.class, Boolean.class, Double.class, Byte.class, Short.class, Long.class,
|
||||||
|
Float.class
|
||||||
|
});
|
||||||
|
|
||||||
protected WebAppContext _context;
|
protected WebAppContext _context;
|
||||||
|
|
||||||
|
public ResourceAnnotationHandler(WebAppContext wac)
|
||||||
public ResourceAnnotationHandler (WebAppContext wac)
|
|
||||||
{
|
{
|
||||||
super(true);
|
super(true);
|
||||||
_context = wac;
|
_context = wac;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class level Resource annotations declare a name in the
|
* Class level Resource annotations declare a name in the
|
||||||
* environment that will be looked up at runtime. They do
|
* environment that will be looked up at runtime. They do
|
||||||
|
@ -69,16 +69,20 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||||
handleClass(clazz);
|
handleClass(clazz);
|
||||||
|
|
||||||
Method[] methods = clazz.getDeclaredMethods();
|
Method[] methods = clazz.getDeclaredMethods();
|
||||||
for (int i=0; i<methods.length; i++)
|
for (int i = 0; i < methods.length; i++)
|
||||||
|
{
|
||||||
handleMethod(clazz, methods[i]);
|
handleMethod(clazz, methods[i]);
|
||||||
|
}
|
||||||
Field[] fields = clazz.getDeclaredFields();
|
Field[] fields = clazz.getDeclaredFields();
|
||||||
//For each field, get all of it's annotations
|
//For each field, get all of it's annotations
|
||||||
for (int i=0; i<fields.length; i++)
|
for (int i = 0; i < fields.length; i++)
|
||||||
|
{
|
||||||
handleField(clazz, fields[i]);
|
handleField(clazz, fields[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void handleClass (Class<?> clazz)
|
public void handleClass(Class<?> clazz)
|
||||||
{
|
{
|
||||||
Resource resource = (Resource)clazz.getAnnotation(Resource.class);
|
Resource resource = (Resource)clazz.getAnnotation(Resource.class);
|
||||||
if (resource != null)
|
if (resource != null)
|
||||||
|
@ -86,14 +90,14 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||||
String name = resource.name();
|
String name = resource.name();
|
||||||
String mappedName = resource.mappedName();
|
String mappedName = resource.mappedName();
|
||||||
|
|
||||||
if (name==null || name.trim().equals(""))
|
if (name == null || name.trim().equals(""))
|
||||||
throw new IllegalStateException ("Class level Resource annotations must contain a name (Common Annotations Spec Section 2.3)");
|
throw new IllegalStateException("Class level Resource annotations must contain a name (Common Annotations Spec Section 2.3)");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!org.eclipse.jetty.plus.jndi.NamingEntryUtil.bindToENC(_context, name,mappedName))
|
if (!org.eclipse.jetty.plus.jndi.NamingEntryUtil.bindToENC(_context, name, mappedName))
|
||||||
if (!org.eclipse.jetty.plus.jndi.NamingEntryUtil.bindToENC(_context.getServer(), name,mappedName))
|
if (!org.eclipse.jetty.plus.jndi.NamingEntryUtil.bindToENC(_context.getServer(), name, mappedName))
|
||||||
throw new IllegalStateException("No resource at "+(mappedName==null?name:mappedName));
|
throw new IllegalStateException("No resource at " + (mappedName == null ? name : mappedName));
|
||||||
}
|
}
|
||||||
catch (NamingException e)
|
catch (NamingException e)
|
||||||
{
|
{
|
||||||
|
@ -110,23 +114,23 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||||
//JavaEE Spec 5.2.3: Field cannot be static
|
//JavaEE Spec 5.2.3: Field cannot be static
|
||||||
if (Modifier.isStatic(field.getModifiers()))
|
if (Modifier.isStatic(field.getModifiers()))
|
||||||
{
|
{
|
||||||
LOG.warn("Skipping Resource annotation on "+clazz.getName()+"."+field.getName()+": cannot be static");
|
LOG.warn("Skipping Resource annotation on " + clazz.getName() + "." + field.getName() + ": cannot be static");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//JavaEE Spec 5.2.3: Field cannot be final
|
//JavaEE Spec 5.2.3: Field cannot be final
|
||||||
if (Modifier.isFinal(field.getModifiers()))
|
if (Modifier.isFinal(field.getModifiers()))
|
||||||
{
|
{
|
||||||
LOG.warn("Skipping Resource annotation on "+clazz.getName()+"."+field.getName()+": cannot be final");
|
LOG.warn("Skipping Resource annotation on " + clazz.getName() + "." + field.getName() + ": cannot be final");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//work out default name
|
//work out default name
|
||||||
String name = clazz.getCanonicalName()+"/"+field.getName();
|
String name = clazz.getName() + "/" + field.getName();
|
||||||
|
|
||||||
//allow @Resource name= to override the field name
|
//allow @Resource name= to override the field name
|
||||||
name = (resource.name()!=null && !resource.name().trim().equals("")? resource.name(): name);
|
name = (resource.name() != null && !resource.name().trim().equals("") ? resource.name() : name);
|
||||||
String mappedName = (resource.mappedName()!=null && !resource.mappedName().trim().equals("")?resource.mappedName():null);
|
String mappedName = (resource.mappedName() != null && !resource.mappedName().trim().equals("") ? resource.mappedName() : null);
|
||||||
//get the type of the Field
|
//get the type of the Field
|
||||||
Class<?> type = field.getType();
|
Class<?> type = field.getType();
|
||||||
|
|
||||||
|
@ -134,7 +138,7 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||||
//If a descriptor has specified at least 1 injection target for this
|
//If a descriptor has specified at least 1 injection target for this
|
||||||
//resource, then it overrides this annotation
|
//resource, then it overrides this annotation
|
||||||
MetaData metaData = _context.getMetaData();
|
MetaData metaData = _context.getMetaData();
|
||||||
if (metaData.getOriginDescriptor("resource-ref."+name+".injection") != null)
|
if (metaData.getOriginDescriptor("resource-ref." + name + ".injection") != null)
|
||||||
{
|
{
|
||||||
//at least 1 injection was specified for this resource by a descriptor, so
|
//at least 1 injection was specified for this resource by a descriptor, so
|
||||||
//it overrides this annotation
|
//it overrides this annotation
|
||||||
|
@ -166,8 +170,8 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
InitialContext ic = new InitialContext();
|
InitialContext ic = new InitialContext();
|
||||||
String nameInEnvironment = (mappedName!=null?mappedName:name);
|
String nameInEnvironment = (mappedName != null ? mappedName : name);
|
||||||
ic.lookup("java:comp/env/"+nameInEnvironment);
|
ic.lookup("java:comp/env/" + nameInEnvironment);
|
||||||
bound = true;
|
bound = true;
|
||||||
}
|
}
|
||||||
catch (NameNotFoundException e)
|
catch (NameNotFoundException e)
|
||||||
|
@ -178,16 +182,13 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||||
//Check there is a JNDI entry for this annotation
|
//Check there is a JNDI entry for this annotation
|
||||||
if (bound)
|
if (bound)
|
||||||
{
|
{
|
||||||
LOG.debug("Bound "+(mappedName==null?name:mappedName) + " as "+ name);
|
LOG.debug("Bound " + (mappedName == null ? name : mappedName) + " as " + name);
|
||||||
// Make the Injection for it if the binding succeeded
|
// Make the Injection for it if the binding succeeded
|
||||||
injection = new Injection();
|
injection = new Injection(clazz, field, type, name, mappedName);
|
||||||
injection.setTarget(clazz, field, type);
|
|
||||||
injection.setJndiName(name);
|
|
||||||
injection.setMappingName(mappedName);
|
|
||||||
injections.add(injection);
|
injections.add(injection);
|
||||||
|
|
||||||
//TODO - an @Resource is equivalent to a resource-ref, resource-env-ref, message-destination
|
//TODO - an @Resource is equivalent to a resource-ref, resource-env-ref, message-destination
|
||||||
metaData.setOrigin("resource-ref."+name+".injection",resource,clazz);
|
metaData.setOrigin("resource-ref." + name + ".injection", resource, clazz);
|
||||||
}
|
}
|
||||||
else if (!isEnvEntryType(type))
|
else if (!isEnvEntryType(type))
|
||||||
{
|
{
|
||||||
|
@ -195,7 +196,7 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||||
//an error, it just means that perhaps the code will use a default value instead
|
//an error, it just means that perhaps the code will use a default value instead
|
||||||
// JavaEE Spec. sec 5.4.1.3
|
// JavaEE Spec. sec 5.4.1.3
|
||||||
|
|
||||||
throw new IllegalStateException("No resource at "+(mappedName==null?name:mappedName));
|
throw new IllegalStateException("No resource at " + (mappedName == null ? name : mappedName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (NamingException e)
|
catch (NamingException e)
|
||||||
|
@ -210,7 +211,6 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process a Resource annotation on a Method.
|
* Process a Resource annotation on a Method.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -246,7 +246,7 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||||
//JavaEE Spec 5.2.3: Method cannot be static
|
//JavaEE Spec 5.2.3: Method cannot be static
|
||||||
if (Modifier.isStatic(method.getModifiers()))
|
if (Modifier.isStatic(method.getModifiers()))
|
||||||
{
|
{
|
||||||
LOG.warn("Skipping Resource annotation on "+clazz.getName()+"."+method.getName()+": cannot be static");
|
LOG.warn("Skipping Resource annotation on " + clazz.getName() + "." + method.getName() + ": cannot be static");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,30 +254,29 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||||
// only 1 parameter
|
// only 1 parameter
|
||||||
if (!method.getName().startsWith("set"))
|
if (!method.getName().startsWith("set"))
|
||||||
{
|
{
|
||||||
LOG.warn("Skipping Resource annotation on "+clazz.getName()+"."+method.getName()+": invalid java bean, does not start with 'set'");
|
LOG.warn("Skipping Resource annotation on " + clazz.getName() + "." + method.getName() + ": invalid java bean, does not start with 'set'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (method.getParameterCount() != 1)
|
if (method.getParameterCount() != 1)
|
||||||
{
|
{
|
||||||
LOG.warn("Skipping Resource annotation on "+clazz.getName()+"."+method.getName()+": invalid java bean, not single argument to method");
|
LOG.warn("Skipping Resource annotation on " + clazz.getName() + "." + method.getName() + ": invalid java bean, not single argument to method");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Void.TYPE != method.getReturnType())
|
if (Void.TYPE != method.getReturnType())
|
||||||
{
|
{
|
||||||
LOG.warn("Skipping Resource annotation on "+clazz.getName()+"."+method.getName()+": invalid java bean, not void");
|
LOG.warn("Skipping Resource annotation on " + clazz.getName() + "." + method.getName() + ": invalid java bean, not void");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//default name is the javabean property name
|
//default name is the javabean property name
|
||||||
String name = method.getName().substring(3);
|
String name = method.getName().substring(3);
|
||||||
name = name.substring(0,1).toLowerCase(Locale.ENGLISH)+name.substring(1);
|
name = name.substring(0, 1).toLowerCase(Locale.ENGLISH) + name.substring(1);
|
||||||
name = clazz.getCanonicalName()+"/"+name;
|
name = clazz.getName() + "/" + name;
|
||||||
|
|
||||||
name = (resource.name()!=null && !resource.name().trim().equals("")? resource.name(): name);
|
name = (resource.name() != null && !resource.name().trim().equals("") ? resource.name() : name);
|
||||||
String mappedName = (resource.mappedName()!=null && !resource.mappedName().trim().equals("")?resource.mappedName():null);
|
String mappedName = (resource.mappedName() != null && !resource.mappedName().trim().equals("") ? resource.mappedName() : null);
|
||||||
Class<?> paramType = method.getParameterTypes()[0];
|
Class<?> paramType = method.getParameterTypes()[0];
|
||||||
|
|
||||||
Class<?> resourceType = resource.type();
|
Class<?> resourceType = resource.type();
|
||||||
|
@ -286,7 +285,7 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||||
//If a descriptor has specified at least 1 injection target for this
|
//If a descriptor has specified at least 1 injection target for this
|
||||||
//resource, then it overrides this annotation
|
//resource, then it overrides this annotation
|
||||||
MetaData metaData = _context.getMetaData();
|
MetaData metaData = _context.getMetaData();
|
||||||
if (metaData.getOriginDescriptor("resource-ref."+name+".injection") != null)
|
if (metaData.getOriginDescriptor("resource-ref." + name + ".injection") != null)
|
||||||
{
|
{
|
||||||
//at least 1 injection was specified for this resource by a descriptor, so
|
//at least 1 injection was specified for this resource by a descriptor, so
|
||||||
//it overrides this annotation
|
//it overrides this annotation
|
||||||
|
@ -324,8 +323,8 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
InitialContext ic = new InitialContext();
|
InitialContext ic = new InitialContext();
|
||||||
String nameInEnvironment = (mappedName!=null?mappedName:name);
|
String nameInEnvironment = (mappedName != null ? mappedName : name);
|
||||||
ic.lookup("java:comp/env/"+nameInEnvironment);
|
ic.lookup("java:comp/env/" + nameInEnvironment);
|
||||||
bound = true;
|
bound = true;
|
||||||
}
|
}
|
||||||
catch (NameNotFoundException e)
|
catch (NameNotFoundException e)
|
||||||
|
@ -336,15 +335,12 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||||
|
|
||||||
if (bound)
|
if (bound)
|
||||||
{
|
{
|
||||||
LOG.debug("Bound "+(mappedName==null?name:mappedName) + " as "+ name);
|
LOG.debug("Bound " + (mappedName == null ? name : mappedName) + " as " + name);
|
||||||
// Make the Injection for it
|
// Make the Injection for it
|
||||||
injection = new Injection();
|
injection = new Injection(clazz, method, paramType, resourceType, name, mappedName);
|
||||||
injection.setTarget(clazz, method,paramType,resourceType);
|
|
||||||
injection.setJndiName(name);
|
|
||||||
injection.setMappingName(mappedName);
|
|
||||||
injections.add(injection);
|
injections.add(injection);
|
||||||
//TODO - an @Resource is equivalent to a resource-ref, resource-env-ref, message-destination
|
//TODO - an @Resource is equivalent to a resource-ref, resource-env-ref, message-destination
|
||||||
metaData.setOrigin("resource-ref."+name+".injection",resource,clazz);
|
metaData.setOrigin("resource-ref." + name + ".injection", resource, clazz);
|
||||||
}
|
}
|
||||||
else if (!isEnvEntryType(paramType))
|
else if (!isEnvEntryType(paramType))
|
||||||
{
|
{
|
||||||
|
@ -352,7 +348,7 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||||
//if this is an env-entry type resource and there is no value bound for it, it isn't
|
//if this is an env-entry type resource and there is no value bound for it, it isn't
|
||||||
//an error, it just means that perhaps the code will use a default value instead
|
//an error, it just means that perhaps the code will use a default value instead
|
||||||
// JavaEE Spec. sec 5.4.1.3
|
// JavaEE Spec. sec 5.4.1.3
|
||||||
throw new IllegalStateException("No resource at "+(mappedName==null?name:mappedName));
|
throw new IllegalStateException("No resource at " + (mappedName == null ? name : mappedName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (NamingException e)
|
catch (NamingException e)
|
||||||
|
@ -364,7 +360,6 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,7 +369,7 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||||
* @param c the class
|
* @param c the class
|
||||||
* @return true if Resource annotation permitted, false otherwise
|
* @return true if Resource annotation permitted, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean supportsResourceInjection (Class<?> c)
|
public boolean supportsResourceInjection(Class<?> c)
|
||||||
{
|
{
|
||||||
if (javax.servlet.Servlet.class.isAssignableFrom(c) ||
|
if (javax.servlet.Servlet.class.isAssignableFrom(c) ||
|
||||||
javax.servlet.Filter.class.isAssignableFrom(c) ||
|
javax.servlet.Filter.class.isAssignableFrom(c) ||
|
||||||
|
@ -392,14 +387,14 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the class is one of the basic java types permitted as
|
* Check if the class is one of the basic java types permitted as
|
||||||
* env-entries.
|
* env-entries.
|
||||||
|
*
|
||||||
* @param clazz the class to check
|
* @param clazz the class to check
|
||||||
* @return true if class is permitted by the spec to be an env-entry value
|
* @return true if class is permitted by the spec to be an env-entry value
|
||||||
*/
|
*/
|
||||||
public boolean isEnvEntryType (Class<?> clazz)
|
public boolean isEnvEntryType(Class<?> clazz)
|
||||||
{
|
{
|
||||||
return ENV_ENTRY_TYPES.contains(clazz);
|
return ENV_ENTRY_TYPES.contains(clazz);
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue