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/10/24 21:07:27 UTC

tomee git commit: TOMEE-1645 TOMEE-1646 use common.loader for tomee.sh and dont swallow exception for Cipher command

Repository: tomee
Updated Branches:
  refs/heads/master d1a17c6a2 -> a702d89d2


TOMEE-1645 TOMEE-1646 use common.loader for tomee.sh and dont swallow exception for Cipher command


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

Branch: refs/heads/master
Commit: a702d89d23227412ac2b36c0c780ace398477f97
Parents: d1a17c6
Author: Romain Manni-Bucau <rm...@gmail.com>
Authored: Sat Oct 24 21:07:14 2015 +0200
Committer: Romain Manni-Bucau <rm...@gmail.com>
Committed: Sat Oct 24 21:07:14 2015 +0200

----------------------------------------------------------------------
 .../java/org/apache/openejb/cli/Bootstrap.java  | 49 ++++++++++++++++++--
 .../java/org/apache/openejb/config/Cipher.java  |  6 +--
 tomee/apache-tomee/src/main/resources/tomee.sh  | 25 ++++------
 3 files changed, 58 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/a702d89d/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java b/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
index e1ca146..4330f90 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
@@ -17,12 +17,15 @@
 
 package org.apache.openejb.cli;
 
+import org.apache.openejb.loader.IO;
 import org.apache.openejb.loader.SystemClassPath;
+import org.apache.openejb.util.PropertyPlaceHolderHelper;
 import org.apache.openejb.util.URLs;
 
 import java.io.File;
 import java.net.URI;
 import java.net.URL;
+import java.util.StringTokenizer;
 
 /**
  * @version $Rev$ $Date$
@@ -82,11 +85,51 @@ public class Bootstrap {
     }
 
     private static void setupClasspath() {
+        final String base = System.getProperty(OPENEJB_BASE_PROPERTY_NAME, "");
+        final String home = System.getProperty("catalina.home", System.getProperty(OPENEJB_HOME_PROPERTY_NAME, base));
         try {
-            final File lib = new File(System.getProperty(OPENEJB_HOME_PROPERTY_NAME) + File.separator + "lib");
+            final File lib = new File(home + File.separator + "lib");
             final SystemClassPath systemCP = new SystemClassPath();
-            systemCP.addJarsToPath(lib);
-            systemCP.addJarToPath(lib.toURI().toURL()); // add dir too like Tomcat/TomEE
+            File config = new File(base, "conf/catalina.properties");
+            if (!config.isFile()) {
+                config = new File(home, "conf/catalina.properties");
+            }
+            if (config.isFile()) { // like org.apache.catalina.startup.Bootstrap.createClassLoader()
+                String val = IO.readProperties(config).getProperty("common.loader", lib.getAbsolutePath());
+                val = PropertyPlaceHolderHelper.simpleValue(val.replace("${catalina.", "${openejb.")); // base/home
+
+                final StringTokenizer tokenizer = new StringTokenizer(val, ",");
+                while (tokenizer.hasMoreElements()) {
+                    String repository = tokenizer.nextToken().trim();
+                    if (repository.isEmpty()) {
+                        continue;
+                    }
+
+                    if (repository.startsWith("\"") && repository.endsWith("\"")) {
+                        repository = repository.substring(1, repository.length() - 1);
+                    }
+
+                    if (repository.endsWith("*.jar")) {
+                        final File dir = new File(repository.substring(0, repository.length() - "*.jar".length()));
+                        if (dir.isDirectory()) {
+                            systemCP.addJarsToPath(dir);
+                        }
+                    } else if (repository.endsWith(".jar")) {
+                        final File file = new File(repository);
+                        if (file.isFile()) {
+                            systemCP.addJarToPath(file.toURI().toURL());
+                        }
+                    } else {
+                        final File dir = new File(repository);
+                        if (dir.isDirectory()) {
+                            systemCP.addJarToPath(dir.toURI().toURL());
+                        }
+                    }
+                }
+            } else {
+                systemCP.addJarsToPath(lib);
+                systemCP.addJarToPath(lib.toURI().toURL());
+            }
         } catch (final Exception e) {
             System.err.println("Error setting up the classpath: " + e.getClass() + ": " + e.getMessage());
             e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/tomee/blob/a702d89d/container/openejb-core/src/main/java/org/apache/openejb/config/Cipher.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/Cipher.java b/container/openejb-core/src/main/java/org/apache/openejb/config/Cipher.java
index 400d2a7..41d4d18 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/Cipher.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/Cipher.java
@@ -25,8 +25,9 @@ import org.apache.commons.cli.OptionBuilder;
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
 import org.apache.commons.cli.PosixParser;
-import org.apache.openejb.cipher.PasswordCipherFactory;
 import org.apache.openejb.cipher.PasswordCipher;
+import org.apache.openejb.cipher.PasswordCipherException;
+import org.apache.openejb.cipher.PasswordCipherFactory;
 import org.apache.openejb.cli.SystemExitException;
 import org.apache.openejb.util.Join;
 import org.apache.openejb.util.Messages;
@@ -93,14 +94,13 @@ public class Cipher {
                 System.out.println(new String(cipher.encrypt(plainPassword)));
             }
 
-        } catch (final RuntimeException e) {
+        } catch (final PasswordCipherException e) {
             System.out.println("Could not load password cipher implementation class. Check your classpath.");
 
             availableCiphers();
 
             throw new SystemExitException(-1);
         }
-
     }
 
     private static void availableCiphers() {

http://git-wip-us.apache.org/repos/asf/tomee/blob/a702d89d/tomee/apache-tomee/src/main/resources/tomee.sh
----------------------------------------------------------------------
diff --git a/tomee/apache-tomee/src/main/resources/tomee.sh b/tomee/apache-tomee/src/main/resources/tomee.sh
index 5bd1795..2acc688 100644
--- a/tomee/apache-tomee/src/main/resources/tomee.sh
+++ b/tomee/apache-tomee/src/main/resources/tomee.sh
@@ -31,19 +31,11 @@ esac
 
 if $cygwin; then
   [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-  [ -n "$JRE_HOME" ] && JRE_HOME=`cygpath --unix "$JRE_HOME"`
-  [ -n "$TOMEE_HOME" ] && TOMEE_HOME=`cygpath --unix "$TOMEE_HOME"`
-  [ -n "$CATALINA_BASE" ] && CATALINA_BASE=`cygpath --unix "$CATALINA_BASE"`
-  [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+  [ -n "$TOMEE_BASE" ] && TOMEE_BASE=`cygpath --unix "$TOMEE_BASE"`
 fi
 if $cygwin; then
   JAVA_HOME=`cygpath --absolute --windows "$JAVA_HOME"`
-  JRE_HOME=`cygpath --absolute --windows "$JRE_HOME"`
-  TOMEE_HOME=`cygpath --absolute --windows "$TOMEE_HOME"`
-  CATALINA_BASE=`cygpath --absolute --windows "$CATALINA_BASE"`
-  CATALINA_TMPDIR=`cygpath --absolute --windows "$CATALINA_TMPDIR"`
-  CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
-  JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
+  TOMEE_BASE=`cygpath --absolute --windows "$TOMEE_BASE"`
 fi
 
 PRG="$0"
@@ -57,9 +49,10 @@ while [ -h "$PRG" ]; do
   fi
 done
 PRGDIR=`dirname "$PRG"`
-[ -z "$TOMEE_HOME" ] && TOMEE_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`
+[ -z "$TOMEE_BASE" ] && TOMEE_BASE=`cd "$PRGDIR/.." >/dev/null; pwd`
 
-. "$TOMEE_HOME"/bin/setclasspath.sh
+. "$TOMEE_BASE"/bin/setclasspath.sh
+[[ -f "$TOMEE_BASE"/bin/setenv.sh ]] && . "$TOMEE_BASE"/bin/setenv.sh
 
 if [ -z $JAVA_HOME ]; then
   JAVA="java"
@@ -67,8 +60,8 @@ else
   JAVA=$JAVA_HOME"/bin/java"
 fi
 
-CP="$TOMEE_HOME/lib"
-for i in $TOMEE_HOME/lib/*.jar; do
+CP="$TOMEE_BASE/lib"
+for i in $TOMEE_BASE/lib/*.jar; do
   CP="$CP:$i"
 done
 
@@ -76,13 +69,13 @@ done
 if [ "$1" = "deploy" ] || [ "$1" = "undeploy" ]; then
     if [ $# -eq 2 ]; then
         echo "${1}ing $2"
-        $JAVA $DEBUG -Dopenejb.base="$TOMEE_HOME" -cp "\"$CP\"" org.apache.openejb.cli.Bootstrap $1 -s auto $2
+        $JAVA $DEBUG -Dopenejb.base="$TOMEE_BASE" -cp "\"$CP\"" org.apache.openejb.cli.Bootstrap $1 -s auto $2
     else
         echo "Usage: <tomee.sh> $1 <path>"
     fi
 elif [ "$1" = "start" ] || [ "$1" = "stop" ]; then
     echo "To start or stop TomEE please use catalina.sh/startup.sh/shutdown.sh instead of tomee.sh"
 else
-    $JAVA $DEBUG -Dopenejb.base="$TOMEE_HOME" -cp "\"$CP\"" org.apache.openejb.cli.Bootstrap $*
+    $JAVA $DEBUG -Dopenejb.base="$TOMEE_BASE" -cp "\"$CP\"" org.apache.openejb.cli.Bootstrap $*
 fi