Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.osgi.framework.internal.core
Class PackageAdminImpl  view PackageAdminImpl download PackageAdminImpl.java

java.lang.Object
  extended byorg.eclipse.osgi.framework.internal.core.PackageAdminImpl
All Implemented Interfaces:
org.osgi.service.packageadmin.PackageAdmin

public class PackageAdminImpl
extends java.lang.Object
implements org.osgi.service.packageadmin.PackageAdmin

PackageAdmin service for the OSGi specification. Framework service which allows bundle programmers to inspect the packages exported in the framework and eagerly update or uninstall bundles. If present, there will only be a single instance of this service registered in the framework.

The term exported package (and the corresponding interface org.osgi.service.packageadmin.ExportedPackage) refers to a package that has actually been exported (as opposed to one that is available for export).

Note that the information about exported packages returned by this service is valid only until the next time refreshPackages(org.osgi.framework.Bundle[]) 55 is called. If an ExportedPackage becomes stale, (that is, the package it references has been updated or removed as a result of calling PackageAdmin.refreshPackages()), its getName() and getSpecificationVersion() continue to return their old values, isRemovalPending() returns true, and getExportingBundle() and getImportingBundles() return null.


Field Summary
private static boolean checkServiceClassSource
           
private  long cumulativeTime
           
protected  KeyedHashSet exportedBundles
           
protected  KeyedHashSet exportedPackages
           
protected  Framework framework
          framework object
protected  java.util.Vector removalPending
          BundleLoaders that are pending removal.
private static boolean restrictServiceClasses
           
 
Fields inherited from interface org.osgi.service.packageadmin.PackageAdmin
BUNDLE_TYPE_FRAGMENT
 
Constructor Summary
protected PackageAdminImpl(Framework framework)
          Constructor.
 
Method Summary
protected  void addRemovalPending(BundleLoaderProxy loaderProxy)
           
protected  void cleanup()
           
private  java.util.Vector computeAffectedBundles(AbstractBundle[] refresh)
           
protected  void deleteRemovalPending(BundleLoaderProxy loaderProxy)
           
protected  org.eclipse.osgi.service.resolver.BundleDescription[] getBundleDescriptions(java.util.Vector graph)
           
 org.osgi.framework.Bundle[] getBundles(java.lang.String symbolicName, java.lang.String versionRange)
          Returns the bundles with the specified symbolic name within the specified version range.
 int getBundleType(org.osgi.framework.Bundle bundle)
          Returns the special type of the specified bundle.
private  KeyedHashSet getExportedBundles(KeyedHashSet bundleSet)
           
 org.osgi.service.packageadmin.ExportedPackage getExportedPackage(java.lang.String packageName)
          Gets the ExportedPackage with the specified package name.
 org.osgi.service.packageadmin.ExportedPackage[] getExportedPackages(org.osgi.framework.Bundle bundle)
          Gets the packages exported by the specified bundle.
private  KeyedHashSet getExportedPackages(KeyedHashSet packageSet)
           
 org.osgi.framework.Bundle[] getFragments(org.osgi.framework.Bundle bundle)
          Returns an array of attached fragment bundles for the specified bundle.
 org.osgi.framework.Bundle[] getHosts(org.osgi.framework.Bundle bundle)
          Returns an array of host bundles to which the specified fragment bundle is attached or null if the specified bundle is not attached to a host or is not a fragment bundle.
 org.osgi.service.packageadmin.ProvidingBundle[] getProvidingBundles(java.lang.String symbolicName)
          Returns an array of ProvidingBundles for each resolved bundle with the specified symbolic name.
protected  void initialize()
           
protected  java.lang.Class loadServiceClass(java.lang.String className, AbstractBundle bundle)
           
private  void processDelta(java.util.Vector graph)
           
protected  void refreshPackages(AbstractBundle[] refresh)
          Worker routine called on a seperate thread to perform the actual work.
 void refreshPackages(org.osgi.framework.Bundle[] input)
          Forces the update (replacement) or removal of packages exported by the specified bundles.
protected  void resolveBundles()
          Attempt to resolve all unresolved bundles.
 boolean resolveBundles(org.osgi.framework.Bundle[] bundles)
          A permissible implementation of this method is to attempt to resolve all unresolved bundles installed in the framework.
private  void resumeBundles(java.util.Vector graph)
           
protected  void setResolvedBundles()
          Sets all the bundles in the state that are resolved to the resolved state.
protected  void unexportResources(BundleLoaderProxy proxy)
           
private  void unresolvePermissions(java.util.Vector bundles, java.util.Hashtable packages)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

framework

protected Framework framework
framework object


removalPending

protected java.util.Vector removalPending
BundleLoaders that are pending removal. Value is BundleLoader


exportedPackages

protected KeyedHashSet exportedPackages

exportedBundles

protected KeyedHashSet exportedBundles

cumulativeTime

private long cumulativeTime

checkServiceClassSource

private static boolean checkServiceClassSource

restrictServiceClasses

private static boolean restrictServiceClasses
Constructor Detail

PackageAdminImpl

protected PackageAdminImpl(Framework framework)
Constructor.

Method Detail

initialize

protected void initialize()

getExportedPackages

private KeyedHashSet getExportedPackages(KeyedHashSet packageSet)

getExportedBundles

private KeyedHashSet getExportedBundles(KeyedHashSet bundleSet)

cleanup

protected void cleanup()

addRemovalPending

protected void addRemovalPending(BundleLoaderProxy loaderProxy)

deleteRemovalPending

protected void deleteRemovalPending(BundleLoaderProxy loaderProxy)
                             throws org.osgi.framework.BundleException

getExportedPackages

public org.osgi.service.packageadmin.ExportedPackage[] getExportedPackages(org.osgi.framework.Bundle bundle)
Gets the packages exported by the specified bundle.

Specified by:
getExportedPackages in interface org.osgi.service.packageadmin.PackageAdmin

getExportedPackage

public org.osgi.service.packageadmin.ExportedPackage getExportedPackage(java.lang.String packageName)
Gets the ExportedPackage with the specified package name. All exported packages will be checked for the specified name. In an environment where the exhaustive list of packages on the system classpath is not known in advance, this method attempts to see if the named package is on the system classpath. This means that this method may discover an ExportedPackage that was not present in the list returned by getExportedPackages().

Specified by:
getExportedPackage in interface org.osgi.service.packageadmin.PackageAdmin

refreshPackages

public void refreshPackages(org.osgi.framework.Bundle[] input)
Forces the update (replacement) or removal of packages exported by the specified bundles.

If no bundles are specified, this method will update or remove any packages exported by any bundles that were previously updated or uninstalled. The technique by which this is accomplished may vary among different framework implementations. One permissible implementation is to stop and restart the Framework.

This method returns to the caller immediately and then performs the following steps in its own thread:

  1. Compute a graph of bundles starting with the specified ones. If no bundles are specified, compute a graph of bundles starting with previously updated or uninstalled ones. Any bundle that imports a package that is currently exported by a bundle in the graph is added to the graph. The graph is fully constructed when there is no bundle outside the graph that imports a package from a bundle in the graph. The graph may contain UNINSTALLED bundles that are currently still exporting packages.

  2. Each bundle in the graph will be stopped as described in the Bundle.stop method.

  3. Each bundle in the graph that is in the RESOLVED state is moved to the INSTALLED state. The effect of this step is that bundles in the graph are no longer RESOLVED.

  4. Each bundle in the graph that is in the UNINSTALLED state is removed from the graph and is now completely removed from the framework.

  5. Each bundle in the graph that was in the ACTIVE state prior to Step 2 is started as described in the Bundle.start method, causing all bundles required for the restart to be resolved. It is possible that, as a result of the previous steps, packages that were previously exported no longer are. Therefore, some bundles may be unresolvable until another bundle offering a compatible package for export has been installed in the framework.

For any exceptions that are thrown during any of these steps, a FrameworkEvent of type ERROR is broadcast, containing the exception.

Specified by:
refreshPackages in interface org.osgi.service.packageadmin.PackageAdmin

refreshPackages

protected void refreshPackages(AbstractBundle[] refresh)
Worker routine called on a seperate thread to perform the actual work.


resumeBundles

private void resumeBundles(java.util.Vector graph)

processDelta

private void processDelta(java.util.Vector graph)

unresolvePermissions

private void unresolvePermissions(java.util.Vector bundles,
                                  java.util.Hashtable packages)

computeAffectedBundles

private java.util.Vector computeAffectedBundles(AbstractBundle[] refresh)

setResolvedBundles

protected void setResolvedBundles()
Sets all the bundles in the state that are resolved to the resolved state. This should only be called when the framework is launching.


resolveBundles

public boolean resolveBundles(org.osgi.framework.Bundle[] bundles)
A permissible implementation of this method is to attempt to resolve all unresolved bundles installed in the framework. That is what this method does.

Specified by:
resolveBundles in interface org.osgi.service.packageadmin.PackageAdmin

resolveBundles

protected void resolveBundles()
Attempt to resolve all unresolved bundles. When this method returns all bundles are resolved that can be resolved. A resolved bundle has exported and imported packages. An unresolved bundle neither exports nor imports packages.


unexportResources

protected void unexportResources(BundleLoaderProxy proxy)

getBundleDescriptions

protected org.eclipse.osgi.service.resolver.BundleDescription[] getBundleDescriptions(java.util.Vector graph)

getProvidingBundles

public org.osgi.service.packageadmin.ProvidingBundle[] getProvidingBundles(java.lang.String symbolicName)
Description copied from interface: org.osgi.service.packageadmin.PackageAdmin
Returns an array of ProvidingBundles for each resolved bundle with the specified symbolic name. If the symbolic name argument is null then all resolved bundles with symbolic names are returned.

Specified by:
getProvidingBundles in interface org.osgi.service.packageadmin.PackageAdmin

getBundles

public org.osgi.framework.Bundle[] getBundles(java.lang.String symbolicName,
                                              java.lang.String versionRange)
Description copied from interface: org.osgi.service.packageadmin.PackageAdmin
Returns the bundles with the specified symbolic name within the specified version range. If no bundles are installed that have the specified symbolic name, then null is returned. If a version range is specified, then only the bundles that have the specified symbolic name and belong to the specified version range are returned. The returned bundles are ordered by version in descending version order so that the first element of the array contains the bundle with the highest version.

Specified by:
getBundles in interface org.osgi.service.packageadmin.PackageAdmin

getFragments

public org.osgi.framework.Bundle[] getFragments(org.osgi.framework.Bundle bundle)
Description copied from interface: org.osgi.service.packageadmin.PackageAdmin
Returns an array of attached fragment bundles for the specified bundle. If the specified bundle is a fragment then null is returned. If no fragments are attached to the specified bundle then null is returned.

Specified by:
getFragments in interface org.osgi.service.packageadmin.PackageAdmin

getHosts

public org.osgi.framework.Bundle[] getHosts(org.osgi.framework.Bundle bundle)
Description copied from interface: org.osgi.service.packageadmin.PackageAdmin
Returns an array of host bundles to which the specified fragment bundle is attached or null if the specified bundle is not attached to a host or is not a fragment bundle.

Specified by:
getHosts in interface org.osgi.service.packageadmin.PackageAdmin

getBundleType

public int getBundleType(org.osgi.framework.Bundle bundle)
Description copied from interface: org.osgi.service.packageadmin.PackageAdmin
Returns the special type of the specified bundle. The bundle type values are: A bundle may be more than one type at a time. A type code is used to identify the bundle type for future extendability.

If a bundle is not one or more of the defined types then 0x00000000 is returned.

Specified by:
getBundleType in interface org.osgi.service.packageadmin.PackageAdmin

loadServiceClass

protected java.lang.Class loadServiceClass(java.lang.String className,
                                           AbstractBundle bundle)