org.apache.aries.jmx.util
Class FrameworkUtils

java.lang.Object
  extended by org.apache.aries.jmx.util.FrameworkUtils

public class FrameworkUtils
extends Object

This class contains common utilities related to Framework operations for the MBean implementations

Version:
$Rev: 1029176 $ $Date: 2010-10-30 21:05:35 +0100 (Sat, 30 Oct 2010) $

Method Summary
static boolean arrayContains(Object[] array, Object value)
           
static List<String> extractHeaderDeclaration(String headerStatement)
           
static long[] getBundleDependencies(org.osgi.framework.BundleContext localBundleContext, org.osgi.framework.Bundle bundle, org.osgi.service.packageadmin.PackageAdmin packageAdmin)
          Returns an array of ids of bundles the given bundle depends on
static String[] getBundleExportedPackages(org.osgi.framework.Bundle bundle, org.osgi.service.packageadmin.PackageAdmin packageAdmin)
          Returns the packages exported by the specified bundle
static long[] getBundleIds(org.osgi.framework.Bundle[] bundles)
          Returns an array of bundleIds
static long[] getBundleIds(List<org.osgi.framework.Bundle> bundles)
           
static String[] getBundleImportedPackages(org.osgi.framework.BundleContext localBundleContext, org.osgi.framework.Bundle bundle, org.osgi.service.packageadmin.PackageAdmin packageAdmin)
          Returns the resolved package imports for the given bundle
static String getBundleState(org.osgi.framework.Bundle bundle)
          Returns a String representation of the bundles state
static long[] getDependentBundles(org.osgi.framework.Bundle bundle, org.osgi.service.packageadmin.PackageAdmin packageAdmin)
          Returns an array of ids of bundles that depend on the given bundle
static long[] getFragmentIds(org.osgi.framework.Bundle bundle, org.osgi.service.packageadmin.PackageAdmin packageAdmin)
          Returns the bundle ids of any resolved fragments
static long[] getHostIds(org.osgi.framework.Bundle fragment, org.osgi.service.packageadmin.PackageAdmin packageAdmin)
          Returns the bundle ids of any resolved hosts
static long[] getRegisteredServiceIds(org.osgi.framework.Bundle bundle)
          Returns the service.id values for services registered by the given bundle
static long[] getServiceIds(org.osgi.framework.ServiceReference[] serviceReferences)
          Returns an array of service.id values
static long[] getServicesInUseByBundle(org.osgi.framework.Bundle bundle)
          Returns the service.id values of services being used by the given bundle
static boolean isBundlePendingRemoval(org.osgi.framework.Bundle bundle, org.osgi.service.packageadmin.PackageAdmin packageAdmin)
          Returns the status of pending removal
static boolean isBundleRequiredByOthers(org.osgi.framework.Bundle bundle, org.osgi.service.packageadmin.PackageAdmin packageAdmin)
          Checks if the given bundle is currently required by other bundles
static org.osgi.framework.Bundle resolveBundle(org.osgi.framework.BundleContext bundleContext, long bundleId)
          Returns the Bundle object for a given id
static org.osgi.framework.ServiceReference resolveService(org.osgi.framework.BundleContext bundleContext, long serviceId)
          Returns the ServiceReference object with matching service.id
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

resolveBundle

public static org.osgi.framework.Bundle resolveBundle(org.osgi.framework.BundleContext bundleContext,
                                                      long bundleId)
                                               throws IOException
Returns the Bundle object for a given id

Parameters:
bundleContext -
bundleId -
Returns:
Throws:
IllegalArgumentException - if no Bundle is found with matching bundleId
IOException

getBundleIds

public static long[] getBundleIds(org.osgi.framework.Bundle[] bundles)
Returns an array of bundleIds

Parameters:
bundles - array of Bundle objects
Returns:
bundleIds in sequence

getBundleIds

public static long[] getBundleIds(List<org.osgi.framework.Bundle> bundles)

resolveService

public static org.osgi.framework.ServiceReference resolveService(org.osgi.framework.BundleContext bundleContext,
                                                                 long serviceId)
                                                          throws IOException
Returns the ServiceReference object with matching service.id

Parameters:
bundleContext -
serviceId -
Returns:
ServiceReference with matching service.id property
Throws:
IllegalArgumentException - if bundleContext is null
IOException - if no service is found with the given id

getServiceIds

public static long[] getServiceIds(org.osgi.framework.ServiceReference[] serviceReferences)
Returns an array of service.id values

Parameters:
serviceReferences - array of ServiceReference objects
Returns:
service.id values in sequence

getBundleExportedPackages

public static String[] getBundleExportedPackages(org.osgi.framework.Bundle bundle,
                                                 org.osgi.service.packageadmin.PackageAdmin packageAdmin)
                                          throws IllegalArgumentException
Returns the packages exported by the specified bundle

Parameters:
bundle -
packageAdmin -
Returns:
Throws:
IllegalArgumentException - if bundle or packageAdmin are null

getFragmentIds

public static long[] getFragmentIds(org.osgi.framework.Bundle bundle,
                                    org.osgi.service.packageadmin.PackageAdmin packageAdmin)
                             throws IllegalArgumentException
Returns the bundle ids of any resolved fragments

Parameters:
bundle -
packageAdmin -
Returns:
Throws:
IllegalArgumentException - if bundle or packageAdmin are null

getHostIds

public static long[] getHostIds(org.osgi.framework.Bundle fragment,
                                org.osgi.service.packageadmin.PackageAdmin packageAdmin)
                         throws IllegalArgumentException
Returns the bundle ids of any resolved hosts

Parameters:
fragment -
packageAdmin -
Returns:
Throws:
IllegalArgumentException - if fragment or packageAdmin are null

getBundleImportedPackages

public static String[] getBundleImportedPackages(org.osgi.framework.BundleContext localBundleContext,
                                                 org.osgi.framework.Bundle bundle,
                                                 org.osgi.service.packageadmin.PackageAdmin packageAdmin)
                                          throws IllegalArgumentException
Returns the resolved package imports for the given bundle

Parameters:
localBundleContext - BundleContext object of this bundle/caller
bundle - target Bundle object to query imported packages for
packageAdmin -
Returns:
Throws:
IllegalArgumentException - if fragment or packageAdmin are null

getRegisteredServiceIds

public static long[] getRegisteredServiceIds(org.osgi.framework.Bundle bundle)
                                      throws IllegalArgumentException,
                                             IllegalStateException
Returns the service.id values for services registered by the given bundle

Parameters:
bundle -
Returns:
Throws:
IllegalArgumentException - if bundle is null
IlleglStateException - if bundle has been uninstalled
IllegalStateException

getServicesInUseByBundle

public static long[] getServicesInUseByBundle(org.osgi.framework.Bundle bundle)
                                       throws IllegalArgumentException,
                                              IllegalStateException
Returns the service.id values of services being used by the given bundle

Parameters:
bundle -
Returns:
Throws:
IllegalArgumentException - if bundle is null
IlleglStateException - if bundle has been uninstalled
IllegalStateException

isBundlePendingRemoval

public static boolean isBundlePendingRemoval(org.osgi.framework.Bundle bundle,
                                             org.osgi.service.packageadmin.PackageAdmin packageAdmin)
                                      throws IllegalArgumentException
Returns the status of pending removal

Parameters:
bundle -
Returns:
true if the bundle is pending removal
Throws:
IllegalArgumentException - if bundle or packageAdmin are null

isBundleRequiredByOthers

public static boolean isBundleRequiredByOthers(org.osgi.framework.Bundle bundle,
                                               org.osgi.service.packageadmin.PackageAdmin packageAdmin)
                                        throws IllegalArgumentException
Checks if the given bundle is currently required by other bundles

Parameters:
bundle -
packageAdmin -
Returns:
Throws:
IllegalArgumentException - if bundle or packageAdmin are null

getBundleDependencies

public static long[] getBundleDependencies(org.osgi.framework.BundleContext localBundleContext,
                                           org.osgi.framework.Bundle bundle,
                                           org.osgi.service.packageadmin.PackageAdmin packageAdmin)
                                    throws IllegalArgumentException
Returns an array of ids of bundles the given bundle depends on

Parameters:
localBundleContext - BundleContext object of this bundle/caller
bundle - target Bundle object to query dependencies for
packageAdmin -
Returns:
Throws:
IllegalArgumentException - if bundle or packageAdmin are null

getDependentBundles

public static long[] getDependentBundles(org.osgi.framework.Bundle bundle,
                                         org.osgi.service.packageadmin.PackageAdmin packageAdmin)
                                  throws IllegalArgumentException
Returns an array of ids of bundles that depend on the given bundle

Parameters:
bundle -
packageAdmin -
Returns:
Throws:
IllegalArgumentException - if bundle or packageAdmin are null

getBundleState

public static String getBundleState(org.osgi.framework.Bundle bundle)
Returns a String representation of the bundles state

Parameters:
bundle -
Returns:

arrayContains

public static boolean arrayContains(Object[] array,
                                    Object value)

extractHeaderDeclaration

public static List<String> extractHeaderDeclaration(String headerStatement)


Copyright © 2009-2013 The Apache Software Foundation. All Rights Reserved.