Service Activator Toolkit
Version 1.1.0 (20081206)

org.eclipse.soda.sat.core.util
Class BundleUtility

java.lang.Object
  extended by org.eclipse.soda.sat.core.util.BundleUtility

public final class BundleUtility
extends Object

The BundleUtility class is a utility that simplifies working with Bundle objects.

Note: This is a singleton class, accessible only via the static method getInstance(). For example:

 BundleUtility utility = BundleUtility.getInstance();
 boolean result = utility.isBundleState(bundle, Bundle.INSTALLED);
 


Method Summary
static BundleUtility getInstance()
          Public getter for the BundleUtility singleton instance.
 ServiceReference getServiceInstanceOf(Bundle bundle, String name)
          Query a Bundle for a ServiceReference to a named service.
 boolean isBundleState(Bundle bundle, int state)
          Tests whether a Bundle is in a specific state.
 boolean isRegisteredService(Bundle bundle, ServiceReference serviceReference)
          Answers true if the Bundle has registered the ServiceReference, otherwise false.
 boolean isRegisteredService(Bundle bundle, String name)
          Answers true if the Bundle has registered a service with the given name, otherwise false.
 boolean isServiceInUse(Bundle bundle, ServiceReference serviceReference)
          Answers true if the Bundle is using the ServiceReference, otherwise false.
 String toBundleStateString(Bundle bundle)
          Get a human-readable string that describes the state of a given bundle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static BundleUtility getInstance()
Public getter for the BundleUtility singleton instance.

Returns:
BundleUtility

getServiceInstanceOf

public ServiceReference getServiceInstanceOf(Bundle bundle,
                                             String name)
Query a Bundle for a ServiceReference to a named service. Answers the ServiceReference or null if no match was found.

Parameters:
bundle - The bundle to be queried.
name - The fully qualified type name of the service.
Returns:
ServiceReference or null.

isBundleState

public boolean isBundleState(Bundle bundle,
                             int state)
Tests whether a Bundle is in a specific state. Valid bundle states are defined by the Bundle class:
  • Bundle.UNINSTALLED
  • Bundle.INSTALLED
  • Bundle.RESOLVED
  • Bundle.STARTING
  • Bundle.STOPPING
  • Bundle.ACTIVE

For example:

 boolean active = BundleUntility.isBundle(bundle, Bundle.ACTIVE);
 

Parameters:
bundle - The bundle who's state is being tested.
state - The state being tested for.
Returns:
boolean

isRegisteredService

public boolean isRegisteredService(Bundle bundle,
                                   ServiceReference serviceReference)
Answers true if the Bundle has registered the ServiceReference, otherwise false.

Parameters:
bundle - The Bundle being queried.
serviceReference - The ServiceReference being searched for.
Returns:
boolean

isRegisteredService

public boolean isRegisteredService(Bundle bundle,
                                   String name)
Answers true if the Bundle has registered a service with the given name, otherwise false.

Parameters:
bundle - The Bundle being queried.
name - The fully qualified type name of the service.
Returns:
boolean

isServiceInUse

public boolean isServiceInUse(Bundle bundle,
                              ServiceReference serviceReference)
Answers true if the Bundle is using the ServiceReference, otherwise false.

Parameters:
bundle - The Bundle being queried.
serviceReference - The ServiceReference being searched for.
Returns:
boolean

toBundleStateString

public String toBundleStateString(Bundle bundle)
Get a human-readable string that describes the state of a given bundle.

Parameters:
bundle - A Bundle.
Returns:
The String describing the state of the Bundle.

Service Activator Toolkit
Version 1.1.0 (20081206)