karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject karaf git commit: [KARAF-3368] Support reference:file:xxx urls in startup.properties
Date Tue, 18 Nov 2014 07:21:46 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-2.x c1f563b5e -> ec6995469


[KARAF-3368] Support reference:file:xxx urls in startup.properties

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

Branch: refs/heads/karaf-2.x
Commit: ec699546958f6d83ae430ffa0facfbe58ba2eb95
Parents: c1f563b
Author: Guillaume Nodet <gnodet@gmail.com>
Authored: Tue Nov 18 08:11:54 2014 +0100
Committer: Guillaume Nodet <gnodet@gmail.com>
Committed: Tue Nov 18 08:11:54 2014 +0100

----------------------------------------------------------------------
 .../main/java/org/apache/karaf/main/Main.java   | 37 +++++++++++++-------
 1 file changed, 24 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/ec699546/main/src/main/java/org/apache/karaf/main/Main.java
----------------------------------------------------------------------
diff --git a/main/src/main/java/org/apache/karaf/main/Main.java b/main/src/main/java/org/apache/karaf/main/Main.java
index 46dc0ca..9a12861 100644
--- a/main/src/main/java/org/apache/karaf/main/Main.java
+++ b/main/src/main/java/org/apache/karaf/main/Main.java
@@ -30,13 +30,7 @@ import java.io.OutputStreamWriter;
 import java.io.Writer;
 import java.lang.management.ManagementFactory;
 import java.lang.management.RuntimeMXBean;
-import java.net.InetAddress;
-import java.net.MalformedURLException;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.SocketTimeoutException;
-import java.net.URL;
-import java.net.URLClassLoader;
+import java.net.*;
 import java.security.AccessControlException;
 import java.security.Provider;
 import java.security.Security;
@@ -761,10 +755,15 @@ public class Main {
                     location = nextLocation(st);
                     if (location != null) {
                         try {
-                            // TODO: Workaround for PAXURL-278
-                            String[] parts = location.contains("pax-url-aether") ? convertToMavenUrlsIfNeeded(location,
false) 
-                                :  convertToMavenUrlsIfNeeded(location, convertToMavenUrls);
-                            Bundle b = context.installBundle(parts[0], new URL(parts[1]).openStream());
+                            Bundle b;
+                            if (location.startsWith("reference:")) {
+                                b = context.installBundle(location);
+                            } else {
+                                // TODO: Workaround for PAXURL-278
+                                String[] parts = location.contains("pax-url-aether") ? convertToMavenUrlsIfNeeded(location,
false)
+                                        : convertToMavenUrlsIfNeeded(location, convertToMavenUrls);
+                                b = context.installBundle(parts[0], new URL(parts[1]).openStream());
+                            }
                             b.adapt(BundleStartLevel.class).setStartLevel(startLevel);
                             bundles.add(b);
                         }
@@ -1216,12 +1215,19 @@ public class Main {
             HashMap<Integer, StringBuffer> levels = new HashMap<Integer, StringBuffer>();
             for (Object o : startupProps.keySet()) {
                 String name = (String) o;
+                boolean isRef;
+                if (name.startsWith("reference:file:")) {
+                    isRef = true;
+                    name = name.substring("reference:file:".length());
+                } else {
+                    isRef = false;
+                }
                 File file = findFile(bundleDirs, name);
 
                 if (file != null) {
                     Integer level;
                     try {
-                        level = new Integer(startupProps.getProperty(name).trim());
+                        level = new Integer(startupProps.getProperty((String) o).trim());
                     } catch (NumberFormatException e1) {
                         System.err.print("Ignoring " + file.toString() + " (run level must
be an integer)");
                         continue;
@@ -1232,7 +1238,12 @@ public class Main {
                         levels.put(level, sb);
                     }
                     try {
-                        sb.append("\"").append(file.toURI().toURL().toString()).append("|").append(name).append("\"
");
+                        if (isRef) {
+                            URI rel = new File(".").getAbsoluteFile().toURI().relativize(file.toURI());
+                            sb.append("\"reference:file:").append(rel.toString()).append("\"
");
+                        } else {
+                            sb.append("\"").append(file.toURI().toURL().toString()).append("|").append(name).append("\"
");
+                        }
                     } catch (MalformedURLException e) {
                         System.err.print("Ignoring " + file.toString() + " (" + e + ")");
                     }


Mime
View raw message