- /** Intermediary structure used by path matching */
- protected class BundlesSet {
- private String baseUrl = "reference:file";// not used yet
- private final String dir;
- private List includes = new ArrayList();
- private List excludes = new ArrayList();
-
- public BundlesSet(String def) {
- StringTokenizer st = new StringTokenizer(def, ";");
-
- if (!st.hasMoreTokens())
- 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)
- debug("Base dir: " + dir);
- } catch (IOException e) {
- throw new RuntimeException("Cannot convert to absolute path", e);
- }
-
- while (st.hasMoreTokens()) {
- String tk = st.nextToken();
- StringTokenizer stEq = new StringTokenizer(tk, "=");
- String type = stEq.nextToken();
- String pattern = stEq.nextToken();
- if ("in".equals(type) || "include".equals(type)) {
- includes.add(pattern);
- } else if ("ex".equals(type) || "exclude".equals(type)) {
- excludes.add(pattern);
- } else if ("baseUrl".equals(type)) {
- baseUrl = pattern;
- } else {
- System.err.println("Unkown bundles pattern type " + type);
- }
- }
-
- if (excludeSvn && !excludes.contains(EXCLUDES_SVN_PATTERN)) {
- excludes.add(EXCLUDES_SVN_PATTERN);
- }
- }
-
- public String getDir() {
- return dir;
- }
-
- public List getIncludes() {
- return includes;
- }
-
- public List getExcludes() {
- return excludes;
- }
-
- public String getBaseUrl() {
- return baseUrl;
- }
-
- }
-
- /* @deprecated Doesn't seem to be used anymore. */
- // public void installOrUpdateUrls(Map urls) {
- // Map installedBundles = getBundles();
- //
- // for (Iterator modules = urls.keySet().iterator(); modules.hasNext();) {
- // String moduleName = (String) modules.next();
- // String urlStr = (String) urls.get(moduleName);
- // if (installedBundles.containsKey(moduleName)) {
- // Bundle bundle = (Bundle) installedBundles.get(moduleName);
- // InputStream in;
- // try {
- // URL url = new URL(urlStr);
- // in = url.openStream();
- // bundle.update(in);
- // OsgiBootUtils.info("Updated bundle " + moduleName
- // + " from " + urlStr);
- // } catch (Exception e) {
- // throw new RuntimeException("Cannot update " + moduleName
- // + " from " + urlStr);
- // }
- // if (in != null)
- // try {
- // in.close();
- // } catch (IOException e) {
- // e.printStackTrace();
- // }
- // } else {
- // try {
- // Bundle bundle = bundleContext.installBundle(urlStr);
- // if (debug)
- // debug("Installed bundle " + bundle.getSymbolicName()
- // + " from " + urlStr);
- // } catch (BundleException e) {
- // OsgiBootUtils.warn("Could not install bundle from "
- // + urlStr + ": " + e.getMessage());
- // }
- // }
- // }
- //
- // }
-