Repository: tomee
Updated Branches:
  refs/heads/fb_tomee2_owb16 a19d26e0f -> fc1207450


TOMEE-1579 one more step to do friendly jars (executable) + slight rework of 
our tomee-embedded uber jar to avoid to bring descriptors we don't want


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

Branch: refs/heads/fb_tomee2_owb16
Commit: 151887528f8d15ad5c01a36185b0375c7d463640
Parents: 554ccb1
Author: Romain Manni-Bucau <rmannibu...@apache.org>
Authored: Wed May 6 12:51:40 2015 +0200
Committer: Romain Manni-Bucau <rmannibu...@apache.org>
Committed: Wed May 6 12:51:40 2015 +0200

----------------------------------------------------------------------
 .../apache/openejb/config/DeploymentLoader.java | 28 ++++++++++++++++++--
 tomee/tomee-embedded/pom.xml                    | 28 ++++++++++++++++++++
 .../java/org/apache/tomee/embedded/Main.java    | 11 ++++++++
 3 files changed, 65 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/15188752/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
----------------------------------------------------------------------
diff --git 
a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
 
b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
index 1242ae2..58ba02e 100644
--- 
a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
+++ 
b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
@@ -958,8 +958,10 @@ public class DeploymentLoader implements 
DeploymentFilterable {
         ensureContainerUrls();
         webUrls.addAll(containerUrls);
 
+        final SystemInstance systemInstance = SystemInstance.get();
+
         // add these urls first to ensure we load classes from here first
-        final String externalRepos = SystemInstance.get().getProperty("tomee." 
+ warFile.getName().replace(".war", "") + ".externalRepositories");
+        final String externalRepos = systemInstance.getProperty("tomee." + 
warFile.getName().replace(".war", "") + ".externalRepositories");
         List<URL> externalUrls = null;
         if (externalRepos != null) {
             externalUrls = new ArrayList<URL>();
@@ -1023,12 +1025,34 @@ public class DeploymentLoader implements 
DeploymentFilterable {
         // if we want to manage it in a generic way
         // simply add a boolean shared between tomcat and openejb world
         // to know if we should fire it or not
-        SystemInstance.get().fireEvent(new BeforeDeploymentEvent(webUrlsArray, 
parentClassLoader));
+        systemInstance.fireEvent(new BeforeDeploymentEvent(webUrlsArray, 
parentClassLoader));
 
         final ClassLoader warClassLoader = 
ClassLoaderUtil.createTempClassLoader(appId, webUrlsArray, parentClassLoader);
 
         // create web module
         final List<URL> scannableUrls = filterWebappUrls(webUrlsArray, 
descriptors.get(NewLoaderLogic.EXCLUSION_FILE));
+        // executable war will add war in scannable urls, we don't want it 
since it will surely contain tomee, cxf, ...
+        if 
(Boolean.parseBoolean(systemInstance.getProperty("openejb.core.skip-war-in-loader",
 "true"))) {
+            File archive = warFile;
+            if (!archive.getName().endsWith(".war")) {
+                archive = new File(warFile.getParentFile(), warFile.getName() 
+ ".war");
+                final String unpackDir = 
systemInstance.getProperty("tomee.unpack.dir");
+                if (unpackDir != null && !archive.isFile()) {
+                    try {
+                        archive = new 
File(systemInstance.getBase().getDirectory(unpackDir, false), 
warFile.getName());
+                    } catch (final IOException e) {
+                        // no-op
+                    }
+                }
+            }
+            if (archive.isFile()) {
+                try {
+                    scannableUrls.remove(archive.toURI().toURL());
+                } catch (final MalformedURLException e) {
+                    // no-op
+                }
+            }
+        }
         if (externalUrls != null) {
             for (final URL url : externalUrls) {
                 if (scannableUrls.contains(url)) {

http://git-wip-us.apache.org/repos/asf/tomee/blob/15188752/tomee/tomee-embedded/pom.xml
----------------------------------------------------------------------
diff --git a/tomee/tomee-embedded/pom.xml b/tomee/tomee-embedded/pom.xml
index f8c0f0a..e000f66 100644
--- a/tomee/tomee-embedded/pom.xml
+++ b/tomee/tomee-embedded/pom.xml
@@ -66,6 +66,34 @@
               <createDependencyReducedPom>false</createDependencyReducedPom>
               <shadedArtifactAttached>true</shadedArtifactAttached>
               <shadedClassifierName>uber</shadedClassifierName>
+              <transformers>
+                <transformer 
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+                  <mainClass>org.apache.tomee.embedded.Main</mainClass>
+                </transformer>
+                <transformer 
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+                  <resource>META-INF/cxf/bus-extensions.txt</resource>
+                </transformer>
+                <transformer 
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+                  
<resource>META-INF/openwebbeans/openwebbeans.properties</resource>
+                </transformer>
+              </transformers>
+              <filters>
+                <filter>
+                  <artifact>*:*</artifact>
+                  <excludes>
+                    <exclude>META-INF/ejb-jar.xml</exclude>
+                    <exclude>META-INF/openejb-jar.xml</exclude>
+                    <exclude>META-INF/web-fragment.xml</exclude>
+                    <!--
+                    NOTE:
+                    we shouldn't exclude faces-config.xml while we didn't impl 
the feature in another manner
+                    but it breaks all apps not using JSF.
+                    Solution would be to handle it more deeply in our myfaces 
integration
+                    -->
+                    <exclude>META-INF/faces-config.xml</exclude>
+                  </excludes>
+                </filter>
+              </filters>
             </configuration>
           </execution>
         </executions>

http://git-wip-us.apache.org/repos/asf/tomee/blob/15188752/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Main.java
----------------------------------------------------------------------
diff --git 
a/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Main.java 
b/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Main.java
index e8edf6c..1720f9f 100644
--- a/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Main.java
+++ b/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Main.java
@@ -27,6 +27,8 @@ import org.apache.commons.cli.ParseException;
 import org.apache.commons.cli.PosixParser;
 import org.apache.openejb.loader.ProvisioningUtil;
 
+import static org.apache.openejb.loader.JarLocation.jarLocation;
+
 public class Main {
     public static final String PORT = "port";
     public static final String SHUTDOWN = "shutdown";
@@ -59,6 +61,7 @@ public class Main {
                 contexts = null;
             }
 
+            boolean autoWar = true;
             int i = 0;
             if (line.hasOption(PATH)) {
                 for (final String path : line.getOptionValues(PATH)) {
@@ -77,10 +80,18 @@ public class Main {
                         container.deploy(name, file, true);
                     }
                 }
+                autoWar = false;
             }
             if (line.hasOption(AS_WAR)) {
                 container.deployClasspathAsWebApp(contexts == null || i == 
contexts.length ? "" : contexts[i],
                         line.hasOption(DOC_BASE) ? new 
File(line.getOptionValue(DOC_BASE)) : null);
+                autoWar = false;
+            }
+            if (autoWar) { // nothing deployed check if we are a war and 
deploy ourself then
+                final File me = jarLocation(Main.class);
+                if (me.getName().endsWith(".war")) {
+                    container.deploy(contexts == null || i == contexts.length 
? "" : contexts[i], me);
+                }
             }
 
             Runtime.getRuntime().addShutdownHook(new Thread() {

Reply via email to