org.eclipse.osgi.framework.internal.core
Class BundleHost

java.lang.Object
  extended by org.eclipse.osgi.framework.internal.core.AbstractBundle
      extended by org.eclipse.osgi.framework.internal.core.BundleHost
All Implemented Interfaces:
java.lang.Comparable, KeyedElement, Bundle
Direct Known Subclasses:
SystemBundle

public class BundleHost
extends AbstractBundle


Field Summary
protected  BundleContextImpl context
          The BundleContext that represents this Bundle and all of its fragments
protected  BundleFragment[] fragments
          The List of BundleFragments
 
Fields inherited from class org.eclipse.osgi.framework.internal.core.AbstractBundle
bundledata, domain, framework, manifestLocalization, state, statechangeLock, stateChanging
 
Fields inherited from interface org.osgi.framework.Bundle
ACTIVE, INSTALLED, RESOLVED, START_ACTIVATION_POLICY, START_TRANSIENT, STARTING, STOP_TRANSIENT, STOPPING, UNINSTALLED
 
Constructor Summary
BundleHost(BundleData bundledata, Framework framework)
           
 
Method Summary
protected  void attachFragment(BundleFragment fragment)
          Attaches a fragment to this BundleHost.
protected  BundleContextImpl createContext()
          Create a BundleContext for this bundle.
protected  BundleLoader getBundleLoader()
           
protected  BundleContextImpl getContext()
          Return the current context for this bundle.
protected  Bundle[] getFragments()
           
protected  BundleLoaderProxy getLoaderProxy()
           
 ServiceReference[] getRegisteredServices()
          Provides a list of ServiceReferenceImpls for the services registered by this bundle or null if the bundle has no registered services.
 java.net.URL getResource(java.lang.String name)
          Find the specified resource in this bundle.
 java.util.Enumeration getResources(java.lang.String name)
          Find the specified resources from this bundle.
 ServiceReference[] getServicesInUse()
          Provides a list of ServiceReferenceImpls for the services this bundle is using, or null if the bundle is not using any services.
protected  void load()
          Load the bundle.
protected  java.lang.Class loadClass(java.lang.String name, boolean checkPermission)
          This method loads a class from the bundle.
protected  boolean readyToResume()
          This method does the following Return false if the bundle is a fragment Return false if the bundle is not at the correct start-level Return false if the bundle is not persistently marked for start Return true if the bundle's activation policy is persistently ignored Return true if the bundle does not define an activation policy Transition to STARTING state and Fire LAZY_ACTIVATION event Return false
protected  void refresh()
          Refresh the bundle.
protected  boolean reload(AbstractBundle newBundle)
          Reload from a new bundle.
protected  void startWorker(int options)
          Internal worker to start a bundle.
protected  void stopWorker(int options)
          Internal worker to stop a bundle.
protected  boolean unload()
          Unload the bundle.
 
Methods inherited from class org.eclipse.osgi.framework.internal.core.AbstractBundle
beginStateChange, checkValid, close, compare, compareTo, completeStateChange, createBundle, findEntries, findLocalEntryPaths, getBundleContext, getBundleData, getBundleDescription, getBundleId, getEntry, getEntryPaths, getHeaders, getHeaders, getHosts, getKey, getKeyHashCode, getLastModified, getLocation, getProtectionDomain, getResolutionFailureMessage, getResourceBundle, getStartLevel, getState, getStateChanging, getSymbolicName, getVersion, hasPermission, isActive, isFragment, isResolved, loadBundleActivator, loadClass, resolve, resume, setStatus, start, start, stop, stop, suspend, testStateChanging, toString, uninstall, uninstallWorker, uninstallWorkerPrivileged, unresolvePermissions, update, update, updateWorker, updateWorkerPrivileged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

context

protected BundleContextImpl context
The BundleContext that represents this Bundle and all of its fragments


fragments

protected BundleFragment[] fragments
The List of BundleFragments

Constructor Detail

BundleHost

public BundleHost(BundleData bundledata,
                  Framework framework)
           throws BundleException
Throws:
BundleException
Method Detail

load

protected void load()
Load the bundle.

Specified by:
load in class AbstractBundle

reload

protected boolean reload(AbstractBundle newBundle)
Reload from a new bundle. This method must be called while holding the bundles lock.

Specified by:
reload in class AbstractBundle
Parameters:
newBundle - Dummy Bundle which contains new data.
Returns:
true if an exported package is "in use". i.e. it has been imported by a bundle

refresh

protected void refresh()
Refresh the bundle. This is called by Framework.refreshPackages. This method must be called while holding the bundles lock.

Specified by:
refresh in class AbstractBundle

unload

protected boolean unload()
Unload the bundle. This method must be called while holding the bundles lock.

Specified by:
unload in class AbstractBundle
Returns:
true if an exported package is "in use". i.e. it has been imported by a bundle

loadClass

protected java.lang.Class loadClass(java.lang.String name,
                                    boolean checkPermission)
                             throws java.lang.ClassNotFoundException
This method loads a class from the bundle.

Specified by:
loadClass in class AbstractBundle
Parameters:
name - the name of the desired Class.
checkPermission - indicates whether a permission check should be done.
Returns:
the resulting Class
Throws:
java.lang.ClassNotFoundException - if the class definition was not found.

getResource

public java.net.URL getResource(java.lang.String name)
Find the specified resource in this bundle. This bundle's class loader is called to search for the named resource. If this bundle's state is INSTALLED, then only this bundle will be searched for the specified resource. Imported packages cannot be searched when a bundle has not been resolved.

Parameters:
name - The name of the resource. See java.lang.ClassLoader.getResource for a description of the format of a resource name.
Returns:
a URL to the named resource, or null if the resource could not be found or if the caller does not have the AdminPermission, and the Java Runtime Environment supports permissions.
Throws:
java.lang.IllegalStateException - If this bundle has been uninstalled.
See Also:
Bundle.getEntry(java.lang.String), Bundle.findEntries(java.lang.String, java.lang.String, boolean)

getResources

public java.util.Enumeration getResources(java.lang.String name)
                                   throws java.io.IOException
Description copied from interface: Bundle
Find the specified resources from this bundle. This bundle's class loader is called to search for the specified resources. If this bundle's state is INSTALLED, this method must attempt to resolve this bundle before attempting to get the specified resources. If this bundle cannot be resolved, then only this bundle must be searched for the specified resources. Imported packages cannot be searched when a bundle has not been resolved. If this bundle is a fragment bundle then null is returned.

Parameters:
name - The name of the resource. See java.lang.ClassLoader.getResources for a description of the format of a resource name.
Returns:
An enumeration of URLs to the named resources, or null if the resource could not be found or if this bundle is a fragment bundle or if the caller does not have the appropriate AdminPermission[this,RESOURCE], and the Java Runtime Environment supports permissions.
Throws:
java.io.IOException - If there is an I/O error.

startWorker

protected void startWorker(int options)
                    throws BundleException
Internal worker to start a bundle.

Specified by:
startWorker in class AbstractBundle
Parameters:
options - the start options
Throws:
BundleException

readyToResume

protected boolean readyToResume()
Description copied from class: AbstractBundle
This method does the following
  1. Return false if the bundle is a fragment
  2. Return false if the bundle is not at the correct start-level
  3. Return false if the bundle is not persistently marked for start
  4. Return true if the bundle's activation policy is persistently ignored
  5. Return true if the bundle does not define an activation policy
  6. Transition to STARTING state and Fire LAZY_ACTIVATION event
  7. Return false

Overrides:
readyToResume in class AbstractBundle
Returns:
true if the bundle should be resumed

createContext

protected BundleContextImpl createContext()
Create a BundleContext for this bundle.

Returns:
BundleContext for this bundle.

getContext

protected BundleContextImpl getContext()
Return the current context for this bundle.

Specified by:
getContext in class AbstractBundle
Returns:
BundleContext for this bundle.

stopWorker

protected void stopWorker(int options)
                   throws BundleException
Internal worker to stop a bundle.

Specified by:
stopWorker in class AbstractBundle
Parameters:
options - the stop options
Throws:
BundleException

getRegisteredServices

public ServiceReference[] getRegisteredServices()
Provides a list of ServiceReferenceImpls for the services registered by this bundle or null if the bundle has no registered services.

The list is valid at the time of the call to this method, but the framework is a very dynamic environment and services can be modified or unregistered at anytime.

Returns:
An array of ServiceReferenceImpl or null.
Throws:
java.lang.IllegalStateException - If the bundle has been uninstalled.
See Also:
ServiceRegistrationImpl, ServiceReferenceImpl

getServicesInUse

public ServiceReference[] getServicesInUse()
Provides a list of ServiceReferenceImpls for the services this bundle is using, or null if the bundle is not using any services. A bundle is considered to be using a service if the bundle's use count for the service is greater than zero.

The list is valid at the time of the call to this method, but the framework is a very dynamic environment and services can be modified or unregistered at anytime.

Returns:
An array of ServiceReferenceImpl or null.
Throws:
java.lang.IllegalStateException - If the bundle has been uninstalled.
See Also:
ServiceReferenceImpl

getFragments

protected Bundle[] getFragments()
Overrides:
getFragments in class AbstractBundle

attachFragment

protected void attachFragment(BundleFragment fragment)
                       throws BundleException
Attaches a fragment to this BundleHost. Fragments must be attached to the host by ID order. If the ClassLoader of the host is already created then the fragment must be attached to the host ClassLoader

Parameters:
fragment - The fragment bundle to attach return true if the fragment successfully attached; false if the fragment could not be logically inserted at the end of the fragment chain.
Throws:
BundleException

getBundleLoader

protected BundleLoader getBundleLoader()
Specified by:
getBundleLoader in class AbstractBundle

getLoaderProxy

protected BundleLoaderProxy getLoaderProxy()