Merge branch 'jetty-9.2.x'

This commit is contained in:
Joakim Erdfelt 2014-10-28 12:32:55 -07:00
commit 8a72a153a1
33 changed files with 980 additions and 116 deletions

View File

@ -6,7 +6,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>apache-jsp</artifactId>
<name>Jetty :: Apache JSP</name>
<name>Jetty :: Apache JSP Implementation</name>
<url>http://www.eclipse.org/jetty</url>
<packaging>jar</packaging>
<properties>

View File

@ -108,12 +108,5 @@
<artifactId>jetty-test-helper</artifactId>
<!-- scope>test</scope-->
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -123,7 +123,7 @@ public class SpdyServer
// create a ServerConnector and pass in the supported factories. NPN will then be used to negotiate the
// protocol with the client.
HTTPSPDYServerConnectionFactory spdy3 = new HTTPSPDYServerConnectionFactory(3,config,push);
spdy2.setInputBufferSize(8192);
spdy3.setInputBufferSize(8192);
NPNServerConnectionFactory npn = new NPNServerConnectionFactory(spdy3.getProtocol(),spdy2.getProtocol(),http.getProtocol());
npn.setDefaultProtocol(http.getProtocol());

49
jetty-cdi/pom.xml Normal file
View File

@ -0,0 +1,49 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.2.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-cdi</artifactId>
<name>Jetty :: CDI Configurations</name>
<url>http://www.eclipse.org/jetty</url>
<packaging>jar</packaging>
<properties>
<bundle-symbolic-name>${project.groupId}.${project.artifactId}</bundle-symbolic-name>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptorRefs>
<descriptorRef>config</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-plus</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-deploy</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<!-- =============================================================== -->
<!-- Mixin the Weld / CDI classes to the class loader -->
<!-- =============================================================== -->
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Ref refid="DeploymentManager">
<Call name="addLifeCycleBinding">
<Arg>
<New
class="org.eclipse.jetty.cdi.WeldDeploymentBinding">
</New>
</Arg>
</Call>
</Ref>
</Configure>

View File

@ -0,0 +1,26 @@
#
# CDI / Weld Jetty module
#
[depend]
deploy
annotations
plus
# JSP (and EL) are requirements for CDI and Weld
jsp
[files]
lib/weld/
http://central.maven.org/maven2/org/jboss/weld/servlet/weld-servlet/2.2.5.Final/weld-servlet-2.2.5.Final.jar|lib/weld/weld-servlet-2.2.5.Final.jar
[lib]
lib/weld/weld-servlet-2.2.5.Final.jar
lib/jetty-cdi-${jetty.version}.jar
[xml]
etc/jetty-cdi.xml
[license]
Weld is an open source project hosted on Github and released under the Apache 2.0 license.
http://weld.cdi-spec.org/
http://www.apache.org/licenses/LICENSE-2.0.html

View File

@ -0,0 +1,77 @@
//
// ========================================================================
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.cdi;
import javax.naming.Reference;
import org.eclipse.jetty.deploy.App;
import org.eclipse.jetty.deploy.AppLifeCycle;
import org.eclipse.jetty.deploy.graph.Node;
import org.eclipse.jetty.plus.jndi.Resource;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.webapp.WebAppContext;
/**
* Perform some basic weld configuration of WebAppContext
*/
public class WeldDeploymentBinding implements AppLifeCycle.Binding
{
public String[] getBindingTargets()
{
return new String[]
{ "deploying" };
}
public void processBinding(Node node, App app) throws Exception
{
ContextHandler handler = app.getContextHandler();
if (handler == null)
{
throw new NullPointerException("No Handler created for App: " + app);
}
if (handler instanceof WebAppContext)
{
WebAppContext webapp = (WebAppContext)handler;
// Add context specific weld container reference.
// See https://issues.jboss.org/browse/WELD-1710
// and https://github.com/weld/core/blob/2.2.5.Final/environments/servlet/core/src/main/java/org/jboss/weld/environment/servlet/WeldServletLifecycle.java#L244-L253
webapp.setInitParameter("org.jboss.weld.environment.container.class",
"org.jboss.weld.environment.jetty.JettyContainer");
// Setup Weld BeanManager reference
Reference ref = new Reference("javax.enterprise.inject.spi.BeanManager",
"org.jboss.weld.resources.ManagerObjectFactory", null);
new Resource(webapp,"BeanManager",ref);
// webapp cannot change / replace weld classes
webapp.addSystemClass("org.jboss.weld.");
webapp.addSystemClass("org.jboss.classfilewriter.");
webapp.addSystemClass("org.jboss.logging.");
webapp.addSystemClass("com.google.common.");
// don't hide weld classes from webapps (allow webapp to use ones from system classloader)
webapp.addServerClass("-org.jboss.weld.");
webapp.addServerClass("-org.jboss.classfilewriter.");
webapp.addServerClass("-org.jboss.logging.");
webapp.addServerClass("-com.google.common.");
}
}
}

View File

@ -579,8 +579,7 @@
<arguments>
<argument>jetty.home=${assembly-directory}</argument>
<argument>jetty.base=${assembly-directory}</argument>
<argument>--add-to-start=server,deploy,websocket,ext,resources</argument>
<argument>--add-to-startd=jsp,jstl,http</argument>
<argument>--add-to-start=server,deploy,websocket,ext,resources,jsp,jstl,http</argument>
</arguments>
</configuration>
<goals>
@ -802,6 +801,11 @@
<artifactId>jetty-overlay-deployer</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-cdi</artifactId>
<version>${project.version}</version>
</dependency>
-->
<dependency>
<groupId>org.eclipse.jetty</groupId>

View File

@ -1,35 +1,23 @@
#===========================================================
# Jetty start.jar arguments
# NOTE: Jetty is starting using LEGACY behavior
#
# The contents of this file, together with the *.ini
# files found in start.d directory are used to build
# the classpath and command line on a call to
# java -jar start.jar [arg...]
# Starting Jetty from this {jetty.home} is LEGACY behavior.
#
# Use the following command to see more options
# java -jar start.jar --help
# A proper {jetty.base} should be configured with no changes
# being made to this {jetty.home}.
#
# Each line in these files is prepended to the command line
# as arguments and may be either:
# + A property like: name=value
# + A module to enable like: --module=jmx
# + An XML configuration file like: etc/jetty-feature.xml
# + A start.jar option like: --dry-run
# http://www.eclipse.org/jetty/documentation/current/startup.html
#
# If --exec or --dry-run are used, then this file may also
# contain lines with:
# + A JVM option like: -Xmx2000m
# + A System Property like: -Dcom.sun.management.jmxremote
# A demo-base directory has been provided as an example of
# this setup.
#
# The --add-to-start=module option can be used to append
# a configuration template for a module to start.ini
# The --add-to-startd=module option can be used to create
# a configuration template for a module in start.d/module.ini
# For example configure and run with SPDY use
# $ cd demo-base
# $ java -jar ../start.jar
#
# java -jar start.jar --add-to-startd=spdy
# $EDITOR start.d/spdy.ini
# java -jar start.jar
# This {jetty.home}/start.ini has been provided to duplicate
# historical default jetty-distribution settings.
#
#===========================================================
# To disable the warning message, uncomment the following line
# -Dorg.eclipse.jetty.start.home.warning=false

View File

@ -6,7 +6,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-jsp</artifactId>
<name>Jetty :: JSP dependencies</name>
<name>Jetty :: Glassfish JSP Implementation</name>
<url>http://www.eclipse.org/jetty</url>
<packaging>jar</packaging>
<properties>

View File

@ -2453,6 +2453,11 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
@Override
public String getServerInfo()
{
// NOTE: DO NOT CHANGE
// this is used by weld to detect Jetty
// implementation version
// See: https://github.com/weld/core/blob/master/environments/servlet/core/src/main/java/org/jboss/weld/environment/jetty/JettyContainer.java
// and its touch(ContainerContext) method
return "jetty/" + Server.getVersion();
}

View File

@ -62,13 +62,6 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>

View File

@ -0,0 +1,51 @@
//
// ========================================================================
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.start;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.start.Props.Prop;
public class BaseHomeWarning
{
public static void show(Props props)
{
Prop showWarn = props.getProp("org.eclipse.jetty.start.home.warning",true);
if (showWarn == null || Boolean.parseBoolean(showWarn.value))
{
if (!Main.printTextResource("org/eclipse/jetty/start/base-home-warning.txt"))
{
StartLog.warn("It is not recommended to run Jetty from within {jetty.home}");
StartLog.warn("Use a proper {jetty.base} setup");
StartLog.warn("See: http://www.eclipse.org/jetty/documentation/current/startup.html");
}
try
{
System.err.print("Your startup will proceed shortly ...");
TimeUnit.SECONDS.sleep(2);
System.err.println();
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
}
}

View File

@ -82,12 +82,13 @@ import org.eclipse.jetty.start.config.CommandLineConfigSource;
public class Main
{
private static final int EXIT_USAGE = 1;
private static BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
public static String join(Collection<?> objs, String delim)
{
if (objs==null)
{
return "";
}
StringBuilder str = new StringBuilder();
boolean needDelim = false;
for (Object obj : objs)
@ -399,23 +400,29 @@ public class Main
{
// is it an explicit request to create an ini file?
if (topLevel && !FS.exists(startd_ini) && !appendStartIni)
{
buildIni=true;
// else is it transitive
else if (transitive)
}
// else is it transitive
else if (transitive)
{
// do we need an ini anyway?
if (module.hasDefaultConfig() || module.hasLicense())
buildIni=true;
if (module.hasDefaultConfig() || module.hasLicense())
{
buildIni = true;
}
else
{
StartLog.info("%-15s initialised transitively",name);
}
}
// else must be initialized explicitly
else
{
for (String source : module.getSources())
{
StartLog.info("%-15s initialised in %s",name,baseHome.toShortForm(source));
}
}
}
else
@ -435,13 +442,28 @@ public class Main
System.err.printf(" + has not been audited for compliance with its license%n");
System.err.printf("%n");
for (String l : module.getLicense())
{
System.err.printf(" %s%n",l);
}
System.err.printf("%nProceed (y/N)? ");
String line = input.readLine();
if (line==null || line.length()==0 || !line.toLowerCase().startsWith("y"))
System.exit(1);
if (args.isApproveAllLicenses())
{
System.err.println("All licenses approved via command line");
}
else
{
try (BufferedReader input = new BufferedReader(new InputStreamReader(System.in)))
{
System.err.printf("%nProceed (y/N)? ");
String line = input.readLine();
if (line == null || line.length() == 0 || !line.toLowerCase().startsWith("y"))
{
System.err.printf("Exiting: license not acknowledged%n");
System.exit(1);
}
}
}
}
@ -567,7 +589,9 @@ public class Main
}
if (complete)
{
break;
}
// look for any new ones resolved via expansion
depends.clear();
@ -701,7 +725,7 @@ public class Main
if (args.isStopCommand())
{
doStop(args);
doStop(args);
}
// Initialize start.ini
@ -727,14 +751,25 @@ public class Main
if (!FS.exists(file))
{
/* Startup should NEVER fail to run on missing content.
* See Bug #427204
*/
// args.setRun(false);
String type=arg.location.endsWith("/")?"directory":"file";
if (arg.uri!=null)
boolean isDir = arg.location.endsWith("/");
if (isDir)
{
StartLog.warn("Required %s '%s' not downloaded from %s. Run with --create-files to download",type,baseHome.toShortForm(file),arg.uri);
System.err.println("MKDIR: " + baseHome.toShortForm(file));
FS.ensureDirectoryExists(file);
/* Startup should not fail to run on missing directories.
* See Bug #427204
*/
// args.setRun(false);
}
else
{
StartLog.warn("Missing Required File: %s",baseHome.toShortForm(file));
args.setRun(false);
if (arg.uri != null)
{
StartLog.warn(" Can be downloaded From: %s",arg.uri);
StartLog.warn(" Run start.jar --create-files to download");
}
}
}
}
@ -744,6 +779,12 @@ public class Main
{
return;
}
// Warning Message
if (!baseHome.isBaseDifferent() && args.isNormalMainClass())
{
BaseHomeWarning.show(args.getProperties());
}
// execute Jetty in another JVM
if (args.isExec())
@ -791,20 +832,21 @@ public class Main
}
}
private void doStop(StartArgs args) {
int stopPort = Integer.parseInt(args.getProperties().getString("STOP.PORT"));
String stopKey = args.getProperties().getString("STOP.KEY");
private void doStop(StartArgs args)
{
int stopPort = Integer.parseInt(args.getProperties().getString("STOP.PORT"));
String stopKey = args.getProperties().getString("STOP.KEY");
if (args.getProperties().getString("STOP.WAIT") != null)
{
int stopWait = Integer.parseInt(args.getProperties().getString("STOP.WAIT"));
if (args.getProperties().getString("STOP.WAIT") != null)
{
int stopWait = Integer.parseInt(args.getProperties().getString("STOP.WAIT"));
stop(stopPort,stopKey,stopWait);
}
else
{
stop(stopPort,stopKey);
}
stop(stopPort,stopKey,stopWait);
}
else
{
stop(stopPort,stopKey);
}
}
/**
@ -880,15 +922,26 @@ public class Main
public void usage(boolean exit)
{
StartLog.endStartLog();
String usageResource = "org/eclipse/jetty/start/usage.txt";
boolean usagePresented = false;
try (InputStream usageStream = getClass().getClassLoader().getResourceAsStream(usageResource))
if(!printTextResource("org/eclipse/jetty/start/usage.txt"))
{
if (usageStream != null)
System.err.println("ERROR: detailed usage resource unavailable");
}
if (exit)
{
System.exit(EXIT_USAGE);
}
}
public static boolean printTextResource(String resourceName)
{
boolean resourcePrinted = false;
try (InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName))
{
if (stream != null)
{
try (InputStreamReader reader = new InputStreamReader(usageStream); BufferedReader buf = new BufferedReader(reader))
try (InputStreamReader reader = new InputStreamReader(stream); BufferedReader buf = new BufferedReader(reader))
{
usagePresented = true;
resourcePrinted = true;
String line;
while ((line = buf.readLine()) != null)
{
@ -898,50 +951,44 @@ public class Main
}
else
{
System.out.println("No usage.txt ??");
System.out.println("Unable to find resource: " + resourceName);
}
}
catch (IOException e)
{
StartLog.warn(e);
}
if (!usagePresented)
{
System.err.println("ERROR: detailed usage resource unavailable");
}
if (exit)
{
System.exit(EXIT_USAGE);
}
return resourcePrinted;
}
// ------------------------------------------------------------
// implement Apache commons daemon (jsvc) lifecycle methods (init, start, stop, destroy)
public void init(String[] args) throws Exception
{
try
{
startupArgs = processCommandLine(args);
}
catch (UsageException e)
{
System.err.println(e.getMessage());
usageExit(e.getCause(),e.getExitCode());
}
catch (Throwable e)
{
usageExit(e,UsageException.ERR_UNKNOWN);
}
try
{
startupArgs = processCommandLine(args);
}
catch (UsageException e)
{
System.err.println(e.getMessage());
usageExit(e.getCause(),e.getExitCode());
}
catch (Throwable e)
{
usageExit(e,UsageException.ERR_UNKNOWN);
}
}
public void start() throws Exception
{
start(startupArgs);
start(startupArgs);
}
public void stop() throws Exception
{
doStop(startupArgs);
doStop(startupArgs);
}
public void destroy()

View File

@ -78,7 +78,7 @@ public class StartArgs
private Map<String, String> propertySource = new HashMap<>();
/** List of all active [files] sections from enabled modules */
private List<FileArg> files = new ArrayList<>();
/** List of all active [lib] sectinos from enabled modules */
/** List of all active [lib] sections from enabled modules */
private Classpath classpath;
/** List of all active [xml] sections from enabled modules */
private List<Path> xmls = new ArrayList<>();
@ -122,6 +122,7 @@ public class StartArgs
private boolean dryRun = false;
private boolean exec = false;
private boolean approveAllLicenses = false;
public StartArgs()
{
@ -574,7 +575,7 @@ public class StartArgs
for (String key : systemPropertyKeys)
{
// ignored keys
if ("jetty.home".equals(key) || "jetty.base".equals(key))
if ("jetty.home".equals(key) || "jetty.base".equals(key) || "main.class".equals(key))
{
// skip
continue;
@ -584,6 +585,11 @@ public class StartArgs
return false;
}
public boolean isApproveAllLicenses()
{
return approveAllLicenses;
}
public boolean isDownload()
{
return download;
@ -598,6 +604,11 @@ public class StartArgs
{
return exec;
}
public boolean isNormalMainClass()
{
return SERVER_MAIN.equals(getMainClassname());
}
public boolean isHelp()
{
@ -749,6 +760,13 @@ public class StartArgs
return;
}
// Enable forked execution of Jetty server
if ("--approve-all-licenses".equals(arg))
{
approveAllLicenses = true;
return;
}
// Arbitrary Libraries
if (arg.startsWith("--lib="))
{

View File

@ -0,0 +1,16 @@
============================================================================
WARNING: Jetty is starting using LEGACY behavior.
A proper {jetty.base} should be configured with no changes being made to the {jetty.home} directory.
Please see http://www.eclipse.org/jetty/documentation/current/startup.html
A demo-base directory has been provided as an example of this setup.
$ cd demo-base
$ java -jar ../start.jar
This warning may be disabled by setting the system property
-Dorg.eclipse.jetty.start.home.warning=false
============================================================================

View File

@ -115,7 +115,8 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
"org.eclipse.jetty.jndi.", // webapp cannot change naming classes
"org.eclipse.jetty.jaas.", // webapp cannot change jaas classes
"org.eclipse.jetty.websocket.", // webapp cannot change / replace websocket classes
"org.eclipse.jetty.util.log.", // webapp should use server log
"org.eclipse.jetty.util.log.", // webapp should use server log
"org.eclipse.jetty.servlet.ServletContextHandler.Decorator", // for CDI / weld use
"org.eclipse.jetty.servlet.DefaultServlet", // webapp cannot change default servlets
"org.eclipse.jetty.servlets.PushCacheFilter" //must be loaded by container classpath
} ;
@ -135,6 +136,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
"-org.eclipse.jetty.websocket.", // don't hide websocket classes from webapps (allow webapp to use ones from system classloader)
"-org.eclipse.jetty.apache.", // don't hide jetty apache impls
"-org.eclipse.jetty.util.log.", // don't hide server log
"-org.eclipse.jetty.servlet.ServletContextHandler.Decorator", // don't hide CDI / weld interface
"org.objectweb.asm.", // hide asm used by jetty
"org.eclipse.jdt.", // hide jdt used by jetty
"org.eclipse.jetty." // hide other jetty classes

View File

@ -471,6 +471,7 @@
<module>jetty-annotations</module>
<module>jetty-jndi</module>
<module>jetty-jaas</module>
<module>jetty-cdi</module>
<module>jetty-spring</module>
<module>jetty-client</module>
<module>jetty-proxy</module>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
// ========================================================================
// Copyright (c) Webtide LLC
//
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.apache.org/licenses/LICENSE-2.0.txt
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
-->
<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.tests</groupId>
<artifactId>test-cdi-parent</artifactId>
<version>9.2.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cdi-client</artifactId>
<packaging>jar</packaging>
<name>Jetty Tests :: CDI :: Clients</name>
<url>http://www.eclipse.org/jetty</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bundle-symbolic-name>${project.groupId}.cdi.clients</bundle-symbolic-name>
</properties>
<dependencies>
</dependencies>
</project>

View File

@ -0,0 +1,215 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
// ========================================================================
// Copyright (c) Webtide LLC
//
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.apache.org/licenses/LICENSE-2.0.txt
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
-->
<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.tests</groupId>
<artifactId>test-cdi-parent</artifactId>
<version>9.2.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cdi-webapp-it</artifactId>
<packaging>jar</packaging>
<name>Jetty Tests :: CDI :: WebApp Integration Tests</name>
<url>http://www.eclipse.org/jetty</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<bundle-symbolic-name>${project.groupId}.cdi.webapp.it</bundle-symbolic-name>
<scripts-dir>${project.basedir}/src/test/scripts</scripts-dir>
<test-base-dir>${project.build.directory}/test-base</test-base-dir>
<test-home-dir>${project.build.directory}/test-home</test-home-dir>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-distribution</artifactId>
<version>${project.version}</version>
<type>zip</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.tests</groupId>
<artifactId>cdi-webapp</artifactId>
<version>${project.version}</version>
<type>war</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-apps-for-testing</id>
<phase>process-test-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeArtifactIds>cdi-webapp</includeArtifactIds>
<includeScope>runtime</includeScope>
<includeTypes>war</includeTypes>
<overwriteSnapshots>true</overwriteSnapshots>
<overwriteReleases>true</overwriteReleases>
<stripVersion>true</stripVersion>
<outputDirectory>${test-base-dir}/webapps</outputDirectory>
</configuration>
</execution>
<execution>
<id>unpack-jetty-distro</id>
<phase>process-test-resources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeArtifactIds>jetty-distribution</includeArtifactIds>
<includeScope>runtime</includeScope>
<includeTypes>zip</includeTypes>
<outputAbsoluteArtifactFilename>true</outputAbsoluteArtifactFilename>
<outputDirectory>${test-home-dir}</outputDirectory>
<overWriteSnapshots>true</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="jetty.home" location="${test-home-dir}/jetty-distribution-${project.version}"/>
<property name="jetty.base" location="${test-base-dir}"/>
<echo>Integration Test : Setup Jetty</echo>
<exec executable="${run.command}"
dir="${scripts-dir}"
spawn="false">
<arg value="${run.command.xtra}"/>
<arg value="${setup.script}"/>
<arg file="${java.home}"/>
<arg file="${jetty.home}"/>
<arg file="${jetty.base}"/>
</exec>
<echo>Integration Test : Starting Jetty ...</echo>
<exec executable="${run.command}"
dir="${scripts-dir}"
spawn="true">
<arg value="${run.command.xtra}"/>
<arg value="${start.script}"/>
<arg file="${java.home}"/>
<arg file="${jetty.home}"/>
<arg file="${jetty.base}"/>
</exec>
<waitfor maxwait="5" maxwaitunit="second"
checkevery="100" checkeveryunit="millisecond">
<http url="http://localhost:58080/cdi-webapp/"/>
</waitfor>
<echo>Integration Test : Jetty is now available</echo>
</target>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="jetty.home" location="${test-home-dir}/jetty-distribution-${project.version}"/>
<property name="jetty.base" location="${test-base-dir}"/>
<echo>Integration Test : Stop Jetty</echo>
<exec executable="${run.command}"
dir="${scripts-dir}"
spawn="false">
<arg value="${run.command.xtra}"/>
<arg value="${stop.script}"/>
<arg file="${java.home}"/>
<arg file="${jetty.home}"/>
<arg file="${jetty.base}"/>
</exec>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>it-windows</id>
<activation>
<os>
<family>Windows</family>
</os>
</activation>
<properties>
<run.command>cmd</run.command>
<run.command.xtra>/c</run.command.xtra>
<start.script>start-jetty.bat</start.script>
<stop.script>stop-jetty.bat</stop.script>
</properties>
</profile>
<profile>
<id>it-unix</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<properties>
<run.command>sh</run.command>
<run.command.xtra>--</run.command.xtra>
<setup.script>setup-jetty.sh</setup.script>
<start.script>start-jetty.sh</start.script>
<stop.script>stop-jetty.sh</stop.script>
</properties>
</profile>
</profiles>
</project>

View File

@ -0,0 +1,41 @@
//
// ========================================================================
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.tests;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import java.net.URI;
import org.eclipse.jetty.toolchain.test.SimpleRequest;
import org.junit.Test;
/**
* Basic tests for a simple @WebServlet with no CDI
*/
public class HelloIT
{
@Test
public void testBasic() throws Exception
{
URI serverURI = new URI("http://localhost:58080/cdi-webapp/");
SimpleRequest req = new SimpleRequest(serverURI);
assertThat(req.getString("hello"),is("Hello World"));
}
}

View File

@ -0,0 +1,37 @@
//
// ========================================================================
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.tests;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import java.net.URI;
import org.eclipse.jetty.toolchain.test.SimpleRequest;
import org.junit.Test;
public class ServerInfoIT
{
@Test
public void testGET() throws Exception {
URI serverURI = new URI("http://localhost:58080/cdi-webapp/");
SimpleRequest req = new SimpleRequest(serverURI);
assertThat(req.getString("serverinfo"),is("Hello World"));
}
}

View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
JAVA_HOME=$1
JETTY_HOME=$2
JETTY_BASE=$3
echo \${java.home} : $JAVA_HOME
echo \${jetty.home} : $JETTY_HOME
echo \${jetty.base} : $JETTY_BASE
cd "$JETTY_BASE"
"$JAVA_HOME/bin/java" -jar "$JETTY_HOME/start.jar" \
--approve-all-licenses \
--add-to-start=deploy,http,annotations,cdi,logging
"$JAVA_HOME/bin/java" -jar "$JETTY_HOME/start.jar" \
--version

View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
JAVA_HOME=$1
JETTY_HOME=$2
JETTY_BASE=$3
echo \${java.home} : $JAVA_HOME
echo \${jetty.home} : $JETTY_HOME
echo \${jetty.base} : $JETTY_BASE
cd "$JETTY_BASE"
"$JAVA_HOME/bin/java" -jar "$JETTY_HOME/start.jar" \
jetty.port=58080 \
STOP.PORT=58181 STOP.KEY=it

View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
JAVA_HOME=$1
JETTY_HOME=$2
JETTY_BASE=$3
cd "$JETTY_BASE"
"$JAVA_HOME/bin/java" -jar "$JETTY_HOME/start.jar" \
--stop STOP.PORT=58181 STOP.KEY=it

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
// ========================================================================
// Copyright (c) Webtide LLC
//
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.apache.org/licenses/LICENSE-2.0.txt
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
-->
<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.tests</groupId>
<artifactId>test-cdi-parent</artifactId>
<version>9.2.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cdi-webapp</artifactId>
<packaging>war</packaging>
<name>Jetty Tests :: CDI :: WebApp</name>
<url>http://www.eclipse.org/jetty</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bundle-symbolic-name>${project.groupId}.cdi.webapp</bundle-symbolic-name>
</properties>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>cdi-webapp</finalName>
</build>
</project>

View File

@ -0,0 +1,42 @@
//
// ========================================================================
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.tests;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* The most basic servlet here, no CDI use.
*/
@SuppressWarnings("serial")
@WebServlet("/hello")
public class HelloServlet extends HttpServlet
{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
resp.setContentType("text/plain");
resp.getWriter().println("Hello World");
}
}

View File

@ -0,0 +1,54 @@
//
// ========================================================================
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.tests;
import java.io.IOException;
import java.io.PrintWriter;
import javax.inject.Inject;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@SuppressWarnings("serial")
@WebServlet("/serverinfo")
public class ServerInfoServlet extends HttpServlet
{
@Inject
private ServletContext context;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
resp.setContentType("text/plain");
PrintWriter out = resp.getWriter();
if (context == null)
{
out.println("context = null");
return;
}
out.printf("context = %s%n",context);
out.printf("context.contextPath = %s%n",context.getContextPath());
out.printf("context.effective-version = %d.%d%n",context.getEffectiveMajorVersion(),context.getEffectiveMinorVersion());
}
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>CDI Integration Test WebApp</display-name>
<listener>
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
<resource-env-ref>
<description>Object factory for the CDI Bean Manager</description>
<resource-env-ref-name>BeanManager</resource-env-ref-name>
<resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
</resource-env-ref>
</web-app>

35
tests/test-cdi/pom.xml Normal file
View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
// ========================================================================
// Copyright (c) Webtide LLC
//
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.apache.org/licenses/LICENSE-2.0.txt
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
-->
<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.tests</groupId>
<artifactId>tests-parent</artifactId>
<version>9.2.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-cdi-parent</artifactId>
<packaging>pom</packaging>
<name>Jetty Tests :: CDI Parent</name>
<url>http://www.eclipse.org/jetty</url>
<modules>
<module>cdi-webapp</module>
<module>cdi-webapp-it</module>
<module>cdi-client</module>
</modules>
</project>

View File

@ -118,13 +118,6 @@
<version>${project.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>