org.apache.felix.jmood.utils
Class InstrumentationSupport

java.lang.Object
  extended by org.apache.felix.jmood.utils.InstrumentationSupport

public class InstrumentationSupport
extends Object

This class contains helper methods


Constructor Summary
InstrumentationSupport(AgentContext ac)
           
 
Method Summary
static Bundle[] getBundleDependencies(Bundle bundle, AgentContext ac)
           
static long getBundleId(String symbolicName, AgentContext ac)
           
static int getBundleStartLevel(Bundle bundle, AgentContext ac)
           
static ExportedPackage[] getExportedPackages(Bundle bundle, AgentContext ac)
           
static Hashtable getHashtable(Dictionary dic)
           
static ExportedPackage[] getImportedPackages(Bundle bundle, AgentContext ac)
           
static String getPackageName(ExportedPackage pkg)
           
static String[] getPackageNames(ExportedPackage[] packages)
           OSGi exported packages can be uniquely identified by the tuple (packageName, packageVersion).
static RequiredBundle getRequiredBundle(Bundle bundle, AgentContext ac)
           
static Bundle[] getRequiringBundles(Bundle bundle, AgentContext ac)
           
static String[] getServiceNames(ServiceReference[] services)
           OSGi Services can be registered under more than one interface (objectClass in the spec).
static String getState(int state)
           
static String getSymbolicName(Bundle bundle)
           
static String[] getSymbolicNames(Bundle[] bundles)
          For each BundleInfo, this method returns the symbolic name String, which we define as the concatenation of the getSymbolicName of the Bundle interface and the bundle version as specified in the bundle header.
static boolean isBundlePersistentlyStarted(Bundle bundle, AgentContext ac)
           
static boolean isBundleRequired(Bundle bundle, AgentContext ac)
           
static boolean isFragment(Bundle bundle, AgentContext ac)
           
static boolean isRequiredBundleRemovalPending(Bundle bundle, AgentContext ac)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InstrumentationSupport

public InstrumentationSupport(AgentContext ac)
Method Detail

getSymbolicNames

public static String[] getSymbolicNames(Bundle[] bundles)

For each BundleInfo, this method returns the symbolic name String, which we define as the concatenation of the getSymbolicName of the Bundle interface and the bundle version as specified in the bundle header. Both parts are divided by a semicolon. An example would be:

com.acme.foo;1.0.0

Parameters:
bundles - The Bundle array to be converted
Returns:
The String array
See Also:
Bundle.getSymbolicName()

getSymbolicName

public static String getSymbolicName(Bundle bundle)

getPackageNames

public static String[] getPackageNames(ExportedPackage[] packages)

OSGi exported packages can be uniquely identified by the tuple (packageName, packageVersion). This methods returns a String array representing those packages with the following syntax:

packageName;packageVersion

where packageName is as returned by the method getName() and packageVersion as returned by the method getVersion() in package admin's ExportedPackage class.

Parameters:
packages - The ExportedPackage array to be converted
Returns:
The String array
See Also:
ExportedPackage

getPackageName

public static String getPackageName(ExportedPackage pkg)

getServiceNames

public static String[] getServiceNames(ServiceReference[] services)

OSGi Services can be registered under more than one interface (objectClass in the spec). Services have a mandatory unique service id (as defined in the SERVICE_ID property of the org.osgi.framework.Constants interface), during their lifetime (i.e, until they are garbage collected). To show this information in a consistent way, we use the following String representation of the service:

objectClass1[;objectClass2[;objectClass3...]]:service.id

where objectClass1..objectClassN are the elements of the mandatory objectClass array included in the service property dictionary (and set by the framework at registration time. The property name is defined in org.osgi.framework.Constants#OBJECTCLASS

Parameters:
services - The ServiceReference array to be converted
Returns:
The String array
See Also:
Constants.OBJECTCLASS, Constants.SERVICE_ID, ServiceReference

getImportedPackages

public static ExportedPackage[] getImportedPackages(Bundle bundle,
                                                    AgentContext ac)
                                             throws ServiceNotAvailableException
Throws:
ServiceNotAvailableException

getRequiringBundles

public static Bundle[] getRequiringBundles(Bundle bundle,
                                           AgentContext ac)
                                    throws ServiceNotAvailableException
Throws:
ServiceNotAvailableException

getBundleDependencies

public static Bundle[] getBundleDependencies(Bundle bundle,
                                             AgentContext ac)
                                      throws ServiceNotAvailableException
Throws:
ServiceNotAvailableException

isBundleRequired

public static boolean isBundleRequired(Bundle bundle,
                                       AgentContext ac)
                                throws ServiceNotAvailableException
Throws:
ServiceNotAvailableException

isRequiredBundleRemovalPending

public static boolean isRequiredBundleRemovalPending(Bundle bundle,
                                                     AgentContext ac)
                                              throws ServiceNotAvailableException
Throws:
ServiceNotAvailableException

getRequiredBundle

public static RequiredBundle getRequiredBundle(Bundle bundle,
                                               AgentContext ac)
                                        throws ServiceNotAvailableException
Throws:
ServiceNotAvailableException

getState

public static String getState(int state)

isBundlePersistentlyStarted

public static boolean isBundlePersistentlyStarted(Bundle bundle,
                                                  AgentContext ac)
                                           throws ServiceNotAvailableException
Throws:
ServiceNotAvailableException

getBundleStartLevel

public static int getBundleStartLevel(Bundle bundle,
                                      AgentContext ac)
                               throws ServiceNotAvailableException
Throws:
ServiceNotAvailableException

getExportedPackages

public static ExportedPackage[] getExportedPackages(Bundle bundle,
                                                    AgentContext ac)
                                             throws ServiceNotAvailableException
Throws:
ServiceNotAvailableException

isFragment

public static boolean isFragment(Bundle bundle,
                                 AgentContext ac)
                          throws ServiceNotAvailableException
Throws:
ServiceNotAvailableException

getHashtable

public static Hashtable getHashtable(Dictionary dic)

getBundleId

public static long getBundleId(String symbolicName,
                               AgentContext ac)
                        throws BundleNotAvailableException
Throws:
BundleNotAvailableException


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.