org.apache.aries.jmx.framework
Class BundleState

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by org.apache.aries.jmx.framework.BundleState
All Implemented Interfaces:
MBeanRegistration, NotificationBroadcaster, NotificationEmitter, BundleStateMBean

public class BundleState
extends NotificationBroadcasterSupport
implements BundleStateMBean, MBeanRegistration

Implementation of BundleStateMBean which emits JMX Notification on Bundle state changes

Version:
$Rev: 931474 $ $Date: 2010-04-07 10:20:32 +0100 (Wed, 07 Apr 2010) $

Field Summary
static String BUNDLE_EVENT
           
protected  org.osgi.framework.BundleContext bundleContext
           
protected  org.osgi.framework.BundleListener bundleListener
           
protected  ExecutorService eventDispatcher
           
protected  Logger logger
           
protected  org.osgi.service.packageadmin.PackageAdmin packageAdmin
           
protected  org.osgi.service.startlevel.StartLevel startLevel
           
 
Fields inherited from interface org.osgi.jmx.framework.BundleStateMBean
ACTIVE, BUNDLE_EVENT_TYPE, BUNDLE_TYPE, BUNDLES_TYPE, EVENT, EVENT_ITEM, EXPORTED_PACKAGES, EXPORTED_PACKAGES_ITEM, FRAGMENT, FRAGMENT_ITEM, FRAGMENTS, FRAGMENTS_ITEM, HEADER_TYPE, HEADERS, HEADERS_ITEM, HEADERS_TYPE, HOSTS, HOSTS_ITEM, IDENTIFIER, IDENTIFIER_ITEM, IMPORTED_PACKAGES, IMPORTED_PACKAGES_ITEM, INSTALLED, KEY, KEY_ITEM, LAST_MODIFIED, LAST_MODIFIED_ITEM, LOCATION, LOCATION_ITEM, OBJECTNAME, PERSISTENTLY_STARTED, PERSISTENTLY_STARTED_ITEM, REGISTERED_SERVICES, REGISTERED_SERVICES_ITEM, REMOVAL_PENDING, REMOVAL_PENDING_ITEM, REQUIRED, REQUIRED_BUNDLES, REQUIRED_BUNDLES_ITEM, REQUIRED_ITEM, REQUIRING_BUNDLES, REQUIRING_BUNDLES_ITEM, RESOLVED, SERVICES_IN_USE, SERVICES_IN_USE_ITEM, START_LEVEL, START_LEVEL_ITEM, STARTING, STATE, STATE_ITEM, STOPPING, SYMBOLIC_NAME, SYMBOLIC_NAME_ITEM, UNINSTALLED, UNKNOWN, VALUE, VALUE_ITEM, VERSION, VERSION_ITEM
 
Constructor Summary
BundleState(org.osgi.framework.BundleContext bundleContext, org.osgi.service.packageadmin.PackageAdmin packageAdmin, org.osgi.service.startlevel.StartLevel startLevel, Logger logger)
           
 
Method Summary
protected  ExecutorService getEventDispatcher()
           
 String[] getExportedPackages(long bundleId)
          Answer the list of exported packages for this bundle.
 long[] getFragments(long bundleId)
          Answer the list of the bundle ids of the fragments associated with this bundle
 TabularData getHeaders(long bundleId)
          Answer the headers for the bundle uniquely identified by the bundle id.
 long[] getHosts(long fragmentId)
          Answer the list of bundle ids of the bundles which host a fragment
 String[] getImportedPackages(long bundleId)
          Answer the array of the packages imported by this bundle
 long getLastModified(long bundleId)
          Answer the last modified time of a bundle
 String getLocation(long bundleId)
          Answer the location of the bundle.
 MBeanNotificationInfo[] getNotificationInfo()
           
 long[] getRegisteredServices(long bundleId)
          Answer the list of service identifiers representing the services this bundle exports
 long[] getRequiredBundles(long bundleIdentifier)
          Answer the list of identifiers of the bundles this bundle depends upon
 long[] getRequiringBundles(long bundleIdentifier)
          Answer the list of identifiers of the bundles which require this bundle
 long[] getServicesInUse(long bundleIdentifier)
          Answer the list of service identifiers which refer to the the services this bundle is using
 int getStartLevel(long bundleId)
          Answer the start level of the bundle
 String getState(long bundleId)
          Answer the symbolic name of the state of the bundle
 String getSymbolicName(long bundleId)
          Answer the symbolic name of the bundle
 String getVersion(long bundleId)
          Answer the location of the bundle.
 boolean isFragment(long bundleId)
          Answer whether the bundle is a fragment or not
 boolean isPersistentlyStarted(long bundleId)
          Answer if the bundle is persistently started when its start level is reached
 boolean isRemovalPending(long bundleId)
          Answer true if the bundle is pending removal
 boolean isRequired(long bundleId)
          Answer true if the bundle is required by another bundle
 TabularData listBundles()
          Answer the bundle state of the system in tabular form.
 void postDeregister()
           
 void postRegister(Boolean registrationDone)
           
 void preDeregister()
           
 ObjectName preRegister(MBeanServer server, ObjectName name)
           
protected  void shutDownDispatcher()
           
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected Logger logger

bundleContext

protected org.osgi.framework.BundleContext bundleContext

packageAdmin

protected org.osgi.service.packageadmin.PackageAdmin packageAdmin

startLevel

protected org.osgi.service.startlevel.StartLevel startLevel

eventDispatcher

protected ExecutorService eventDispatcher

bundleListener

protected org.osgi.framework.BundleListener bundleListener

BUNDLE_EVENT

public static String BUNDLE_EVENT
Constructor Detail

BundleState

public BundleState(org.osgi.framework.BundleContext bundleContext,
                   org.osgi.service.packageadmin.PackageAdmin packageAdmin,
                   org.osgi.service.startlevel.StartLevel startLevel,
                   Logger logger)
Method Detail

getExportedPackages

public String[] getExportedPackages(long bundleId)
                             throws IOException,
                                    IllegalArgumentException
Description copied from interface: BundleStateMBean
Answer the list of exported packages for this bundle.

Specified by:
getExportedPackages in interface BundleStateMBean
Returns:
the array of package names, combined with their version in the format <packageName;version>
Throws:
IOException - if the operation fails
IllegalArgumentException - if the bundle indicated does not exist
See Also:
BundleStateMBean.getExportedPackages(long)

getFragments

public long[] getFragments(long bundleId)
                    throws IOException,
                           IllegalArgumentException
Description copied from interface: BundleStateMBean
Answer the list of the bundle ids of the fragments associated with this bundle

Specified by:
getFragments in interface BundleStateMBean
Returns:
the array of bundle identifiers
Throws:
IOException - if the operation fails
IllegalArgumentException - if the bundle indicated does not exist
See Also:
BundleStateMBean.getFragments(long)

getHeaders

public TabularData getHeaders(long bundleId)
                       throws IOException,
                              IllegalArgumentException
Description copied from interface: BundleStateMBean
Answer the headers for the bundle uniquely identified by the bundle id. The Tabular Data is typed by the BundleStateMBean.HEADERS_TYPE.

Specified by:
getHeaders in interface BundleStateMBean
Parameters:
bundleId - the unique identifier of the bundle
Returns:
the table of associated header key and values
Throws:
IOException - if the operation fails
IllegalArgumentException - if the bundle indicated does not exist
See Also:
BundleStateMBean.getHeaders(long)

getHosts

public long[] getHosts(long fragmentId)
                throws IOException,
                       IllegalArgumentException
Description copied from interface: BundleStateMBean
Answer the list of bundle ids of the bundles which host a fragment

Specified by:
getHosts in interface BundleStateMBean
Parameters:
fragmentId - the bundle id of the fragment
Returns:
the array of bundle identifiers
Throws:
IOException - if the operation fails
IllegalArgumentException - if the bundle indicated does not exist
See Also:
BundleStateMBean.getHosts(long)

getImportedPackages

public String[] getImportedPackages(long bundleId)
                             throws IOException,
                                    IllegalArgumentException
Description copied from interface: BundleStateMBean
Answer the array of the packages imported by this bundle

Specified by:
getImportedPackages in interface BundleStateMBean
Parameters:
bundleId - the bundle identifier
Returns:
the array of package names, combined with their version in the format <packageName;version>
Throws:
IOException - if the operation fails
IllegalArgumentException - if the bundle indicated does not exist
See Also:
BundleStateMBean.getImportedPackages(long)

getLastModified

public long getLastModified(long bundleId)
                     throws IOException,
                            IllegalArgumentException
Description copied from interface: BundleStateMBean
Answer the last modified time of a bundle

Specified by:
getLastModified in interface BundleStateMBean
Parameters:
bundleId - the unique identifier of a bundle
Returns:
the last modified time
Throws:
IOException - if the operation fails
IllegalArgumentException - if the bundle indicated does not exist
See Also:
BundleStateMBean.getLastModified(long)

getLocation

public String getLocation(long bundleId)
                   throws IOException,
                          IllegalArgumentException
Description copied from interface: BundleStateMBean
Answer the location of the bundle.

Specified by:
getLocation in interface BundleStateMBean
Parameters:
bundleId - the identifier of the bundle
Returns:
The location string of this bundle
Throws:
IOException - if the operation fails
IllegalArgumentException - if the bundle indicated does not exist
See Also:
BundleStateMBean.getLocation(long)

getRegisteredServices

public long[] getRegisteredServices(long bundleId)
                             throws IOException,
                                    IllegalArgumentException
Description copied from interface: BundleStateMBean
Answer the list of service identifiers representing the services this bundle exports

Specified by:
getRegisteredServices in interface BundleStateMBean
Parameters:
bundleId - the bundle identifier
Returns:
the list of service identifiers
Throws:
IOException - if the operation fails
IllegalArgumentException - if the bundle indicated does not exist
See Also:
BundleStateMBean.getRegisteredServices(long)

getRequiredBundles

public long[] getRequiredBundles(long bundleIdentifier)
                          throws IOException,
                                 IllegalArgumentException
Description copied from interface: BundleStateMBean
Answer the list of identifiers of the bundles this bundle depends upon

Specified by:
getRequiredBundles in interface BundleStateMBean
Parameters:
bundleIdentifier - the bundle identifier
Returns:
the list of bundle identifiers
Throws:
IOException - if the operation fails
IllegalArgumentException - if the bundle indicated does not exist
See Also:
BundleStateMBean.getRequiredBundles(long)

getRequiringBundles

public long[] getRequiringBundles(long bundleIdentifier)
                           throws IOException,
                                  IllegalArgumentException
Description copied from interface: BundleStateMBean
Answer the list of identifiers of the bundles which require this bundle

Specified by:
getRequiringBundles in interface BundleStateMBean
Parameters:
bundleIdentifier - the bundle identifier
Returns:
the list of bundle identifiers
Throws:
IOException - if the operation fails
IllegalArgumentException - if the bundle indicated does not exist
See Also:
BundleStateMBean.getRequiringBundles(long)

getServicesInUse

public long[] getServicesInUse(long bundleIdentifier)
                        throws IOException,
                               IllegalArgumentException
Description copied from interface: BundleStateMBean
Answer the list of service identifiers which refer to the the services this bundle is using

Specified by:
getServicesInUse in interface BundleStateMBean
Parameters:
bundleIdentifier - the bundle identifier
Returns:
the list of service identifiers
Throws:
IOException - if the operation fails
IllegalArgumentException - if the bundle indicated does not exist
See Also:
BundleStateMBean.getServicesInUse(long)

getStartLevel

public int getStartLevel(long bundleId)
                  throws IOException,
                         IllegalArgumentException
Description copied from interface: BundleStateMBean
Answer the start level of the bundle

Specified by:
getStartLevel in interface BundleStateMBean
Parameters:
bundleId - the identifier of the bundle
Returns:
the start level
Throws:
IOException - if the operation fails
IllegalArgumentException - if the bundle indicated does not exist
See Also:
BundleStateMBean.getStartLevel(long)

getState

public String getState(long bundleId)
                throws IOException,
                       IllegalArgumentException
Description copied from interface: BundleStateMBean
Answer the symbolic name of the state of the bundle

Specified by:
getState in interface BundleStateMBean
Parameters:
bundleId - the identifier of the bundle
Returns:
the string name of the bundle state
Throws:
IOException - if the operation fails
IllegalArgumentException - if the bundle indicated does not exist
See Also:
BundleStateMBean.getState(long)

getSymbolicName

public String getSymbolicName(long bundleId)
                       throws IOException,
                              IllegalArgumentException
Description copied from interface: BundleStateMBean
Answer the symbolic name of the bundle

Specified by:
getSymbolicName in interface BundleStateMBean
Parameters:
bundleId - the identifier of the bundle
Returns:
the symbolic name
Throws:
IOException - if the operation fails
IllegalArgumentException - if the bundle indicated does not exist
See Also:
BundleStateMBean.getSymbolicName(long)

getVersion

public String getVersion(long bundleId)
                  throws IOException,
                         IllegalArgumentException
Description copied from interface: BundleStateMBean
Answer the location of the bundle.

Specified by:
getVersion in interface BundleStateMBean
Parameters:
bundleId - the identifier of the bundle
Returns:
The location string of this bundle
Throws:
IOException - if the operation fails
IllegalArgumentException - if the bundle indicated does not exist
See Also:
BundleStateMBean.getVersion(long)

isFragment

public boolean isFragment(long bundleId)
                   throws IOException,
                          IllegalArgumentException
Description copied from interface: BundleStateMBean
Answer whether the bundle is a fragment or not

Specified by:
isFragment in interface BundleStateMBean
Parameters:
bundleId - the identifier of the bundle
Returns:
true if the bundle is a fragment
Throws:
IOException - if the operation fails
IllegalArgumentException - if the bundle indicated does not exist
See Also:
BundleStateMBean.isFragment(long)

isPersistentlyStarted

public boolean isPersistentlyStarted(long bundleId)
                              throws IOException,
                                     IllegalArgumentException
Description copied from interface: BundleStateMBean
Answer if the bundle is persistently started when its start level is reached

Specified by:
isPersistentlyStarted in interface BundleStateMBean
Parameters:
bundleId - the identifier of the bundle
Returns:
true if the bundle is persistently started
Throws:
IOException - if the operation fails
IllegalArgumentException - if the bundle indicated does not exist
See Also:
BundleStateMBean.isPersistentlyStarted(long)

isRemovalPending

public boolean isRemovalPending(long bundleId)
                         throws IOException,
                                IllegalArgumentException
Description copied from interface: BundleStateMBean
Answer true if the bundle is pending removal

Specified by:
isRemovalPending in interface BundleStateMBean
Parameters:
bundleId - the identifier of the bundle
Returns:
true if the bundle is pending removal
Throws:
IOException - if the operation fails
IllegalArgumentException - if the bundle indicated does not exist
See Also:
BundleStateMBean.isRemovalPending(long)

isRequired

public boolean isRequired(long bundleId)
                   throws IOException,
                          IllegalArgumentException
Description copied from interface: BundleStateMBean
Answer true if the bundle is required by another bundle

Specified by:
isRequired in interface BundleStateMBean
Parameters:
bundleId - the identifier of the bundle
Returns:
true if the bundle is required by another bundle
Throws:
IOException - if the operation fails
IllegalArgumentException - if the bundle indicated does not exist
See Also:
BundleStateMBean.isRequired(long)

listBundles

public TabularData listBundles()
                        throws IOException
Description copied from interface: BundleStateMBean
Answer the bundle state of the system in tabular form. Each row of the returned table represents a single bundle. The Tabular Data consists of Composite Data that is type by BundleStateMBean.BUNDLES_TYPE.

Specified by:
listBundles in interface BundleStateMBean
Returns:
the tabular representation of the bundle state
Throws:
IOException
See Also:
BundleStateMBean.listBundles()

getNotificationInfo

public MBeanNotificationInfo[] getNotificationInfo()
Specified by:
getNotificationInfo in interface NotificationBroadcaster
Overrides:
getNotificationInfo in class NotificationBroadcasterSupport
See Also:
NotificationBroadcasterSupport.getNotificationInfo()

postDeregister

public void postDeregister()
Specified by:
postDeregister in interface MBeanRegistration
See Also:
MBeanRegistration.postDeregister()

postRegister

public void postRegister(Boolean registrationDone)
Specified by:
postRegister in interface MBeanRegistration
See Also:
MBeanRegistration.postRegister(java.lang.Boolean)

preDeregister

public void preDeregister()
                   throws Exception
Specified by:
preDeregister in interface MBeanRegistration
Throws:
Exception
See Also:
MBeanRegistration.preDeregister()

preRegister

public ObjectName preRegister(MBeanServer server,
                              ObjectName name)
                       throws Exception
Specified by:
preRegister in interface MBeanRegistration
Throws:
Exception
See Also:
MBeanRegistration.preRegister(javax.management.MBeanServer, javax.management.ObjectName)

shutDownDispatcher

protected void shutDownDispatcher()

getEventDispatcher

protected ExecutorService getEventDispatcher()


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