Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.drools.util
Class OSGiLocator

    java.lang.Object
      org.drools.util.OSGiLocator

    public final class OSGiLocator

extends Object

Maintains a mapping of service names to an ordered set of service providers when running in an OSGi container.

It is expected that a bundle using Drools will populate this map with properties from its own ClassLoader.

This is an adaptation of the technique described by Guillaume Nodet in his article Java EE specs in OSGi. The main changes were to add comments.

See Also:
  `http://gnodet.blogspot.com/2008/05/jee-specs-in-osgi.html}`

Method Summary
`static Class<?>` | `locate(String serviceName)` Finds the preferred provider for the given service.
`static List<Class<?>>` | `locateAll(String serviceName)` Finds all providers for the given service.
`static void` | `register(String serviceName, Callable<Class<?>> factory)` Adds the given service provider factory to the set of providers for the service.
`static void` | `unregister(String serviceName, Callable<Class<?>> factory)` Removes the given service provider factory from the set of providers for the service.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### unregister

    public static void unregister(String serviceName,
                                  Callable<Class<?>> factory)

  Removes the given service provider factory from the set of providers for the service.

  Parameters:
    `serviceName` - The fully qualified name of the service interface.
    `factory` - A factory for creating a specific type of service provider. May be `null` in which case this method does nothing.
  Throws:
    `IllegalArgumentException` - if serviceName is `null`

### register

    public static void register(String serviceName,
                                Callable<Class<?>> factory)

  Adds the given service provider factory to the set of providers for the service.

  Parameters:
    `serviceName` - The fully qualified name of the service interface.
    `factory` - A factory for creating a specific type of service provider. May be `null` in which case this method does nothing.
  Throws:
    `IllegalArgumentException` - if serviceName is `null`

### locate

    public static Class<?> locate(String serviceName)

  Finds the preferred provider for the given service. The preferred provider is the last one added to the set of providers.

  Parameters:
    `serviceName` - The fully qualified name of the service interface.
  Returns:
    The last provider added for the service if any exists. Otherwise, it returns `null`.
  Throws:
    `IllegalArgumentException` - if serviceName is `null`

### locateAll

    public static List<Class<?>> locateAll(String serviceName)

  Finds all providers for the given service.

  Parameters:
    `serviceName` - The fully qualified name of the service interface.
  Returns:
    The ordered set of providers for the service if any exists. Otherwise, it returns an empty list.
  Throws:
    `IllegalArgumentException` - if serviceName is `null`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2012 JBoss by Red Hat. All Rights Reserved.