You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2016/05/18 10:42:58 UTC
[3/3] tomee git commit: TOMEE-1812 reload command for tomee embedded
TOMEE-1812 reload command for tomee embedded
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/b0d0eab1
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/b0d0eab1
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/b0d0eab1
Branch: refs/heads/master
Commit: b0d0eab14e8074ef1b003503038f8334bd14b4af
Parents: 643a9b0
Author: Romain manni-Bucau <rm...@gmail.com>
Authored: Wed May 18 12:41:16 2016 +0200
Committer: Romain manni-Bucau <rm...@gmail.com>
Committed: Wed May 18 12:41:16 2016 +0200
----------------------------------------------------------------------
.../maven/plugins/TomEEEmbeddedMojo.java | 241 +++++++++++++++++--
.../maven/plugins/TomEEEmbeddedMojoTest.java | 145 +++++++++--
.../src/test/java/org/superbiz/Endpoint.java | 13 +
.../tomee/catalina/TomcatWebAppBuilder.java | 7 +-
4 files changed, 360 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/b0d0eab1/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java
----------------------------------------------------------------------
diff --git a/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java b/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java
index c075beb..8f841b7 100644
--- a/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java
+++ b/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java
@@ -30,6 +30,10 @@ import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.UndeployException;
+import org.apache.openejb.assembler.classic.AppInfo;
+import org.apache.openejb.assembler.classic.Assembler;
import org.apache.openejb.core.ParentClassLoaderFinder;
import org.apache.openejb.core.ProvidedClassLoaderFinder;
import org.apache.openejb.loader.Files;
@@ -37,6 +41,7 @@ import org.apache.openejb.loader.IO;
import org.apache.openejb.loader.SystemInstance;
import org.apache.openejb.maven.util.MavenLogStreamFactory;
import org.apache.openejb.maven.util.XmlFormatter;
+import org.apache.openejb.spi.ContainerSystem;
import org.apache.openejb.util.JuliLogStreamFactory;
import org.apache.tomee.catalina.TomEERuntimeException;
import org.apache.tomee.embedded.Configuration;
@@ -45,17 +50,22 @@ import org.apache.tomee.livereload.LiveReloadInstaller;
import org.codehaus.plexus.configuration.PlexusConfiguration;
import org.codehaus.plexus.util.FileUtils;
+import javax.naming.NamingException;
import java.io.File;
+import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Scanner;
+import java.util.ServiceLoader;
import java.util.Set;
import java.util.logging.SimpleFormatter;
@@ -67,101 +77,191 @@ public class TomEEEmbeddedMojo extends AbstractMojo {
@Parameter(defaultValue = "${project.packaging}")
protected String packaging;
+ /**
+ * When not in classpath mode which war to deploy.
+ */
@Parameter(defaultValue = "${project.build.directory}/${project.build.finalName}")
protected File warFile;
+ /**
+ * HTTP port.
+ */
@Parameter(property = "tomee-embedded-plugin.http", defaultValue = "8080")
protected int httpPort;
+ /**
+ * HTTPS port if relevant.
+ */
@Parameter(property = "tomee-embedded-plugin.httpsPort", defaultValue = "8443")
protected int httpsPort;
- @Parameter(property = "tomee-embedded-plugin.ajp", defaultValue = "8009")
- protected int ajpPort = 8009;
-
+ /**
+ * Shutdown port.
+ */
@Parameter(property = "tomee-embedded-plugin.stop", defaultValue = "8005")
protected int stopPort;
+ /**
+ * Server host.
+ */
@Parameter(property = "tomee-embedded-plugin.host", defaultValue = "localhost")
protected String host;
- @Parameter(property = "tomee-embedded-plugin.lib", defaultValue = "${project.build.directory}/apache-tomee-embedded")
+ /**
+ * Temporary working directory.
+ */
+ @Parameter(property = "tomee-embedded-plugin.dir", defaultValue = "${project.build.directory}/apache-tomee-embedded")
protected String dir;
+ /**
+ * For https connector the keystore location.
+ */
@Parameter(property = "tomee-embedded-plugin.keystoreFile")
protected String keystoreFile;
+ /**
+ * For https connector the keystore password.
+ */
@Parameter(property = "tomee-embedded-plugin.keystorePass")
protected String keystorePass;
+ /**
+ * For https connector the keystore type.
+ */
@Parameter(property = "tomee-embedded-plugin.keystoreType", defaultValue = "JKS")
protected String keystoreType;
+ /**
+ * For https connector if client auth is activated.
+ */
@Parameter(property = "tomee-embedded-plugin.clientAuth")
protected String clientAuth;
+ /**
+ * For https connector the keystore alias to use.
+ */
@Parameter(property = "tomee-embedded-plugin.keyAlias")
protected String keyAlias;
+ /**
+ * For https connector the SSL protocol.
+ */
@Parameter(property = "tomee-embedded-plugin.sslProtocol")
protected String sslProtocol;
+ /**
+ * Where is the server.xml to use if provided.
+ */
@Parameter
protected File serverXml;
+ /**
+ * Is https activated.
+ */
@Parameter(property = "tomee-embedded-plugin.ssl", defaultValue = "false")
protected boolean ssl;
+ /**
+ * Is EJBd activated.
+ */
@Parameter(property = "tomee-embedded-plugin.withEjbRemote", defaultValue = "false")
protected boolean withEjbRemote;
+ /**
+ * Should we use a fast but unsecured session id generation implementation.
+ */
@Parameter(property = "tomee-embedded-plugin.quickSession", defaultValue = "true")
protected boolean quickSession;
+ /**
+ * Should we skip http connector (and rely only on other connectors if setup).
+ */
@Parameter(property = "tomee-embedded-plugin.skipHttp", defaultValue = "false")
protected boolean skipHttp;
+ /**
+ * Deploy the classpath as a webapp (instead of deploying a war).
+ */
@Parameter(property = "tomee-embedded-plugin.classpathAsWar", defaultValue = "false")
protected boolean classpathAsWar;
+ /**
+ * Use pom dependencies when classpathAsWar=true.
+ */
@Parameter(property = "tomee-embedded-plugin.useProjectClasspath", defaultValue = "true")
protected boolean useProjectClasspath;
+ /**
+ * Used to deactivate tomcat web resources caching (useful to get F5 working).
+ */
@Parameter(property = "tomee-embedded-plugin.webResourceCached", defaultValue = "true")
protected boolean webResourceCached;
+ /**
+ * Avoid to create multiple classloaders and use root one for the application.
+ */
@Parameter(property = "tomee-embedded-plugin.singleClassLoader", defaultValue = "false" /* for compat */)
protected boolean singleClassLoader;
+ /**
+ * Support for reload command (ie redeploy the webapp by undeploying/deploying).
+ */
+ @Parameter(property = "tomee-embedded-plugin.forceReloadable", defaultValue = "true")
+ protected boolean forceReloadable;
+
+ /**
+ * Additional modules.
+ */
@Parameter(property = "tomee-embedded-plugin.modules", defaultValue = "${project.build.outputDirectory}")
protected List<File> modules;
+ /**
+ * Where is docBase/web resources.
+ */
@Parameter(property = "tomee-embedded-plugin.docBase", defaultValue = "${project.basedir}/src/main/webapp")
protected File docBase;
+ /**
+ * Context name.
+ */
@Parameter(property = "tomee-embedded-plugin.context")
protected String context;
+ /**
+ * TomEE properties.
+ */
@Parameter // don't call it properties to avoid to break getConfig()
protected Map<String, String> containerProperties;
@Parameter(defaultValue = "${project}", readonly = true, required = true)
private MavenProject project;
+ /**
+ * Should TomEE use maven logging system instead of default one.
+ */
@Parameter(property = "tomee-embedded-plugin.mavenLog", defaultValue = "true")
private boolean mavenLog;
+ /**
+ * Don't try to update port/host in server.xml.
+ */
@Parameter(property = "tomee-embedded-plugin.keepServerXmlAsThis", defaultValue = "false")
private boolean keepServerXmlAsThis;
+ /**
+ * User/Password map.
+ */
@Parameter
private Map<String, String> users;
+ /**
+ * Role/users map.
+ */
@Parameter
private Map<String, String> roles;
/**
- * force webapp to be reloadable
+ * force webapp to be support JSP reloading.
*/
@Parameter(property = "tomee-plugin.jsp-development", defaultValue = "true")
private boolean forceJspDevelopment;
@@ -178,9 +278,15 @@ public class TomEEEmbeddedMojo extends AbstractMojo {
@Parameter(defaultValue = "${project.remoteArtifactRepositories}", readonly = true)
private List<ArtifactRepository> remoteRepos;
+ /**
+ * Additional applications to deploy.
+ */
@Parameter
private List<String> applications;
+ /**
+ * Scopes to take into account when deploying the project classpath.
+ */
@Parameter
private List<String> applicationScopes;
@@ -193,18 +299,33 @@ public class TomEEEmbeddedMojo extends AbstractMojo {
@Parameter(property = "tomee-plugin.work", defaultValue = "${project.build.directory}/tomee-embedded-work")
private File workDir;
+ /**
+ * serverl.xml content directly in the pom.xml.
+ */
@Parameter
protected PlexusConfiguration inlinedServerXml;
+ /**
+ * tomee.xml directly in the pom.xml.
+ */
@Parameter
protected PlexusConfiguration inlinedTomEEXml;
- @Parameter //a dvanced config but a simple boolean will be used for defaults (withLiveReload)
+ /**
+ * Advanced configuration for live reload (to change port, context...).
+ */
+ @Parameter //advanced config but a simple boolean will be used for defaults (withLiveReload)
private LiveReload liveReload;
+ /**
+ * Use livereload.
+ */
@Parameter(property = "tomee-plugin.liveReload", defaultValue = "false")
private boolean withLiveReload;
+ private Map<String, Command> commands;
+ private String deployedName;
+
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (!classpathAsWar && "pom".equals(packaging)) {
@@ -291,16 +412,7 @@ public class TomEEEmbeddedMojo extends AbstractMojo {
Runtime.getRuntime().addShutdownHook(hook);
- if (!skipCurrentProject) {
- if (!classpathAsWar) {
- container.deploy('/' + (context == null ? warFile.getName() : context), warFile, true);
- } else {
- if (useProjectClasspath) {
- thread.setContextClassLoader(createClassLoader(loader));
- }
- container.deployClasspathAsWebApp(context, docBase, singleClassLoader);
- }
- }
+ deployedName = doDeploy(thread, loader, container, useProjectClasspath);
if (applications != null && !applications.isEmpty()) {
Files.mkdirs(applicationCopyFolder);
@@ -329,7 +441,7 @@ public class TomEEEmbeddedMojo extends AbstractMojo {
try {
String line;
- final Scanner scanner = new Scanner(System.in);
+ final Scanner scanner = newScanner();
while ((line = scanner.nextLine()) != null) {
switch (line.trim()) {
case "exit":
@@ -337,6 +449,11 @@ public class TomEEEmbeddedMojo extends AbstractMojo {
Runtime.getRuntime().removeShutdownHook(hook);
container.close();
return;
+ case "reload":
+ reload(thread, loader, container);
+ break;
+ default:
+ onMissingCommand(line);
}
}
} catch (final Exception e) {
@@ -352,6 +469,67 @@ public class TomEEEmbeddedMojo extends AbstractMojo {
}
}
+ protected Scanner newScanner() {
+ return new Scanner(System.in);
+ }
+
+ private String doDeploy(final Thread thread, final ClassLoader loader, final Container container, final boolean useProjectClasspath) throws OpenEJBException, IOException, NamingException {
+ if (!skipCurrentProject) {
+ if (!classpathAsWar) {
+ final String name = '/' + (context == null ? warFile.getName() : context);
+ container.deploy(name, warFile, true);
+ return name;
+ } else {
+ if (useProjectClasspath) {
+ thread.setContextClassLoader(createClassLoader(loader));
+ }
+ container.deployClasspathAsWebApp(context, docBase, singleClassLoader);
+ }
+ }
+ return context;
+ }
+
+ protected void onMissingCommand(final String line) {
+ if (line == null) {
+ return;
+ }
+ if (commands == null) { // lazy loading
+ commands = new HashMap<>();
+ for (final Command c : ServiceLoader.load(Command.class)) {
+ commands.put(c.name(), c);
+ }
+ }
+ { // direct command
+ final Command c = commands.get(line.trim());
+ if (c != null) {
+ c.invoke(line);
+ return;
+ }
+ }
+ // else match by "startsWith" all possible commands
+ for (final Map.Entry<String, Command> c : commands.entrySet()) {
+ if (line.startsWith(c.getKey())) {
+ c.getValue().invoke(line);
+ }
+ }
+ }
+
+ protected synchronized void reload(final Thread thread, final ClassLoader loader, final Container container) throws OpenEJBException, NamingException, IOException {
+ getLog().info("Redeploying " + (deployedName == null ? '/' : deployedName));
+ try {
+ final Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
+ if (classpathAsWar) { // this doesn't track module names so no need to go through container.undeploy()
+ assembler.destroyApplication(assembler.getDeployedApplications().iterator().next().path);
+ } else {
+ container.undeploy(deployedName);
+ }
+ } catch (final UndeployException e) {
+ throw new IllegalStateException(e);
+ }
+ doDeploy(thread, loader, container, false/*already done*/);
+ getLog().info("Redeployed " + (deployedName == null ? '/' : deployedName));
+ }
+
private void installLiveReloadEndpointIfNeeded() {
if (withLiveReload && liveReload == null) {
liveReload = new LiveReload();
@@ -447,7 +625,7 @@ public class TomEEEmbeddedMojo extends AbstractMojo {
private Configuration getConfig() { // lazy way but it works fine
final Configuration config = new Configuration();
- for (final Field field : getClass().getDeclaredFields()) {
+ for (final Field field : TomEEEmbeddedMojo.class.getDeclaredFields()) {
try {
final Field configField = Configuration.class.getDeclaredField(field.getName());
field.setAccessible(true);
@@ -475,6 +653,33 @@ public class TomEEEmbeddedMojo extends AbstractMojo {
}
config.getProperties().put("tomee.jsp-development", "true");
}
+ if (forceReloadable) {
+ if (config.getProperties() == null) {
+ config.setProperties(new Properties());
+ }
+ config.getProperties().setProperty("tomee.force-reloadable", "true");
+ }
return config;
}
+
+ /**
+ * A potential command identified by a name.
+ *
+ * Note that reload and quit/exit are built in commands.
+ *
+ * It is recommanded to prefix the command by something specific to your set of commands.
+ */
+ public interface Command {
+ /**
+ * @return the string to invoke this comamnd.
+ */
+ String name();
+
+ /**
+ * Executes this command.
+ *
+ * @param line the raw line entered by the user.
+ */
+ void invoke(String line);
+ }
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/b0d0eab1/maven/tomee-embedded-maven-plugin/src/test/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojoTest.java
----------------------------------------------------------------------
diff --git a/maven/tomee-embedded-maven-plugin/src/test/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojoTest.java b/maven/tomee-embedded-maven-plugin/src/test/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojoTest.java
index 5b630a8..21a511a 100644
--- a/maven/tomee-embedded-maven-plugin/src/test/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojoTest.java
+++ b/maven/tomee-embedded-maven-plugin/src/test/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojoTest.java
@@ -25,54 +25,68 @@ import org.apache.openejb.util.NetworkUtil;
import org.junit.Test;
import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.util.HashMap;
+import java.util.Scanner;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
+import static java.lang.System.lineSeparator;
+import static java.lang.Thread.sleep;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
public class TomEEEmbeddedMojoTest {
@Test
- public void run() throws MojoFailureException, MojoExecutionException, IOException {
+ public void run() throws MojoFailureException, MojoExecutionException, IOException, InterruptedException {
+ final File docBase = new File("target/TomEEEmbeddedMojoTest/base");
+ docBase.mkdirs();
+ try (final FileWriter w = new FileWriter(new File(docBase, "index.html"))) {
+ w.write("initial");
+ }
+
+ // we use a dynamic InputStream to be able to simulate commands without hacking System.in
+ final Input input = new Input();
+ final Semaphore reloaded = new Semaphore(0);
final CountDownLatch started = new CountDownLatch(1);
- final TomEEEmbeddedMojo mojo = new TomEEEmbeddedMojo();
+ final TomEEEmbeddedMojo mojo = new TomEEEmbeddedMojo() {
+ @Override
+ protected Scanner newScanner() {
+ return new Scanner(input);
+ }
+ };
mojo.classpathAsWar = true;
mojo.httpPort = NetworkUtil.getNextAvailablePort();
mojo.ssl = false;
+ mojo.docBase = docBase;
+ mojo.forceReloadable = true;
+ mojo.webResourceCached = false;
mojo.containerProperties = new HashMap<>();
mojo.containerProperties.put(DeploymentFilterable.CLASSPATH_INCLUDE, ".*tomee-embedded-maven-plugin.*");
mojo.containerProperties.put("openejb.additional.include", "tomee-embedded-maven-plugin");
- mojo.setLog(new SystemStreamLog() { // not the best solution...
+ mojo.setLog(new SystemStreamLog() { // not the best solution but fine for now...
@Override
public void info(final CharSequence charSequence) {
final String string = charSequence.toString();
if (string.startsWith("TomEE embedded started on") || string.equals("can't start TomEE")) {
started.countDown();
+ } else if (string.contains("Redeployed /")) {
+ reloaded.release();
}
super.info(charSequence);
}
});
- final InputStream originalIn = System.in;
- final ByteArrayInputStream newIn = new ByteArrayInputStream("exit".getBytes());
- final CountDownLatch sendExitLatch = new CountDownLatch(1);
final CountDownLatch stopped = new CountDownLatch(1);
- System.setIn(new InputStream() {
- @Override
- public int read() throws IOException {
- try {
- sendExitLatch.await();
- } catch (final InterruptedException e) {
- Thread.interrupted();
- }
- return newIn.read();
- }
- });
final AtomicReference<Exception> error = new AtomicReference<>();
final Thread mojoThread = new Thread() {
@@ -93,22 +107,101 @@ public class TomEEEmbeddedMojoTest {
};
mojoThread.start();
try {
- try {
- started.await(10, TimeUnit.MINUTES);
+ started.await(10, TimeUnit.MINUTES);
+ } catch (final InterruptedException e) {
+ Thread.interrupted();
+ }
+
+ assertNull("all started fine", error.get());
+ assertEquals("ok", IO.slurp(new URL("http://localhost:" + mojo.httpPort + "/endpoint/")).trim());
+
+ long initTs = timestamp(mojo);
+
+ assertEquals("initial", IO.slurp(new URL("http://localhost:" + mojo.httpPort + "/")).trim());
+ try (final FileWriter w = new FileWriter(new File(docBase, "index.html"))) {
+ w.write("changed");
+ }
+ assertEquals("changed", IO.slurp(new URL("http://localhost:" + mojo.httpPort + "/")).trim());
+
+ assertEquals(timestamp(mojo), initTs);
+
+ for (int i = 0; i < 4; i++) { // ensure it works multiple times
+ System.out.println("Reloading, #" + (i + 1));
+
+ try { // ensure timestamp changed even on super fast machines
+ sleep(200);
} catch (final InterruptedException e) {
Thread.interrupted();
+ fail();
}
- assertNull("all started fine", error.get());
- assertEquals("ok", IO.slurp(new URL("http://localhost:" + mojo.httpPort + "/endpoint/")).trim());
- sendExitLatch.countDown();
- try {
- stopped.await(5, TimeUnit.MINUTES);
+ input.write("reload");
+ reloaded.tryAcquire(5, TimeUnit.MINUTES);
+ final long newTimestamp = timestamp(mojo);
+ assertTrue(Integer.toString(i) + " iteration", newTimestamp > initTs);
+ initTs = newTimestamp;
+
+ try { // check timestamp is fixed and we didn't code wrong the test
+ sleep(200);
} catch (final InterruptedException e) {
Thread.interrupted();
+ fail();
}
- } finally {
- System.setIn(originalIn);
+ assertEquals(timestamp(mojo), initTs);
+
+ }
+
+ input.write("exit");
+ stopped.await(5, TimeUnit.MINUTES);
+ input.close();
+ }
+
+ private long timestamp(final TomEEEmbeddedMojo mojo) throws IOException {
+ return Long.parseLong(IO.slurp(new URL("http://localhost:" + mojo.httpPort + "/endpoint/timestamp")).trim());
+ }
+
+ private static final class Input extends InputStream {
+ private final Semaphore inputSema = new Semaphore(0);
+ private InputStream currentInput = null;
+ private boolean metEnd = true;
+
+ private void write(final String data) {
+ try {
+ currentInput = new ByteArrayInputStream((data + lineSeparator()).getBytes("UTF-8"));
+ } catch (final UnsupportedEncodingException e) {
+ currentInput = new ByteArrayInputStream((data + lineSeparator()).getBytes());
+ }
+ inputSema.release();
+ }
+
+ @Override
+ public int read() throws IOException {
+ int read;
+ if (currentInput == null || (read = currentInput.read()) < 0) {
+ if (!metEnd) { // ensure scanner gets an end event
+ metEnd = true;
+ currentInput = null;
+ return -1;
+ }
+
+ try {
+ inputSema.acquire(1);
+ } catch (final InterruptedException e) {
+ Thread.interrupted();
+ fail();
+ }
+ read = currentInput != null ? currentInput.read() : -1;
+ if (read > 0) {
+ metEnd = false;
+ }
+ }
+ return read;
+ }
+
+ @Override
+ public void close() throws IOException {
+ inputSema.release();
+ super.close();
}
}
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/b0d0eab1/maven/tomee-embedded-maven-plugin/src/test/java/org/superbiz/Endpoint.java
----------------------------------------------------------------------
diff --git a/maven/tomee-embedded-maven-plugin/src/test/java/org/superbiz/Endpoint.java b/maven/tomee-embedded-maven-plugin/src/test/java/org/superbiz/Endpoint.java
index d06d67f..c6d7243 100644
--- a/maven/tomee-embedded-maven-plugin/src/test/java/org/superbiz/Endpoint.java
+++ b/maven/tomee-embedded-maven-plugin/src/test/java/org/superbiz/Endpoint.java
@@ -16,13 +16,26 @@
*/
package org.superbiz;
+import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
@Path("endpoint")
+@Produces(MediaType.TEXT_PLAIN)
+@ApplicationScoped
public class Endpoint {
+ private final long init = System.currentTimeMillis();
+
@GET
public String get() {
return "ok";
}
+
+ @GET
+ @Path("timestamp")
+ public long timestamp() {
+ return init;
+ }
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/b0d0eab1/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
index 01fa3d0..8a6aa73 100644
--- a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
+++ b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
@@ -811,8 +811,11 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
+ Contexts.getHostname(standardContext).replace("_", hosts.getDefaultHost()) + " -> "
+ finalName(standardContext.getPath()));
- if (FORCE_RELOADABLE && getContextInfo(standardContext) == null) { // don't do it for ears
- standardContext.setReloadable(true);
+ if (FORCE_RELOADABLE) {
+ final ContextInfo ctxInfo = getContextInfo(standardContext);
+ if (ctxInfo == null || (ctxInfo.appInfo != null && ctxInfo.appInfo.webAppAlone)) { // don't do it for ears
+ standardContext.setReloadable(true);
+ }
}
if (SKIP_TLD) {
if (standardContext.getJarScanner() != null && standardContext.getJarScanner().getJarScanFilter() != null) {