karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject svn commit: r960853 - in /karaf/trunk: assembly/src/main/distribution/text/etc/ assembly/src/main/distribution/unix-shell/bin/ assembly/src/main/distribution/windows-text/bin/ assembly/src/main/filtered-resources/etc/ itests/src/test/resources/ main/sr...
Date Tue, 06 Jul 2010 09:29:04 GMT
Author: jbonofre
Date: Tue Jul  6 09:29:03 2010
New Revision: 960853

URL: http://svn.apache.org/viewvc?rev=960853&view=rev
Log:
[KARAF-59] Introduce a ${karaf.data} system property to be able to easily move the data directory
to a different location.

Modified:
    karaf/trunk/assembly/src/main/distribution/text/etc/org.apache.felix.fileinstall-deploy.cfg
    karaf/trunk/assembly/src/main/distribution/text/etc/org.ops4j.pax.logging.cfg
    karaf/trunk/assembly/src/main/distribution/unix-shell/bin/karaf
    karaf/trunk/assembly/src/main/distribution/unix-shell/bin/start
    karaf/trunk/assembly/src/main/distribution/unix-shell/bin/stop
    karaf/trunk/assembly/src/main/distribution/windows-text/bin/karaf.bat
    karaf/trunk/assembly/src/main/filtered-resources/etc/config.properties
    karaf/trunk/itests/src/test/resources/log4j.properties
    karaf/trunk/main/src/main/java/org/apache/karaf/main/BootstrapLogManager.java
    karaf/trunk/main/src/main/java/org/apache/karaf/main/Main.java
    karaf/trunk/main/src/main/java/org/apache/karaf/main/Stop.java
    karaf/trunk/main/src/main/java/org/apache/karaf/main/Utils.java
    karaf/trunk/shell/wrapper/src/main/resources/org/apache/karaf/shell/wrapper/unix/karaf-service
    karaf/trunk/shell/wrapper/src/main/resources/org/apache/karaf/shell/wrapper/unix/karaf-wrapper.conf
    karaf/trunk/shell/wrapper/src/main/resources/org/apache/karaf/shell/wrapper/windows/karaf-wrapper.conf

Modified: karaf/trunk/assembly/src/main/distribution/text/etc/org.apache.felix.fileinstall-deploy.cfg
URL: http://svn.apache.org/viewvc/karaf/trunk/assembly/src/main/distribution/text/etc/org.apache.felix.fileinstall-deploy.cfg?rev=960853&r1=960852&r2=960853&view=diff
==============================================================================
--- karaf/trunk/assembly/src/main/distribution/text/etc/org.apache.felix.fileinstall-deploy.cfg
(original)
+++ karaf/trunk/assembly/src/main/distribution/text/etc/org.apache.felix.fileinstall-deploy.cfg
Tue Jul  6 09:29:03 2010
@@ -18,5 +18,5 @@
 ################################################################################
 
 felix.fileinstall.dir     = ${karaf.base}/deploy
-felix.fileinstall.tmpdir  = ${karaf.base}/data/generated-bundles
+felix.fileinstall.tmpdir  = ${karaf.data}/generated-bundles
 felix.fileinstall.poll    = 1000

Modified: karaf/trunk/assembly/src/main/distribution/text/etc/org.ops4j.pax.logging.cfg
URL: http://svn.apache.org/viewvc/karaf/trunk/assembly/src/main/distribution/text/etc/org.ops4j.pax.logging.cfg?rev=960853&r1=960852&r2=960853&view=diff
==============================================================================
--- karaf/trunk/assembly/src/main/distribution/text/etc/org.ops4j.pax.logging.cfg (original)
+++ karaf/trunk/assembly/src/main/distribution/text/etc/org.ops4j.pax.logging.cfg Tue Jul
 6 09:29:03 2010
@@ -30,7 +30,7 @@ log4j.appender.stdout.layout.ConversionP
 log4j.appender.out=org.apache.log4j.FileAppender
 log4j.appender.out.layout=org.apache.log4j.PatternLayout
 log4j.appender.out.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1}
| %-32.32C %4L | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
-log4j.appender.out.file=${karaf.base}/data/log/karaf.log
+log4j.appender.out.file=${karaf.data}/log/karaf.log
 log4j.appender.out.append=true
 
 # Sift appender
@@ -40,6 +40,6 @@ log4j.appender.sift.default=karaf
 log4j.appender.sift.appender=org.apache.log4j.FileAppender
 log4j.appender.sift.appender.layout=org.apache.log4j.PatternLayout
 log4j.appender.sift.appender.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t |
%-32.32c{1} | %-32.32C %4L | %m%n
-log4j.appender.sift.appender.file=${karaf.base}/data/log/$\\{bundle.name\\}.log
+log4j.appender.sift.appender.file=${karaf.data}/log/$\\{bundle.name\\}.log
 log4j.appender.sift.appender.append=true
 

Modified: karaf/trunk/assembly/src/main/distribution/unix-shell/bin/karaf
URL: http://svn.apache.org/viewvc/karaf/trunk/assembly/src/main/distribution/unix-shell/bin/karaf?rev=960853&r1=960852&r2=960853&view=diff
==============================================================================
--- karaf/trunk/assembly/src/main/distribution/unix-shell/bin/karaf (original)
+++ karaf/trunk/assembly/src/main/distribution/unix-shell/bin/karaf Tue Jul  6 09:29:03 2010
@@ -131,6 +131,16 @@ locateBase() {
     fi
 }
 
+locateData() {
+    if [ "x$KARAF_DATA" != "x" ]; then
+        if [ ! -d "$KARAF_DATA" ]; then
+            die "KARAF_DATA is not valid: $KARAF_DATA"
+        fi
+    else
+        KARAF_DATA=$KARAF_BASE/data
+    fi
+}
+
 setupNativePath() {
     # Support for loading native libraries
     LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:$KARAF_BASE/lib:$KARAF_HOME/lib"
@@ -275,6 +285,9 @@ init() {
 
     # Locate the Karaf base directory
     locateBase
+    
+    # Locate the Karaf data directory
+    locateData
 
     # Setup the native library path
     setupNativePath
@@ -317,10 +330,11 @@ run() {
     if $cygwin; then
         KARAF_HOME=`cygpath --path --windows "$KARAF_HOME"`
         KARAF_BASE=`cygpath --path --windows "$KARAF_BASE"`
+        KARAF_DATA=`cygpath --path --windows "$KARAF_DATA"`
         CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
     fi
     cd $KARAF_BASE
-    exec $JAVA $JAVA_OPTS -Djava.endorsed.dirs="${JAVA_HOME}/jre/lib/endorsed:${JAVA_HOME}/lib/endorsed:${KARAF_HOME}/lib/endorsed"
-Djava.ext.dirs="${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext:${KARAF_HOME}/lib/ext" -Dstorage.location="${KARAF_HOME}/instances"
-Dkaraf.home="$KARAF_HOME" -Dkaraf.base="$KARAF_BASE" -Djava.util.logging.config.file=$KARAF_BASE/etc/java.util.logging.properties
$OPTS -classpath "$CLASSPATH" $MAIN "$@"
+    exec $JAVA $JAVA_OPTS -Djava.endorsed.dirs="${JAVA_HOME}/jre/lib/endorsed:${JAVA_HOME}/lib/endorsed:${KARAF_HOME}/lib/endorsed"
-Djava.ext.dirs="${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext:${KARAF_HOME}/lib/ext" -Dstorage.location="${KARAF_HOME}/instances"
-Dkaraf.home="$KARAF_HOME" -Dkaraf.base="$KARAF_BASE" -Dkaraf.data="$KARAF_DATA" -Djava.util.logging.config.file=$KARAF_BASE/etc/java.util.logging.properties
$OPTS -classpath "$CLASSPATH" $MAIN "$@"
 }
 
 main() {

Modified: karaf/trunk/assembly/src/main/distribution/unix-shell/bin/start
URL: http://svn.apache.org/viewvc/karaf/trunk/assembly/src/main/distribution/unix-shell/bin/start?rev=960853&r1=960852&r2=960853&view=diff
==============================================================================
--- karaf/trunk/assembly/src/main/distribution/unix-shell/bin/start (original)
+++ karaf/trunk/assembly/src/main/distribution/unix-shell/bin/start Tue Jul  6 09:29:03 2010
@@ -82,6 +82,16 @@ locateBase() {
     fi
 }
 
+locateData() {
+    if [ "x$KARAF_DATA" != "x" ]; then
+        if [ ! -d "$KARAF_DATA" ]; then
+            die "KARAF_DATA is not valid: $KARAF_DATA"
+        fi
+    else
+        KARAF_DATA=$KARAF_BASE/data
+    fi
+}
+
 init() {
     # Determine if there is special OS handling we must perform
     detectOS
@@ -91,19 +101,23 @@ init() {
 
     # Locate the Karaf base directory
     locateBase
+    
+    # Locate the Karaf data directory
+    locateData
 }
 
 run() {
     if $cygwin; then
         KARAF_HOME=`cygpath --path --windows "$KARAF_HOME"`
         KARAF_BASE=`cygpath --path --windows "$KARAF_BASE"`
+        KARAF_DATA=`cygpath --path --windows "$KARAF_DATA"`
         CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
     fi
     # Ensure the log directory exists -- we need to have a place to redirect stdout/stderr
-    if [ ! -d "$KARAF_HOME/data/log" ]; then
-        mkdir -p "$KARAF_HOME/data/log"
+    if [ ! -d "$KARAF_DATA/log" ]; then
+        mkdir -p "$KARAF_DATA/log"
     fi
-    exec "$KARAF_HOME"/bin/karaf server "$@" >> "$KARAF_HOME/data/log/karaf.out" 2>&1
&
+    exec "$KARAF_HOME"/bin/karaf server "$@" >> "$KARAF_DATA/karaf.out" 2>&1
&
 }
 
 main() {

Modified: karaf/trunk/assembly/src/main/distribution/unix-shell/bin/stop
URL: http://svn.apache.org/viewvc/karaf/trunk/assembly/src/main/distribution/unix-shell/bin/stop?rev=960853&r1=960852&r2=960853&view=diff
==============================================================================
--- karaf/trunk/assembly/src/main/distribution/unix-shell/bin/stop (original)
+++ karaf/trunk/assembly/src/main/distribution/unix-shell/bin/stop Tue Jul  6 09:29:03 2010
@@ -82,6 +82,16 @@ locateBase() {
     fi
 }
 
+locateData() {
+    if [ "x$KARAF_DATA" != "x" ]; then
+        if [ ! -d "$KARAF_DATA" ]; then
+            die "KARAF_DATA is not valid: $KARAF_DATA"
+        fi
+    else
+        KARAF_DATA=$KARAF_BASE/data
+    fi
+}
+
 init() {
     # Determine if there is special OS handling we must perform
     detectOS
@@ -91,17 +101,21 @@ init() {
 
     # Locate the Karaf base directory
     locateBase
+    
+    # Locate the Karaf data directory
+    locateData
 }
 
 run() {
     if $cygwin; then
         KARAF_HOME=`cygpath --path --windows "$KARAF_HOME"`
         KARAF_BASE=`cygpath --path --windows "$KARAF_BASE"`
+        KARAF_DATA=`cygpath --path --windows "$KARAF_DATA"`
         CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
     fi
     # Ensure the log directory exists -- we need to have a place to redirect stdout/stderr
-    if [ ! -d "$KARAF_HOME/data/log" ]; then
-        mkdir -p "$KARAF_HOME/data/log"
+    if [ ! -d "$KARAF_DATA/log" ]; then
+        mkdir -p "$KARAF_DATA/log"
     fi
     exec "$KARAF_HOME"/bin/karaf stop "$@"
 }

Modified: karaf/trunk/assembly/src/main/distribution/windows-text/bin/karaf.bat
URL: http://svn.apache.org/viewvc/karaf/trunk/assembly/src/main/distribution/windows-text/bin/karaf.bat?rev=960853&r1=960852&r2=960853&view=diff
==============================================================================
--- karaf/trunk/assembly/src/main/distribution/windows-text/bin/karaf.bat (original)
+++ karaf/trunk/assembly/src/main/distribution/windows-text/bin/karaf.bat Tue Jul  6 09:29:03
2010
@@ -58,8 +58,18 @@ if "%KARAF_BASE%" == "" (
   set KARAF_BASE=%KARAF_HOME%
 )
 
+if not "%KARAF_DATA%" == "" (
+    if not exist "%KARAF_DATA%" (
+        call :warn KARAF_DATA is not valid: %KARAF_DATA%
+        goto END
+    )
+)
+if "%KARAF_DATA%" == "" (
+    set KARAF_DATA=%KARAF_BASE%\data
+)        
+
 set LOCAL_CLASSPATH=%CLASSPATH%
-set DEFAULT_JAVA_OPTS=-server -Xmx512M -Dderby.system.home="%KARAF_BASE%\data\derby" -Dderby.storage.fileSyncTransactionLog=true
-Dcom.sun.management.jmxremote
+set DEFAULT_JAVA_OPTS=-server -Xmx512M -Dderby.system.home="%KARAF_DATA%\derby" -Dderby.storage.fileSyncTransactionLog=true
-Dcom.sun.management.jmxremote
 set CLASSPATH=%LOCAL_CLASSPATH%;%KARAF_BASE%\conf
 set DEFAULT_JAVA_DEBUG_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
 
@@ -228,7 +238,7 @@ if "%KARAF_PROFILER%" == "" goto :RUN
     if not "%SHIFT%" == "true" SET ARGS=%1 %2 %3 %4 %5 %6 %7 %8
     rem Execute the Java Virtual Machine
     cd %KARAF_BASE%
-    "%JAVA%" %JAVA_OPTS% %OPTS% -classpath "%CLASSPATH%" -Djava.endorsed.dirs="%JAVA_HOME%\jre\lib\endorsed;%JAVA_HOME%\lib\endorsed;%KARAF_HOME%\lib\endorsed"
-Djava.ext.dirs="%JAVA_HOME%\jre\lib\ext;%JAVA_HOME%\lib\ext;%KARAF_HOME%\lib\ext" -Dstorage.location="%KARAF_HOME%\instances"
-Dkaraf.home="%KARAF_HOME%" -Dkaraf.base="%KARAF_BASE%" -Djava.util.logging.config.file="%KARAF_BASE%\etc\java.util.logging.properties"
%MAIN% %ARGS%
+    "%JAVA%" %JAVA_OPTS% %OPTS% -classpath "%CLASSPATH%" -Djava.endorsed.dirs="%JAVA_HOME%\jre\lib\endorsed;%JAVA_HOME%\lib\endorsed;%KARAF_HOME%\lib\endorsed"
-Djava.ext.dirs="%JAVA_HOME%\jre\lib\ext;%JAVA_HOME%\lib\ext;%KARAF_HOME%\lib\ext" -Dstorage.location="%KARAF_HOME%\instances"
-Dkaraf.home="%KARAF_HOME%" -Dkaraf.base="%KARAF_BASE%" -Dkaraf.data="%KARAF_DATA%" -Djava.util.logging.config.file="%KARAF_BASE%\etc\java.util.logging.properties"
%MAIN% %ARGS%
 
 rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 

Modified: karaf/trunk/assembly/src/main/filtered-resources/etc/config.properties
URL: http://svn.apache.org/viewvc/karaf/trunk/assembly/src/main/filtered-resources/etc/config.properties?rev=960853&r1=960852&r2=960853&view=diff
==============================================================================
--- karaf/trunk/assembly/src/main/filtered-resources/etc/config.properties (original)
+++ karaf/trunk/assembly/src/main/filtered-resources/etc/config.properties Tue Jul  6 09:29:03
2010
@@ -57,7 +57,7 @@ karaf.auto.start=startup.properties
 org.osgi.framework.startlevel.beginning=100
 karaf.startlevel.bundle=60
 
-karaf.shutdown.port.file=${karaf.base}/data/port
+karaf.shutdown.port.file=${karaf.data}/port
 
 #
 # FileMonitor properties

Modified: karaf/trunk/itests/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/karaf/trunk/itests/src/test/resources/log4j.properties?rev=960853&r1=960852&r2=960853&view=diff
==============================================================================
--- karaf/trunk/itests/src/test/resources/log4j.properties (original)
+++ karaf/trunk/itests/src/test/resources/log4j.properties Tue Jul  6 09:29:03 2010
@@ -29,5 +29,5 @@ log4j.appender.stdout.layout.ConversionP
 log4j.appender.out=org.apache.log4j.FileAppender
 log4j.appender.out.layout=org.apache.log4j.PatternLayout
 log4j.appender.out.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1}
| %-32.32C %4L | %m%n
-log4j.appender.out.file=${karaf.base}/data/log/karaf.log
+log4j.appender.out.file=${karaf.data}/log/karaf.log
 log4j.appender.out.append=true

Modified: karaf/trunk/main/src/main/java/org/apache/karaf/main/BootstrapLogManager.java
URL: http://svn.apache.org/viewvc/karaf/trunk/main/src/main/java/org/apache/karaf/main/BootstrapLogManager.java?rev=960853&r1=960852&r2=960853&view=diff
==============================================================================
--- karaf/trunk/main/src/main/java/org/apache/karaf/main/BootstrapLogManager.java (original)
+++ karaf/trunk/main/src/main/java/org/apache/karaf/main/BootstrapLogManager.java Tue Jul
 6 09:29:03 2010
@@ -55,7 +55,7 @@ public class BootstrapLogManager {
                 fis = new FileInputStream(System.getProperty("karaf.base") + "/etc/org.ops4j.pax.logging.cfg");
                 props.load(fis);
             } catch (IOException e) {
-                props.setProperty("log4j.appender.out.file", "${karaf.base}/data/log/karaf.log");
+                props.setProperty("log4j.appender.out.file", "${karaf.data}/log/karaf.log");
             } finally {
                 if (fis != null) { 
                     try {

Modified: karaf/trunk/main/src/main/java/org/apache/karaf/main/Main.java
URL: http://svn.apache.org/viewvc/karaf/trunk/main/src/main/java/org/apache/karaf/main/Main.java?rev=960853&r1=960852&r2=960853&view=diff
==============================================================================
--- karaf/trunk/main/src/main/java/org/apache/karaf/main/Main.java (original)
+++ karaf/trunk/main/src/main/java/org/apache/karaf/main/Main.java Tue Jul  6 09:29:03 2010
@@ -98,6 +98,16 @@ public class Main {
      * holds the configuration and data for a Karaf instance.
      */
     public static final String ENV_KARAF_BASE = "KARAF_BASE";
+    /**
+     * The system property for specifying the Karaf data directory. The data directory
+     * holds the bundles data and cache for a Karaf instance.
+     */
+    public static final String PROP_KARAF_DATA = "karaf.data";
+    /**
+     * The environment variable for specifying the Karaf data directory. The data directory
+     * holds the bundles data and cache for a Karaf instance.
+     */
+    public static final String ENV_KARAF_DATA = "KARAF_DATA";
 
     /**
      * Config property which identifies directories which contain bundles to be loaded by
SMX
@@ -145,6 +155,7 @@ public class Main {
 
     private File karafHome;
     private File karafBase;
+    private File karafData;
     private Properties configProps = null;
     private Framework framework = null;
     private final String[] args;
@@ -162,13 +173,16 @@ public class Main {
 
     public void launch() throws Exception {
         karafHome = Utils.getKarafHome();
-        karafBase = Utils.getKarafBase(karafHome);
+        karafBase = Utils.getKarafDirectory(Main.PROP_KARAF_BASE, Main.ENV_KARAF_BASE, karafHome,
false);
+        karafData = Utils.getKarafDirectory(Main.PROP_KARAF_DATA, Main.ENV_KARAF_DATA, new
File(karafBase.getPath() + "/data"), true);
 
         //System.out.println("Karaf Home: "+main.karafHome.getPath());
         //System.out.println("Karaf Base: "+main.karafBase.getPath());
+        //System.out.println("Karaf Data: "+main.karafData.getPath());
 
         System.setProperty(PROP_KARAF_HOME, karafHome.getPath());
         System.setProperty(PROP_KARAF_BASE, karafBase.getPath());
+        System.setProperty(PROP_KARAF_DATA, karafData.getPath());
 
         // Load system properties.
         loadSystemProperties(karafBase);
@@ -188,7 +202,7 @@ public class Main {
         processSecurityProperties(configProps);
 
         if (configProps.getProperty(Constants.FRAMEWORK_STORAGE) == null) {
-            File storage = new File(karafBase.getPath(), "data/cache");
+            File storage = new File(karafData.getPath(), "cache");
             try {
                 storage.mkdirs();
             } catch (SecurityException se) {

Modified: karaf/trunk/main/src/main/java/org/apache/karaf/main/Stop.java
URL: http://svn.apache.org/viewvc/karaf/trunk/main/src/main/java/org/apache/karaf/main/Stop.java?rev=960853&r1=960852&r2=960853&view=diff
==============================================================================
--- karaf/trunk/main/src/main/java/org/apache/karaf/main/Stop.java (original)
+++ karaf/trunk/main/src/main/java/org/apache/karaf/main/Stop.java Tue Jul  6 09:29:03 2010
@@ -34,10 +34,12 @@ public class Stop {
 
     public static void main(String[] args) throws Exception {
         File karafHome = Utils.getKarafHome();
-        File karafBase = Utils.getKarafBase(karafHome);
+        File karafBase = Utils.getKarafDirectory(Main.PROP_KARAF_BASE, Main.ENV_KARAF_BASE,
karafHome, false);
+        File karafData = Utils.getKarafDirectory(Main.PROP_KARAF_DATA, Main.ENV_KARAF_DATA,
new File(karafBase.getPath() + "/data"), true);
 
         System.setProperty(Main.PROP_KARAF_HOME, karafHome.getPath());
         System.setProperty(Main.PROP_KARAF_BASE, karafBase.getPath());
+        System.setProperty(Main.PROP_KARAF_DATA, karafData.getPath());
 
         // Load system properties.
         Main.loadSystemProperties(karafBase);

Modified: karaf/trunk/main/src/main/java/org/apache/karaf/main/Utils.java
URL: http://svn.apache.org/viewvc/karaf/trunk/main/src/main/java/org/apache/karaf/main/Utils.java?rev=960853&r1=960852&r2=960853&view=diff
==============================================================================
--- karaf/trunk/main/src/main/java/org/apache/karaf/main/Utils.java (original)
+++ karaf/trunk/main/src/main/java/org/apache/karaf/main/Utils.java Tue Jul  6 09:29:03 2010
@@ -34,13 +34,13 @@ public class Utils {
         // Use the system property if specified.
         String path = System.getProperty(Main.PROP_KARAF_HOME);
         if (path != null) {
-            rc = validateDirectoryExists(path, "Invalid " + Main.PROP_KARAF_HOME + " system
property");
+            rc = validateDirectoryExists(path, "Invalid " + Main.PROP_KARAF_HOME + " system
property", false);
         }
 
         if (rc == null) {
             path = System.getenv(Main.ENV_KARAF_HOME);
             if (path != null) {
-                rc = validateDirectoryExists(path, "Invalid " + Main.ENV_KARAF_HOME + " environment
variable");
+                rc = validateDirectoryExists(path, "Invalid " + Main.ENV_KARAF_HOME + " environment
variable", false);
             }
         }
 
@@ -75,40 +75,48 @@ public class Utils {
         return rc;
     }
 
-    public static File validateDirectoryExists(String path, String errPrefix) {
+    public static File validateDirectoryExists(String path, String errPrefix, boolean createDirectory)
{
         File rc;
         try {
             rc = new File(path).getCanonicalFile();
         } catch (IOException e) {
             throw new IllegalArgumentException(errPrefix + " '" + path + "' : " + e.getMessage());
         }
-        if (!rc.exists()) {
+        if (!rc.exists() && !createDirectory) {
             throw new IllegalArgumentException(errPrefix + " '" + path + "' : does not exist");
         }
+        if (!rc.exists()) {
+            try {
+                rc.mkdirs();
+            } catch (SecurityException se) {
+                throw new IllegalArgumentException(errPrefix + " '" + path + "' : " + se.getMessage());
+            }
+        }
         if (!rc.isDirectory()) {
             throw new IllegalArgumentException(errPrefix + " '" + path + "' : is not a directory");
         }
         return rc;
     }
-
-    public static File getKarafBase(File defaultValue) {
+    
+    public static File getKarafDirectory(String directoryProperty, String directoryEnvironmentVariable,
File defaultValue, boolean create) {
         File rc = null;
-
-        String path = System.getProperty(Main.PROP_KARAF_BASE);
+        
+        String path = System.getProperty(directoryProperty);
         if (path != null) {
-            rc = validateDirectoryExists(path, "Invalid " + Main.PROP_KARAF_BASE + " system
property");
+            rc = validateDirectoryExists(path, "Invalid " + directoryProperty + " system
property", create);
         }
-
+        
         if (rc == null) {
-            path = System.getenv(Main.ENV_KARAF_BASE);
+            path = System.getenv(directoryEnvironmentVariable);
             if (path != null) {
-                rc = validateDirectoryExists(path, "Invalid " + Main.ENV_KARAF_BASE + " environment
variable");
+                rc = validateDirectoryExists(path, "Invalid " + directoryEnvironmentVariable
 + " environment variable", create);
             }
         }
-
+        
         if (rc == null) {
             rc = defaultValue;
         }
+        
         return rc;
     }
 }

Modified: karaf/trunk/shell/wrapper/src/main/resources/org/apache/karaf/shell/wrapper/unix/karaf-service
URL: http://svn.apache.org/viewvc/karaf/trunk/shell/wrapper/src/main/resources/org/apache/karaf/shell/wrapper/unix/karaf-service?rev=960853&r1=960852&r2=960853&view=diff
==============================================================================
--- karaf/trunk/shell/wrapper/src/main/resources/org/apache/karaf/shell/wrapper/unix/karaf-service
(original)
+++ karaf/trunk/shell/wrapper/src/main/resources/org/apache/karaf/shell/wrapper/unix/karaf-service
Tue Jul  6 09:29:03 2010
@@ -30,7 +30,7 @@ WRAPPER_CONF="${karaf.base}/etc/${APP_NA
 PRIORITY=
 
 # Location of the pid file.
-PIDDIR="${karaf.base}/data"
+PIDDIR="${karaf.data}"
 
 # If uncommented, causes the Wrapper to be shutdown using an anchor file.
 #  When launched with the 'start' command, it will also ignore all INT and

Modified: karaf/trunk/shell/wrapper/src/main/resources/org/apache/karaf/shell/wrapper/unix/karaf-wrapper.conf
URL: http://svn.apache.org/viewvc/karaf/trunk/shell/wrapper/src/main/resources/org/apache/karaf/shell/wrapper/unix/karaf-wrapper.conf?rev=960853&r1=960852&r2=960853&view=diff
==============================================================================
--- karaf/trunk/shell/wrapper/src/main/resources/org/apache/karaf/shell/wrapper/unix/karaf-wrapper.conf
(original)
+++ karaf/trunk/shell/wrapper/src/main/resources/org/apache/karaf/shell/wrapper/unix/karaf-wrapper.conf
Tue Jul  6 09:29:03 2010
@@ -20,6 +20,7 @@
 #********************************************************************
 set.default.KARAF_HOME=${karaf.home}
 set.default.KARAF_BASE=${karaf.base}
+set.default.KARAF_DATA=${karaf.data}
 
 # Java Application
 wrapper.working.dir=%KARAF_BASE%
@@ -37,11 +38,12 @@ wrapper.app.parameter.1=org.apache.karaf
 # note that n is the parameter number starting from 1.
 wrapper.java.additional.1=-Dkaraf.home=%KARAF_HOME%
 wrapper.java.additional.2=-Dkaraf.base=%KARAF_BASE%
-wrapper.java.additional.3=-Dcom.sun.management.jmxremote
-wrapper.java.additional.4=-Dkaraf.startLocalConsole=false
-wrapper.java.additional.5=-Dkaraf.startRemoteShell=true
-wrapper.java.additional.6=-Djava.endorsed.dirs="%JAVA_HOME%/jre/lib/endorsed;%JAVA_HOME%/lib/endorsed;%KARAF_HOME%/lib/endorsed"
-wrapper.java.additional.7=-Djava.ext.dirs="%JAVA_HOME%/jre/lib/ext;%JAVA_HOME%/lib/ext;%KARAF_HOME%/lib/ext"
+wrapper.java.additional.3=-Dkaraf.data=%KARAF_DATA%
+wrapper.java.additional.4=-Dcom.sun.management.jmxremote
+wrapper.java.additional.5=-Dkaraf.startLocalConsole=false
+wrapper.java.additional.6=-Dkaraf.startRemoteShell=true
+wrapper.java.additional.7=-Djava.endorsed.dirs="%JAVA_HOME%/jre/lib/endorsed;%JAVA_HOME%/lib/endorsed;%KARAF_HOME%/lib/endorsed"
+wrapper.java.additional.8=-Djava.ext.dirs="%JAVA_HOME%/jre/lib/ext;%JAVA_HOME%/lib/ext;%KARAF_HOME%/lib/ext"
 
 # Uncomment to enable jmx
 #wrapper.java.additional.n=-Dcom.sun.management.jmxremote.port=1616
@@ -72,7 +74,7 @@ wrapper.console.format=PM
 wrapper.console.loglevel=INFO
 
 # Log file to use for wrapper output logging.
-wrapper.logfile=%KARAF_BASE%/data/log/wrapper.log
+wrapper.logfile=%KARAF_DATA%/log/wrapper.log
 
 # Format of output for the log file.  (See docs for formats)
 wrapper.logfile.format=LPTM

Modified: karaf/trunk/shell/wrapper/src/main/resources/org/apache/karaf/shell/wrapper/windows/karaf-wrapper.conf
URL: http://svn.apache.org/viewvc/karaf/trunk/shell/wrapper/src/main/resources/org/apache/karaf/shell/wrapper/windows/karaf-wrapper.conf?rev=960853&r1=960852&r2=960853&view=diff
==============================================================================
--- karaf/trunk/shell/wrapper/src/main/resources/org/apache/karaf/shell/wrapper/windows/karaf-wrapper.conf
(original)
+++ karaf/trunk/shell/wrapper/src/main/resources/org/apache/karaf/shell/wrapper/windows/karaf-wrapper.conf
Tue Jul  6 09:29:03 2010
@@ -20,6 +20,7 @@
 #********************************************************************
 set.default.KARAF_HOME=${karaf.home}
 set.default.KARAF_BASE=${karaf.base}
+set.default.KARAF_DATA=${karaf.data}
 
 # Java Application
 wrapper.working.dir=%KARAF_BASE%
@@ -37,11 +38,12 @@ wrapper.app.parameter.1=org.apache.karaf
 # note that n is the parameter number starting from 1.
 wrapper.java.additional.1=-Dkaraf.home="%KARAF_HOME%"
 wrapper.java.additional.2=-Dkaraf.base="%KARAF_BASE%"
-wrapper.java.additional.3=-Dcom.sun.management.jmxremote
-wrapper.java.additional.4=-Dkaraf.startLocalConsole=false
-wrapper.java.additional.5=-Dkaraf.startRemoteShell=true
-wrapper.java.additional.6=-Djava.endorsed.dirs="%JAVA_HOME%/jre/lib/endorsed;%JAVA_HOME%/lib/endorsed;%KARAF_HOME%/lib/endorsed"
-wrapper.java.additional.7=-Djava.ext.dirs="%JAVA_HOME%/jre/lib/ext;%JAVA_HOME%/lib/ext;%KARAF_HOME%/lib/ext"
+wrapper.java.additional.3=-Dkaraf.data="%KARAF_DATA%"
+wrapper.java.additional.4=-Dcom.sun.management.jmxremote
+wrapper.java.additional.5=-Dkaraf.startLocalConsole=false
+wrapper.java.additional.6=-Dkaraf.startRemoteShell=true
+wrapper.java.additional.7=-Djava.endorsed.dirs="%JAVA_HOME%/jre/lib/endorsed;%JAVA_HOME%/lib/endorsed;%KARAF_HOME%/lib/endorsed"
+wrapper.java.additional.8=-Djava.ext.dirs="%JAVA_HOME%/jre/lib/ext;%JAVA_HOME%/lib/ext;%KARAF_HOME%/lib/ext"
 
 # Uncomment to enable jmx
 #wrapper.java.additional.n=-Dcom.sun.management.jmxremote.port=1616
@@ -72,7 +74,7 @@ wrapper.console.format=PM
 wrapper.console.loglevel=INFO
 
 # Log file to use for wrapper output logging.
-wrapper.logfile=%KARAF_BASE%/data/log/wrapper.log
+wrapper.logfile=%KARAF_DATA%/log/wrapper.log
 
 # Format of output for the log file.  (See docs for formats)
 wrapper.logfile.format=LPTM



Mime
View raw message