From 3f38365459d29ecd8fd83d95ecbc593586627116 Mon Sep 17 00:00:00 2001 From: lresende Date: Sun, 29 Aug 2010 08:53:22 +0000 Subject: TUSCANY-3595 - Allowing service discover to handle resources that are not services, such as properties. In this case, shouldn't append META-INF/services prefix. For compatibility, still try to append META-INF/services if nothing found git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@990510 13f79535-47bb-0310-9956-ffa450edef68 --- .../equinox/EquinoxServiceDiscoverer.java | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'sca-java-2.x/trunk/modules/extensibility-equinox/src/main/java/org/apache/tuscany') 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 6736f9cfb4..2503c0606e 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 @@ -64,7 +64,7 @@ public class EquinoxServiceDiscoverer implements ServiceDiscoverer { bundleTracker = new ActiveBundleTracker(context); bundleTracker.open(); } - + public void stop() { bundleTracker.close(); } @@ -73,7 +73,7 @@ public class EquinoxServiceDiscoverer implements ServiceDiscoverer { String header = (String)bundle.getHeaders().get("SCA-Version"); return Version.parseVersion(header); } - + public static class ActiveBundleTracker extends BundleTracker { /** @@ -162,7 +162,7 @@ public class EquinoxServiceDiscoverer implements ServiceDiscoverer { try { loadClass(); } catch (ClassNotFoundException e) { - // Ignore + // Ignore } return (javaClass != null && serviceType.isAssignableFrom(javaClass)); } @@ -210,13 +210,13 @@ public class EquinoxServiceDiscoverer implements ServiceDiscoverer { return declarations.iterator().next(); } } - + 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 // Skip the 1.x runtime bundle as this has 1.x services in it - // For testing running 1.x and 2.x in same VM. + // For testing running 1.x and 2.x in same VM. // Don't know what final form will be yet. // Skip bundle fragments too return false; @@ -231,7 +231,7 @@ public class EquinoxServiceDiscoverer implements ServiceDiscoverer { } return true; } - + protected Collection getBundles(boolean isTuscanyService) { // return bundles.keySet(); Set set = new HashSet(); @@ -256,8 +256,8 @@ 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; + boolean isTuscanyService = serviceName.startsWith("org.apache.tuscany.sca.") || + serviceName.startsWith("META-INF/services/org.apache.tuscany.sca."); Set visited = new HashSet(); //System.out.println(">>>> getServiceDeclarations()"); @@ -291,6 +291,10 @@ public class EquinoxServiceDiscoverer implements ServiceDiscoverer { logger.log(Level.SEVERE, e.getMessage(), e); } if (urls == null) { + if(! serviceName.startsWith("META-INF/services/")) { + return getServiceDeclarations("META-INF/services/" + serviceName); + } + continue; } while (urls.hasMoreElements()) { @@ -317,7 +321,7 @@ public class EquinoxServiceDiscoverer implements ServiceDiscoverer { } return descriptors; } - + public ClassLoader getContextClassLoader() { // Get the bundle classloader for the extensibility bundle that has DynamicImport-Package * return getClass().getClassLoader(); -- cgit v1.2.3