You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Raymond Feng <en...@gmail.com> on 2010/08/29 18:08:39 UTC
Re: svn commit: r990510 - /tuscany/sca-java-2.x/trunk/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java
I don't think that we should pay the penalty for this corner case. Instead of not adding META-INF/services, we could do the following:
If the name starts with /, we treat it as the full path. Otherwise, we add the META-INF/services (99.9% of all cases).
Raymond Feng
Sent from my iPhone
On Aug 29, 2010, at 1:53 AM, lresende@apache.org wrote:
> Author: lresende
> Date: Sun Aug 29 08:53:22 2010
> New Revision: 990510
>
> URL: http://svn.apache.org/viewvc?rev=990510&view=rev
> Log:
> 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
>
> Modified:
> tuscany/sca-java-2.x/trunk/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java
>
> Modified: tuscany/sca-java-2.x/trunk/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java
> URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java?rev=990510&r1=990509&r2=990510&view=diff
> ==============================================================================
> --- tuscany/sca-java-2.x/trunk/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java (original)
> +++ tuscany/sca-java-2.x/trunk/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java Sun Aug 29 08:53:22 2010
> @@ -64,7 +64,7 @@ public class EquinoxServiceDiscoverer im
> bundleTracker = new ActiveBundleTracker(context);
> bundleTracker.open();
> }
> -
> +
> public void stop() {
> bundleTracker.close();
> }
> @@ -73,7 +73,7 @@ public class EquinoxServiceDiscoverer im
> 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 im
> try {
> loadClass();
> } catch (ClassNotFoundException e) {
> - // Ignore
> + // Ignore
> }
> return (javaClass != null && serviceType.isAssignableFrom(javaClass));
> }
> @@ -210,13 +210,13 @@ public class EquinoxServiceDiscoverer im
> 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 im
> }
> return true;
> }
> -
> +
> protected Collection<Bundle> getBundles(boolean isTuscanyService) {
> // return bundles.keySet();
> Set<Bundle> set = new HashSet<Bundle>();
> @@ -256,8 +256,8 @@ public class EquinoxServiceDiscoverer im
>
> // 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<URL> visited = new HashSet<URL>();
> //System.out.println(">>>> getServiceDeclarations()");
> @@ -291,6 +291,10 @@ public class EquinoxServiceDiscoverer im
> 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 im
> }
> return descriptors;
> }
> -
> +
> public ClassLoader getContextClassLoader() {
> // Get the bundle classloader for the extensibility bundle that has DynamicImport-Package *
> return getClass().getClassLoader();
>
>