tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: TOMEE-1440 simpleDeployment for openejb embedded adapter as well
Date Wed, 12 Nov 2014 08:14:30 GMT
Repository: tomee
Updated Branches:
  refs/heads/develop c5dea27ad -> 3761a61b6


TOMEE-1440 simpleDeployment for openejb embedded adapter as well


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

Branch: refs/heads/develop
Commit: 3761a61b65e8daff24ab2e309d2d52797457be73
Parents: c5dea27
Author: Romain Manni-Bucau <rmannibucau@apache.org>
Authored: Wed Nov 12 09:13:57 2014 +0100
Committer: Romain Manni-Bucau <rmannibucau@apache.org>
Committed: Wed Nov 12 09:13:57 2014 +0100

----------------------------------------------------------------------
 .../openejb/OpenEJBConfiguration.java           | 16 ++++++++
 .../openejb/OpenEJBDeployableContainer.java     | 39 ++++++++++++++------
 2 files changed, 44 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/3761a61b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBConfiguration.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBConfiguration.java
b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBConfiguration.java
index 9df5cb2..23cdb2f 100644
--- a/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBConfiguration.java
+++ b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBConfiguration.java
@@ -20,9 +20,16 @@ import org.jboss.arquillian.config.descriptor.api.Multiline;
 import org.jboss.arquillian.container.spi.ConfigurationException;
 import org.jboss.arquillian.container.spi.client.container.ContainerConfiguration;
 
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+
+import static java.util.Arrays.asList;
+
 public class OpenEJBConfiguration implements ContainerConfiguration {
     private String properties = "";
     private String preloadClasses;
+    private Collection<String> singleDeploymentByArchiveName = Collections.emptyList();
 
     @Override
     public void validate() throws ConfigurationException {
@@ -45,4 +52,13 @@ public class OpenEJBConfiguration implements ContainerConfiguration {
     public void setPreloadClasses(final String preloadClasses) {
         this.preloadClasses = preloadClasses;
     }
+
+    public boolean isSingleDeploymentByArchiveName(final String name) {
+        return singleDeploymentByArchiveName.contains(name) || singleDeploymentByArchiveName.contains("*")
|| singleDeploymentByArchiveName.contains("true");
+    }
+
+    public void setSingleDeploymentByArchiveName(final String singleDeploymentByArchiveName)
{
+        this.singleDeploymentByArchiveName = singleDeploymentByArchiveName == null || singleDeploymentByArchiveName.trim().isEmpty()
?
+                Collections.<String>emptyList() : new HashSet<String>(asList(singleDeploymentByArchiveName.split("
*, *")));
+    }
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/3761a61b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
index f73135a..4ba6ae9 100644
--- a/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
+++ b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
@@ -60,6 +60,8 @@ import java.io.IOException;
 import java.util.Collection;
 import java.util.Map;
 import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -82,6 +84,8 @@ public class OpenEJBDeployableContainer implements DeployableContainer<OpenEJBCo
         }
     }
 
+    private static final ConcurrentMap<String, DeploymentInfo> DEPLOYMENT_INFO = new
ConcurrentHashMap<String, DeploymentInfo>();
+
     // config
     private Properties properties;
 
@@ -138,6 +142,8 @@ public class OpenEJBDeployableContainer implements DeployableContainer<OpenEJBCo
     @Inject
     private Instance<TestClass> testClass;
 
+    private OpenEJBConfiguration configuration;
+
     @Override
     public Class<OpenEJBConfiguration> getConfigurationClass() {
         return OpenEJBConfiguration.class;
@@ -146,6 +152,7 @@ public class OpenEJBDeployableContainer implements DeployableContainer<OpenEJBCo
     @Override
     public void setup(final OpenEJBConfiguration openEJBConfiguration) {
         properties = new Properties();
+        configuration = openEJBConfiguration;
 
         final ByteArrayInputStream bais = new ByteArrayInputStream(openEJBConfiguration.getProperties().getBytes());
         try {
@@ -224,20 +231,28 @@ public class OpenEJBDeployableContainer implements DeployableContainer<OpenEJBCo
     }
 
     private DeploymentInfo quickDeploy(final Archive<?> archive, final TestClass testClass,
final Closeables cls) throws DeploymentException {
-        try {
-            final AppModule module = OpenEJBArchiveProcessor.createModule(archive, testClass,
cls);
-            final AppInfo appInfo = configurationFactory.configureApplication(module);
-            final AppContext appCtx = assembler.createApplication(appInfo, module.getClassLoader());
+        final String name = archive.getName();
+        DeploymentInfo info = DEPLOYMENT_INFO.get(name);
+        if (info == null) {
+            try {
+                final AppModule module = OpenEJBArchiveProcessor.createModule(archive, testClass,
cls);
+                final AppInfo appInfo = configurationFactory.configureApplication(module);
+                final AppContext appCtx = assembler.createApplication(appInfo, module.getClassLoader());
 
-            final ServletContext appServletContext = new MockServletContext();
-            final HttpSession appSession = new MockHttpSession();
+                final ServletContext appServletContext = new MockServletContext();
+                final HttpSession appSession = new MockHttpSession();
 
-            startContexts(appCtx.getWebBeansContext().getContextsService(), appServletContext,
appSession);
+                startContexts(appCtx.getWebBeansContext().getContextsService(), appServletContext,
appSession);
 
-            return new DeploymentInfo(appServletContext, appSession, appInfo, appCtx);
-        } catch (final Exception e) {
-            throw new DeploymentException("can't deploy " + archive.getName(), e);
+                info = new DeploymentInfo(appServletContext, appSession, appInfo, appCtx);
+                if (configuration.isSingleDeploymentByArchiveName(name)) {
+                    DEPLOYMENT_INFO.putIfAbsent(name, info);
+                }
+            } catch (final Exception e) {
+                throw new DeploymentException("can't deploy " + name, e);
+            }
         }
+        return info;
     }
 
     @Override
@@ -260,7 +275,9 @@ public class OpenEJBDeployableContainer implements DeployableContainer<OpenEJBCo
         }
 
         try {
-            assembler.destroyApplication(info.get().path);
+            if (!configuration.isSingleDeploymentByArchiveName(archive.getName())) {
+                assembler.destroyApplication(info.get().path);
+            }
             stopContexts(appContext.get().getWebBeansContext().getContextsService(), servletContext.get(),
session.get());
         } catch (final Exception e) {
             throw new DeploymentException("can't undeploy " + archive.getName(), e);


Mime
View raw message