]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.osgiboot/src/main/java/org/argeo/slc/osgiboot/OsgiBoot.java
Improve SSH support
[gpl/argeo-slc.git] / runtime / org.argeo.slc.osgiboot / src / main / java / org / argeo / slc / osgiboot / OsgiBoot.java
index fdcb77df07abfb513572dce2165b32e55886414c..0f4f5ab23813d292689852ba6acbdec6f847ed66 100644 (file)
@@ -23,10 +23,13 @@ public class OsgiBoot {
        public final static String PROP_SLC_OSGIBOOT_DEBUG = "slc.osgiboot.debug";
 
        public final static String DEFAULT_BASE_URL = "reference:file:";
+       public final static String EXCLUDES_SVN_PATTERN = "**/.svn/**";
 
        private Boolean debug = Boolean.parseBoolean(System.getProperty(
                        PROP_SLC_OSGIBOOT_DEBUG, "false"));
 
+       private boolean excludeSvn = true;
+
        private final BundleContext bundleContext;
 
        public OsgiBoot(BundleContext bundleContext) {
@@ -62,14 +65,26 @@ public class OsgiBoot {
                startBundles(bundlesToStart);
        }
 
-       public void startBundles(String bundlesToStart) throws Exception {
-               if (bundlesToStart == null)
+       public void startBundles(String bundlesToStartStr) throws Exception {
+               if (bundlesToStartStr == null)
                        return;
 
-               StringTokenizer st = new StringTokenizer(bundlesToStart, ",");
-               Map<String, Bundle> bundles = getBundles();
+               StringTokenizer st = new StringTokenizer(bundlesToStartStr, ",");
+               List bundlesToStart = new ArrayList();
                while (st.hasMoreTokens()) {
                        String name = st.nextToken().trim();
+                       bundlesToStart.add(name);
+               }
+               startBundles(bundlesToStart);
+       }
+
+       public void startBundles(List bundlesToStart) throws Exception {
+               if (bundlesToStart.size() == 0)
+                       return;
+
+               Map<String, Bundle> bundles = getBundles();
+               for (int i = 0; i < bundlesToStart.size(); i++) {
+                       String name = bundlesToStart.get(i).toString();
                        Bundle bundle = bundles.get(name);
                        if (bundle != null)
                                try {
@@ -115,6 +130,8 @@ public class OsgiBoot {
                        return urls;
                bundleLocations = SystemPropertyUtils
                                .resolvePlaceholders(bundleLocations);
+               if (debug)
+                       debug(PROP_SLC_OSGI_LOCATIONS + "=" + bundleLocations);
 
                StringTokenizer st = new StringTokenizer(bundleLocations,
                                File.pathSeparator);
@@ -136,8 +153,11 @@ public class OsgiBoot {
                List<BundlesSet> bundlesSets = new ArrayList<BundlesSet>();
                if (bundlePatterns == null)
                        return urls;
-               // TODO: resolve placeholders
-               info(PROP_SLC_OSGI_BUNDLES + "=" + bundlePatterns);
+               bundlePatterns = SystemPropertyUtils
+                               .resolvePlaceholders(bundlePatterns);
+               if (debug)
+                       debug(PROP_SLC_OSGI_BUNDLES + "=" + bundlePatterns
+                                       + " (excludeSvn=" + excludeSvn + ")");
 
                StringTokenizer st = new StringTokenizer(bundlePatterns, ",");
                while (st.hasMoreTokens()) {
@@ -213,7 +233,7 @@ public class OsgiBoot {
                                                        }
                                                }
                                } else {
-                                       warn("Not a directory: " + newFullPath);
+                                       // warn("Not a directory: " + newFullPath);
                                }
                        }
                }
@@ -266,7 +286,16 @@ public class OsgiBoot {
                return bundleContext;
        }
 
-       private class BundlesSet {
+       /** Whether to exclude Subversion directories (true by default) */
+       public boolean isExcludeSvn() {
+               return excludeSvn;
+       }
+
+       public void setExcludeSvn(boolean excludeSvn) {
+               this.excludeSvn = excludeSvn;
+       }
+
+       protected class BundlesSet {
                private String baseUrl = "reference:file";// not used yet
                private final String dir;
                private List<String> includes = new ArrayList<String>();
@@ -279,6 +308,10 @@ public class OsgiBoot {
                                throw new RuntimeException("Base dir not defined.");
                        try {
                                String dirPath = st.nextToken();
+
+                               if (dirPath.startsWith("file:"))
+                                       dirPath = dirPath.substring("file:".length());
+
                                dir = new File(dirPath.replace('/', File.separatorChar))
                                                .getCanonicalPath();
                                if (debug)
@@ -302,6 +335,10 @@ public class OsgiBoot {
                                        System.err.println("Unkown bundles pattern type " + type);
                                }
                        }
+
+                       if (excludeSvn && !excludes.contains(EXCLUDES_SVN_PATTERN)) {
+                               excludes.add(EXCLUDES_SVN_PATTERN);
+                       }
                }
 
                public String getDir() {