diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-02-04 20:50:00 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-02-04 20:50:00 +0000 |
commit | 8d9c4b8268cd7331c43464ae93b22f230a7c275b (patch) | |
tree | 350c86da13a31f34c5a390a49abbfb43799f9779 /sca-java-2.x/trunk/modules/extensibility-equinox/src/main/java | |
parent | 1818d4791ba467cffa31cadc00f0c2f957452bd5 (diff) |
Improve the bundle discovery filtering based on the ML discussion
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@906646 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/extensibility-equinox/src/main/java')
-rw-r--r-- | sca-java-2.x/trunk/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/sca-java-2.x/trunk/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java b/sca-java-2.x/trunk/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java index 56b889b607..5b3f7bdb39 100644 --- a/sca-java-2.x/trunk/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java +++ b/sca-java-2.x/trunk/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java @@ -215,7 +215,7 @@ public class EquinoxServiceDiscoverer implements ServiceDiscoverer { } } - private boolean isProviderBundle(Bundle bundle) { + private boolean isProviderBundle(Bundle bundle, boolean isTuscanyService) { if (bundle.getBundleId() == 0 || bundle.getSymbolicName().startsWith("1.x-osgi-bundle") || bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null) { // Skip system bundle as it has access to the application classloader @@ -225,19 +225,27 @@ public class EquinoxServiceDiscoverer implements ServiceDiscoverer { // Skip bundle fragments too return false; } - if (bundle.getSymbolicName().startsWith("org.apache.tuscany.sca.")) { + // FIXME: [rfeng] What bundles should be searched? ACTIVE and STARTING? + if ((bundle.getState() & Bundle.UNINSTALLED) != 0) { + return false; + } + if (isTuscanyService) { Version scaVersion = getSCAVersion(bundle); return scaVersion.compareTo(version) >= 0; } return true; } - protected Collection<Bundle> getBundles() { + protected Collection<Bundle> getBundles(boolean isTuscanyService) { // return bundles.keySet(); Set<Bundle> set = new HashSet<Bundle>(); for (Bundle b : context.getBundles()) { - if (isProviderBundle(b)) { + if (isProviderBundle(b, isTuscanyService)) { set.add(b); + } else { + if (b.getBundleId() != 0) { + logger.warning("Bundle is skipped for service discovery: " + toString(b)); + } } } return set; @@ -249,11 +257,12 @@ public class EquinoxServiceDiscoverer implements ServiceDiscoverer { // http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/xpath/XPathFactory.html boolean isPropertyFile = "javax.xml.xpath.XPathFactory".equals(serviceName); + boolean isTuscanyService = serviceName.startsWith("org.apache.tuscany.sca."); serviceName = "META-INF/services/" + serviceName; Set<URL> visited = new HashSet<URL>(); //System.out.println(">>>> getServiceDeclarations()"); - for (Bundle bundle : getBundles()) { + for (Bundle bundle : getBundles(isTuscanyService)) { // if (!isProviderBundle(bundle)) { // continue; // } |