Jetty 10.0.x reformat (#3812)

* Removing Legacy Method Separators
* Restyling branch `jetty-9.4.x`
* Applying changes highlighted by checkstyle
* Removing Legacy Method Separators
* Restyling branch `jetty-10.0.x`
* Applying checkstyle changes
* Applying checkstyle changes
* Applying XML restyling
* Restyling XML in branch `jetty-10.0.x`
* Fixing XML codestyle for IntelliJ
* Fixing XML style mistakes
* Fixing XML restyling in branch `jetty-10.0.x`
* Revert "Applying XML restyling"
* Updating checkstyle for XML codestyle
* Revert "Restyling XML in branch `jetty-10.0.x`"

# Conflicts:
#	jetty-xml/src/test/resources/org/eclipse/jetty/xml/configureWithAttr.xml
#	jetty-xml/src/test/resources/org/eclipse/jetty/xml/configureWithElements.xml

* Adding back build-resources
* Reformatting pom.xml files
* Disabling Checkstyle job
* fixed empty string on line wrap
* reformatted with latest intellij style
* misc checkstyle fixes

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2019-06-24 17:42:39 +02:00 committed by GitHub
parent 804419bf89
commit b7a7a53a18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2314 changed files with 62953 additions and 67347 deletions

3
Jenkinsfile vendored
View File

@ -60,6 +60,7 @@ pipeline {
}
}
*/
/*
stage("Checkstyle ") {
agent { node { label 'linux' } }
options { timeout(time: 30, unit: 'MINUTES') }
@ -71,7 +72,7 @@ pipeline {
)
}
}
*/
}
}
}

View File

@ -63,8 +63,7 @@
</goals>
<configuration>
<archive>
<manifest>
</manifest>
<manifest></manifest>
<manifestEntries>
<mode>development</mode>
<url>http://eclipse.org/jetty</url>

View File

@ -1,5 +1,4 @@
<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">
<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>
@ -24,11 +23,9 @@
<instructions>
<Bundle-Description>Jetty-specific ServletContainerInitializer for Jasper</Bundle-Description>
<Export-Package>
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.apache.jsp.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}", org.eclipse.jetty.jsp.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"
</Export-Package>
<Require-Capability>osgi.extender;
filter:="(osgi.extender=osgi.serviceloader.registrar)";resolution:=optional
<Require-Capability>osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)";resolution:=optional
</Require-Capability>
<Provide-Capability>
osgi.serviceloader;osgi.serviceloader=javax.servlet.ServletContainerInitializer,osgi.serviceloader;osgi.serviceloader=org.apache.juli.logging.Log

View File

@ -23,7 +23,6 @@ import java.net.URL;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import javax.servlet.ServletContext;
import org.apache.jasper.servlet.JasperInitializer;
@ -38,6 +37,7 @@ import org.xml.sax.SAXException;
public class JettyJasperInitializer extends JasperInitializer
{
private static final Log LOG = LogFactory.getLog(JasperInitializer.class);
/**
* NullTldScanner
*
@ -47,10 +47,7 @@ public class JettyJasperInitializer extends JasperInitializer
private final class NullTldScanner extends TldScanner
{
/**
* @param context
* @param namespaceAware
* @param validation
* @param blockExternal
*
*/
private NullTldScanner(ServletContext context, boolean namespaceAware, boolean validation, boolean blockExternal)
{
@ -95,18 +92,21 @@ public class JettyJasperInitializer extends JasperInitializer
String tmp = context.getInitParameter("org.eclipse.jetty.jsp.precompiled");
if (tmp != null && !tmp.equals("") && Boolean.valueOf(tmp))
{
if (LOG.isDebugEnabled()) LOG.debug("Jsp precompilation detected");
if (LOG.isDebugEnabled())
LOG.debug("Jsp precompilation detected");
return new NullTldScanner(context, namespaceAware, validate, blockExternal);
}
Collection<URL> tldUrls = (Collection<URL>)context.getAttribute("org.eclipse.jetty.tlds");
if (tldUrls != null)
{
if (LOG.isDebugEnabled()) LOG.debug("Tld pre-scan detected");
if (LOG.isDebugEnabled())
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);
}
}

View File

@ -16,12 +16,10 @@
// ========================================================================
//
package org.eclipse.jetty.apache.jsp;
import java.net.URL;
import java.util.Collection;
import javax.servlet.ServletContext;
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
* plugin. That means that the tlds will be used from their location in
* the file system, rather than from their assembled jar.
*
*/
public class JettyTldPreScanned extends TldPreScanned
{
@ -95,5 +92,4 @@ public class JettyTldPreScanned extends TldPreScanned
}
}
}
}

View File

@ -22,7 +22,6 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@ -30,7 +29,6 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.jasper.servlet.JspServlet;
/**
* JettyJspServlet
*
@ -46,10 +44,6 @@ public class JettyJspServlet extends JspServlet
*/
private static final long serialVersionUID = -5387857473125086791L;
@Override
public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{

View File

@ -22,7 +22,6 @@ import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@ -72,7 +71,6 @@ public class TestJettyJspServlet
resp.setContentType("html/text");
resp.getOutputStream().println("This.Is.The.Default.");
}
}
@BeforeEach
@ -105,7 +103,7 @@ public class TestJettyJspServlet
public void testWithJsp() throws Exception
{
//test that an ordinary jsp is served by jsp servlet
String request = "" +
String request =
"GET /context/foo.jsp HTTP/1.1\r\n" +
"Host: localhost\r\n" +
"Connection: close\r\n" +
@ -116,12 +114,11 @@ public class TestJettyJspServlet
assertThat(response.toString(), response.getContent(), not(containsString("This.Is.The.Default.")));
}
@Test
public void testWithDirectory() throws Exception
{
//test that a dir is served by the default servlet
String request = "" +
String request =
"GET /context/dir HTTP/1.1\r\n" +
"Host: localhost\r\n" +
"Connection: close\r\n" +

View File

@ -16,11 +16,8 @@
// ========================================================================
//
package org.eclipse.jetty.jsp;
import static org.junit.jupiter.api.Assertions.*;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
@ -34,10 +31,12 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
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
*
*
*/
public class TestJettyTldPreScanned
{
@ -70,5 +69,4 @@ public class TestJettyTldPreScanned
fail("unknown tag");
}
}
}

View File

@ -18,12 +18,11 @@
package org.eclipse.jetty.jsp;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class TestJspFileNameToClass
{
@ -33,7 +32,6 @@ public class TestJspFileNameToClass
ServletHolder h = new ServletHolder();
h.setName("test");
assertEquals(null, h.getClassNameForJsp(null));
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"));
}
}

View File

@ -18,10 +18,6 @@
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.IOException;
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.JAR;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.webapp.Configuration;
import org.eclipse.jetty.webapp.Configurations;
import org.eclipse.jetty.webapp.JettyWebXmlConfiguration;
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.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
public class JspIncludeTest
{
private static Server server;

View File

@ -18,18 +18,12 @@
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.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import javax.servlet.jsp.JspException;
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.MavenTestingUtils;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.webapp.Configuration;
import org.eclipse.jetty.webapp.WebAppContext;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
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
{
private static Server server;
@ -78,7 +76,6 @@ public class JstlTest
context.addConfiguration(new AnnotationConfiguration());
server.setHandler(context);
// Start Server

View File

@ -1,4 +1,5 @@
<code_scheme name="Jetty" version="173">
<code_scheme name="Jetty-StyleChecked" version="173">
<option name="AUTODETECT_INDENTS" value="false" />
<option name="LINE_SEPARATOR" value="&#xA;" />
<option name="RIGHT_MARGIN" value="128" />
<AndroidXmlCodeStyleSettings>
@ -8,6 +9,7 @@
<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" />
@ -36,6 +38,13 @@
<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">
@ -61,7 +70,6 @@
<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_METHODS_IN_ONE_LINE" value="true" />
<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" />
@ -72,7 +80,6 @@
<option name="FOR_BRACE_FORCE" value="3" />
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="USE_RELATIVE_INDENTS" value="true" />
</indentOptions>
<arrangement>
<rules>
@ -362,6 +369,7 @@
</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" />

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>build-resources</artifactId>
<version>9.4.19-SNAPSHOT</version>
<version>10.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Jetty :: Build Resources</name>

View File

@ -1,5 +1,4 @@
<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">
<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>example-async-rest</artifactId>

View File

@ -42,8 +42,8 @@ import javax.servlet.http.HttpServletResponse;
*/
public class AbstractRestServlet extends HttpServlet
{
protected final static String __DEFAULT_APPID = "Webtide81-adf4-4f0a-ad58-d91e41bbe85";
protected final static String STYLE =
protected static final String __DEFAULT_APPID = "Webtide81-adf4-4f0a-ad58-d91e41bbe85";
protected static final String STYLE =
"<style type='text/css'>" +
" img.thumb:hover {height:50px}" +
" img.thumb {vertical-align:text-top}" +
@ -52,8 +52,8 @@ public class AbstractRestServlet extends HttpServlet
" iframe {border: 0px}" +
"</style>";
protected final static String ITEMS_PARAM = "items";
protected final static String APPID_PARAM = "appid";
protected static final String ITEMS_PARAM = "items";
protected static final String APPID_PARAM = "appid";
protected String _appid;
@ -138,5 +138,4 @@ public class AbstractRestServlet extends HttpServlet
{
doGet(request, response);
}
}

View File

@ -25,7 +25,6 @@ import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;
import javax.servlet.AsyncContext;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@ -52,9 +51,9 @@ import org.eclipse.jetty.util.ajax.JSON;
*/
public class AsyncRestServlet extends AbstractRestServlet
{
final static String RESULTS_ATTR = "org.eclipse.jetty.demo.client";
final static String DURATION_ATTR = "org.eclipse.jetty.demo.duration";
final static String START_ATTR = "org.eclispe.jetty.demo.start";
static final String RESULTS_ATTR = "org.eclipse.jetty.demo.client";
static final String DURATION_ATTR = "org.eclipse.jetty.demo.duration";
static final String START_ATTR = "org.eclispe.jetty.demo.start";
HttpClient _client;
@ -111,6 +110,7 @@ public class AsyncRestServlet extends AbstractRestServlet
{
resultsQueue.add(auction);
}
@Override
void onComplete()
{
@ -187,15 +187,16 @@ public class AsyncRestServlet extends AbstractRestServlet
if (auctions != null)
{
for (Object o : auctions)
{
onAuctionFound((Map<String, String>)o);
}
}
onComplete();
}
abstract void onAuctionFound(Map<String, String> details);
abstract void onComplete();
abstract void onComplete();
}
@Override

View File

@ -27,7 +27,6 @@ import java.net.URL;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@ -45,7 +44,6 @@ public class SerialRestServlet extends AbstractRestServlet
{
long start = System.nanoTime();
String[] keywords = sanitize(request.getParameter(ITEMS_PARAM)).split(",");
Queue<Map<String, String>> results = new LinkedList<Map<String, String>>();
@ -62,10 +60,11 @@ public class SerialRestServlet extends AbstractRestServlet
if (auctions != null)
{
for (Object o : auctions)
{
results.add((Map)o);
}
}
}
// Generate the response
String thumbs = generateThumbs(results);
@ -90,9 +89,6 @@ public class SerialRestServlet extends AbstractRestServlet
out.println("</small>");
out.println("</body></html>");
out.close();
}
/**
@ -104,5 +100,4 @@ public class SerialRestServlet extends AbstractRestServlet
{
doGet(request, response);
}
}

View File

@ -1,5 +1,4 @@
<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">
<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>example-async-rest</artifactId>

View File

@ -18,15 +18,13 @@
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.Files;
import java.nio.file.Path;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
public class AsyncRestServer
{
public static void main(String[] args)

View File

@ -1,5 +1,4 @@
<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">
<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>example-async-rest</artifactId>

View File

@ -1,5 +1,4 @@
<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">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.eclipse.jetty.examples</groupId>
<artifactId>examples-parent</artifactId>

View File

@ -20,7 +20,6 @@ package org.eclipse.jetty.embedded;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.servlet.AsyncContext;
import javax.servlet.ReadListener;
import javax.servlet.ServletException;
@ -31,7 +30,6 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class AsyncEchoServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;

View File

@ -20,8 +20,6 @@ package org.eclipse.jetty.embedded;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -31,8 +29,7 @@ public class DumpServlet extends HttpServlet
{
@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response ) throws ServletException,
IOException
HttpServletResponse response) throws IOException
{
response.setContentType("text/html");
response.setStatus(HttpServletResponse.SC_OK);
@ -51,8 +48,7 @@ public class DumpServlet extends HttpServlet
String r = request.getParameter("resource");
if (r != null)
{
out.println("resource(" + r + ")="
+ getServletContext().getResource(r));
out.println("resource(" + r + ")=" + getServletContext().getResource(r));
}
out.println("</pre>");

View File

@ -65,7 +65,8 @@ public class FastFileServer
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{
new FastFileHandler(new File(System.getProperty("user.dir"))),
new DefaultHandler() });
new DefaultHandler()
});
server.setHandler(handlers);
server.start();

View File

@ -39,17 +39,17 @@ public class FileServer
// 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.
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.
// 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);
resource_handler.setWelcomeFiles(new String[]{ "index.html" });
resource_handler.setResourceBase(".");
resourceHandler.setDirectoriesListed(true);
resourceHandler.setWelcomeFiles(new String[]{"index.html"});
resourceHandler.setResourceBase(".");
// Add the ResourceHandler to the server.
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resource_handler, new DefaultHandler() });
handlers.setHandlers(new Handler[]{resourceHandler, new DefaultHandler()});
server.setHandler(handlers);
// Start things up! By using the server.join() the server thread will join with the current thread.

View File

@ -20,7 +20,6 @@ package org.eclipse.jetty.embedded;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -19,7 +19,6 @@
package org.eclipse.jetty.embedded;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;

View File

@ -20,7 +20,6 @@ package org.eclipse.jetty.embedded;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@ -30,7 +29,9 @@ import javax.servlet.http.HttpSession;
@SuppressWarnings("serial")
public class HelloSessionServlet extends HttpServlet
{
public HelloSessionServlet() {}
public HelloSessionServlet()
{
}
@Override
protected void doGet(HttpServletRequest request,
@ -77,8 +78,6 @@ public class HelloSessionServlet extends HttpServlet
out.println("session.isNew() = " + session.isNew());
out.println("</pre>");
out.println("<p>" + link + "</p>");
}
}
}

View File

@ -19,7 +19,6 @@
package org.eclipse.jetty.embedded;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -16,7 +16,6 @@
// ========================================================================
//
package org.eclipse.jetty.embedded;
import java.io.File;
@ -27,7 +26,6 @@ import java.util.Date;
import java.util.EnumSet;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.servlet.DispatcherType;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
@ -83,34 +81,34 @@ public class Http2Server
server.setHandler(context);
// HTTP Configuration
HttpConfiguration http_config = new HttpConfiguration();
http_config.setSecureScheme("https");
http_config.setSecurePort(8443);
http_config.setSendXPoweredBy(true);
http_config.setSendServerVersion(true);
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSecureScheme("https");
httpConfig.setSecurePort(8443);
httpConfig.setSendXPoweredBy(true);
httpConfig.setSendServerVersion(true);
// 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);
server.addConnector(http);
// SSL Context Factory for HTTPS and HTTP/2
String jetty_distro = System.getProperty("jetty.distro","../../jetty-distribution/target/distribution");
if (!new File(jetty_distro).exists())
jetty_distro = "jetty-distribution/target/distribution";
String jettyDistro = System.getProperty("jetty.distro", "../../jetty-distribution/target/distribution");
if (!new File(jettyDistro).exists())
jettyDistro = "jetty-distribution/target/distribution";
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.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");
sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR);
// sslContextFactory.setProvider("Conscrypt");
// HTTPS Configuration
HttpConfiguration https_config = new HttpConfiguration(http_config);
https_config.addCustomizer(new SecureRequestCustomizer());
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
httpsConfig.addCustomizer(new SecureRequestCustomizer());
// HTTP/2 Connection Factory
HTTP2ServerConnectionFactory h2 = new HTTP2ServerConnectionFactory(https_config);
HTTP2ServerConnectionFactory h2 = new HTTP2ServerConnectionFactory(httpsConfig);
ALPNServerConnectionFactory alpn = new ALPNServerConnectionFactory();
alpn.setDefaultProtocol(http.getDefaultProtocol());
@ -120,7 +118,7 @@ public class Http2Server
// HTTP/2 Connector
ServerConnector http2Connector =
new ServerConnector(server,ssl,alpn,h2,new HttpConnectionFactory(https_config));
new ServerConnector(server, ssl, alpn, h2, new HttpConnectionFactory(httpsConfig));
http2Connector.setPort(8443);
server.addConnector(http2Connector);

View File

@ -28,6 +28,7 @@ import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.resource.Resource;
/**
*
*/
public class JarServer
{

View File

@ -35,8 +35,8 @@ import org.eclipse.jetty.util.log.Logger;
*/
public class JettyDistribution
{
private final static Logger LOG = Log.getLogger(JettyDistribution.class);
public final static Path DISTRIBUTION;
private static final Logger LOG = Log.getLogger(JettyDistribution.class);
public static final Path DISTRIBUTION;
static
{

View File

@ -72,10 +72,10 @@ public class LikeJettyXml
File baseDir = new File(basePath);
// Configure jetty.home and jetty.base system properties
String jetty_home = homeDir.getAbsolutePath();
String jetty_base = baseDir.getAbsolutePath();
System.setProperty("jetty.home", jetty_home);
System.setProperty("jetty.base", jetty_base);
String jettyHome = homeDir.getAbsolutePath();
String jettyBase = baseDir.getAbsolutePath();
System.setProperty("jetty.home", jettyHome);
System.setProperty("jetty.base", jettyBase);
// === jetty.xml ===
// Setup Threadpool
@ -89,14 +89,14 @@ public class LikeJettyXml
server.addBean(new ScheduledExecutorScheduler(null, false));
// HTTP Configuration
HttpConfiguration http_config = new HttpConfiguration();
http_config.setSecureScheme("https");
http_config.setSecurePort(8443);
http_config.setOutputBufferSize(32768);
http_config.setRequestHeaderSize(8192);
http_config.setResponseHeaderSize(8192);
http_config.setSendServerVersion(true);
http_config.setSendDateHeader(false);
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSecureScheme("https");
httpConfig.setSecurePort(8443);
httpConfig.setOutputBufferSize(32768);
httpConfig.setRequestHeaderSize(8192);
httpConfig.setResponseHeaderSize(8192);
httpConfig.setSendServerVersion(true);
httpConfig.setSendDateHeader(false);
// httpConfig.addCustomizer(new ForwardedRequestCustomizer());
// Handler Structure
@ -115,22 +115,20 @@ public class LikeJettyXml
ManagementFactory.getPlatformMBeanServer());
server.addBean(mbContainer);
// === jetty-http.xml ===
ServerConnector http = new ServerConnector(server,
new HttpConnectionFactory(http_config));
new HttpConnectionFactory(httpConfig));
http.setPort(8080);
http.setIdleTimeout(30000);
server.addConnector(http);
// === jetty-https.xml ===
// SSL Context Factory
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.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.setExcludeCipherSuites("SSL_RSA_WITH_DES_CBC_SHA",
"SSL_DHE_RSA_WITH_DES_CBC_SHA", "SSL_DHE_DSS_WITH_DES_CBC_SHA",
@ -140,17 +138,16 @@ public class LikeJettyXml
"SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA");
// SSL HTTP Configuration
HttpConfiguration https_config = new HttpConfiguration(http_config);
https_config.addCustomizer(new SecureRequestCustomizer());
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
httpsConfig.addCustomizer(new SecureRequestCustomizer());
// SSL Connector
ServerConnector sslConnector = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
new HttpConnectionFactory(https_config));
new HttpConnectionFactory(httpsConfig));
sslConnector.setPort(8443);
server.addConnector(sslConnector);
// === jetty-deploy.xml ===
DeploymentManager deployer = new DeploymentManager();
//DebugListener debug = new DebugListener(System.out,true,true,true);
@ -161,14 +158,14 @@ public class LikeJettyXml
"org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
".*/jetty-servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$");
WebAppProvider webapp_provider = new WebAppProvider();
webapp_provider.setMonitoredDirName(jetty_base + "/webapps");
webapp_provider.setDefaultsDescriptor(jetty_home + "/etc/webdefault.xml");
webapp_provider.setScanInterval(1);
webapp_provider.setExtractWars(true);
webapp_provider.setConfigurationManager(new PropertiesConfigurationManager());
WebAppProvider webAppProvider = new WebAppProvider();
webAppProvider.setMonitoredDirName(jettyBase + "/webapps");
webAppProvider.setDefaultsDescriptor(jettyHome + "/etc/webdefault.xml");
webAppProvider.setScanInterval(1);
webAppProvider.setExtractWars(true);
webAppProvider.setConfigurationManager(new PropertiesConfigurationManager());
deployer.addAppProvider(webapp_provider);
deployer.addAppProvider(webAppProvider);
server.addBean(deployer);
// === setup jetty plus ==
@ -188,14 +185,13 @@ public class LikeJettyXml
rewrite.addRule(new ValidUrlRule());
// === 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.setRetainDays(90);
logWriter.setTimeZone("GMT");
server.setRequestLog(requestLog);
// === jetty-lowresources.xml ===
LowResourceMonitor lowResourcesMonitor = new LowResourceMonitor(server);
lowResourcesMonitor.setPeriod(1000);
@ -205,11 +201,10 @@ public class LikeJettyXml
lowResourcesMonitor.setMaxLowResourcesTime(5000);
server.addBean(lowResourcesMonitor);
// === test-realm.xml ===
HashLoginService login = new HashLoginService();
login.setName("Test Realm");
login.setConfig(jetty_base + "/etc/realm.properties");
login.setConfig(jettyBase + "/etc/realm.properties");
login.setHotReload(false);
server.addBean(login);

View File

@ -65,10 +65,10 @@ public class ManyConnectors
// <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
// done. The port for secured communication is also set here.
HttpConfiguration http_config = new HttpConfiguration();
http_config.setSecureScheme("https");
http_config.setSecurePort(8443);
http_config.setOutputBufferSize(32768);
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSecureScheme("https");
httpConfig.setSecurePort(8443);
httpConfig.setOutputBufferSize(32768);
// HTTP connector
// 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
// configure an idle timeout.
ServerConnector http = new ServerConnector(server,
new HttpConnectionFactory(http_config));
new HttpConnectionFactory(httpConfig));
http.setPort(8080);
http.setIdleTimeout(30000);
@ -105,11 +105,11 @@ public class ManyConnectors
// SecureRequestCustomizer which is how a new connector is able to
// resolve the https connection before handing control over to the Jetty
// Server.
HttpConfiguration https_config = new HttpConfiguration(http_config);
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
SecureRequestCustomizer src = new SecureRequestCustomizer();
src.setStsMaxAge(2000);
src.setStsIncludeSubDomains(true);
https_config.addCustomizer(src);
httpsConfig.addCustomizer(src);
// HTTPS connector
// We create a second ServerConnector, passing in the http configuration
@ -117,7 +117,7 @@ public class ManyConnectors
// Next we set the port and a longer idle timeout.
ServerConnector https = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
new HttpConnectionFactory(https_config));
new HttpConnectionFactory(httpsConfig));
https.setPort(8443);
https.setIdleTimeout(500000);

View File

@ -44,8 +44,10 @@ public class ManyContexts
contextV.setHandler(new HelloHandler("Virtual Hello"));
ContextHandlerCollection contexts = new ContextHandlerCollection();
contexts.setHandlers(new Handler[] { context, contextFR, contextIT,
contextV });
contexts.setHandlers(new Handler[]{
context, contextFR, contextIT,
contextV
});
server.setHandler(contexts);

View File

@ -21,7 +21,6 @@ package org.eclipse.jetty.embedded;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -19,7 +19,6 @@
package org.eclipse.jetty.embedded;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;

View File

@ -18,11 +18,8 @@
package org.eclipse.jetty.embedded;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ListenerHolder;
import org.eclipse.jetty.servlet.ServletContextHandler;
import java.io.IOException;
import java.util.EnumSet;
import javax.servlet.DispatcherType;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
@ -34,8 +31,11 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
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
{
@ -68,7 +68,6 @@ public class OneServletContext
server.join();
}
public static class TestFilter implements Filter
{
@Override
@ -103,7 +102,6 @@ public class OneServletContext
}
}
public static class RequestListener implements ServletRequestListener
{
@Override

View File

@ -25,7 +25,6 @@ import org.eclipse.jetty.server.session.SessionCache;
import org.eclipse.jetty.server.session.SessionHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
public class OneServletContextWithSession
{
public static void main(String[] args) throws Exception

View File

@ -58,13 +58,11 @@ public class OneWebAppWithJsp
"jetty-distribution/target/distribution/demo-base/webapps/test.war");
if (!warFile.exists())
{
throw new RuntimeException( "Unable to find WAR File: "
+ warFile.getAbsolutePath() );
throw new RuntimeException("Unable to find WAR File: " + warFile.getAbsolutePath());
}
webapp.setWar(warFile.getAbsolutePath());
webapp.setExtractWAR(true);
// This webapp will use jsps and jstl. We need to enable the
// AnnotationConfiguration in order to correctly
// set up the jsp container

View File

@ -47,5 +47,4 @@ public class ProxyServer
server.start();
}
}

View File

@ -36,7 +36,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
*/
public class ServerWithAnnotations
{
public static final void main( String args[] ) throws Exception
public static final void main(String[] args) throws Exception
{
// Create the server
Server server = new Server(8080);
@ -75,10 +75,8 @@ public class ServerWithAnnotations
loginService.setConfig("examples/embedded/src/test/resources/realm.properties");
server.addBean(loginService);
server.start();
server.dumpStdErr();
server.join();
}
}

View File

@ -19,7 +19,6 @@
package org.eclipse.jetty.embedded;
import java.lang.management.ManagementFactory;
import javax.management.remote.JMXServiceURL;
import org.eclipse.jetty.jmx.ConnectorServer;

View File

@ -20,7 +20,6 @@ package org.eclipse.jetty.embedded;
import javax.websocket.OnMessage;
import javax.websocket.Session;
import javax.websocket.server.ServerContainer;
import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.server.Server;

View File

@ -1,6 +1,5 @@
<?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"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<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>

View File

@ -21,7 +21,6 @@ package org.eclipse.jetty.alpn.client;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
import javax.net.ssl.SSLEngine;
import org.eclipse.jetty.io.ClientConnectionFactory;

View File

@ -24,7 +24,6 @@ import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.concurrent.Executor;
import javax.net.ssl.SSLEngine;
import org.eclipse.jetty.io.ClientConnectionFactory;

View File

@ -1,7 +1,5 @@
<?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"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<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">
<parent>
<groupId>org.eclipse.jetty</groupId>

View File

@ -1,6 +1,5 @@
<?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"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<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">
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-parent</artifactId>
@ -84,8 +83,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>
@{argLine} ${jetty.surefire.argLine}
--add-reads org.eclipse.jetty.alpn.conscrypt.server=org.eclipse.jetty.server
@{argLine} ${jetty.surefire.argLine} --add-reads org.eclipse.jetty.alpn.conscrypt.server=org.eclipse.jetty.server
</argLine>
</configuration>
</plugin>

View File

@ -76,7 +76,6 @@ public class ConscryptServerALPNProcessor implements ALPNProcessor.Server
{
private final ALPNServerConnection alpnConnection;
private ALPNCallback(ALPNServerConnection connection)
{
alpnConnection = connection;

View File

@ -1,7 +1,5 @@
<?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"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<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">
<parent>
<groupId>org.eclipse.jetty</groupId>

View File

@ -19,7 +19,6 @@
package org.eclipse.jetty.alpn.java.client;
import java.util.List;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLParameters;

View File

@ -1,7 +1,5 @@
<?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"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<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">
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-parent</artifactId>
@ -22,8 +20,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>
@{argLine} ${jetty.surefire.argLine}
--add-reads org.eclipse.jetty.alpn.java.server=org.eclipse.jetty.server
@{argLine} ${jetty.surefire.argLine} --add-reads org.eclipse.jetty.alpn.java.server=org.eclipse.jetty.server
</argLine>
</configuration>
</plugin>

View File

@ -20,7 +20,6 @@ package org.eclipse.jetty.alpn.java.server;
import java.util.List;
import java.util.function.BiFunction;
import javax.net.ssl.SSLEngine;
import org.eclipse.jetty.alpn.server.ALPNServerConnection;

View File

@ -23,7 +23,6 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLParameters;
import javax.net.ssl.SSLSocket;
@ -105,7 +104,7 @@ public class JDK9ALPNTest
client.startHandshake();
OutputStream output = client.getOutputStream();
output.write(("" +
output.write((
"GET / HTTP/1.1\r\n" +
"Host: localhost\r\n" +
"Connection: close\r\n" +
@ -150,7 +149,7 @@ public class JDK9ALPNTest
client.startHandshake();
OutputStream output = client.getOutputStream();
output.write(("" +
output.write((
"GET / HTTP/1.1\r\n" +
"Host: localhost\r\n" +
"Connection: close\r\n" +

View File

@ -20,7 +20,6 @@ package org.eclipse.jetty.alpn.server;
import java.util.Collections;
import java.util.List;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSession;

View File

@ -23,7 +23,6 @@ import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.ServiceLoader;
import javax.net.ssl.SSLEngine;
import org.eclipse.jetty.io.AbstractConnection;

View File

@ -1,6 +1,4 @@
<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">
<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>

View File

@ -1,5 +1,4 @@
<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">
<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>
@ -21,8 +20,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>
@{argLine} ${jetty.surefire.argLine}
--add-opens org.eclipse.jetty.annotations/org.eclipse.jetty.annotations.resources=org.eclipse.jetty.plus
@{argLine} ${jetty.surefire.argLine} --add-opens org.eclipse.jetty.annotations/org.eclipse.jetty.annotations.resources=org.eclipse.jetty.plus
</argLine>
</configuration>
</plugin>
@ -33,9 +31,7 @@
<configuration>
<instructions>
<Import-Package>org.objectweb.asm;version="5",*</Import-Package>
<Require-Capability>osgi.serviceloader;
filter:="(osgi.serviceloader=javax.servlet.ServletContainerInitializer)";resolution:=optional;cardinality:=multiple,
osgi.extender; filter:="(osgi.extender=osgi.serviceloader.processor)";resolution:=optional
<Require-Capability>osgi.serviceloader; filter:="(osgi.serviceloader=javax.servlet.ServletContainerInitializer)";resolution:=optional;cardinality:=multiple, osgi.extender; filter:="(osgi.extender=osgi.serviceloader.processor)";resolution:=optional
</Require-Capability>
</instructions>
</configuration>

View File

@ -26,22 +26,18 @@ import org.eclipse.jetty.webapp.WebAppContext;
* DiscoverableAnnotationHandler
*
* Base class for handling the discovery of an annotation.
*
*/
public abstract class AbstractDiscoverableAnnotationHandler extends AbstractHandler
{
protected WebAppContext _context;
public AbstractDiscoverableAnnotationHandler(WebAppContext context)
{
_context = context;
}
public void addAnnotation(DiscoveredAnnotation a)
{
_context.getMetaData().addDiscoveredAnnotation(a);
}
}

View File

@ -79,7 +79,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
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 int DEFAULT_MAX_SCAN_WAIT = 60; /* time in sec */
public static final boolean DEFAULT_MULTI_THREADED = true;
@ -107,7 +106,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
* TimeStatistic
*
* Simple class to capture elapsed time of an operation.
*
*/
public class TimeStatistic
{
@ -140,12 +138,10 @@ public class AnnotationConfiguration extends AbstractConfiguration
}
}
/**
* ParserTask
*
* Task to executing scanning of a resource for annotations.
*
*/
public class ParserTask implements Callable<Void>
{
@ -190,7 +186,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
}
}
/**
* ServletContainerInitializerOrdering
*
@ -223,7 +218,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
throw new IllegalArgumentException("Duplicate wildcards in ServletContainerInitializer ordering " + ordering);
_star = i;
}
}
}
}
@ -256,6 +250,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
/**
* Get the order index of the given classname
*
* @param name the classname to look up
* @return the index of the class name (or -1 if not found)
*/
@ -269,6 +264,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
/**
* Get the number of elements of the ordering
*
* @return the size of the index
*/
public int getSize()
@ -285,21 +281,19 @@ public class AnnotationConfiguration extends AbstractConfiguration
}
}
/**
* ServletContainerInitializerComparator
*
* Comparator impl that orders a set of ServletContainerInitializers according to the
* list of classnames (optionally containing a "*" wildcard character) established in a
* ServletContainerInitializerOrdering.
*
* @see ServletContainerInitializerOrdering
*/
public class ServletContainerInitializerComparator implements Comparator<ServletContainerInitializer>
{
private ServletContainerInitializerOrdering _ordering;
public ServletContainerInitializerComparator(ServletContainerInitializerOrdering ordering)
{
_ordering = ordering;
@ -370,10 +364,11 @@ public class AnnotationConfiguration extends AbstractConfiguration
{
Map<String, Set<String>> map = (Map<String, Set<String>>)context.getAttribute(AnnotationConfiguration.CLASS_INHERITANCE_MAP);
for (ContainerInitializer i : initializers)
{
i.resolveClasses(context, map);
}
}
}
/**
* @see org.eclipse.jetty.webapp.AbstractConfiguration#postConfigure(org.eclipse.jetty.webapp.WebAppContext)
@ -417,8 +412,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
super.postConfigure(context);
}
/**
* Perform scanning of classes for annotations
*
@ -437,7 +430,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
long start = 0;
if (LOG.isDebugEnabled())
LOG.debug("Annotation scanning commencing: webxml={}, metadatacomplete={}, configurationDiscovered={}, multiThreaded={}, maxScanWait={}",
context.getServletContext().getEffectiveMajorVersion(),
@ -446,7 +438,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
isUseMultiThreading(context),
getMaxScanWait(context));
parseContainerPath(context, parser);
//email from Rajiv Mordani jsrs 315 7 April 2010
// If there is a <others/> then the ordering should be
@ -496,7 +487,9 @@ public class AnnotationConfiguration extends AbstractConfiguration
if (LOG.isDebugEnabled())
{
for (ParserTask p : _parserTasks)
{
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 {}",
(_containerPathStats == null ? -1 : _containerPathStats.getTotal()),
@ -511,8 +504,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
me.ifExceptionThrow();
}
/**
* @param javaPlatform The java platform to scan for.
* @return a new AnnotationParser. This method can be overridden to use a different implementation of
@ -525,6 +516,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
/**
* Check if we should use multiple threads to scan for annotations or not
*
* @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.
* @see #MULTI_THREADED
@ -547,8 +539,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
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.
*
@ -603,7 +593,10 @@ public class AnnotationConfiguration extends AbstractConfiguration
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);
@ -623,7 +616,8 @@ public class AnnotationConfiguration extends AbstractConfiguration
//register a handler for it
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));
}
}
@ -631,19 +625,20 @@ public class AnnotationConfiguration extends AbstractConfiguration
else
{
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
{
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);
}
//add a bean to the context which will call the servletcontainerinitializers when appropriate
ServletContainerInitializersStarter starter = (ServletContainerInitializersStarter)context.getAttribute(CONTAINER_INITIALIZER_STARTER);
if (starter != null)
@ -757,7 +752,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
return _sciExcludePattern.matcher(sci.getClass().getName()).matches();
}
/**
* Test if the ServletContainerInitializer is from the container classpath
*
@ -813,6 +807,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
/**
* Get SCIs that are not excluded from consideration
*
* @param context the web app context
* @return the list of non-excluded servlet container initializers
* @throws Exception if unable to get list
@ -868,8 +863,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
//check containerInitializerOrdering doesn't exclude it
String name = sci.getClass().getName();
if (initializerOrdering != null
&& (!initializerOrdering.hasWildcard() && initializerOrdering.getIndexOf(name) < 0))
if (initializerOrdering != null && (!initializerOrdering.hasWildcard() && initializerOrdering.getIndexOf(name) < 0))
{
if (LOG.isDebugEnabled())
LOG.debug("{} is excluded by ordering", sci);
@ -922,7 +916,9 @@ public class AnnotationConfiguration extends AbstractConfiguration
//throw out the ones we've already accounted for
for (ServletContainerInitializer s : nonExcludedInitializers)
{
sciResourceMap.remove(s);
}
if (context.getMetaData().getOrdering() == null)
{
@ -971,13 +967,14 @@ public class AnnotationConfiguration extends AbstractConfiguration
{
int i = 0;
for (ServletContainerInitializer sci : nonExcludedInitializers)
{
LOG.debug("ServletContainerInitializer: {} {} from {}", (++i), sci.getClass().getName(), sciResourceMap.get(sci));
}
}
return nonExcludedInitializers;
}
/**
* Jetty-specific extension that allows an ordering to be applied across ALL ServletContainerInitializers.
*
@ -996,7 +993,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
return new ServletContainerInitializerOrdering(tmp);
}
/**
* Scan jars on container path.
*
@ -1032,7 +1028,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
}
}
/**
* Scan jars in WEB-INF/lib
*
@ -1101,7 +1096,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
}
}
/**
* Scan classes in WEB-INF/classes
*
@ -1136,8 +1130,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
}
}
/**
* Get the web-fragment.xml from a jar
*

View File

@ -54,6 +54,7 @@ public class AnnotationDecorator implements Decorator
* <li> PreDestroy </li>
* <li> ServletSecurity? </li>
* </ul>
*
* @param o the object ot introspect
*/
protected void introspect(Object o)

View File

@ -23,14 +23,11 @@ import java.util.List;
/**
* AnnotationIntrospector
*
*
*/
public class AnnotationIntrospector
{
protected List<IntrospectableAnnotationHandler> _handlers = new ArrayList<IntrospectableAnnotationHandler>();
/**
* IntrospectableAnnotationHandler
*
@ -41,21 +38,18 @@ public class AnnotationIntrospector
public void handle(Class<?> clazz);
}
/**
* AbstractIntrospectableAnnotationHandler
*
* Base class for handlers that introspect a class to find a particular annotation.
* 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;
public abstract void doHandle(Class<?> clazz);
public AbstractIntrospectableAnnotationHandler(boolean introspectAncestors)
{
_introspectAncestors = introspectAncestors;
@ -105,6 +99,5 @@ public class AnnotationIntrospector
throw new RuntimeException(e);
}
}
}
}

View File

@ -82,6 +82,7 @@ public class AnnotationParser
/**
* Determine the runtime version of asm.
*
* @return the org.objectweb.asm.Opcode matching the runtime version of asm.
*/
public static int asmVersion()
@ -168,7 +169,9 @@ public class AnnotationParser
String[] normalList = new String[list.length];
int i = 0;
for (String s : list)
{
normalList[i++] = normalize(s);
}
return normalList;
}
@ -347,17 +350,22 @@ public class AnnotationParser
public static interface Handler
{
public void handle(ClassInfo classInfo);
public void handle(MethodInfo methodInfo);
public void handle(FieldInfo fieldInfo);
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.
*/
public static abstract class AbstractHandler implements Handler
public abstract static class AbstractHandler implements Handler
{
@Override
public void handle(ClassInfo classInfo)
@ -420,7 +428,9 @@ public class AnnotationParser
{
String annotationName = normalize(desc);
for (Handler h : _handlers)
{
h.handle(_mi, annotationName);
}
return null;
}
}
@ -456,7 +466,9 @@ public class AnnotationParser
{
String annotationName = normalize(desc);
for (Handler h : _handlers)
{
h.handle(_fieldInfo, annotationName);
}
return null;
}
@ -490,8 +502,10 @@ public class AnnotationParser
{
_ci = new ClassInfo(_containingResource, normalize(name), version, access, signature, normalize(superName), normalize(interfaces));
for (Handler h : _handlers)
{
h.handle(_ci);
}
}
/**
* Visit an annotation on a Class
@ -501,7 +515,9 @@ public class AnnotationParser
{
String annotationName = normalize(desc);
for (Handler h : _handlers)
{
h.handle(_ci, annotationName);
}
return null;
}
@ -548,7 +564,6 @@ public class AnnotationParser
_javaPlatform = javaPlatform;
}
public AnnotationParser(int javaPlatform, int asmVersion)
{
if (javaPlatform == 0)
@ -725,13 +740,15 @@ public class AnnotationParser
}
catch (Exception ex)
{
if (LOG.isDebugEnabled()) LOG.debug("Error scanning file "+file, 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);
if (LOG.isDebugEnabled())
LOG.debug("Skipping scan on invalid file {}", file);
}
}
}
@ -816,7 +833,8 @@ public class AnnotationParser
}
}
if (LOG.isDebugEnabled()) LOG.warn("Resource not scannable for classes: {}", r);
if (LOG.isDebugEnabled())
LOG.warn("Resource not scannable for classes: {}", r);
}
/**
@ -919,6 +937,7 @@ public class AnnotationParser
* <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>
* </ul>
*
* @param name the class file name
* @return whether the class file name is valid
*/
@ -932,13 +951,15 @@ public class AnnotationParser
String lc = name.toLowerCase(Locale.ENGLISH);
if (!lc.endsWith(".class"))
{
if (LOG.isDebugEnabled()) LOG.debug("Not a class: {}",name);
if (LOG.isDebugEnabled())
LOG.debug("Not a class: {}", name);
return false;
}
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;
}
@ -948,7 +969,8 @@ public class AnnotationParser
c0 = (ldir > -1 ? ldir + 1 : 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;
}
@ -970,7 +992,8 @@ public class AnnotationParser
// skip any classfiles that are in a hidden directory
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;
}

View File

@ -38,7 +38,6 @@ public class ClassInheritanceHandler extends AbstractHandler
Map<String, Set<String>> _inheritanceMap;
public ClassInheritanceHandler(Map<String, Set<String>> map)
{
_inheritanceMap = map;

View File

@ -16,10 +16,8 @@
// ========================================================================
//
package org.eclipse.jetty.annotations;
import org.eclipse.jetty.annotations.AnnotationParser.AbstractHandler;
import org.eclipse.jetty.annotations.AnnotationParser.ClassInfo;
import org.eclipse.jetty.annotations.AnnotationParser.FieldInfo;
@ -84,7 +82,6 @@ public class ContainerInitializerAnnotationHandler extends AbstractHandler
_initializer.addAnnotatedTypeName(info.getClassInfo().getClassName());
}
public ContainerInitializer getContainerInitializer()
{
return _initializer;

View File

@ -18,7 +18,6 @@
package org.eclipse.jetty.annotations;
import javax.annotation.security.DeclareRoles;
import javax.servlet.Servlet;
@ -44,7 +43,6 @@ public class DeclareRolesAnnotationHandler extends AbstractIntrospectableAnnotat
_context = context;
}
/**
* @see org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler#doHandle(java.lang.Class)
*/
@ -69,8 +67,9 @@ public class DeclareRolesAnnotationHandler extends AbstractIntrospectableAnnotat
if (roles != null && roles.length > 0)
{
for (String r : roles)
{
((ConstraintSecurityHandler)_context.getSecurityHandler()).addRole(r);
}
}
}
}

View File

@ -30,8 +30,6 @@ import org.eclipse.jetty.webapp.WebAppContext;
/**
* MultiPartConfigAnnotationHandler
*
*
*/
public class MultiPartConfigAnnotationHandler extends AbstractIntrospectableAnnotationHandler
{
@ -43,6 +41,7 @@ public class MultiPartConfigAnnotationHandler extends AbstractIntrospectableAnno
super(false);
_context = context;
}
/**
* @see org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler#doHandle(java.lang.Class)
*/

View File

@ -20,7 +20,6 @@ package org.eclipse.jetty.annotations;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import javax.annotation.PostConstruct;
import org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler;
@ -40,7 +39,6 @@ public class PostConstructAnnotationHandler extends AbstractIntrospectableAnnota
_context = wac;
}
@Override
public void doHandle(Class clazz)
{
@ -88,6 +86,7 @@ public class PostConstructAnnotationHandler extends AbstractIntrospectableAnnota
/**
* Check if the given class is permitted to have PostConstruct annotation.
*
* @param c the class
* @return true if the spec permits the class to have PostConstruct, false otherwise
*/

View File

@ -20,7 +20,6 @@ package org.eclipse.jetty.annotations;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import javax.annotation.PreDestroy;
import org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler;
@ -89,6 +88,7 @@ public class PreDestroyAnnotationHandler extends AbstractIntrospectableAnnotatio
/**
* Check if the spec permits the given class to use the PreDestroy annotation.
*
* @param c the class
* @return true if permitted, false otherwise
*/

View File

@ -24,7 +24,6 @@ import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import javax.annotation.Resource;
import javax.naming.InitialContext;
import javax.naming.NameNotFoundException;
@ -43,19 +42,19 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
private static final Logger LOG = Log.getLogger(ResourceAnnotationHandler.class);
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;
public ResourceAnnotationHandler(WebAppContext wac)
{
super(true);
_context = wac;
}
/**
* Class level Resource annotations declare a name in the
* environment that will be looked up at runtime. They do
@ -70,13 +69,17 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
Method[] methods = clazz.getDeclaredMethods();
for (int i = 0; i < methods.length; i++)
{
handleMethod(clazz, methods[i]);
}
Field[] fields = clazz.getDeclaredFields();
//For each field, get all of it's annotations
for (int i = 0; i < fields.length; i++)
{
handleField(clazz, fields[i]);
}
}
}
public void handleClass(Class<?> clazz)
{
@ -210,7 +213,6 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
}
}
/**
* Process a Resource annotation on a Method.
* <p>
@ -270,7 +272,6 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
return;
}
//default name is the javabean property name
String name = method.getName().substring(3);
name = name.substring(0, 1).toLowerCase(Locale.ENGLISH) + name.substring(1);
@ -364,7 +365,6 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
throw new IllegalStateException(e);
}
}
}
}
@ -392,10 +392,10 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
return false;
}
/**
* Check if the class is one of the basic java types permitted as
* env-entries.
*
* @param clazz the class to check
* @return true if class is permitted by the spec to be an env-entry value
*/

View File

@ -31,7 +31,6 @@ public class ResourcesAnnotationHandler extends AbstractIntrospectableAnnotation
{
private static final Logger LOG = Log.getLogger(ResourcesAnnotationHandler.class);
protected WebAppContext _wac;
public ResourcesAnnotationHandler(WebAppContext wac)
@ -76,5 +75,4 @@ public class ResourcesAnnotationHandler extends AbstractIntrospectableAnnotation
}
}
}
}

View File

@ -29,7 +29,6 @@ import org.eclipse.jetty.webapp.Descriptor;
import org.eclipse.jetty.webapp.MetaData;
import org.eclipse.jetty.webapp.WebAppContext;
public class RunAsAnnotationHandler extends AbstractIntrospectableAnnotationHandler
{
private static final Logger LOG = Log.getLogger(RunAsAnnotationHandler.class);

View File

@ -27,7 +27,6 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.webapp.WebAppContext;
/**
* ServletContainerInitializersStarter
*
@ -46,6 +45,7 @@ public class ServletContainerInitializersStarter extends AbstractLifeCycle imple
/**
* Call the doStart method of the ServletContainerInitializers
*
* @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart()
*/
@Override

View File

@ -20,7 +20,6 @@ package org.eclipse.jetty.annotations;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletSecurityElement;
import javax.servlet.annotation.ServletSecurity;
import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic;
@ -111,14 +110,14 @@ public class ServletSecurityAnnotationHandler extends AbstractIntrospectableAnno
ConstraintAware securityHandler = (ConstraintAware)_context.getSecurityHandler();
for (ConstraintMapping m : constraintMappings)
{
securityHandler.addConstraintMapping(m);
}
//Servlet Spec 3.1 requires paths with uncovered http methods to be reported
securityHandler.checkPathsWithUncoveredHttpMethods();
}
/**
* Make a jetty Constraint object, which represents the <code>&lt;auth-constraint&gt;</code> and
* <code>&lt;user-data-constraint&gt;</code> elements, based on the security annotation.
@ -134,10 +133,9 @@ public class ServletSecurityAnnotationHandler extends AbstractIntrospectableAnno
return ConstraintSecurityHandler.createConstraint(servlet.getName(), rolesAllowed, permitOrDeny, transport);
}
/**
* Get the ServletMappings for the servlet's class.
*
* @param className the class name
* @return the servlet mappings for the class
*/
@ -155,8 +153,6 @@ public class ServletSecurityAnnotationHandler extends AbstractIntrospectableAnno
return results;
}
/**
* Check if there are already <code>&lt;security-constraint&gt;</code> elements defined that match the url-patterns for
* the servlet.
@ -196,5 +192,4 @@ public class ServletSecurityAnnotationHandler extends AbstractIntrospectableAnno
}
return exists;
}
}

View File

@ -20,7 +20,6 @@ package org.eclipse.jetty.annotations;
import java.util.ArrayList;
import java.util.EnumSet;
import javax.servlet.DispatcherType;
import javax.servlet.Filter;
import javax.servlet.annotation.WebFilter;
@ -70,7 +69,6 @@ public class WebFilterAnnotation extends DiscoveredAnnotation
return;
}
//Servlet Spec 8.1.2
if (!Filter.class.isAssignableFrom(clazz))
{
@ -215,5 +213,4 @@ public class WebFilterAnnotation extends DiscoveredAnnotation
}
}
}
}

View File

@ -27,8 +27,6 @@ import org.eclipse.jetty.webapp.WebAppContext;
/**
* WebFilterAnnotationHandler
*
*
*/
public class WebFilterAnnotationHandler extends AbstractDiscoverableAnnotationHandler
{
@ -39,7 +37,6 @@ public class WebFilterAnnotationHandler extends AbstractDiscoverableAnnotationHa
super(context);
}
@Override
public void handle(ClassInfo info, String annotationName)
{

View File

@ -19,7 +19,6 @@
package org.eclipse.jetty.annotations;
import java.util.EventListener;
import javax.servlet.ServletContextAttributeListener;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletRequestAttributeListener;

View File

@ -21,14 +21,12 @@ package org.eclipse.jetty.annotations;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.servlet.Servlet;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import org.eclipse.jetty.http.pathmap.ServletPathSpec;
import org.eclipse.jetty.servlet.Holder;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.servlet.ServletMapping;
import org.eclipse.jetty.servlet.Source;
@ -44,8 +42,6 @@ import org.eclipse.jetty.webapp.WebAppContext;
/**
* WebServletAnnotation
*
*
*/
public class WebServletAnnotation extends DiscoveredAnnotation
{
@ -56,7 +52,6 @@ public class WebServletAnnotation extends DiscoveredAnnotation
super(context, className);
}
public WebServletAnnotation(WebAppContext context, String className, Resource resource)
{
super(context, className, resource);
@ -105,7 +100,9 @@ public class WebServletAnnotation extends DiscoveredAnnotation
//canonicalize the patterns
ArrayList<String> urlPatternList = new ArrayList<String>();
for (String p : urlPatterns)
{
urlPatternList.add(ServletPathSpec.normalize(p));
}
String servletName = (annotation.name().equals("") ? clazz.getName() : annotation.name());
@ -157,7 +154,6 @@ public class WebServletAnnotation extends DiscoveredAnnotation
_context.getServletHandler().addServlet(holder);
mapping = new ServletMapping(source);
mapping.setServletName(holder.getName());
mapping.setPathSpecs(LazyList.toStringArray(urlPatternList));
@ -184,7 +180,6 @@ public class WebServletAnnotation extends DiscoveredAnnotation
}
}
//check the url-patterns
//ServletSpec 3.0 p81 If a servlet already has url mappings from a
//webxml or fragment descriptor the annotation is ignored.
@ -201,7 +196,6 @@ public class WebServletAnnotation extends DiscoveredAnnotation
}
}
//We also want to be able to replace mappings that were defined in webdefault.xml
//that were for a different servlet eg a mapping in webdefault.xml for / to the jetty
//default servlet should be able to be replaced by an annotation for / to a different
@ -227,12 +221,14 @@ public class WebServletAnnotation extends DiscoveredAnnotation
if (updatedPaths == null || updatedPaths.length == 0)
{
boolean success = allMappings.remove(existingMapping);
if (LOG.isDebugEnabled()) LOG.debug("Removed empty mapping {} from defaults descriptor success:{}",existingMapping, success);
if (LOG.isDebugEnabled())
LOG.debug("Removed empty mapping {} from defaults descriptor success:{}", existingMapping, success);
}
else
{
existingMapping.setPathSpecs(updatedPaths);
if (LOG.isDebugEnabled()) LOG.debug("Removed path {} from mapping {} from defaults descriptor ", p,existingMapping);
if (LOG.isDebugEnabled())
LOG.debug("Removed path {} from mapping {} from defaults descriptor ", p, existingMapping);
}
}
_context.getMetaData().setOrigin(servletName + ".servlet.mapping." + p, annotation, clazz);
@ -242,12 +238,8 @@ public class WebServletAnnotation extends DiscoveredAnnotation
}
}
/**
* @param name
* @return
*
*/
private List<ServletMapping> getServletMappingsForServlet(String name)
{
@ -266,10 +258,8 @@ public class WebServletAnnotation extends DiscoveredAnnotation
return mappings;
}
/**
* @param mappings
* @return
*
*/
private boolean containsNonDefaultMappings(List<ServletMapping> mappings)
{

View File

@ -39,7 +39,6 @@ public class WebServletAnnotationHandler extends AbstractDiscoverableAnnotationH
super(context);
}
/**
* Handle discovering a WebServlet annotation.
*/

View File

@ -17,13 +17,8 @@ package org.acme;
// ========================================================================
//
/**
* ClassOne
*
*
*/
public class ClassOne
{
@ -31,5 +26,4 @@ public class ClassOne
public void one()
{
}
}

View File

@ -18,11 +18,8 @@
package org.eclipse.jetty.annotations;
/**
* ClassA
*
*
*/
@Sample(1)
public class ClassA
@ -34,7 +31,6 @@ public class ClassA
private Integer j;
private Integer k;
public static class Foo
{

View File

@ -18,12 +18,8 @@
package org.eclipse.jetty.annotations;
/**
* ClassB
*
*
*/
@Sample(value = 50)
@Multi({"do", "re", "mi"})
@ -51,11 +47,9 @@ public class ClassB extends ClassA implements InterfaceD
System.err.println("Overridden method l has no annotation");
}
//test no annotation
public void z()
{
System.err.println("ClassB.z");
}
}

View File

@ -19,7 +19,6 @@
package org.eclipse.jetty.annotations;
import java.io.IOException;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
@ -37,7 +36,9 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@WebFilter(filterName="CFilter", dispatcherTypes={DispatcherType.REQUEST}, urlPatterns = {"/*"}, initParams={@WebInitParam(name="a", value="99")}, asyncSupported=false)
@WebFilter(filterName = "CFilter", dispatcherTypes = {DispatcherType.REQUEST}, urlPatterns = {"/*"}, initParams = {
@WebInitParam(name = "a", value = "99")
}, asyncSupported = false)
@RunAs("admin")
public class FilterC implements Filter
{
@ -56,7 +57,6 @@ public class FilterC implements Filter
}
@Override
public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2)
throws IOException, ServletException

View File

@ -20,8 +20,6 @@ package org.eclipse.jetty.annotations;
/**
* InterfaceD
*
*
*/
public interface InterfaceD
{

View File

@ -37,5 +37,4 @@ public class ListenerC implements ServletContextListener
{
}
}

View File

@ -19,7 +19,6 @@
package org.eclipse.jetty.annotations;
import java.io.IOException;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
@ -37,10 +36,14 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@DeclareRoles({"alice"})
@WebServlet(urlPatterns = { "/foo/*", "/bah/*" }, name="CServlet", initParams={@WebInitParam(name="x", value="y")}, loadOnStartup=2, asyncSupported=false)
@WebServlet(urlPatterns = {"/foo/*", "/bah/*"}, name = "CServlet", initParams = {
@WebInitParam(name = "x", value = "y")
}, loadOnStartup = 2, asyncSupported = false)
@MultipartConfig(fileSizeThreshold = 1000, maxFileSize = 2000, maxRequestSize = 3000)
@RunAs("admin")
@ServletSecurity(value=@HttpConstraint(rolesAllowed={"fred", "bill", "dorothy"}), httpMethodConstraints={@HttpMethodConstraint(value="GET", rolesAllowed={"bob", "carol", "ted"})})
@ServletSecurity(value = @HttpConstraint(rolesAllowed = {"fred", "bill", "dorothy"}), httpMethodConstraints = {
@HttpMethodConstraint(value = "GET", rolesAllowed = {"bob", "carol", "ted"})
})
public class ServletC extends HttpServlet
{
@Resource(mappedName = "foo", type = Double.class)

View File

@ -22,9 +22,9 @@ import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
@WebServlet(urlPatterns = { "/", "/bah/*" }, name="DServlet", initParams={@WebInitParam(name="x", value="y")}, loadOnStartup=1, asyncSupported=false)
@WebServlet(urlPatterns = {"/", "/bah/*"}, name = "DServlet", initParams = {
@WebInitParam(name = "x", value = "y")
}, loadOnStartup = 1, asyncSupported = false)
public class ServletD extends HttpServlet
{

View File

@ -102,13 +102,17 @@ public class TestAnnotationConfiguration
JAR.unpack(testWebInfClassesJar, unpacked);
webInfClasses = Resource.newResource(unpacked);
containerLoader = new URLClassLoader(new URL[] { testContainerSciJar.toURI().toURL() }, Thread.currentThread().getContextClassLoader());
containerLoader = new URLClassLoader(new URL[]{
testContainerSciJar.toURI().toURL()
}, Thread.currentThread().getContextClassLoader());
targetClasses = Resource.newResource(MavenTestingUtils.getTargetDir().toURI()).addPath("/test-classes");
classes = Arrays.asList(new Resource[]{webInfClasses, targetClasses});
webAppLoader = new URLClassLoader(new URL[] { testSciJar.toURI().toURL(), targetClasses.getURI().toURL(), webInfClasses.getURI().toURL() },
webAppLoader = new URLClassLoader(new URL[]{
testSciJar.toURI().toURL(), targetClasses.getURI().toURL(), webInfClasses.getURI().toURL()
},
containerLoader);
}
@ -243,8 +247,10 @@ public class TestAnnotationConfiguration
File orderedFragmentJar = new File(jarDir, "test-sci-with-ordering.jar");
assertTrue(orderedFragmentJar.exists());
URLClassLoader orderedLoader = new URLClassLoader(new URL[] { orderedFragmentJar.toURI().toURL(), testSciJar.toURI().toURL(),
targetClasses.getURI().toURL(), webInfClasses.getURI().toURL() },
URLClassLoader orderedLoader = new URLClassLoader(new URL[]{
orderedFragmentJar.toURI().toURL(), testSciJar.toURI().toURL(),
targetClasses.getURI().toURL(), webInfClasses.getURI().toURL()
},
containerLoader);
Thread.currentThread().setContextClassLoader(orderedLoader);
@ -270,7 +276,6 @@ public class TestAnnotationConfiguration
assertEquals("com.acme.webinf.WebInfClassServletContainerInitializer", scis.get(1).getClass().getName()); // web-inf
assertEquals("com.acme.ordering.AcmeServletContainerInitializer", scis.get(2).getClass().getName()); // first
assertEquals("com.acme.initializer.FooInitializer", scis.get(3).getClass().getName()); //other in ordering
}
finally
{
@ -338,7 +343,6 @@ public class TestAnnotationConfiguration
assertEquals("com.acme.ServerServletContainerInitializer", scis.get(0).getClass().getName()); //container path
assertEquals("com.acme.webinf.WebInfClassServletContainerInitializer", scis.get(1).getClass().getName()); // web-inf
assertEquals("com.acme.initializer.FooInitializer", scis.get(2).getClass().getName()); //web-inf jar no web-fragment
}
finally
{
@ -346,8 +350,6 @@ public class TestAnnotationConfiguration
}
}
@Test
public void testGetFragmentFromJar() throws Exception
{

View File

@ -18,22 +18,12 @@
package org.eclipse.jetty.annotations;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.hasKey;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import javax.naming.Context;
import javax.naming.InitialContext;
@ -44,6 +34,15 @@ import org.eclipse.jetty.annotations.AnnotationParser.MethodInfo;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.hasKey;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
*
*/
@ -51,7 +50,6 @@ public class TestAnnotationInheritance
{
List<String> classNames = new ArrayList<String>();
class SampleHandler extends AbstractHandler
{
public final List<String> annotatedClassNames = new ArrayList<String>();

View File

@ -81,7 +81,6 @@ public class TestAnnotationParser
}
}
public static class DuplicateClassScanHandler extends AnnotationParser.AbstractHandler
{
private Map<String, List<String>> _classMap = new ConcurrentHashMap();
@ -100,12 +99,10 @@ public class TestAnnotationParser
}
}
public List<String> getParsedList(String classname)
{
return _classMap.get(classname);
}
}
public WorkDir testdir;
@ -262,7 +259,6 @@ public class TestAnnotationParser
assertThat("Found Class", tracker.foundClasses, contains(ClassA.class.getName()));
}
@Test
public void testScanDuplicateClassesInJars() throws Exception
{
@ -279,7 +275,6 @@ public class TestAnnotationParser
assertTrue(!(locations.get(0).equals(locations.get(1))));
}
@Test
public void testScanDuplicateClasses() throws Exception
{
@ -296,8 +291,6 @@ public class TestAnnotationParser
assertTrue(!(locations.get(0).equals(locations.get(1))));
}
private void copyClass(Class<?> clazz, File basedir) throws IOException
{
String classRef = TypeUtil.toClassReference(clazz);

View File

@ -18,15 +18,8 @@
package org.eclipse.jetty.annotations;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import java.util.Arrays;
import java.util.List;
import javax.servlet.annotation.HttpConstraint;
import javax.servlet.annotation.HttpMethodConstraint;
import javax.servlet.annotation.ServletSecurity;
@ -43,6 +36,12 @@ import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.webapp.WebAppContext;
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.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
public class TestSecurityAnnotationConversions
{
@ServletSecurity(value = @HttpConstraint(value = EmptyRoleSemantic.DENY))
@ -53,21 +52,26 @@ public class TestSecurityAnnotationConversions
public static class PermitServlet extends HttpServlet
{}
@ServletSecurity(value=@HttpConstraint(value=EmptyRoleSemantic.PERMIT, transportGuarantee=TransportGuarantee.CONFIDENTIAL, rolesAllowed={"tom", "dick", "harry"}))
@ServletSecurity(value = @HttpConstraint(value = EmptyRoleSemantic.PERMIT, transportGuarantee = TransportGuarantee.CONFIDENTIAL, rolesAllowed = {
"tom", "dick", "harry"
}))
public static class RolesServlet extends HttpServlet
{}
@ServletSecurity(value=@HttpConstraint(value=EmptyRoleSemantic.PERMIT, transportGuarantee=TransportGuarantee.CONFIDENTIAL, rolesAllowed={"tom", "dick", "harry"}),
@ServletSecurity(value = @HttpConstraint(value = EmptyRoleSemantic.PERMIT, transportGuarantee = TransportGuarantee.CONFIDENTIAL, rolesAllowed = {
"tom", "dick", "harry"
}),
httpMethodConstraints = {@HttpMethodConstraint(value = "GET")})
public static class Method1Servlet extends HttpServlet
{}
@ServletSecurity(value=@HttpConstraint(value=EmptyRoleSemantic.PERMIT, transportGuarantee=TransportGuarantee.CONFIDENTIAL, rolesAllowed={"tom", "dick", "harry"}),
@ServletSecurity(value = @HttpConstraint(value = EmptyRoleSemantic.PERMIT, transportGuarantee = TransportGuarantee.CONFIDENTIAL, rolesAllowed = {
"tom", "dick", "harry"
}),
httpMethodConstraints = {@HttpMethodConstraint(value = "GET", transportGuarantee = TransportGuarantee.CONFIDENTIAL)})
public static class Method2Servlet extends HttpServlet
{}
public void setUp()
{
}
@ -76,7 +80,9 @@ public class TestSecurityAnnotationConversions
public void testDenyAllOnClass() throws Exception
{
WebAppContext wac = makeWebAppContext(DenyServlet.class.getCanonicalName(), "denyServlet", new String[]{"/foo/*", "*.foo"});
WebAppContext wac = makeWebAppContext(DenyServlet.class.getCanonicalName(), "denyServlet", new String[]{
"/foo/*", "*.foo"
});
//Assume we found 1 servlet with a @HttpConstraint with value=EmptyRoleSemantic.DENY security annotation
ServletSecurityAnnotationHandler annotationHandler = new ServletSecurityAnnotationHandler(wac);
@ -108,17 +114,17 @@ public class TestSecurityAnnotationConversions
public void testPermitAll() throws Exception
{
//Assume we found 1 servlet with a @ServletSecurity security annotation
WebAppContext wac = makeWebAppContext(PermitServlet.class.getCanonicalName(), "permitServlet", new String[]{"/foo/*", "*.foo"});
WebAppContext wac = makeWebAppContext(PermitServlet.class.getCanonicalName(), "permitServlet", new String[]{
"/foo/*", "*.foo"
});
ServletSecurityAnnotationHandler annotationHandler = new ServletSecurityAnnotationHandler(wac);
AnnotationIntrospector introspector = new AnnotationIntrospector();
introspector.registerHandler(annotationHandler);
//set up the expected outcomes - no constraints at all as per Servlet Spec 3.1 pg 129
//1 ConstraintMapping per ServletMapping pathSpec
ConstraintMapping[] expectedMappings = new ConstraintMapping[]{};
introspector.introspect(PermitServlet.class);
@ -132,7 +138,9 @@ public class TestSecurityAnnotationConversions
//Assume we found 1 servlet with annotation with roles defined and
//and a TransportGuarantee
WebAppContext wac = makeWebAppContext(RolesServlet.class.getCanonicalName(), "rolesServlet", new String[]{"/foo/*", "*.foo"});
WebAppContext wac = makeWebAppContext(RolesServlet.class.getCanonicalName(), "rolesServlet", new String[]{
"/foo/*", "*.foo"
});
ServletSecurityAnnotationHandler annotationHandler = new ServletSecurityAnnotationHandler(wac);
AnnotationIntrospector introspector = new AnnotationIntrospector();
@ -164,7 +172,9 @@ public class TestSecurityAnnotationConversions
//ServletSecurity annotation with HttpConstraint of TransportGuarantee.CONFIDENTIAL, and a list of rolesAllowed, and
//a HttpMethodConstraint for GET method that permits all and has TransportGuarantee.NONE (ie is default)
WebAppContext wac = makeWebAppContext(Method1Servlet.class.getCanonicalName(), "method1Servlet", new String[]{"/foo/*", "*.foo"});
WebAppContext wac = makeWebAppContext(Method1Servlet.class.getCanonicalName(), "method1Servlet", new String[]{
"/foo/*", "*.foo"
});
//set up the expected outcomes: - a Constraint for the RolesAllowed on the class
//with userdata constraint of DC_CONFIDENTIAL
@ -210,7 +220,9 @@ public class TestSecurityAnnotationConversions
{
//A ServletSecurity annotation that has HttpConstraint of CONFIDENTIAL with defined roles, but a
//HttpMethodConstraint for GET that permits all, but also requires CONFIDENTIAL
WebAppContext wac = makeWebAppContext(Method2Servlet.class.getCanonicalName(), "method2Servlet", new String[]{"/foo/*", "*.foo"});
WebAppContext wac = makeWebAppContext(Method2Servlet.class.getCanonicalName(), "method2Servlet", new String[]{
"/foo/*", "*.foo"
});
AnnotationIntrospector introspector = new AnnotationIntrospector();
ServletSecurityAnnotationHandler annotationHandler = new ServletSecurityAnnotationHandler(wac);
@ -299,7 +311,6 @@ public class TestSecurityAnnotationConversions
}
}
private WebAppContext makeWebAppContext(String className, String servletName, String[] paths)
{
WebAppContext wac = new WebAppContext();

View File

@ -18,15 +18,6 @@
package org.eclipse.jetty.annotations;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -40,6 +31,15 @@ import org.eclipse.jetty.webapp.DiscoveredAnnotation;
import org.eclipse.jetty.webapp.WebAppContext;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
/**
* TestServletAnnotations
*/
@ -77,7 +77,6 @@ public class TestServletAnnotations
parser.parse(Collections.singleton(handler), classes);
assertEquals(1, results.size());
assertTrue(results.get(0) instanceof WebServletAnnotation);
@ -103,7 +102,6 @@ public class TestServletAnnotations
assertEquals(2, paths.length);
}
@Test
public void testWebServletAnnotationOverrideDefault() throws Exception
{
@ -138,8 +136,6 @@ public class TestServletAnnotations
}
}
@Test
public void testWebServletAnnotationReplaceDefault() throws Exception
{
@ -189,10 +185,8 @@ public class TestServletAnnotations
else
fail("Unexpected servlet mapping: " + r);
}
}
@Test
public void testWebServletAnnotationNotOverride() throws Exception
{
@ -262,7 +256,6 @@ public class TestServletAnnotations
if (!r.getPathSpecs()[0].equals("/default") && !r.getPathSpecs()[0].equals("/other"))
fail("Unexpected path in mapping: " + r);
}
}
@Test
@ -275,7 +268,6 @@ public class TestServletAnnotations
servlet.setName("foo");
wac.getServletHandler().addServlet(servlet);
WebServletAnnotation annotation = new WebServletAnnotation(wac, "org.eclipse.jetty.annotations.ServletD", null);
annotation.apply();
@ -288,8 +280,6 @@ public class TestServletAnnotations
}
}
@Test
public void testDeclareRoles()
throws Exception

View File

@ -19,7 +19,6 @@
package org.eclipse.jetty.annotations.resources;
import java.io.IOException;
import javax.annotation.Resource;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@ -28,8 +27,6 @@ import javax.servlet.ServletResponse;
/**
* ResourceA
*
*
*/
public class ResourceA implements javax.servlet.Servlet
{
@ -37,7 +34,6 @@ public class ResourceA implements javax.servlet.Servlet
private Integer h;
private Integer k;
@Resource(name = "myf", mappedName = "resB") //test giving both a name and mapped name from the environment
private Integer f;//test a non inherited field that needs injection
@ -50,12 +46,12 @@ public class ResourceA implements javax.servlet.Servlet
@Resource(mappedName = "resB") //test using the default name on an inherited field
protected Integer n; //TODO - if it's inherited, is it supposed to use the classname of the class it is inherited by?
@Resource(name = "mye", mappedName = "resA", type = Integer.class)
public void setE(Integer e)
{
this.e = e;
}
public Integer getE()
{
return this.e;
@ -87,28 +83,34 @@ public class ResourceA implements javax.servlet.Servlet
{
this.k = k;
}
public void x()
{
System.err.println("ResourceA.x");
}
@Override
public void destroy()
{
}
@Override
public ServletConfig getServletConfig()
{
return null;
}
@Override
public String getServletInfo()
{
return null;
}
@Override
public void init(ServletConfig arg0) throws ServletException
{
}
@Override
public void service(ServletRequest arg0, ServletResponse arg1)
throws ServletException, IOException

View File

@ -17,13 +17,12 @@
//
package org.eclipse.jetty.annotations.resources;
import javax.annotation.Resource;
import javax.annotation.Resources;
/**
* ResourceB
*
*
*/
@Resources({
@Resource(name = "peach", mappedName = "resA"),

View File

@ -18,12 +18,8 @@
package org.eclipse.jetty.annotations.resources;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.lang.reflect.Field;
import java.util.List;
import javax.naming.Context;
import javax.naming.InitialContext;
@ -38,6 +34,9 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class TestResourceAnnotations
{
private Server server;

View File

@ -25,17 +25,11 @@ import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import org.apache.tools.ant.AntClassLoader;
import org.eclipse.jetty.util.PatternMatcher;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.Configuration;
import org.eclipse.jetty.webapp.MetaInfConfiguration;
import org.eclipse.jetty.webapp.WebAppClassLoader;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.webapp.WebInfConfiguration;
import org.eclipse.jetty.webapp.WebXmlConfiguration;
public class AntMetaInfConfiguration extends MetaInfConfiguration
{
@ -46,8 +40,6 @@ public class AntMetaInfConfiguration extends MetaInfConfiguration
return MetaInfConfiguration.class;
}
@Override
public void findAndFilterContainerPaths(WebAppContext context) throws Exception
{
@ -55,9 +47,6 @@ public class AntMetaInfConfiguration extends MetaInfConfiguration
super.findAndFilterContainerPaths(context);
}
/* ------------------------------------------------------------------------------- */
@Override
protected List<URI> getAllContainerJars(final WebAppContext context) throws URISyntaxException
{
@ -72,8 +61,10 @@ public class AntMetaInfConfiguration extends MetaInfConfiguration
URL[] urls = ((URLClassLoader)loader).getURLs();
if (urls != null)
for (URL url : urls)
{
uris.add(new URI(url.toString().replaceAll(" ", "%20")));
}
}
else if (loader instanceof AntClassLoader)
{
AntClassLoader antLoader = (AntClassLoader)loader;

View File

@ -66,36 +66,45 @@ public class AntWebAppContext extends WebAppContext
{
private static final Logger LOG = Log.getLogger(WebAppContext.class);
public final static String DEFAULT_CONTAINER_INCLUDE_JAR_PATTERN =
public static final String DEFAULT_CONTAINER_INCLUDE_JAR_PATTERN =
".*/.*jsp-api-[^/]*\\.jar$|.*/.*jsp-[^/]*\\.jar$|.*/.*taglibs[^/]*\\.jar$|.*/.*jstl[^/]*\\.jar$|.*/.*jsf-impl-[^/]*\\.jar$|.*/.*javax.faces-[^/]*\\.jar$|.*/.*myfaces-impl-[^/]*\\.jar$";
/** Location of jetty-env.xml file. */
/**
* Location of jetty-env.xml file.
*/
private File jettyEnvXml;
/** List of web application libraries. */
/**
* List of web application libraries.
*/
private List<FileSet> libraries = new ArrayList<>();
/** List of web application class directories. */
/**
* List of web application class directories.
*/
private List<FileSet> classes = new ArrayList<>();
/** context xml file to apply to the webapp */
/**
* context xml file to apply to the webapp
*/
private File contextXml;
/** List of extra scan targets for this web application. */
/**
* List of extra scan targets for this web application.
*/
private FileSet scanTargets;
/** context attributes to set **/
/**
* context attributes to set
**/
private Attributes attributes;
private Project project;
private List<File> scanFiles;
private FileMatchingConfiguration librariesConfiguration;
public static void dump(ClassLoader loader)
{
while (loader != null)
@ -107,14 +116,15 @@ public class AntWebAppContext extends WebAppContext
if (urls != null)
{
for (URL u : urls)
{
System.err.println("\t" + u + "\n");
}
}
}
loader = loader.getParent();
}
}
/**
* AntURLClassLoader
*
@ -177,8 +187,10 @@ public class AntWebAppContext extends WebAppContext
if (ourURLS != null)
{
for (URL u : ourURLS)
{
urls.add(u);
}
}
return urls.toArray(new URL[urls.size()]);
}
@ -287,11 +299,8 @@ public class AntWebAppContext extends WebAppContext
}
}
/**
* AntServletHolder
*
*
*/
public static class AntServletHolder extends ServletHolder
{
@ -301,25 +310,21 @@ public class AntWebAppContext extends WebAppContext
super();
}
public AntServletHolder(Class<? extends Servlet> servlet)
{
super(servlet);
}
public AntServletHolder(Servlet servlet)
{
super(servlet);
}
public AntServletHolder(String name, Class<? extends Servlet> servlet)
{
super(name, servlet);
}
public AntServletHolder(String name, Servlet servlet)
{
super(name, servlet);
@ -358,15 +363,10 @@ public class AntWebAppContext extends WebAppContext
return classpath.toString();
}
}
/**
* AntServletHandler
*
*
*/
public static class AntServletHandler extends ServletHandler
{
@ -376,11 +376,8 @@ public class AntWebAppContext extends WebAppContext
{
return new AntServletHolder();
}
}
/**
* Default constructor. Takes project as an argument
*
@ -396,9 +393,9 @@ public class AntWebAppContext extends WebAppContext
addConfiguration(new AntWebInfConfiguration(), new AntWebXmlConfiguration(), new AntMetaInfConfiguration());
}
/**
* Adds a new Ant's attributes tag object if it have not been created yet.
*
* @param atts the attributes
*/
public void addAttributes(Attributes atts)
@ -411,27 +408,22 @@ public class AntWebAppContext extends WebAppContext
this.attributes = atts;
}
public void addLib(FileSet lib)
{
libraries.add(lib);
}
public void addClasses(FileSet classes)
{
this.classes.add(classes);
}
@Override
protected ServletHandler newServletHandler()
{
return new AntServletHandler();
}
public void setJettyEnvXml(File jettyEnvXml)
{
this.jettyEnvXml = jettyEnvXml;
@ -443,15 +435,11 @@ public class AntWebAppContext extends WebAppContext
return this.jettyEnvXml;
}
public List<File> getLibraries()
{
return librariesConfiguration.getBaseDirectories();
}
public void addScanTargets(FileSet scanTargets)
{
if (this.scanTargets != null)
@ -467,7 +455,6 @@ public class AntWebAppContext extends WebAppContext
if (this.scanTargets == null)
return null;
FileMatchingConfiguration configuration = new FileMatchingConfiguration();
configuration.addDirectoryScanner(scanTargets.getDirectoryScanner(project));
return configuration.getBaseDirectories();
@ -480,7 +467,6 @@ public class AntWebAppContext extends WebAppContext
return scanFiles;
}
public boolean isScanned(File file)
{
List<File> files = getScanFiles();
@ -489,7 +475,6 @@ public class AntWebAppContext extends WebAppContext
return files.contains(file);
}
public List<File> initScanFiles()
{
List<File> scanList = new ArrayList<File>();
@ -559,8 +544,6 @@ public class AntWebAppContext extends WebAppContext
return scanList;
}
@Override
public void setWar(String path)
{
@ -581,7 +564,6 @@ public class AntWebAppContext extends WebAppContext
}
}
/**
*
*/
@ -603,8 +585,10 @@ public class AntWebAppContext extends WebAppContext
if (attributes != null && attributes.getAttributes() != null)
{
for (Attribute a : attributes.getAttributes())
{
setAttribute(a.getName(), a.getValue());
}
}
//apply a context xml file if one was supplied
if (contextXml != null)
@ -649,8 +633,6 @@ public class AntWebAppContext extends WebAppContext
}
}
/**
* @return a list of classpath files (libraries and class directories).
*/
@ -677,11 +659,9 @@ public class AntWebAppContext extends WebAppContext
}
}
return classPathFiles;
}
/**
* @return a <code>FileMatchingConfiguration</code> object describing the
* configuration of all libraries added to this particular web app
@ -708,16 +688,13 @@ public class AntWebAppContext extends WebAppContext
return config;
}
public File getContextXml()
{
return contextXml;
}
public void setContextXml(File contextXml)
{
this.contextXml = contextXml;
}
}

View File

@ -24,10 +24,8 @@ import java.util.List;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.webapp.Configuration;
import org.eclipse.jetty.webapp.WebInfConfiguration;
import org.eclipse.jetty.webapp.WebXmlConfiguration;
/**
* This configuration object provides additional way to inject application
* properties into the configured web application. The list of classpath files,
@ -38,13 +36,16 @@ public class AntWebXmlConfiguration extends WebXmlConfiguration
{
private static final Logger LOG = Log.getLogger(WebXmlConfiguration.class);
/** List of classpath files. */
/**
* List of classpath files.
*/
private List classPathFiles;
/** Web application root directory. */
/**
* Web application root directory.
*/
private File webAppBaseDir;
public AntWebXmlConfiguration()
{
super();
@ -65,7 +66,4 @@ public class AntWebXmlConfiguration extends WebXmlConfiguration
{
this.webAppBaseDir = webAppBaseDir;
}
}

View File

@ -43,32 +43,49 @@ public class JettyRunTask extends Task
{
private int scanIntervalSeconds;
/** Temporary files directory. */
/**
* Temporary files directory.
*/
private File tempDirectory;
/** List of web applications to be deployed. */
/**
* List of web applications to be deployed.
*/
private List<AntWebAppContext> webapps = new ArrayList<>();
/** Location of jetty.xml file. */
/**
* Location of jetty.xml file.
*/
private File jettyXml;
/** List of server connectors. */
/**
* List of server connectors.
*/
private Connectors connectors = null;
/** Server request logger object. */
/**
* Server request logger object.
*/
private RequestLog requestLog;
/** List of login services. */
/**
* List of login services.
*/
private LoginServices loginServices;
/** List of system properties to be set. */
/**
* List of system properties to be set.
*/
private SystemProperties systemProperties;
/** List of other contexts to deploy */
/**
* List of other contexts to deploy
*/
private ContextHandlers contextHandlers;
/** Port Jetty will use for the default connector */
/**
* Port Jetty will use for the default connector
*/
private int jettyPort = 8080;
private int stopPort;
@ -84,6 +101,7 @@ public class JettyRunTask extends Task
/**
* Creates a new <code>WebApp</code> Ant object.
*
* @param webapp the webapp context
*/
public void addWebApp(AntWebAppContext webapp)
@ -93,6 +111,7 @@ public class JettyRunTask extends Task
/**
* Adds a new Ant's connector tag object if it have not been created yet.
*
* @param connectors the connectors
*/
public void addConnectors(Connectors connectors)
@ -157,7 +176,6 @@ public class JettyRunTask extends Task
{
throw new BuildException("Request logger instantiation exception: " + e);
}
}
public String getRequestLog()
@ -294,5 +312,4 @@ public class JettyRunTask extends Task
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More