felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r822663 - in /felix/trunk/karaf: assembly/src/main/distribution/text/etc/ assembly/src/main/filtered-resources/etc/ main/src/main/java/org/apache/felix/karaf/main/
Date Wed, 07 Oct 2009 11:05:14 GMT
Author: gnodet
Date: Wed Oct  7 11:05:14 2009
New Revision: 822663

URL: http://svn.apache.org/viewvc?rev=822663&view=rev
Log:
FELIX-1660: karaf should not hardcode the 'system' location of its maven-like repository,
patch provided by Richard Stone

Modified:
    felix/trunk/karaf/assembly/src/main/distribution/text/etc/org.ops4j.pax.url.mvn.cfg
    felix/trunk/karaf/assembly/src/main/distribution/text/etc/system.properties
    felix/trunk/karaf/assembly/src/main/filtered-resources/etc/config.properties
    felix/trunk/karaf/main/src/main/java/org/apache/felix/karaf/main/Bootstrap.java
    felix/trunk/karaf/main/src/main/java/org/apache/felix/karaf/main/Main.java

Modified: felix/trunk/karaf/assembly/src/main/distribution/text/etc/org.ops4j.pax.url.mvn.cfg
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/assembly/src/main/distribution/text/etc/org.ops4j.pax.url.mvn.cfg?rev=822663&r1=822662&r2=822663&view=diff
==============================================================================
--- felix/trunk/karaf/assembly/src/main/distribution/text/etc/org.ops4j.pax.url.mvn.cfg (original)
+++ felix/trunk/karaf/assembly/src/main/distribution/text/etc/org.ops4j.pax.url.mvn.cfg Wed
Oct  7 11:05:14 2009
@@ -55,7 +55,7 @@
 #
 # The following property value will add the system folder as a repo.
 #
-org.ops4j.pax.url.mvn.defaultRepositories=file:${karaf.home}/system@snapshots
+org.ops4j.pax.url.mvn.defaultRepositories=file:${karaf.home}/${karaf.default.repository}@snapshots
 
 #
 # Comma separated list of repositories scanned when resolving an artifact.

Modified: felix/trunk/karaf/assembly/src/main/distribution/text/etc/system.properties
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/assembly/src/main/distribution/text/etc/system.properties?rev=822663&r1=822662&r2=822663&view=diff
==============================================================================
--- felix/trunk/karaf/assembly/src/main/distribution/text/etc/system.properties (original)
+++ felix/trunk/karaf/assembly/src/main/distribution/text/etc/system.properties Wed Oct  7
11:05:14 2009
@@ -19,4 +19,5 @@
 
 org.ops4j.pax.logging.DefaultServiceLog.level=ERROR
 karaf.name=root
+karaf.default.repository=system
 xml.catalog.files=

Modified: felix/trunk/karaf/assembly/src/main/filtered-resources/etc/config.properties
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/assembly/src/main/filtered-resources/etc/config.properties?rev=822663&r1=822662&r2=822663&view=diff
==============================================================================
--- felix/trunk/karaf/assembly/src/main/filtered-resources/etc/config.properties (original)
+++ felix/trunk/karaf/assembly/src/main/filtered-resources/etc/config.properties Wed Oct 
7 11:05:14 2009
@@ -22,8 +22,8 @@
 #
 karaf.framework=felix
 
-karaf.framework.equinox=system/org/eclipse/osgi/${equinox.version}/osgi-${equinox.version}.jar
-karaf.framework.felix=system/org/apache/felix/org.apache.felix.framework/${felix.framework.version}/org.apache.felix.framework-${felix.framework.version}.jar
+karaf.framework.equinox=${karaf.default.repository}/org/eclipse/osgi/${equinox.version}/osgi-${equinox.version}.jar
+karaf.framework.felix=${karaf.default.repository}/org/apache/felix/org.apache.felix.framework/${felix.framework.version}/org.apache.felix.framework-${felix.framework.version}.jar
 
 #
 # Framework config properties.

Modified: felix/trunk/karaf/main/src/main/java/org/apache/felix/karaf/main/Bootstrap.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/main/src/main/java/org/apache/felix/karaf/main/Bootstrap.java?rev=822663&r1=822662&r2=822663&view=diff
==============================================================================
--- felix/trunk/karaf/main/src/main/java/org/apache/felix/karaf/main/Bootstrap.java (original)
+++ felix/trunk/karaf/main/src/main/java/org/apache/felix/karaf/main/Bootstrap.java Wed Oct
 7 11:05:14 2009
@@ -29,13 +29,8 @@
 
 public class Bootstrap {
 
-    public static final String FRAMEWORK_PROPERTIES_FILE_NAME = "config.properties";
-
-    public static final String KARAF_FRAMEWORK = "karaf.framework";
-
     public static void main(String[] args) {
         try {
-            updateClassLoader();
             Main.main(args);
         } catch (Throwable t) {
             t.printStackTrace();
@@ -44,46 +39,9 @@
     }
 
     public static Main launch(String[] args) throws Exception {
-        updateClassLoader();
         Main main = new Main(args);
         main.launch();
         return main;
     }
 
-    private static void updateClassLoader() throws Exception {
-        File home = Utils.getKarafHome();
-        File base = Utils.getKarafBase(home);
-        File file = new File(new File(base, "etc"), FRAMEWORK_PROPERTIES_FILE_NAME);
-        if (!file.exists()) {
-            file = new File(new File(home, "etc"), FRAMEWORK_PROPERTIES_FILE_NAME);
-        }
-        if (!file.exists()) {
-            throw new FileNotFoundException(file.getAbsolutePath());
-        }
-        Properties props = new Properties();
-        InputStream is = new FileInputStream(file);
-        props.load(is);
-        is.close();
-
-        String framework = props.getProperty(KARAF_FRAMEWORK);
-        if (framework == null) {
-            throw new IllegalArgumentException("Property " + KARAF_FRAMEWORK + " must be
set in the etc/" + FRAMEWORK_PROPERTIES_FILE_NAME + " configuration file");
-        }
-        String bundle = props.getProperty(KARAF_FRAMEWORK + "." + framework);
-        if (bundle == null) {
-            throw new IllegalArgumentException("Property " + KARAF_FRAMEWORK + "." + framework
+ " must be set in the etc/" + FRAMEWORK_PROPERTIES_FILE_NAME + " configuration file");
-        }
-        File bundleFile = new File(base, bundle);
-        if (!bundleFile.exists()) {
-            bundleFile = new File(home, bundle);
-        }
-        if (!bundleFile.exists()) {
-            throw new FileNotFoundException(bundleFile.getAbsolutePath());
-        }
-
-        URLClassLoader classLoader = (URLClassLoader) Bootstrap.class.getClassLoader();
-        Method mth = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
-        mth.setAccessible(true);
-        mth.invoke(classLoader, bundleFile.toURL());
-    }
 }

Modified: felix/trunk/karaf/main/src/main/java/org/apache/felix/karaf/main/Main.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/main/src/main/java/org/apache/felix/karaf/main/Main.java?rev=822663&r1=822662&r2=822663&view=diff
==============================================================================
--- felix/trunk/karaf/main/src/main/java/org/apache/felix/karaf/main/Main.java (original)
+++ felix/trunk/karaf/main/src/main/java/org/apache/felix/karaf/main/Main.java Wed Oct  7
11:05:14 2009
@@ -133,6 +133,8 @@
     public static final String PROPERTY_LOCK_LEVEL = "karaf.lock.level";
 
     public static final String DEFAULT_REPO = "karaf.default.repository";
+    
+    public static final String KARAF_FRAMEWORK = "karaf.framework";
 
     public static final String PROPERTY_LOCK_CLASS_DEFAULT = SimpleFileLock.class.getName();
 
@@ -172,6 +174,8 @@
         configProps = loadConfigProperties();
         BootstrapLogManager.setProperties(configProps);
         LOG.addHandler(BootstrapLogManager.getDefaultHandler());
+        
+        updateClassLoader(configProps);
 
         // Copy framework properties from the system properties.
         Main.copySystemProperties(configProps);
@@ -731,7 +735,7 @@
         Properties configProps = loadPropertiesFile(configPropURL);
         Properties startupProps = loadPropertiesFile(startupPropURL);
 
-        String defaultRepo = configProps.getProperty(DEFAULT_REPO, "system");
+        String defaultRepo = System.getProperty(DEFAULT_REPO, "system");
 
         if (karafBase.equals(karafHome)) {
             bundleDirs.add(new File(karafHome, defaultRepo));
@@ -817,6 +821,30 @@
             }
         }
     }
+    
+    private void updateClassLoader(Properties configProps) throws Exception {
+    	String framework = configProps.getProperty(KARAF_FRAMEWORK);
+        if (framework == null) {
+            throw new IllegalArgumentException("Property " + KARAF_FRAMEWORK + " must be
set in the etc/" + CONFIG_PROPERTIES_FILE_NAME + " configuration file");
+        }
+        String bundle = configProps.getProperty(KARAF_FRAMEWORK + "." + framework);
+        if (bundle == null) {
+            throw new IllegalArgumentException("Property " + KARAF_FRAMEWORK + "." + framework
+ " must be set in the etc/" + CONFIG_PROPERTIES_FILE_NAME + " configuration file");
+        }
+        File bundleFile = new File(karafBase, bundle);
+        if (!bundleFile.exists()) {
+            bundleFile = new File(karafHome, bundle);
+        }
+        if (!bundleFile.exists()) {
+            throw new FileNotFoundException(bundleFile.getAbsolutePath());
+        }
+
+        URLClassLoader classLoader = (URLClassLoader) Bootstrap.class.getClassLoader();
+        Method mth = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
+        mth.setAccessible(true);
+        mth.invoke(classLoader, bundleFile.toURL());
+
+    }
 
     /**
      * Process properties to customize default felix behavior



Mime
View raw message