tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1510878 - in /tomee/tomee/trunk: maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/ tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/ tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/
Date Tue, 06 Aug 2013 07:53:29 GMT
Author: rmannibucau
Date: Tue Aug  6 07:53:28 2013
New Revision: 1510878

URL: http://svn.apache.org/r1510878
Log:
TOMEE-1014 making tomee webapp optional for ejbd

Added:
    tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/
    tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/TomEERemoteWebapp.java
Modified:
    tomee/tomee/trunk/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
    tomee/tomee/trunk/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/UpdatableTomEEMojo.java
    tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/GlobalListenerSupport.java
    tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/IgnoredStandardContext.java

Modified: tomee/tomee/trunk/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java?rev=1510878&r1=1510877&r2=1510878&view=diff
==============================================================================
--- tomee/tomee/trunk/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
(original)
+++ tomee/tomee/trunk/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
Tue Aug  6 07:53:28 2013
@@ -208,9 +208,12 @@ public abstract class AbstractTomEEMojo 
     @Parameter(property = "tomee-plugin.deploy-openejb-internal-application", defaultValue
= "false")
     protected boolean deployOpenEjbApplication;
 
-    @Parameter(property = "tomee-plugin.remove-tomee-webapps", defaultValue = "false")
+    @Parameter(property = "tomee-plugin.remove-tomee-webapps", defaultValue = "true")
     protected boolean removeTomeeWebapp;
 
+    @Parameter(property = "tomee-plugin.ejb-remote", defaultValue = "true")
+    protected boolean ejbRemote;
+
     @Parameter(defaultValue = "${project.packaging}", readonly = true)
     protected String packaging;
 
@@ -643,6 +646,9 @@ public abstract class AbstractTomEEMojo 
         if (quickSession) {
             strings.add("-Dopenejb.session.manager=org.apache.tomee.catalina.session.QuickSessionManager");
         }
+        if (removeTomeeWebapp && ejbRemote) { // if we have tomee webapp no need
to activate ejb remote support this way
+            strings.add("-Dtomee.remote.support=true");
+        }
         if (!deployOpenEjbApplication) { // true is the default so don't need to set the
property
             if (args == null || !args.contains("-D" + deployOpenEjbAppKey)) {
                 strings.add("-D" + deployOpenEjbAppKey + "=false");

Modified: tomee/tomee/trunk/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/UpdatableTomEEMojo.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/UpdatableTomEEMojo.java?rev=1510878&r1=1510877&r2=1510878&view=diff
==============================================================================
--- tomee/tomee/trunk/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/UpdatableTomEEMojo.java
(original)
+++ tomee/tomee/trunk/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/UpdatableTomEEMojo.java
Tue Aug  6 07:53:28 2013
@@ -84,8 +84,8 @@ public abstract class UpdatableTomEEMojo
             forceReloadable = true;
         }
 
-        if (removeTomeeWebapp) {
-            getLog().warn("TomEE webapp is asked to be removed (<removeTomeeWebapp>true</removeTomeeWebapp>)
so you can use reload feature");
+        if (removeTomeeWebapp && !ejbRemote) {
+            getLog().warn("TomEE webapp is asked to be removed (<ejbRemote>true>
or <removeTomeeWebapp>true</removeTomeeWebapp>) so you can use reload feature");
         }
 
         super.run();
@@ -330,8 +330,8 @@ public abstract class UpdatableTomEEMojo
     }
 
     private Deployer deployer() {
-        if (removeTomeeWebapp) {
-            throw new OpenEJBRuntimeException("Can't use reload feature without TomEE Webapp,
please set removeTomeeWebapp to false");
+        if (removeTomeeWebapp && !ejbRemote) {
+            throw new OpenEJBRuntimeException("Can't use reload feature without TomEE Webapp,
please set removeTomeeWebapp to false or ejbRemote to true");
         }
 
         final Properties properties = new Properties();

Modified: tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/GlobalListenerSupport.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/GlobalListenerSupport.java?rev=1510878&r1=1510877&r2=1510878&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/GlobalListenerSupport.java
(original)
+++ tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/GlobalListenerSupport.java
Tue Aug  6 07:53:28 2013
@@ -27,13 +27,14 @@ import org.apache.catalina.core.Standard
 import org.apache.catalina.core.StandardEngine;
 import org.apache.catalina.core.StandardHost;
 import org.apache.catalina.core.StandardServer;
+import org.apache.openejb.loader.SystemInstance;
 import org.apache.tomee.catalina.cluster.TomEEClusterListener;
+import org.apache.tomee.catalina.remote.TomEERemoteWebapp;
 import org.apache.tomee.loader.TomcatHelper;
 
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.lang.reflect.Field;
-import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
@@ -44,6 +45,7 @@ import java.util.Map;
  * @version $Rev$ $Date$
  */
 public class GlobalListenerSupport implements PropertyChangeListener, LifecycleListener {
+    private static final boolean REMOTE_SUPPORT = SystemInstance.get().getOptions().get("tomee.remote.support",
true);
 
     /**
      * The LifecycleEvent type for the "component init" event.
@@ -129,6 +131,8 @@ public class GlobalListenerSupport imple
             String type = event.getType();
             if (Lifecycle.PERIODIC_EVENT.equals(type)) {
                 contextListener.checkHost(standardHost);
+            } else if (Lifecycle.AFTER_START_EVENT.equals(type) && REMOTE_SUPPORT)
{
+                standardHost.addChild(new TomEERemoteWebapp());
             }
         } else if (StandardServer.class.isInstance(source)) {
             StandardServer standardServer = (StandardServer) source;

Modified: tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/IgnoredStandardContext.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/IgnoredStandardContext.java?rev=1510878&r1=1510877&r2=1510878&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/IgnoredStandardContext.java
(original)
+++ tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/IgnoredStandardContext.java
Tue Aug  6 07:53:28 2013
@@ -28,8 +28,8 @@ public class IgnoredStandardContext exte
         // Tomcat has a stupid rule where a life cycle listener must set
         // configured true, or it will treat it as a failed deployment
         addLifecycleListener(new LifecycleListener() {
-            public void lifecycleEvent(LifecycleEvent event) {
-                Context context = (Context) event.getLifecycle();
+            public void lifecycleEvent(final LifecycleEvent event) {
+                final Context context = Context.class.cast(event.getLifecycle());
                 if (event.getType().equals(Lifecycle.START_EVENT)
                         || event.getType().equals(Lifecycle.BEFORE_START_EVENT)
                         || event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) {

Added: tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/TomEERemoteWebapp.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/TomEERemoteWebapp.java?rev=1510878&view=auto
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/TomEERemoteWebapp.java
(added)
+++ tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/TomEERemoteWebapp.java
Tue Aug  6 07:53:28 2013
@@ -0,0 +1,132 @@
+/*
+ * 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.Container;
+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 java.beans.PropertyChangeListener;
+
+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());
+        setDelegate(true);
+        setName(CONTEXT_NAME);
+        setPath("/" + CONTEXT_NAME);
+        setLoader(new ServerClassLoaderLoader(this));
+    }
+
+    @Override
+    protected void initInternal() throws LifecycleException {
+        super.initInternal();
+        final Wrapper servlet = createWrapper();
+        servlet.setName(ServerServlet.class.getSimpleName());
+        servlet.setServletClass(ServerServlet.class.getName());
+        addChild(servlet);
+        addServletMapping(MAPPING, ServerServlet.class.getSimpleName());
+    }
+
+    private static class ServerClassLoaderLoader implements Loader {
+        private static final String[] EMPTY_ARRAY = new String[0];
+
+        private final TomEERemoteWebapp container;
+
+        public ServerClassLoaderLoader(final TomEERemoteWebapp tomEERemoteWebapp) {
+            container = tomEERemoteWebapp;
+        }
+
+        @Override
+        public void backgroundProcess() {
+            // no-op
+        }
+
+        @Override
+        public ClassLoader getClassLoader() {
+            return OpenEJB.class.getClassLoader();
+        }
+
+        @Override
+        public Container getContainer() {
+            return container;
+        }
+
+        @Override
+        public void setContainer(final Container container) {
+            // no-op
+        }
+
+        @Override
+        public boolean getDelegate() {
+            return true;
+        }
+
+        @Override
+        public void setDelegate(final boolean delegate) {
+            // no-op
+        }
+
+        @Override
+        public String getInfo() {
+            return ServerClassLoaderLoader.class.getName() + "/1.0";
+        }
+
+        @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 void addRepository(final String repository) {
+            // no-op
+        }
+
+        @Override
+        public String[] findRepositories() {
+            return EMPTY_ARRAY;
+        }
+
+        @Override
+        public boolean modified() {
+            return false;
+        }
+
+        @Override
+        public void removePropertyChangeListener(final PropertyChangeListener listener) {
+            // no-op
+        }
+    }
+}



Mime
View raw message