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/05/30 08:10:44 UTC

tomee git commit: abstracting a bit TomEEContainer (protected method for now) to let it easily extended for all cases = remote or embedded

Repository: tomee
Updated Branches:
  refs/heads/master 8c0d055b1 -> 8c9a23ad7


abstracting a bit TomEEContainer (protected method for now) to let it easily extended for all cases = remote or embedded


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

Branch: refs/heads/master
Commit: 8c9a23ad784e534144e66d507880235dc64cf639
Parents: 8c0d055
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Sat May 30 08:10:23 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Sat May 30 08:10:23 2015 +0200

----------------------------------------------------------------------
 .../arquillian/common/TomEEContainer.java       | 65 +++++++++++++-------
 1 file changed, 42 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/8c9a23ad/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TomEEContainer.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TomEEContainer.java b/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TomEEContainer.java
index 6460d96..5ac79d2 100644
--- a/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TomEEContainer.java
+++ b/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TomEEContainer.java
@@ -16,7 +16,9 @@
  */
 package org.apache.openejb.arquillian.common;
 
+import org.apache.openejb.NoSuchApplicationException;
 import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.UndeployException;
 import org.apache.openejb.assembler.Deployer;
 import org.apache.openejb.assembler.DeployerEjb;
 import org.apache.openejb.assembler.classic.AppInfo;
@@ -82,12 +84,8 @@ public abstract class TomEEContainer<Configuration extends TomEEConfiguration> i
                 && deploymentDescription.testable();
     }
 
-    @Override
-    public void setup(final Configuration configuration) {
-        this.configuration = configuration;
-
+    protected void handlePrefix() {
         final Prefixes prefixes = configuration.getClass().getAnnotation(Prefixes.class);
-
         if (prefixes == null) {
             return;
         }
@@ -118,6 +116,13 @@ public abstract class TomEEContainer<Configuration extends TomEEConfiguration> i
                 }
             }
         }
+    }
+
+    @Override
+    public void setup(final Configuration configuration) {
+        this.configuration = configuration;
+
+        handlePrefix();
 
         ArquillianUtil.preLoadClassesAsynchronously(configuration.getPreloadClasses());
     }
@@ -283,21 +288,7 @@ public abstract class TomEEContainer<Configuration extends TomEEConfiguration> i
             final String archiveName = archive.getName();
             try {
                 if (dump.isCreated() || !configuration.isSingleDeploymentByArchiveName(archiveName)) {
-                    final Properties deployerProperties = getDeployerProperties();
-                    if (deployerProperties == null) {
-                        appInfo = deployer().deploy(file.getAbsolutePath());
-                    } else {
-                        final Properties props = new Properties();
-                        props.putAll(deployerProperties);
-
-                        if ("true".equalsIgnoreCase(deployerProperties.getProperty(DeployerEjb.OPENEJB_USE_BINARIES, "false"))) {
-                            final byte[] slurpBinaries = IO.slurpBytes(file);
-                            props.put(DeployerEjb.OPENEJB_VALUE_BINARIES, slurpBinaries);
-                            props.put(DeployerEjb.OPENEJB_PATH_BINARIES, archive.getName());
-                        }
-
-                        appInfo = deployer().deploy(file.getAbsolutePath(), props);
-                    }
+                    appInfo = doDeploy(archive, file);
 
                     if (appInfo != null) {
                         moduleIds.put(archiveName, new DeployedApp(appInfo.path, file));
@@ -306,7 +297,7 @@ public abstract class TomEEContainer<Configuration extends TomEEConfiguration> i
                 } else {
                     final String path = moduleIds.get(archiveName).path;
                     AppInfo selected = null;
-                    for (final AppInfo info : deployer().getDeployedApps()) {
+                    for (final AppInfo info : getDeployedApps()) {
                         if (path.equals(info.path)) {
                             selected = info;
                             break;
@@ -339,6 +330,30 @@ public abstract class TomEEContainer<Configuration extends TomEEConfiguration> i
         }
     }
 
+    protected Collection<AppInfo> getDeployedApps() throws NamingException {
+        return deployer().getDeployedApps();
+    }
+
+    protected AppInfo doDeploy(final Archive<?> archive, final File file) throws OpenEJBException, NamingException, IOException {
+        AppInfo appInfo;
+        final Properties deployerProperties = getDeployerProperties();
+        if (deployerProperties == null) {
+            appInfo = deployer().deploy(file.getAbsolutePath());
+        } else {
+            final Properties props = new Properties();
+            props.putAll(deployerProperties);
+
+            if ("true".equalsIgnoreCase(deployerProperties.getProperty(DeployerEjb.OPENEJB_USE_BINARIES, "false"))) {
+                final byte[] slurpBinaries = IO.slurpBytes(file);
+                props.put(DeployerEjb.OPENEJB_VALUE_BINARIES, slurpBinaries);
+                props.put(DeployerEjb.OPENEJB_PATH_BINARIES, archive.getName());
+            }
+
+            appInfo = deployer().deploy(file.getAbsolutePath(), props);
+        }
+        return appInfo;
+    }
+
     protected Properties getDeployerProperties() {
         return null;
     }
@@ -394,7 +409,7 @@ public abstract class TomEEContainer<Configuration extends TomEEConfiguration> i
     private Collection<String> apps() {
         final Collection<String> paths = new ArrayList<String>();
         try {
-            final Collection<AppInfo> appInfos = deployer().getDeployedApps();
+            final Collection<AppInfo> appInfos = getDeployedApps();
             for (final AppInfo info : appInfos) {
                 paths.add(info.path);
             }
@@ -471,7 +486,7 @@ public abstract class TomEEContainer<Configuration extends TomEEConfiguration> i
                 LOGGER.warning(archiveName + " was not deployed");
                 return;
             }
-            deployer().undeploy(deployed.path);
+            doUndeploy(deployed);
         } catch (final Exception e) {
             throw new DeploymentException("Unable to undeploy " + archiveName, e);
         } finally {
@@ -493,6 +508,10 @@ public abstract class TomEEContainer<Configuration extends TomEEConfiguration> i
         }
     }
 
+    protected void doUndeploy(DeployedApp deployed) throws UndeployException, NoSuchApplicationException, NamingException {
+        deployer().undeploy(deployed.path);
+    }
+
     @Override
     public void deploy(final Descriptor descriptor) throws DeploymentException {
         throw new UnsupportedOperationException("Not implemented");