1 package org
.argeo
.slc
.osgiboot
;
3 import java
.io
.BufferedReader
;
5 import java
.io
.IOException
;
6 import java
.io
.InputStream
;
7 import java
.io
.InputStreamReader
;
9 import java
.util
.ArrayList
;
10 import java
.util
.HashMap
;
11 import java
.util
.Iterator
;
12 import java
.util
.List
;
14 import java
.util
.StringTokenizer
;
16 import org
.argeo
.slc
.osgiboot
.internal
.springutil
.AntPathMatcher
;
17 import org
.argeo
.slc
.osgiboot
.internal
.springutil
.PathMatcher
;
18 import org
.argeo
.slc
.osgiboot
.internal
.springutil
.SystemPropertyUtils
;
19 import org
.osgi
.framework
.Bundle
;
20 import org
.osgi
.framework
.BundleContext
;
21 import org
.osgi
.framework
.BundleException
;
22 import org
.osgi
.framework
.Constants
;
23 import org
.osgi
.framework
.ServiceReference
;
24 import org
.osgi
.service
.packageadmin
.PackageAdmin
;
26 public class OsgiBoot
{
27 public final static String SYMBOLIC_NAME_OSGI_BOOT
= "org.argeo.osgi.boot";
28 public final static String SYMBOLIC_NAME_EQUINOX
= "org.eclipse.osgi";
30 public final static String PROP_ARGEO_OSGI_DATA_DIR
= "argeo.osgi.data.dir";
32 public final static String PROP_ARGEO_OSGI_START
= "argeo.osgi.start";
33 public final static String PROP_ARGEO_OSGI_BUNDLES
= "argeo.osgi.bundles";
34 public final static String PROP_ARGEO_OSGI_LOCATIONS
= "argeo.osgi.locations";
35 public final static String PROP_ARGEO_OSGI_BASE_URL
= "argeo.osgi.baseUrl";
36 public final static String PROP_ARGEO_OSGI_MODULES_URL
= "argeo.osgi.modulesUrl";
38 public final static String PROP_ARGEO_OSGI_BOOT_DEBUG
= "argeo.osgi.boot.debug";
39 public final static String PROP_ARGEO_OSGI_BOOT_DEFAULT_TIMEOUT
= "argeo.osgi.boot.defaultTimeout";
40 public final static String PROP_ARGEO_OSGI_BOOT_MODULES_URL_SEPARATOR
= "argeo.osgi.boot.modulesUrlSeparator";
41 public final static String PROP_ARGEO_OSGI_BOOT_SYSTEM_PROPERTIES_FILE
= "argeo.osgi.boot.systemPropertiesFile";
44 public final static String PROP_SLC_OSGI_START
= "slc.osgi.start";
46 public final static String PROP_SLC_OSGI_BUNDLES
= "slc.osgi.bundles";
48 public final static String PROP_SLC_OSGI_LOCATIONS
= "slc.osgi.locations";
50 public final static String PROP_SLC_OSGI_BASE_URL
= "slc.osgi.baseUrl";
52 public final static String PROP_SLC_OSGI_MODULES_URL
= "slc.osgi.modulesUrl";
55 public final static String PROP_SLC_OSGIBOOT_DEBUG
= "slc.osgiboot.debug";
57 public final static String PROP_SLC_OSGIBOOT_DEFAULT_TIMEOUT
= "slc.osgiboot.defaultTimeout";
59 public final static String PROP_SLC_OSGIBOOT_MODULES_URL_SEPARATOR
= "slc.osgiboot.modulesUrlSeparator";
61 public final static String PROP_SLC_OSGIBOOT_SYSTEM_PROPERTIES_FILE
= "slc.osgiboot.systemPropertiesFile";
63 public final static String DEFAULT_BASE_URL
= "reference:file:";
64 public final static String EXCLUDES_SVN_PATTERN
= "**/.svn/**";
66 private boolean debug
= Boolean
.valueOf(
67 System
.getProperty(PROP_ARGEO_OSGI_BOOT_DEBUG
, System
.getProperty(
68 PROP_SLC_OSGIBOOT_DEBUG
, "false"))).booleanValue();
69 /** Default is 10s (set in constructor) */
70 private long defaultTimeout
;
72 private boolean excludeSvn
= true;
73 /** Default is ',' (set in constructor) */
74 private String modulesUrlSeparator
= ",";
76 private final BundleContext bundleContext
;
78 public OsgiBoot(BundleContext bundleContext
) {
79 this.bundleContext
= bundleContext
;
80 defaultTimeout
= Long
.parseLong(getPropertyCompat(
81 PROP_ARGEO_OSGI_BOOT_DEFAULT_TIMEOUT
,
82 PROP_SLC_OSGIBOOT_DEFAULT_TIMEOUT
, "10000"));
83 modulesUrlSeparator
= getPropertyCompat(
84 PROP_ARGEO_OSGI_BOOT_MODULES_URL_SEPARATOR
,
85 PROP_SLC_OSGIBOOT_MODULES_URL_SEPARATOR
, ",");
86 initSystemProperties();
89 protected void initSystemProperties() {
90 String osgiInstanceArea
= System
.getProperty("osgi.instance.area");
91 String osgiInstanceAreaDefault
= System
92 .getProperty("osgi.instance.area.default");
93 String tempDir
= System
.getProperty("java.io.tmpdir");
96 if (osgiInstanceArea
!= null) {
97 // within OSGi with -data specified
98 osgiInstanceArea
= removeFilePrefix(osgiInstanceArea
);
99 dataDir
= new File(osgiInstanceArea
);
100 } else if (osgiInstanceAreaDefault
!= null) {
101 // within OSGi without -data specified
102 osgiInstanceAreaDefault
= removeFilePrefix(osgiInstanceAreaDefault
);
103 dataDir
= new File(osgiInstanceAreaDefault
);
104 } else {// outside OSGi
105 dataDir
= new File(tempDir
+ File
.separator
+ "argeoOsgiData");
108 System
.setProperty(PROP_ARGEO_OSGI_DATA_DIR
, dataDir
.getAbsolutePath());
111 public static String
removeFilePrefix(String url
) {
112 if (url
.startsWith("file:"))
113 return url
.substring("file:".length());
114 else if (url
.startsWith("reference:file:"))
115 return url
.substring("reference:file:".length());
120 public void bootstrap() {
121 long begin
= System
.currentTimeMillis();
122 System
.out
.println();
123 info("OSGi bootstrap starting...");
124 info("Writable data directory : "
125 + System
.getProperty(PROP_ARGEO_OSGI_DATA_DIR
)
126 + " (set as system property " + PROP_ARGEO_OSGI_DATA_DIR
+ ")");
127 installUrls(getBundlesUrls());
128 installUrls(getLocationsUrls());
129 installUrls(getModulesUrls());
132 long duration
= System
.currentTimeMillis() - begin
;
133 info("OSGi bootstra completed in "
134 + Math
.round(((double) duration
) / 1000) + "s (" + duration
135 + "ms), " + bundleContext
.getBundles().length
+ " bundles");
136 System
.out
.println();
139 public void installUrls(List urls
) {
140 Map installedBundles
= getInstalledBundles();
141 for (int i
= 0; i
< urls
.size(); i
++) {
142 String url
= (String
) urls
.get(i
);
144 if (installedBundles
.containsKey(url
)) {
145 Bundle bundle
= (Bundle
) installedBundles
.get(url
);
148 debug("Bundle " + bundle
.getSymbolicName()
149 + " already installed from " + url
);
151 Bundle bundle
= bundleContext
.installBundle(url
);
153 debug("Installed bundle " + bundle
.getSymbolicName()
156 } catch (BundleException e
) {
157 String message
= e
.getMessage();
158 if ((message
.contains("Bundle \"" + SYMBOLIC_NAME_OSGI_BOOT
159 + "\"") || message
.contains("Bundle \""
160 + SYMBOLIC_NAME_EQUINOX
+ "\""))
161 && message
.contains("has already been installed")) {
162 // silent, in order to avoid warnings: we know that both
163 // have already been installed...
165 warn("Could not install bundle from " + url
+ ": "
175 public void installOrUpdateUrls(Map urls
) {
176 Map installedBundles
= getBundles();
178 for (Iterator modules
= urls
.keySet().iterator(); modules
.hasNext();) {
179 String moduleName
= (String
) modules
.next();
180 String urlStr
= (String
) urls
.get(moduleName
);
181 if (installedBundles
.containsKey(moduleName
)) {
182 Bundle bundle
= (Bundle
) installedBundles
.get(moduleName
);
185 URL url
= new URL(urlStr
);
186 in
= url
.openStream();
188 info("Updated bundle " + moduleName
+ " from " + urlStr
);
189 } catch (Exception e
) {
190 throw new RuntimeException("Cannot update " + moduleName
191 + " from " + urlStr
);
196 } catch (IOException e
) {
201 Bundle bundle
= bundleContext
.installBundle(urlStr
);
203 debug("Installed bundle " + bundle
.getSymbolicName()
204 + " from " + urlStr
);
205 } catch (BundleException e
) {
206 warn("Could not install bundle from " + urlStr
+ ": "
214 public void startBundles() {
215 String bundlesToStart
= getPropertyCompat(PROP_ARGEO_OSGI_START
,
216 PROP_SLC_OSGI_START
);
217 startBundles(bundlesToStart
);
220 public void startBundles(String bundlesToStartStr
) {
221 if (bundlesToStartStr
== null)
224 StringTokenizer st
= new StringTokenizer(bundlesToStartStr
, ",");
225 List bundlesToStart
= new ArrayList();
226 while (st
.hasMoreTokens()) {
227 String name
= st
.nextToken().trim();
228 bundlesToStart
.add(name
);
230 startBundles(bundlesToStart
);
233 public void startBundles(List bundlesToStart
) {
234 if (bundlesToStart
.size() == 0)
237 // used to log the bundles not found
238 List notFoundBundles
= new ArrayList(bundlesToStart
);
240 Bundle
[] bundles
= bundleContext
.getBundles();
241 long startBegin
= System
.currentTimeMillis();
242 for (int i
= 0; i
< bundles
.length
; i
++) {
243 Bundle bundle
= bundles
[i
];
244 String symbolicName
= bundle
.getSymbolicName();
245 if (bundlesToStart
.contains(symbolicName
))
249 } catch (Exception e
) {
250 warn("Start of bundle " + symbolicName
251 + " failed because of " + e
252 + ", maybe bundle is not yet resolved,"
253 + " waiting and trying again.");
254 waitForBundleResolvedOrActive(startBegin
, bundle
);
257 notFoundBundles
.remove(symbolicName
);
258 } catch (Exception e
) {
259 warn("Bundle " + symbolicName
+ " cannot be started: "
263 // was found even if start failed
264 notFoundBundles
.remove(symbolicName
);
268 for (int i
= 0; i
< notFoundBundles
.size(); i
++)
269 warn("Bundle " + notFoundBundles
.get(i
)
270 + " not started because it was not found.");
273 protected void checkUnresolved() {
275 ServiceReference packageAdminRef
= bundleContext
276 .getServiceReference(PackageAdmin
.class.getName());
277 PackageAdmin packageAdmin
= (PackageAdmin
) bundleContext
278 .getService(packageAdminRef
);
279 packageAdmin
.resolveBundles(null);
281 Bundle
[] bundles
= bundleContext
.getBundles();
282 List
/* Bundle */unresolvedBundles
= new ArrayList();
283 for (int i
= 0; i
< bundles
.length
; i
++) {
284 int bundleState
= bundles
[i
].getState();
285 if (!(bundleState
== Bundle
.ACTIVE
286 || bundleState
== Bundle
.RESOLVED
|| bundleState
== Bundle
.STARTING
))
287 unresolvedBundles
.add(bundles
[i
]);
290 if (unresolvedBundles
.size() != 0) {
291 warn("Unresolved bundles " + unresolvedBundles
);
295 protected void waitForBundleResolvedOrActive(long startBegin
, Bundle bundle
)
297 int originalState
= bundle
.getState();
298 if ((originalState
== Bundle
.RESOLVED
)
299 || (originalState
== Bundle
.ACTIVE
))
302 String originalStateStr
= stateAsString(originalState
);
304 int currentState
= bundle
.getState();
305 while (!(currentState
== Bundle
.RESOLVED
|| currentState
== Bundle
.ACTIVE
)) {
306 long now
= System
.currentTimeMillis();
307 if ((now
- startBegin
) > defaultTimeout
)
308 throw new Exception("Bundle " + bundle
.getSymbolicName()
309 + " was not RESOLVED or ACTIVE after "
310 + (now
- startBegin
) + "ms (originalState="
311 + originalStateStr
+ ", currentState="
312 + stateAsString(currentState
) + ")");
316 } catch (InterruptedException e
) {
319 currentState
= bundle
.getState();
323 public static String
stateAsString(int state
) {
325 case Bundle
.UNINSTALLED
:
326 return "UNINSTALLED";
327 case Bundle
.INSTALLED
:
329 case Bundle
.RESOLVED
:
331 case Bundle
.STARTING
:
335 case Bundle
.STOPPING
:
338 return Integer
.toString(state
);
342 /** Key is location */
343 public Map
getInstalledBundles() {
344 Map installedBundles
= new HashMap();
346 Bundle
[] bundles
= bundleContext
.getBundles();
347 for (int i
= 0; i
< bundles
.length
; i
++) {
348 installedBundles
.put(bundles
[i
].getLocation(), bundles
[i
]);
350 return installedBundles
;
353 /** Key is symbolic name */
354 public Map
getBundles() {
355 Map namedBundles
= new HashMap();
356 Bundle
[] bundles
= bundleContext
.getBundles();
357 for (int i
= 0; i
< bundles
.length
; i
++) {
358 namedBundles
.put(bundles
[i
].getSymbolicName(), bundles
[i
]);
363 public List
getLocationsUrls() {
364 String baseUrl
= getPropertyCompat(PROP_ARGEO_OSGI_BASE_URL
,
365 PROP_SLC_OSGI_BASE_URL
, DEFAULT_BASE_URL
);
366 String bundleLocations
= getPropertyCompat(PROP_ARGEO_OSGI_LOCATIONS
,
367 PROP_SLC_OSGI_LOCATIONS
);
368 return getLocationsUrls(baseUrl
, bundleLocations
);
371 public List
getModulesUrls() {
372 List urls
= new ArrayList();
373 String modulesUrlStr
= getPropertyCompat(PROP_ARGEO_OSGI_MODULES_URL
,
374 PROP_SLC_OSGI_MODULES_URL
);
375 if (modulesUrlStr
== null)
378 String baseUrl
= getPropertyCompat(PROP_ARGEO_OSGI_BASE_URL
,
379 PROP_SLC_OSGI_BASE_URL
);
381 Map installedBundles
= getBundles();
383 BufferedReader reader
= null;
385 URL modulesUrl
= new URL(modulesUrlStr
);
386 reader
= new BufferedReader(new InputStreamReader(modulesUrl
389 while ((line
= reader
.readLine()) != null) {
390 StringTokenizer st
= new StringTokenizer(line
,
391 modulesUrlSeparator
);
392 String moduleName
= st
.nextToken();
393 String moduleVersion
= st
.nextToken();
394 String url
= st
.nextToken();
398 if (installedBundles
.containsKey(moduleName
)) {
399 Bundle bundle
= (Bundle
) installedBundles
.get(moduleName
);
400 String bundleVersion
= bundle
.getHeaders().get(
401 Constants
.BUNDLE_VERSION
).toString();
402 int comp
= compareVersions(bundleVersion
, moduleVersion
);
404 warn("Installed version " + bundleVersion
405 + " of bundle " + moduleName
406 + " is newer than provided version "
408 } else if (comp
< 0) {
410 info("Updated bundle " + moduleName
+ " with version "
411 + moduleVersion
+ " (old version was "
412 + bundleVersion
+ ")");
420 } catch (Exception e1
) {
421 throw new RuntimeException("Cannot read url " + modulesUrlStr
, e1
);
426 } catch (IOException e
) {
434 * @return ==0: versions are identical, <0: tested version is newer, >0:
435 * currentVersion is newer.
437 protected int compareVersions(String currentVersion
, String testedVersion
) {
438 List cToks
= new ArrayList();
439 StringTokenizer cSt
= new StringTokenizer(currentVersion
, ".");
440 while (cSt
.hasMoreTokens())
441 cToks
.add(cSt
.nextToken());
442 List tToks
= new ArrayList();
443 StringTokenizer tSt
= new StringTokenizer(currentVersion
, ".");
444 while (tSt
.hasMoreTokens())
445 tToks
.add(tSt
.nextToken());
448 comp
: for (int i
= 0; i
< cToks
.size(); i
++) {
449 if (tToks
.size() <= i
) {
450 // equals until then, tested shorter
455 String c
= (String
) cToks
.get(i
);
456 String t
= (String
) tToks
.get(i
);
459 int cInt
= Integer
.parseInt(c
);
460 int tInt
= Integer
.parseInt(t
);
464 comp
= (cInt
- tInt
);
467 } catch (NumberFormatException e
) {
471 comp
= c
.compareTo(t
);
477 if (comp
== 0 && tToks
.size() > cToks
.size()) {
478 // equals until then, current shorter
485 public List
getLocationsUrls(String baseUrl
, String bundleLocations
) {
486 List urls
= new ArrayList();
488 if (bundleLocations
== null)
490 bundleLocations
= SystemPropertyUtils
491 .resolvePlaceholders(bundleLocations
);
493 debug(PROP_ARGEO_OSGI_LOCATIONS
+ "=" + bundleLocations
);
495 StringTokenizer st
= new StringTokenizer(bundleLocations
,
497 while (st
.hasMoreTokens()) {
498 urls
.add(locationToUrl(baseUrl
, st
.nextToken().trim()));
503 public List
getBundlesUrls() {
504 String baseUrl
= getPropertyCompat(PROP_ARGEO_OSGI_BASE_URL
,
505 PROP_SLC_OSGI_BASE_URL
, DEFAULT_BASE_URL
);
506 String bundlePatterns
= getPropertyCompat(PROP_ARGEO_OSGI_BUNDLES
,
507 PROP_SLC_OSGI_BUNDLES
);
508 return getBundlesUrls(baseUrl
, bundlePatterns
);
511 public List
getBundlesUrls(String baseUrl
, String bundlePatterns
) {
512 List urls
= new ArrayList();
514 List bundlesSets
= new ArrayList();
515 if (bundlePatterns
== null)
517 bundlePatterns
= SystemPropertyUtils
518 .resolvePlaceholders(bundlePatterns
);
520 debug(PROP_ARGEO_OSGI_BUNDLES
+ "=" + bundlePatterns
521 + " (excludeSvn=" + excludeSvn
+ ")");
523 StringTokenizer st
= new StringTokenizer(bundlePatterns
, ",");
524 while (st
.hasMoreTokens()) {
525 bundlesSets
.add(new BundlesSet(st
.nextToken()));
528 List included
= new ArrayList();
529 PathMatcher matcher
= new AntPathMatcher();
530 for (int i
= 0; i
< bundlesSets
.size(); i
++) {
531 BundlesSet bundlesSet
= (BundlesSet
) bundlesSets
.get(i
);
532 for (int j
= 0; j
< bundlesSet
.getIncludes().size(); j
++) {
533 String pattern
= (String
) bundlesSet
.getIncludes().get(j
);
534 match(matcher
, included
, bundlesSet
.getDir(), null, pattern
);
538 List excluded
= new ArrayList();
539 for (int i
= 0; i
< bundlesSets
.size(); i
++) {
540 BundlesSet bundlesSet
= (BundlesSet
) bundlesSets
.get(i
);
541 for (int j
= 0; j
< bundlesSet
.getExcludes().size(); j
++) {
542 String pattern
= (String
) bundlesSet
.getExcludes().get(j
);
543 match(matcher
, excluded
, bundlesSet
.getDir(), null, pattern
);
547 for (int i
= 0; i
< included
.size(); i
++) {
548 String fullPath
= (String
) included
.get(i
);
549 if (!excluded
.contains(fullPath
))
550 urls
.add(locationToUrl(baseUrl
, fullPath
));
556 protected void match(PathMatcher matcher
, List matched
, String base
,
557 String currentPath
, String pattern
) {
558 if (currentPath
== null) {
560 File baseDir
= new File(base
.replace('/', File
.separatorChar
));
561 File
[] files
= baseDir
.listFiles();
564 warn("Base dir " + baseDir
+ " has no children, exists="
565 + baseDir
.exists() + ", isDirectory="
566 + baseDir
.isDirectory());
570 for (int i
= 0; i
< files
.length
; i
++)
571 match(matcher
, matched
, base
, files
[i
].getName(), pattern
);
573 String fullPath
= base
+ '/' + currentPath
;
574 if (matched
.contains(fullPath
))
575 return;// don't try deeper if already matched
577 boolean ok
= matcher
.match(pattern
, currentPath
);
579 debug(currentPath
+ " " + (ok ?
"" : " not ")
580 + " matched with " + pattern
);
582 matched
.add(fullPath
);
585 String newFullPath
= relativeToFullPath(base
, currentPath
);
586 File newFile
= new File(newFullPath
);
587 File
[] files
= newFile
.listFiles();
589 for (int i
= 0; i
< files
.length
; i
++) {
590 String newCurrentPath
= currentPath
+ '/'
591 + files
[i
].getName();
592 if (files
[i
].isDirectory()) {
593 if (matcher
.matchStart(pattern
, newCurrentPath
)) {
594 // recurse only if start matches
595 match(matcher
, matched
, base
, newCurrentPath
,
600 + " does not start match with "
605 boolean nonDirectoryOk
= matcher
.match(pattern
,
608 debug(currentPath
+ " " + (ok ?
"" : " not ")
609 + " matched with " + pattern
);
611 matched
.add(relativeToFullPath(base
,
620 protected String
locationToUrl(String baseUrl
, String location
) {
621 int extInd
= location
.lastIndexOf('.');
624 ext
= location
.substring(extInd
);
626 if (baseUrl
.startsWith("reference:") && ".jar".equals(ext
))
627 return "file:" + location
;
629 return baseUrl
+ location
;
632 /** Transforms a relative path in a full system path. */
633 protected String
relativeToFullPath(String basePath
, String relativePath
) {
634 return (basePath
+ '/' + relativePath
).replace('/', File
.separatorChar
);
637 protected static void info(Object obj
) {
638 System
.out
.println("# OSGiBOOT # " + obj
);
641 protected void debug(Object obj
) {
643 System
.out
.println("# OSGiBOOT DBG # " + obj
);
646 protected void warn(Object obj
) {
647 System
.out
.println("# OSGiBOOT WARN # " + obj
);
648 // Because of a weird bug under Windows when starting it in a forked VM
649 // if (System.getProperty("os.name").contains("Windows"))
650 // System.out.println("# WARN " + obj);
652 // System.err.println("# WARN " + obj);
655 protected String
getProperty(String name
, String defaultValue
) {
657 if (defaultValue
!= null)
658 value
= System
.getProperty(name
, defaultValue
);
660 value
= System
.getProperty(name
);
662 if (value
== null || value
.equals(""))
668 protected String
getProperty(String name
) {
669 return getProperty(name
, null);
672 protected String
getPropertyCompat(String name
, String oldName
) {
673 return getPropertyCompat(name
, oldName
, null);
676 protected String
getPropertyCompat(String name
, String oldName
,
677 String defaultValue
) {
680 if (defaultValue
!= null) {
681 res
= getProperty(name
, defaultValue
);
682 if (res
.equals(defaultValue
)) {
683 res
= getProperty(oldName
, defaultValue
);
684 if (!res
.equals(defaultValue
))
685 warnDeprecated(name
, oldName
);
688 res
= getProperty(name
, null);
690 res
= getProperty(oldName
, null);
692 warnDeprecated(name
, oldName
);
698 protected void warnDeprecated(String name
, String oldName
) {
699 warn("Property '" + oldName
700 + "' is deprecated and will be removed soon, use '" + name
704 public boolean getDebug() {
708 public void setDebug(boolean debug
) {
712 public BundleContext
getBundleContext() {
713 return bundleContext
;
716 /** Whether to exclude Subversion directories (true by default) */
717 public boolean isExcludeSvn() {
721 public void setExcludeSvn(boolean excludeSvn
) {
722 this.excludeSvn
= excludeSvn
;
725 protected class BundlesSet
{
726 private String baseUrl
= "reference:file";// not used yet
727 private final String dir
;
728 private List includes
= new ArrayList();
729 private List excludes
= new ArrayList();
731 public BundlesSet(String def
) {
732 StringTokenizer st
= new StringTokenizer(def
, ";");
734 if (!st
.hasMoreTokens())
735 throw new RuntimeException("Base dir not defined.");
737 String dirPath
= st
.nextToken();
739 if (dirPath
.startsWith("file:"))
740 dirPath
= dirPath
.substring("file:".length());
742 dir
= new File(dirPath
.replace('/', File
.separatorChar
))
745 debug("Base dir: " + dir
);
746 } catch (IOException e
) {
747 throw new RuntimeException("Cannot convert to absolute path", e
);
750 while (st
.hasMoreTokens()) {
751 String tk
= st
.nextToken();
752 StringTokenizer stEq
= new StringTokenizer(tk
, "=");
753 String type
= stEq
.nextToken();
754 String pattern
= stEq
.nextToken();
755 if ("in".equals(type
) || "include".equals(type
)) {
756 includes
.add(pattern
);
757 } else if ("ex".equals(type
) || "exclude".equals(type
)) {
758 excludes
.add(pattern
);
759 } else if ("baseUrl".equals(type
)) {
762 System
.err
.println("Unkown bundles pattern type " + type
);
766 if (excludeSvn
&& !excludes
.contains(EXCLUDES_SVN_PATTERN
)) {
767 excludes
.add(EXCLUDES_SVN_PATTERN
);
771 public String
getDir() {
775 public List
getIncludes() {
779 public List
getExcludes() {
783 public String
getBaseUrl() {
789 public void setDefaultTimeout(long defaultTimeout
) {
790 this.defaultTimeout
= defaultTimeout
;
793 public void setModulesUrlSeparator(String modulesUrlSeparator
) {
794 this.modulesUrlSeparator
= modulesUrlSeparator
;