]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.init/src/org/argeo/init/osgi/BundlesSet.java
Simplify multi-runtime
[lgpl/argeo-commons.git] / org.argeo.init / src / org / argeo / init / osgi / BundlesSet.java
1 package org.argeo.init.osgi;
2
3 import static java.lang.System.Logger.Level.TRACE;
4
5 import java.io.File;
6 import java.io.IOException;
7 import java.lang.System.Logger;
8 import java.util.ArrayList;
9 import java.util.List;
10 import java.util.StringTokenizer;
11
12 /** Intermediary structure used by path matching */
13 class BundlesSet {
14 private final static Logger logger = System.getLogger(BundlesSet.class.getName());
15
16 private String baseUrl = "reference:file";// not used yet
17 private final String dir;
18 private List<String> includes = new ArrayList<String>();
19 private List<String> excludes = new ArrayList<String>();
20
21 public BundlesSet(String def) {
22 StringTokenizer st = new StringTokenizer(def, ";");
23
24 if (!st.hasMoreTokens())
25 throw new RuntimeException("Base dir not defined.");
26 try {
27 String dirPath = st.nextToken();
28
29 if (dirPath.startsWith("file:"))
30 dirPath = dirPath.substring("file:".length());
31
32 dir = new File(dirPath.replace('/', File.separatorChar)).getCanonicalPath();
33 logger.log(TRACE, () -> "Base dir: " + dir);
34 } catch (IOException e) {
35 throw new RuntimeException("Cannot convert to absolute path", e);
36 }
37
38 while (st.hasMoreTokens()) {
39 String tk = st.nextToken();
40 StringTokenizer stEq = new StringTokenizer(tk, "=");
41 String type = stEq.nextToken();
42 String pattern = stEq.nextToken();
43 if ("in".equals(type) || "include".equals(type)) {
44 includes.add(pattern);
45 } else if ("ex".equals(type) || "exclude".equals(type)) {
46 excludes.add(pattern);
47 } else if ("baseUrl".equals(type)) {
48 baseUrl = pattern;
49 } else {
50 System.err.println("Unkown bundles pattern type " + type);
51 }
52 }
53
54 // if (excludeSvn && !excludes.contains(EXCLUDES_SVN_PATTERN)) {
55 // excludes.add(EXCLUDES_SVN_PATTERN);
56 // }
57 }
58
59 public String getDir() {
60 return dir;
61 }
62
63 public List<String> getIncludes() {
64 return includes;
65 }
66
67 public List<String> getExcludes() {
68 return excludes;
69 }
70
71 public String getBaseUrl() {
72 return baseUrl;
73 }
74
75 }