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 2015/12/01 18:50:16 UTC

[1/2] tomee git commit: TOMEE-1672 user tx not available during deployment of the app

Repository: tomee
Updated Branches:
  refs/heads/master f79ce15f7 -> 4deaec5c4


TOMEE-1672 user tx not available during deployment of the app


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

Branch: refs/heads/master
Commit: 9a4e6fd4d4123cfade2f6f14a2ba930f64771f85
Parents: f79ce15
Author: Romain Manni-Bucau <rm...@gmail.com>
Authored: Tue Dec 1 18:50:39 2015 +0100
Committer: Romain Manni-Bucau <rm...@gmail.com>
Committed: Tue Dec 1 18:50:39 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/tomee/catalina/ContextListener.java  |  3 ++-
 .../org/apache/tomee/catalina/GlobalListenerSupport.java |  4 ++--
 .../org/apache/tomee/catalina/TomcatWebAppBuilder.java   | 11 ++++++++---
 3 files changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/9a4e6fd4/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/ContextListener.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/ContextListener.java b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/ContextListener.java
index 2fd0c3e..4ad1a87 100644
--- a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/ContextListener.java
+++ b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/ContextListener.java
@@ -16,6 +16,7 @@
  */
 package org.apache.tomee.catalina;
 
+import org.apache.catalina.LifecycleEvent;
 import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.core.StandardHost;
 import org.apache.catalina.core.StandardServer;
@@ -99,5 +100,5 @@ public interface ContextListener {
      */
     void checkHost(StandardHost standardHost);
 
-    void configureStart(StandardContext standardContext);
+    void configureStart(LifecycleEvent event, StandardContext standardContext);
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/9a4e6fd4/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/GlobalListenerSupport.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/GlobalListenerSupport.java b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/GlobalListenerSupport.java
index 0bdf9cb..59759cb 100644
--- a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/GlobalListenerSupport.java
+++ b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/GlobalListenerSupport.java
@@ -130,7 +130,7 @@ public class GlobalListenerSupport implements PropertyChangeListener, LifecycleL
                     contextListener.destroy(standardContext);
                     break;
                 case Lifecycle.CONFIGURE_START_EVENT:
-                    contextListener.configureStart(standardContext);
+                    contextListener.configureStart(event, standardContext);
                     break;
                 default:
             }
@@ -157,7 +157,7 @@ public class GlobalListenerSupport implements PropertyChangeListener, LifecycleL
                 TomcatHelper.setStopping(true);
                 final TomEEClusterListener tomEEClusterListener = SystemInstance.get().getComponent(TomEEClusterListener.class);
                 if (tomEEClusterListener != null) {
-                    tomEEClusterListener.stop();
+                    TomEEClusterListener.stop();
                 }
             }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/9a4e6fd4/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 95b40cf..8949d97 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
@@ -21,6 +21,7 @@ import org.apache.catalina.Container;
 import org.apache.catalina.Engine;
 import org.apache.catalina.Host;
 import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleEvent;
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.LifecycleListener;
 import org.apache.catalina.LifecycleState;
@@ -1059,12 +1060,16 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare
     }
 
     @Override
-    public void configureStart(final StandardContext standardContext) {
-        TomcatHelper.configureJarScanner(standardContext);
-
+    public void configureStart(final LifecycleEvent event, final StandardContext standardContext) {
         final ContextTransaction contextTransaction = new ContextTransaction();
         contextTransaction.setProperty(org.apache.naming.factory.Constants.FACTORY, UserTransactionFactory.class.getName());
         standardContext.getNamingResources().setTransaction(contextTransaction);
+
+        // ensure NamingContext is available for eager usage (@Observes @Initialized(ApplicationScoped) for instance)
+        standardContext.getNamingContextListener().lifecycleEvent(event);
+
+        TomcatHelper.configureJarScanner(standardContext);
+
         startInternal(standardContext);
 
         // clear a bit log for default case


[2/2] tomee git commit: static cleanup

Posted by rm...@apache.org.
static cleanup


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

Branch: refs/heads/master
Commit: 4deaec5c4d259f1a28bf1a299852af5f0416a0f4
Parents: 9a4e6fd
Author: Romain Manni-Bucau <rm...@gmail.com>
Authored: Tue Dec 1 18:50:47 2015 +0100
Committer: Romain Manni-Bucau <rm...@gmail.com>
Committed: Tue Dec 1 18:50:47 2015 +0100

----------------------------------------------------------------------
 .../catalina/cluster/TomEEClusterListener.java  | 44 ++++++++++----------
 1 file changed, 21 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/4deaec5c/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/cluster/TomEEClusterListener.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/cluster/TomEEClusterListener.java b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/cluster/TomEEClusterListener.java
index 26e0037..63ccea0 100644
--- a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/cluster/TomEEClusterListener.java
+++ b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/cluster/TomEEClusterListener.java
@@ -31,14 +31,14 @@ import org.apache.openejb.util.DaemonThreadFactory;
 import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
 
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
 import java.io.File;
 import java.util.Properties;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 
 public class TomEEClusterListener extends ClusterListener {
     @Override
@@ -65,33 +65,33 @@ public class TomEEClusterListener extends ClusterListener {
                         file = dump.getAbsolutePath();
                         ioFile = new File(file);
 
-                        Static.STATIC.LOGGER.info("dumped archive: " + msg.getFile() + " to " + file);
+                        Static.LOGGER.info("dumped archive: " + msg.getFile() + " to " + file);
                     } catch (final Exception e) {
-                        Static.STATIC.LOGGER.error("can't dump archive: "+ file, e);
+                        Static.LOGGER.error("can't dump archive: "+ file, e);
                     }
                 }
 
                 if (ioFile.exists()) {
-                    Static.STATIC.SERVICE.submit(new DeployTask(file));
+                    Static.SERVICE.submit(new DeployTask(file));
                 } else {
-                    Static.STATIC.LOGGER.warning("can't find '" + file);
+                    Static.LOGGER.warning("can't find '" + file);
                 }
             } else {
-                Static.STATIC.LOGGER.info("application already deployed: " + file);
+                Static.LOGGER.info("application already deployed: " + file);
             }
         } else if (UndeployMessage.class.equals(type)) {
             final String file = ((UndeployMessage) clusterMessage).getFile();
             if (isDeployed(file)) {
-                Static.STATIC.SERVICE.submit(new UndeployTask(file));
+                Static.SERVICE.submit(new UndeployTask(file));
             } else {
                 final File alternativeFile = new File(deployedDir(), new File(file).getName());
                 if (isDeployed(alternativeFile.getAbsolutePath())) {
-                    Static.STATIC.SERVICE.submit(new UndeployTask(alternativeFile.getAbsolutePath()));
+                    Static.SERVICE.submit(new UndeployTask(alternativeFile.getAbsolutePath()));
                 }
-                Static.STATIC.LOGGER.info("app '" + file + "' was not deployed");
+                Static.LOGGER.info("app '" + file + "' was not deployed");
             }
         } else {
-            Static.STATIC.LOGGER.warning("message type not supported: " + type);
+            Static.LOGGER.warning("message type not supported: " + type);
         }
     }
 
@@ -104,7 +104,7 @@ public class TomEEClusterListener extends ClusterListener {
     }
 
     private static Deployer deployer() throws NamingException {
-        return (Deployer) new InitialContext(Static.STATIC.IC_PROPS).lookup("openejb/DeployerBusinessRemote");
+        return (Deployer) new InitialContext(Static.IC_PROPS).lookup("openejb/DeployerBusinessRemote");
     }
 
     @Override
@@ -115,11 +115,11 @@ public class TomEEClusterListener extends ClusterListener {
     }
 
     public static void stop() {
-        Static.STATIC.SERVICE.shutdown();
+        Static.SERVICE.shutdown();
         try {
-            Static.STATIC.SERVICE.awaitTermination(1, TimeUnit.MINUTES);
+            Static.SERVICE.awaitTermination(1, TimeUnit.MINUTES);
         } catch (final InterruptedException e) {
-            Static.STATIC.SERVICE.shutdownNow();
+            Static.SERVICE.shutdownNow();
         }
     }
 
@@ -140,9 +140,9 @@ public class TomEEClusterListener extends ClusterListener {
                 try {
                     deployer().deploy(app, REMOTE_DEPLOY_PROPERTIES);
                 } catch (final OpenEJBException e) {
-                    Static.STATIC.LOGGER.warning("can't deploy: " + app, e);
+                    Static.LOGGER.warning("can't deploy: " + app, e);
                 } catch (final NamingException e) {
-                    Static.STATIC.LOGGER.warning("can't find deployer", e);
+                    Static.LOGGER.warning("can't find deployer", e);
                 }
             }
         }
@@ -161,11 +161,11 @@ public class TomEEClusterListener extends ClusterListener {
                 try {
                     deployer().undeploy(app);
                 } catch (final UndeployException e) {
-                    Static.STATIC.LOGGER.error("can't undeploy app", e);
+                    Static.LOGGER.error("can't undeploy app", e);
                 } catch (final NoSuchApplicationException e) {
-                    Static.STATIC.LOGGER.warning("no app toi deploy", e);
+                    Static.LOGGER.warning("no app toi deploy", e);
                 } catch (final NamingException e) {
-                    Static.STATIC.LOGGER.warning("can't find deployer", e);
+                    Static.LOGGER.warning("can't find deployer", e);
                 }
             }
         }
@@ -173,8 +173,6 @@ public class TomEEClusterListener extends ClusterListener {
 
     // lazy init of logger (can fail with shutdown hooks to kill the container) and executor
     private static final class Static {
-        private static final Static STATIC = new Static();
-
         private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB, TomEEClusterListener.class);
         private static final Properties IC_PROPS = new Properties();