org.apache.tuscany.sca.extensibility.osgi
Class OSGiServiceDiscoverer

java.lang.Object
  extended by org.apache.tuscany.sca.extensibility.osgi.OSGiServiceDiscoverer
All Implemented Interfaces:
ServiceDiscoverer

public class OSGiServiceDiscoverer
extends java.lang.Object
implements ServiceDiscoverer

The ServiceDiscoverer that find META-INF/services/... in installed bundles


Nested Class Summary
 class OSGiServiceDiscoverer.ClassLoaderImpl
          This class loader provides resource access to META-INF/services/...
static class OSGiServiceDiscoverer.ServiceDeclarationImpl
           
 
Constructor Summary
OSGiServiceDiscoverer(BundleContext context)
           
 
Method Summary
 java.util.Set<ServiceDeclaration> discover(java.lang.String serviceName, boolean firstOnly)
          Discover the service descriptors by name
 BundleContext getBundleContext()
           
 java.lang.ClassLoader getContextClassLoader()
          This class loader can be set as the thread context class loader for non-OSGi code
protected static java.util.Map<java.lang.String,java.lang.String> parseServiceDeclaration(java.lang.String declaration)
          Parse a service declaration in the form class;attr=value,attr=value and return a map of attributes
static java.lang.String toString(Bundle b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OSGiServiceDiscoverer

public OSGiServiceDiscoverer(BundleContext context)
Method Detail

toString

public static java.lang.String toString(Bundle b)

parseServiceDeclaration

protected static java.util.Map<java.lang.String,java.lang.String> parseServiceDeclaration(java.lang.String declaration)
Parse a service declaration in the form class;attr=value,attr=value and return a map of attributes

Parameters:
declaration -
Returns:
a map of attributes

getBundleContext

public BundleContext getBundleContext()

getContextClassLoader

public java.lang.ClassLoader getContextClassLoader()
This class loader can be set as the thread context class loader for non-OSGi code

Returns:

discover

public java.util.Set<ServiceDeclaration> discover(java.lang.String serviceName,
                                                  boolean firstOnly)
Description copied from interface: ServiceDiscoverer
Discover the service descriptors by name

Specified by:
discover in interface ServiceDiscoverer
Parameters:
serviceName - The name of the service
firstOnly - A flag to indicate if only the first instance is to be discovered
Returns:
A set of service descriptors