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/02/11 11:26:16 UTC

[2/2] tomee git commit: TOMEE-1709 livereload support in tomee-embedded plugin

TOMEE-1709 livereload support in tomee-embedded plugin


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/c273570d
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/c273570d
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/c273570d

Branch: refs/heads/master
Commit: c273570d8868b9cb6224b40caca1dc780a1668cd
Parents: c4bd863
Author: Romain manni-Bucau <rm...@gmail.com>
Authored: Thu Feb 11 11:25:52 2016 +0100
Committer: Romain manni-Bucau <rm...@gmail.com>
Committed: Thu Feb 11 11:25:52 2016 +0100

----------------------------------------------------------------------
 NOTICE                                          |    5 +-
 examples/cdi-ejbcontext-jaas/pom.xml            |    2 +-
 .../openejb/itest/legacy/LegacyServerTest.java" |  338 +++++
 maven/tomee-embedded-maven-plugin/pom.xml       |    5 +
 .../openejb/maven/plugins/LiveReload.java       |   47 +
 .../maven/plugins/TomEEEmbeddedMojo.java        |   25 +-
 pom.xml                                         |    1 +
 server/openejb-cxf-rs/pom.xml                   |    2 +-
 .../remote/ServerClassLoaderLoader.java         |  134 ++
 .../catalina/remote/TomEERemoteWebapp.java      |  119 +-
 .../apache/tomee/embedded/Configuration.java"   |  346 +++++
 .../org/apache/tomee/embedded/Container.java"   |  955 ++++++++++++++
 .../tomee/embedded/EmbeddedTomEEContainer.java" |  214 ++++
 .../tomee/embedded/LoginConfigBuilder.java"     |   65 +
 .../java/org/apache/tomee/embedded/Main.java"   |  136 ++
 .../embedded/SecurityConstaintBuilder.java"     |   59 +
 .../internal/StandardContextCustomizer.java"    |  111 ++
 .../embedded/junit/TomEEEmbeddedRule.java"      |  136 ++
 .../META-INF/org.apache.tomee/service-jar.xml"  |   53 +
 utils/livereload-tomee/pom.xml                  |   59 +
 .../org/apache/tomee/livereload/Command.java    |  115 ++
 .../apache/tomee/livereload/FileWatcher.java    |  168 +++
 .../org/apache/tomee/livereload/Instances.java  |   50 +
 .../tomee/livereload/LiveReloadEndpoint.java    |   79 ++
 .../tomee/livereload/LiveReloadInstaller.java   |  129 ++
 .../apache/tomee/livereload/LiveReloadJs.java   |   49 +
 .../src/main/resources/META-INF/LICENSE         |  212 ++++
 .../src/main/resources/META-INF/NOTICE          |    6 +
 .../src/main/resources/js/livereload.js         | 1183 ++++++++++++++++++
 utils/pom.xml                                   |    1 +
 30 files changed, 4682 insertions(+), 122 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/NOTICE
----------------------------------------------------------------------
diff --git a/NOTICE b/NOTICE
index c0a29c0..46c5e7d 100644
--- a/NOTICE
+++ b/NOTICE
@@ -27,4 +27,7 @@ You can obtain a copy of the License at: https://github.com/wycats/handlebars.js
 You can obtain a copy of the License at: http://codemirror.net/LICENSE
 
 "require.js" is licensed under the MIT License.
-You can obtain a copy of the License at: https://github.com/jrburke/requirejs/blob/master/LICENSE
\ No newline at end of file
+You can obtain a copy of the License at: https://github.com/jrburke/requirejs/blob/master/LICENSE
+
+"livereload.js" is licensed under the MIT License.
+You can obtain a copy of the License at: https://github.com/livereload/livereload-js/blob/master/LICENSE
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/examples/cdi-ejbcontext-jaas/pom.xml
----------------------------------------------------------------------
diff --git a/examples/cdi-ejbcontext-jaas/pom.xml b/examples/cdi-ejbcontext-jaas/pom.xml
index e74f598..2db90f3 100644
--- a/examples/cdi-ejbcontext-jaas/pom.xml
+++ b/examples/cdi-ejbcontext-jaas/pom.xml
@@ -37,7 +37,7 @@
     <dependency>
       <groupId>org.apache.tomcat</groupId>
       <artifactId>tomcat-catalina</artifactId>
-      <version>7.0.29</version>
+      <version>8.0.32</version>
       <scope>provided</scope>
     </dependency>
     <dependency>

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/"itests/legacy-server\263src/test/java/org/apache/openejb/itest/legacy/LegacyServerTest.java"
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/maven/tomee-embedded-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/maven/tomee-embedded-maven-plugin/pom.xml b/maven/tomee-embedded-maven-plugin/pom.xml
index 1b50062..d2df4fa 100644
--- a/maven/tomee-embedded-maven-plugin/pom.xml
+++ b/maven/tomee-embedded-maven-plugin/pom.xml
@@ -65,6 +65,11 @@
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.tomee</groupId>
+      <artifactId>livereload-tomee</artifactId>
+      <version>${project.version}</version>
+    </dependency>
   </dependencies>
 
   <properties>

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/LiveReload.java
----------------------------------------------------------------------
diff --git a/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/LiveReload.java b/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/LiveReload.java
new file mode 100644
index 0000000..db37f5a
--- /dev/null
+++ b/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/LiveReload.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+package org.apache.openejb.maven.plugins;
+
+public class LiveReload {
+    private String watchedFolder;
+    private String path = "/"; // then endpoint is bound to /livereload so to match default we need to set it to ROOT
+    private int port = 35729;
+
+    public String getWatchedFolder() {
+        return watchedFolder;
+    }
+
+    public void setWatchedFolder(final String watchedFolder) {
+        this.watchedFolder = watchedFolder;
+    }
+
+    public String getPath() {
+        return path.startsWith("/") ? path : ('/' + path);
+    }
+
+    public void setPath(final String path) {
+        this.path = path;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public void setPort(final int port) {
+        this.port = port;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/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 346ce1e..845683e 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
@@ -41,6 +41,7 @@ import org.apache.openejb.util.JuliLogStreamFactory;
 import org.apache.tomee.catalina.TomEERuntimeException;
 import org.apache.tomee.embedded.Configuration;
 import org.apache.tomee.embedded.Container;
+import org.apache.tomee.livereload.LiveReloadInstaller;
 import org.codehaus.plexus.configuration.PlexusConfiguration;
 import org.codehaus.plexus.util.FileUtils;
 
@@ -195,6 +196,12 @@ public class TomEEEmbeddedMojo extends AbstractMojo {
     @Parameter
     protected PlexusConfiguration inlinedTomEEXml;
 
+    @Parameter //a dvanced config but a simple boolean will be used for defaults (withLiveReload)
+    private LiveReload liveReload;
+
+    @Parameter(property = "tomee-plugin.liveReload", defaultValue = "false")
+    private boolean withLiveReload;
+
     @Override
     public void execute() throws MojoExecutionException, MojoFailureException {
         if (!classpathAsWar && "pom".equals(packaging)) {
@@ -262,6 +269,9 @@ public class TomEEEmbeddedMojo extends AbstractMojo {
                             container.undeploy(warFile.getAbsolutePath());
                         }
                         container.stop();
+                    } catch (final NoClassDefFoundError noClassDefFoundError) {
+                        // debug cause it is too late to shutdown properly so don't pollute logs
+                        getLog().debug("can't stop TomEE", noClassDefFoundError);
                     } catch (final Exception e) {
                         getLog().error("can't stop TomEE", e);
                     } finally {
@@ -312,6 +322,8 @@ public class TomEEEmbeddedMojo extends AbstractMojo {
             getLog().error("can't start TomEE", e);
         }
 
+        installLiveReloadEndpointIfNeeded();
+
         try {
             String line;
             final Scanner scanner = new Scanner(System.in);
@@ -337,6 +349,17 @@ public class TomEEEmbeddedMojo extends AbstractMojo {
         }
     }
 
+    private void installLiveReloadEndpointIfNeeded() {
+        if (withLiveReload && liveReload == null) {
+            liveReload = new LiveReload();
+        }
+        if (liveReload != null) {
+            LiveReloadInstaller.install(
+                liveReload.getPath(), liveReload.getPort(),
+                liveReload.getWatchedFolder() == null ? docBase.getAbsolutePath() : liveReload.getWatchedFolder());
+        }
+    }
+
     private File mvnToFile(final String lib) throws Exception {
         final String[] infos = lib.split(":");
         final String classifier;
@@ -389,7 +412,7 @@ public class TomEEEmbeddedMojo extends AbstractMojo {
         for (final Artifact artifact : (Set<Artifact>) project.getArtifacts()) {
             final String scope = artifact.getScope();
             if ((applicationScopes == null && !(Artifact.SCOPE_COMPILE.equals(scope) || Artifact.SCOPE_RUNTIME.equals(scope)))
-                    || (applicationScopes != null && !applicationScopes.contains(scope))) {
+                || (applicationScopes != null && !applicationScopes.contains(scope))) {
                 continue;
             }
             try {

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 8493357..f3bfd7c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -99,6 +99,7 @@
     <openjpa.version>2.4.0</openjpa.version>
     <org.apache.openwebbeans.version>1.6.2</org.apache.openwebbeans.version>
     <jcs.version>2.0-M1</jcs.version>
+    <johnzon.version>0.9.2-incubating</johnzon.version>
 
     <!-- Maven module versions -->
     <maven-bundle-plugin.version>2.3.7</maven-bundle-plugin.version>

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/server/openejb-cxf-rs/pom.xml
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/pom.xml b/server/openejb-cxf-rs/pom.xml
index acd3fd6..60e2420 100644
--- a/server/openejb-cxf-rs/pom.xml
+++ b/server/openejb-cxf-rs/pom.xml
@@ -117,7 +117,7 @@
     <dependency> <!-- JohnzonProvider, WadlDocumentMessageBodyWriter and JsrProvider -->
       <groupId>org.apache.johnzon</groupId>
       <artifactId>johnzon-jaxrs</artifactId>
-      <version>0.9.2-incubating</version>
+      <version>${johnzon.version}</version>
     </dependency>
   </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/ServerClassLoaderLoader.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/ServerClassLoaderLoader.java b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/ServerClassLoaderLoader.java
new file mode 100644
index 0000000..b47c9d4
--- /dev/null
+++ b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/ServerClassLoaderLoader.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+package org.apache.tomee.catalina.remote;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Loader;
+
+import java.beans.PropertyChangeListener;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+public class ServerClassLoaderLoader implements Loader {
+    private final Context container;
+    private final FakeWebAppLoader classloader;
+
+    public ServerClassLoaderLoader(final Context tomEERemoteWebapp) {
+        container = tomEERemoteWebapp;
+        classloader = new FakeWebAppLoader(ServerClassLoaderLoader.class.getClassLoader());
+    }
+
+    @Override
+    public void backgroundProcess() {
+        // no-op
+    }
+
+    @Override
+    public ClassLoader getClassLoader() {
+        return classloader;
+    }
+
+    @Override
+    public Context getContext() {
+        return container;
+    }
+
+    @Override
+    public void setContext(final Context context) {
+        // no-op
+    }
+
+    @Override
+    public boolean getDelegate() {
+        return true;
+    }
+
+    @Override
+    public void setDelegate(final boolean delegate) {
+        // no-op
+    }
+
+    @Override
+    public boolean getReloadable() {
+        return false;
+    }
+
+    @Override
+    public void setReloadable(final boolean reloadable) {
+        // no-op
+    }
+
+    @Override
+    public void addPropertyChangeListener(final PropertyChangeListener listener) {
+        // no-op
+    }
+
+    @Override
+    public boolean modified() {
+        return false;
+    }
+
+    @Override
+    public void removePropertyChangeListener(final PropertyChangeListener listener) {
+        // no-op
+    }
+
+    // mainly for StandardContext.setClassLoaderProperty() otherwise OpenEJB.class.getClassLoader() would be fine
+    public static class FakeWebAppLoader extends URLClassLoader {
+        // ignored but validated by tomcat, avoid warnings
+        private boolean clearReferencesHttpClientKeepAliveThread;
+        private boolean clearReferencesStopThreads;
+        private boolean clearReferencesStopTimerThreads;
+        private boolean clearReferencesStatic;
+
+        public FakeWebAppLoader(final ClassLoader classLoader) {
+            super(new URL[0], classLoader);
+        }
+
+        public boolean isClearReferencesHttpClientKeepAliveThread() {
+            return clearReferencesHttpClientKeepAliveThread;
+        }
+
+        public void setClearReferencesHttpClientKeepAliveThread(final boolean clearReferencesHttpClientKeepAliveThread) {
+            this.clearReferencesHttpClientKeepAliveThread = clearReferencesHttpClientKeepAliveThread;
+        }
+
+        public boolean isClearReferencesStopThreads() {
+            return clearReferencesStopThreads;
+        }
+
+        public void setClearReferencesStopThreads(final boolean clearReferencesStopThreads) {
+            this.clearReferencesStopThreads = clearReferencesStopThreads;
+        }
+
+        public boolean isClearReferencesStopTimerThreads() {
+            return clearReferencesStopTimerThreads;
+        }
+
+        public void setClearReferencesStopTimerThreads(final boolean clearReferencesStopTimerThreads) {
+            this.clearReferencesStopTimerThreads = clearReferencesStopTimerThreads;
+        }
+
+        public boolean isClearReferencesStatic() {
+            return clearReferencesStatic;
+        }
+
+        public void setClearReferencesStatic(final boolean clearReferencesStatic) {
+            this.clearReferencesStatic = clearReferencesStatic;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/TomEERemoteWebapp.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/TomEERemoteWebapp.java b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/TomEERemoteWebapp.java
index 86eec6d..dbac236 100644
--- a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/TomEERemoteWebapp.java
+++ b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/TomEERemoteWebapp.java
@@ -16,27 +16,20 @@
  */
 package org.apache.tomee.catalina.remote;
 
-import org.apache.catalina.Context;
 import org.apache.catalina.LifecycleException;
-import org.apache.catalina.Loader;
 import org.apache.catalina.Wrapper;
-import org.apache.openejb.OpenEJB;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.server.httpd.ServerServlet;
 import org.apache.tomee.catalina.IgnoredStandardContext;
 import org.apache.tomee.catalina.OpenEJBValve;
 
-import java.beans.PropertyChangeListener;
-import java.net.URL;
-import java.net.URLClassLoader;
-
 public class TomEERemoteWebapp extends IgnoredStandardContext {
     private static final String CONTEXT_NAME = SystemInstance.get().getProperty("tomee.remote.support.context", "/tomee");
     private static final String MAPPING = SystemInstance.get().getProperty("tomee.remote.support.mapping", "/ejb");
 
     public TomEERemoteWebapp() {
         setDocBase("");
-        setParentClassLoader(OpenEJB.class.getClassLoader());
+        setParentClassLoader(TomEERemoteWebapp.class.getClassLoader());
         setDelegate(true);
         setName(CONTEXT_NAME);
         setPath(CONTEXT_NAME);
@@ -53,114 +46,4 @@ public class TomEERemoteWebapp extends IgnoredStandardContext {
         addChild(servlet);
         addServletMapping(MAPPING, ServerServlet.class.getSimpleName());
     }
-
-    private static class ServerClassLoaderLoader implements Loader {
-        private final TomEERemoteWebapp container;
-        private final FakeWebAppLoader classloader;
-
-        public ServerClassLoaderLoader(final TomEERemoteWebapp tomEERemoteWebapp) {
-            container = tomEERemoteWebapp;
-            classloader = new FakeWebAppLoader(OpenEJB.class.getClassLoader());
-        }
-
-        @Override
-        public void backgroundProcess() {
-            // no-op
-        }
-
-        @Override
-        public ClassLoader getClassLoader() {
-            return classloader;
-        }
-
-        @Override
-        public Context getContext() {
-            return container;
-        }
-
-        @Override
-        public void setContext(final Context context) {
-            // no-op
-        }
-
-        @Override
-        public boolean getDelegate() {
-            return true;
-        }
-
-        @Override
-        public void setDelegate(final boolean delegate) {
-            // no-op
-        }
-
-        @Override
-        public boolean getReloadable() {
-            return false;
-        }
-
-        @Override
-        public void setReloadable(final boolean reloadable) {
-            // no-op
-        }
-
-        @Override
-        public void addPropertyChangeListener(final PropertyChangeListener listener) {
-            // no-op
-        }
-
-        @Override
-        public boolean modified() {
-            return false;
-        }
-
-        @Override
-        public void removePropertyChangeListener(final PropertyChangeListener listener) {
-            // no-op
-        }
-    }
-
-    // mainly for StandardContext.setClassLoaderProperty() otherwise OpenEJB.class.getClassLoader() would be fine
-    public static class FakeWebAppLoader extends URLClassLoader {
-        // ignored but validated by tomcat, avoid warnings
-        private boolean clearReferencesHttpClientKeepAliveThread;
-        private boolean clearReferencesStopThreads;
-        private boolean clearReferencesStopTimerThreads;
-        private boolean clearReferencesStatic;
-
-        public FakeWebAppLoader(final ClassLoader classLoader) {
-            super(new URL[0], classLoader);
-        }
-
-        public boolean isClearReferencesHttpClientKeepAliveThread() {
-            return clearReferencesHttpClientKeepAliveThread;
-        }
-
-        public void setClearReferencesHttpClientKeepAliveThread(final boolean clearReferencesHttpClientKeepAliveThread) {
-            this.clearReferencesHttpClientKeepAliveThread = clearReferencesHttpClientKeepAliveThread;
-        }
-
-        public boolean isClearReferencesStopThreads() {
-            return clearReferencesStopThreads;
-        }
-
-        public void setClearReferencesStopThreads(final boolean clearReferencesStopThreads) {
-            this.clearReferencesStopThreads = clearReferencesStopThreads;
-        }
-
-        public boolean isClearReferencesStopTimerThreads() {
-            return clearReferencesStopTimerThreads;
-        }
-
-        public void setClearReferencesStopTimerThreads(final boolean clearReferencesStopTimerThreads) {
-            this.clearReferencesStopTimerThreads = clearReferencesStopTimerThreads;
-        }
-
-        public boolean isClearReferencesStatic() {
-            return clearReferencesStatic;
-        }
-
-        public void setClearReferencesStatic(final boolean clearReferencesStatic) {
-            this.clearReferencesStatic = clearReferencesStatic;
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/"tomee/tomee-embedded\271src/main/java/org/apache/tomee/embedded/Configuration.java"
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/"tomee/tomee-embedded\271src/main/java/org/apache/tomee/embedded/Container.java"
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/"tomee/tomee-embedded\273src/main/java/org/apache/tomee/embedded/EmbeddedTomEEContainer.java"
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/"tomee/tomee-embedded\273src/main/java/org/apache/tomee/embedded/LoginConfigBuilder.java"
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/"tomee/tomee-embedded\273src/main/java/org/apache/tomee/embedded/Main.java"
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/"tomee/tomee-embedded\273src/main/java/org/apache/tomee/embedded/SecurityConstaintBuilder.java"
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/"tomee/tomee-embedded\273src/main/java/org/apache/tomee/embedded/internal/StandardContextCustomizer.java"
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/"tomee/tomee-embedded\273src/main/java/org/apache/tomee/embedded/junit/TomEEEmbeddedRule.java"
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/"tomee/tomee-embedded\273src/main/resources/META-INF/org.apache.tomee/service-jar.xml"
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/utils/livereload-tomee/pom.xml
----------------------------------------------------------------------
diff --git a/utils/livereload-tomee/pom.xml b/utils/livereload-tomee/pom.xml
new file mode 100644
index 0000000..61bed98
--- /dev/null
+++ b/utils/livereload-tomee/pom.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<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>
+    <artifactId>utils</artifactId>
+    <groupId>org.apache.tomee</groupId>
+    <version>7.0.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>livereload-tomee</artifactId>
+  <name>OpenEJB :: Utils :: LiveReload</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.tomcat</groupId>
+      <artifactId>tomcat-catalina</artifactId>
+      <version>${tomcat.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomcat</groupId>
+      <artifactId>tomcat-websocket</artifactId>
+      <version>${tomcat.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.johnzon</groupId>
+      <artifactId>johnzon-mapper</artifactId>
+      <version>${johnzon.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>tomee-catalina</artifactId>
+      <version>${project.version}</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/Command.java
----------------------------------------------------------------------
diff --git a/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/Command.java b/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/Command.java
new file mode 100644
index 0000000..24328b5
--- /dev/null
+++ b/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/Command.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+package org.apache.tomee.livereload;
+
+import org.apache.johnzon.mapper.JohnzonIgnore;
+
+import java.util.Collection;
+import java.util.Map;
+
+public class Command {
+    private String command;
+
+    // hello
+    private String serverName;
+    private Collection<String> protocols;
+
+    // update client-server
+    private String url;
+
+    // update server-client
+    private String path;
+    private Boolean liveCss;
+
+    // info
+    private Map<String, Object> plugins;
+
+    // alert: not used
+    // String message
+
+
+    public String getCommand() {
+        return command;
+    }
+
+    public void setCommand(final String command) {
+        this.command = command;
+    }
+
+    public String getServerName() {
+        return serverName;
+    }
+
+    public void setServerName(final String serverName) {
+        this.serverName = serverName;
+    }
+
+    public Map<String, Object> getPlugins() {
+        return plugins;
+    }
+
+    public void setPlugins(final Map<String, Object> plugins) {
+        this.plugins = plugins;
+    }
+
+    public Collection<String> getProtocols() {
+        return protocols;
+    }
+
+    public void setProtocols(final Collection<String> protocols) {
+        this.protocols = protocols;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(final String url) {
+        this.url = url;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(final String path) {
+        this.path = path;
+    }
+
+    public Boolean getLiveCss() {
+        return liveCss;
+    }
+
+    public void setLiveCss(final Boolean liveCss) {
+        this.liveCss = liveCss;
+    }
+
+    @JohnzonIgnore
+    public boolean isHello() {
+        return "hello".equals(command);
+    }
+
+    @JohnzonIgnore
+    public boolean isClientUpdate() {
+        return "url".equals(command);
+    }
+
+    @JohnzonIgnore
+    public boolean isInfo() {
+        return "info".equals(command);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/FileWatcher.java
----------------------------------------------------------------------
diff --git a/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/FileWatcher.java b/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/FileWatcher.java
new file mode 100644
index 0000000..f748495
--- /dev/null
+++ b/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/FileWatcher.java
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+package org.apache.tomee.livereload;
+
+import org.apache.johnzon.mapper.Mapper;
+import org.apache.openejb.util.LogCategory;
+import org.apache.openejb.util.Logger;
+
+import javax.websocket.CloseReason;
+import javax.websocket.Session;
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.ClosedWatchServiceException;
+import java.nio.file.Path;
+import java.nio.file.StandardWatchEventKinds;
+import java.nio.file.WatchEvent;
+import java.nio.file.WatchKey;
+import java.nio.file.WatchService;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+public class FileWatcher {
+    private final Logger logger;
+    private final Mapper mapper;
+    private final Collection<Session> sessions = new ArrayList<>();
+
+    public FileWatcher(final LogCategory logger, final Mapper mapper) {
+        this.logger = Logger.getInstance(logger, FileWatcher.class);
+        this.mapper = mapper;
+    }
+
+    public synchronized void addSession(final Session session) {
+        sessions.add(session);
+    }
+
+    public synchronized void removeSession(final Session session) {
+        sessions.remove(session);
+    }
+
+    public Closeable watch(final String folder) {
+        final File file = new File(folder);
+        if (!file.isDirectory()) {
+            throw new IllegalArgumentException(folder + " is not a directory");
+        }
+
+        try {
+            final AtomicBoolean again = new AtomicBoolean(true);
+            final Path path = file.getAbsoluteFile().toPath();
+            final WatchService watchService = path.getFileSystem().newWatchService();
+            path.register(watchService, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_DELETE, StandardWatchEventKinds.ENTRY_MODIFY);
+            final Thread watcherThread = new Thread(new Runnable() {
+                @Override
+                public void run() {
+                    while (again.get()) {
+                        try {
+                            final WatchKey key = watchService.poll(1, TimeUnit.SECONDS); // don't use take to not block forever
+                            if (key == null) {
+                                continue;
+                            }
+
+                            for (final WatchEvent<?> event : key.pollEvents()) {
+                                final WatchEvent.Kind<?> kind = event.kind();
+                                if (kind != StandardWatchEventKinds.ENTRY_CREATE
+                                    && kind != StandardWatchEventKinds.ENTRY_DELETE
+                                    && kind != StandardWatchEventKinds.ENTRY_MODIFY) {
+                                    continue;
+                                }
+
+                                final Path updatedPath = Path.class.cast(event.context());
+                                if (kind == StandardWatchEventKinds.ENTRY_DELETE || updatedPath.toFile().isFile()) {
+                                    final String path = updatedPath.toString();
+                                    if (path.endsWith("___jb_tmp___") || path.endsWith("___jb_old___")) {
+                                        continue;
+                                    } else if (path.endsWith("~")) {
+                                        onChange(path.replace(File.pathSeparatorChar, '/').substring(0, path.length() - 1));
+                                    } else {
+                                        onChange(path.replace(File.pathSeparatorChar, '/'));
+                                    }
+                                }
+                            }
+                            key.reset();
+                        } catch (final InterruptedException e) {
+                            Thread.interrupted();
+                            again.set(false);
+                        } catch (final ClosedWatchServiceException cwse) {
+                            // ok, we finished there
+                        }
+                    }
+                }
+            });
+            watcherThread.setName("livereload-tomee-watcher(" + folder + ")");
+            watcherThread.start();
+
+            return new Closeable() {
+                @Override
+                public void close() throws IOException {
+                    synchronized (this) {
+                        for (final Session s : sessions) {
+                            removeSession(s);
+                            try {
+                                s.close(new CloseReason(CloseReason.CloseCodes.GOING_AWAY, "container shutdowned"));
+                            } catch (final Exception e) {
+                                // ok: not important there
+                            }
+                        }
+                    }
+                    again.compareAndSet(true, false);
+                    try {
+                        watchService.close();
+                    } catch (final IOException ioe) {
+                        logger.warning("Error closing the watch service for " + folder + "(" + ioe.getMessage() + ")");
+                    }
+                    try {
+                        watcherThread.join(TimeUnit.MINUTES.toMillis(1));
+                    } catch (final InterruptedException e) {
+                        Thread.interrupted();
+                    }
+                }
+            };
+        } catch (final IOException e) {
+            throw new IllegalArgumentException(e);
+        }
+    }
+
+    private void onChange(final String path) {
+        final Command command = new Command();
+        command.setCommand("reload");
+        command.setPath(path);
+        command.setLiveCss(true); // TODO: check path to set it to false if not relevant?
+
+        final String asStr = mapper.writeObjectAsString(command);
+
+        final Collection<Session> copy;
+        synchronized (this) {
+            copy = new ArrayList<>(this.sessions);
+        }
+
+        int failed = 0;
+        for (final Session s : copy) {
+            try {
+                s.getBasicRemote().sendText(asStr);
+            } catch (final Exception e) {
+                logger.warning("Can't send one livereload update: " + e.getMessage());
+                failed++;
+            }
+        }
+        if (failed < copy.size()) {
+            logger.info("Updated livereload path: " + path);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/Instances.java
----------------------------------------------------------------------
diff --git a/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/Instances.java b/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/Instances.java
new file mode 100644
index 0000000..be5944a
--- /dev/null
+++ b/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/Instances.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+package org.apache.tomee.livereload;
+
+import org.apache.johnzon.mapper.Mapper;
+import org.apache.johnzon.mapper.MapperBuilder;
+import org.apache.openejb.util.LogCategory;
+
+// Important note: take care to not create cycles with instances returned in getters.
+public class Instances {
+    private static final Instances INSTANCE = new Instances();
+
+    public static Instances get() {
+        return INSTANCE;
+    }
+
+    private Instances() {
+        // no-op
+    }
+
+    private final LogCategory logCategory = LogCategory.OPENEJB.createChild("livereload");
+    private final Mapper mapper = new MapperBuilder().build();
+    private final FileWatcher watcher = new FileWatcher(logCategory, mapper);
+
+    public FileWatcher getWatcher() {
+        return watcher;
+    }
+
+    public Mapper getMapper() {
+        return mapper;
+    }
+
+    public LogCategory getLogCategory() {
+        return logCategory;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/LiveReloadEndpoint.java
----------------------------------------------------------------------
diff --git a/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/LiveReloadEndpoint.java b/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/LiveReloadEndpoint.java
new file mode 100644
index 0000000..85f8a9b
--- /dev/null
+++ b/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/LiveReloadEndpoint.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+package org.apache.tomee.livereload;
+
+import org.apache.johnzon.mapper.Mapper;
+import org.apache.openejb.util.Logger;
+import org.apache.openejb.util.OpenEjbVersion;
+
+import javax.websocket.CloseReason;
+import javax.websocket.OnClose;
+import javax.websocket.OnMessage;
+import javax.websocket.Session;
+import javax.websocket.server.ServerEndpoint;
+import java.io.IOException;
+
+import static java.util.Arrays.asList;
+
+@ServerEndpoint("/livereload")
+public class LiveReloadEndpoint {
+    private static final Command HELLO = new Command();
+    static {
+        HELLO.setCommand("hello");
+        HELLO.setProtocols(asList("http://livereload.com/protocols/official-7", "http://livereload.com/protocols/connection-check-1"));
+        HELLO.setServerName("Apache TomEE " + OpenEjbVersion.get().getVersion());
+    }
+
+    private final FileWatcher watcher;
+    private final Mapper mapper;
+    private final Logger logger;
+    private volatile boolean loggedInfo = false;
+
+    public LiveReloadEndpoint() {
+        this.watcher = Instances.get().getWatcher();
+        this.mapper = Instances.get().getMapper();
+        this.logger = Logger.getInstance(Instances.get().getLogCategory(), LiveReloadEndpoint.class);
+    }
+
+    @OnMessage
+    public void onMessage(final String msg, final Session session) {
+        final Command command = mapper.readObject(msg, Command.class);
+        if (command.isHello()) {
+            try {
+                session.getBasicRemote().sendText(mapper.writeObjectAsString(HELLO));
+            } catch (final IOException e) {
+                throw new IllegalStateException(e);
+            }
+            this.watcher.addSession(session);
+            logger.info("Registered livereload session #" + session.getId());
+        } else if (command.isClientUpdate()) {
+            logger.info("Ignoring livereload client update message: " + msg);
+        } else if (command.isInfo()) {
+            if (!loggedInfo) {
+                logger.info("Livereload registration:\n  - url:" + command.getUrl() + "\n  - plugins: " + command.getPlugins());
+                loggedInfo = true;
+            }
+        } else {
+            logger.info("Unknown livereload message: " + msg);
+        }
+    }
+
+    @OnClose
+    public void onClose(final CloseReason reason, final Session session) {
+        this.watcher.removeSession(session);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/LiveReloadInstaller.java
----------------------------------------------------------------------
diff --git a/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/LiveReloadInstaller.java b/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/LiveReloadInstaller.java
new file mode 100644
index 0000000..32425fe
--- /dev/null
+++ b/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/LiveReloadInstaller.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+package org.apache.tomee.livereload;
+
+import org.apache.catalina.Container;
+import org.apache.catalina.Engine;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.LifecycleState;
+import org.apache.catalina.Server;
+import org.apache.catalina.Service;
+import org.apache.catalina.Wrapper;
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.servlets.DefaultServlet;
+import org.apache.coyote.http11.Http11Protocol;
+import org.apache.openejb.server.httpd.ServerServlet;
+import org.apache.tomcat.websocket.server.WsSci;
+import org.apache.tomee.catalina.IgnoredStandardContext;
+import org.apache.tomee.catalina.OpenEJBValve;
+import org.apache.tomee.catalina.remote.ServerClassLoaderLoader;
+import org.apache.tomee.loader.TomcatHelper;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.http.HttpServlet;
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.Collections;
+
+
+public class LiveReloadInstaller {
+    private LiveReloadInstaller() {
+        // no-op
+    }
+
+    public static void install(String path, final int port, final String folder) {
+        final Server server = TomcatHelper.getServer();
+        if (server == null) {
+            throw new IllegalStateException("tomcat not yet starting");
+        }
+
+        final Service service = server.findServices()[0]; // checking which one is localhost could be better but should be fine
+        final Engine engine = Engine.class.cast(service.getContainer());
+        final Container host = engine.findChild(engine.getDefaultHost() /* likelly localhost */);
+        if (LifecycleState.STARTED != host.getState()) {
+            throw new IllegalStateException("host not started, call LiveReloadInstaller.install() later.");
+        }
+
+        // add connector
+        final Connector connector = new Connector(Http11Protocol.class.getName());
+        connector.setPort(port);
+        connector.setAttribute("connectionTimeout", "30000");
+        service.addConnector(connector);
+
+        // and the endpoint and start the watcher
+        final Closeable watch = Instances.get().getWatcher().watch(folder);
+        final LiveReloadWebapp liveReloadWebapp = new LiveReloadWebapp(path);
+        liveReloadWebapp.addApplicationLifecycleListener(new ServletContextListener() {
+            @Override
+            public void contextInitialized(final ServletContextEvent servletContextEvent) {
+                servletContextEvent.getServletContext().log("Started livereload server on port " + port);
+            }
+
+            @Override
+            public void contextDestroyed(final ServletContextEvent servletContextEvent) {
+                try {
+                    watch.close();
+                } catch (final IOException e) {
+                    // no-op: not that important, we shutdown anyway
+                }
+            }
+        });
+        host.addChild(liveReloadWebapp);
+    }
+
+    private static class LiveReloadWebapp extends IgnoredStandardContext {
+        private LiveReloadWebapp(final String path) {
+            final boolean isRoot = path == null || "/".equals(path) || "ROOT".equals(path);
+
+            setDocBase("");
+            setParentClassLoader(LiveReloadInstaller.class.getClassLoader());
+            setDelegate(true);
+            setName(isRoot ? "" : (path.startsWith("/") ? path : ('/' + path)));
+            setPath(getName());
+            setLoader(new ServerClassLoaderLoader(this));
+            addValve(new OpenEJBValve()); // Ensure security context is reset (ThreadLocal) for each request
+        }
+
+        @Override
+        protected void initInternal() throws LifecycleException {
+            super.initInternal();
+
+            {// fake/not really desired "/*" servlet to ensure in context valve we match the request and got to WS filter
+                final Wrapper servlet = createWrapper();
+                servlet.setName(DefaultServlet.class.getSimpleName());
+                servlet.setServletClass(DefaultServlet.class.getName());
+                addChild(servlet);
+                addServletMapping("/*", DefaultServlet.class.getSimpleName());
+            }
+
+            {// the js injected in the page
+                final Wrapper servlet = createWrapper();
+                servlet.setName(LiveReloadJs.class.getSimpleName());
+                servlet.setServletClass(LiveReloadJs.class.getName());
+                addChild(servlet);
+                addServletMapping("/livereload.js", LiveReloadJs.class.getSimpleName());
+            }
+        }
+
+        @Override
+        protected void startInternal() throws LifecycleException {
+            addServletContainerInitializer(new WsSci(), Collections.<Class<?>>singleton(LiveReloadEndpoint.class));
+            super.startInternal();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/LiveReloadJs.java
----------------------------------------------------------------------
diff --git a/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/LiveReloadJs.java b/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/LiveReloadJs.java
new file mode 100644
index 0000000..3d798cd
--- /dev/null
+++ b/utils/livereload-tomee/src/main/java/org/apache/tomee/livereload/LiveReloadJs.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+package org.apache.tomee.livereload;
+
+import org.apache.openejb.loader.IO;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class LiveReloadJs extends HttpServlet {
+    private byte[] js;
+
+    @Override
+    protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
+        resp.setContentType("application/javascript");
+        resp.getOutputStream().write(js);
+    }
+
+    @Override
+    public void init() throws ServletException {
+        super.init();
+        try (final InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("js/livereload.js")) {
+            final ByteArrayOutputStream out = new ByteArrayOutputStream();
+            IO.copy(is, out);
+            js = out.toByteArray();
+        } catch (final IOException e) {
+            throw new IllegalStateException("impossible to find livereload.js", e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/utils/livereload-tomee/src/main/resources/META-INF/LICENSE
----------------------------------------------------------------------
diff --git a/utils/livereload-tomee/src/main/resources/META-INF/LICENSE b/utils/livereload-tomee/src/main/resources/META-INF/LICENSE
new file mode 100644
index 0000000..be29f50
--- /dev/null
+++ b/utils/livereload-tomee/src/main/resources/META-INF/LICENSE
@@ -0,0 +1,212 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+-----------------------------
+
+The MIT License (MIT)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tomee/blob/c273570d/utils/livereload-tomee/src/main/resources/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/utils/livereload-tomee/src/main/resources/META-INF/NOTICE b/utils/livereload-tomee/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000..0dcffb3
--- /dev/null
+++ b/utils/livereload-tomee/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,6 @@
+Livereload.js is included in this plugin
+
+License: MIT
+Source: https://github.com/livereload/livereload-js
+Site: http://livereload.com/
+