org.eclipse.osgi.internal.composite
Class CompositeConfigurator

java.lang.Object
  extended by org.eclipse.osgi.internal.composite.CompositeConfigurator
All Implemented Interfaces:
java.util.EventListener, HookConfigurator, AdaptorHook, ClassLoadingHook, CompositeResolveHelperRegistry, BundleListener, SynchronousBundleListener, CompositeBundleFactory

public class CompositeConfigurator
extends java.lang.Object
implements SynchronousBundleListener, HookConfigurator, AdaptorHook, ClassLoadingHook, CompositeBundleFactory, CompositeResolveHelperRegistry


Field Summary
 
Fields inherited from interface org.osgi.service.framework.CompositeBundleFactory
COMPOSITE_SERVICE_FILTER_EXPORT, COMPOSITE_SERVICE_FILTER_IMPORT
 
Constructor Summary
CompositeConfigurator()
           
 
Method Summary
 boolean addClassPathEntry(java.util.ArrayList cpEntries, java.lang.String cp, ClasspathManager hostmanager, BaseData sourcedata, java.security.ProtectionDomain sourcedomain)
          Gets called by a classpath manager when looking for ClasspathEntry objects.
 void addHooks(HookRegistry hookRegistry)
          Adds hooks to the specified hook registry.
 void addProperties(java.util.Properties properties)
          Gets called by the adaptor during FrameworkAdaptor.getProperties().
 void bundleChanged(BundleEvent event)
          Receives notification that a bundle has had a lifecycle change.
 BaseClassLoader createClassLoader(java.lang.ClassLoader parent, ClassLoaderDelegate delegate, BundleProtectionDomain domain, BaseData data, java.lang.String[] bundleclasspath)
          Gets called by a base data during BundleData.createClassLoader(ClassLoaderDelegate, BundleProtectionDomain, String[]).
 FrameworkLog createFrameworkLog()
          Gets called by the adaptor during FrameworkAdaptor.getFrameworkLog().
 java.lang.String findLibrary(BaseData data, java.lang.String libName)
          Gets called by a base data during BundleData.findLibrary(String).
 void frameworkStart(BundleContext context)
          Gets called by the adaptor during FrameworkAdaptor.frameworkStart(BundleContext).
 void frameworkStop(BundleContext context)
          Gets called by the adaptor during FrameworkAdaptor.frameworkStop(BundleContext).
 void frameworkStopping(BundleContext context)
          Gets called by the adaptor during FrameworkAdaptor.frameworkStopping(BundleContext).
 java.lang.ClassLoader getBundleClassLoaderParent()
          Gets called by the adaptor during FrameworkAdaptor.getBundleClassLoaderParent().
 CompositeResolveHelper getCompositeResolveHelper(BundleDescription bundle)
           
 void handleRuntimeError(java.lang.Throwable error)
          Gets called by the adaptor during FrameworkAdaptor.handleRuntimeError(Throwable).
 void initialize(BaseAdaptor initAdaptor)
          Gets called by the adaptor during FrameworkAdaptor.initialize(EventPublisher).
 void initializedClassLoader(BaseClassLoader baseClassLoader, BaseData data)
          Gets called by a classpath manager at the end of ClasspathManager.initialize().
 CompositeBundle installCompositeBundle(java.util.Map frameworkConfig, java.lang.String location, java.util.Map compositeManifest)
          Installs a CompositeBundle.
 java.net.URLConnection mapLocationToURLConnection(java.lang.String location)
          Gets called by the adaptor during FrameworkAdaptor.mapLocationToURLConnection(String).
 boolean matchDNChain(java.lang.String pattern, java.lang.String[] dnChain)
           
 byte[] processClass(java.lang.String name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager)
          Gets called by a classpath manager before defining a class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeConfigurator

public CompositeConfigurator()
Method Detail

addHooks

public void addHooks(HookRegistry hookRegistry)
Description copied from interface: HookConfigurator
Adds hooks to the specified hook registry.

Specified by:
addHooks in interface HookConfigurator
Parameters:
hookRegistry - the hook registry used to add hooks

addProperties

public void addProperties(java.util.Properties properties)
Description copied from interface: AdaptorHook
Gets called by the adaptor during FrameworkAdaptor.getProperties(). This method allows an adaptor hook to add property values to the adaptor properties object.

Specified by:
addProperties in interface AdaptorHook
Parameters:
properties - the adaptor properties object.

createFrameworkLog

public FrameworkLog createFrameworkLog()
Description copied from interface: AdaptorHook
Gets called by the adaptor during FrameworkAdaptor.getFrameworkLog(). The adaptor will call this method for each configured adaptor hook until one adaptor hook returns a non-null value. If no adaptor hook returns a non-null value then the adaptor will return null.

Specified by:
createFrameworkLog in interface AdaptorHook
Returns:
a FrameworkLog object or null.

frameworkStart

public void frameworkStart(BundleContext context)
                    throws BundleException
Description copied from interface: AdaptorHook
Gets called by the adaptor during FrameworkAdaptor.frameworkStart(BundleContext). This method allows an adaptor hook to execute code when the framework is starting (e.g. to register services).

Specified by:
frameworkStart in interface AdaptorHook
Parameters:
context - the system bundle context
Throws:
BundleException

frameworkStop

public void frameworkStop(BundleContext context)
Description copied from interface: AdaptorHook
Gets called by the adaptor during FrameworkAdaptor.frameworkStop(BundleContext). This method allows an adaptor hook to execute code when the framework is stopped (e.g. to unregister services).

Specified by:
frameworkStop in interface AdaptorHook
Parameters:
context - the system bundle context

frameworkStopping

public void frameworkStopping(BundleContext context)
Description copied from interface: AdaptorHook
Gets called by the adaptor during FrameworkAdaptor.frameworkStopping(BundleContext). This method allows an adaptor hook to execute code when the framework is about to start the shutdown process.

Specified by:
frameworkStopping in interface AdaptorHook
Parameters:
context - the system bundle context

handleRuntimeError

public void handleRuntimeError(java.lang.Throwable error)
Description copied from interface: AdaptorHook
Gets called by the adaptor during FrameworkAdaptor.handleRuntimeError(Throwable). The adaptor will call this method for each configured adaptor hook.

Specified by:
handleRuntimeError in interface AdaptorHook
Parameters:
error - the unexpected error that occured.

initialize

public void initialize(BaseAdaptor initAdaptor)
Description copied from interface: AdaptorHook
Gets called by the adaptor during FrameworkAdaptor.initialize(EventPublisher). This method allows an adaptor hook to save the adaptor object for later.

Specified by:
initialize in interface AdaptorHook
Parameters:
initAdaptor - the adaptor object associated with this AdaptorHook.

mapLocationToURLConnection

public java.net.URLConnection mapLocationToURLConnection(java.lang.String location)
Description copied from interface: AdaptorHook
Gets called by the adaptor during FrameworkAdaptor.mapLocationToURLConnection(String). The adaptor will call this method for each configured adaptor hook until one adaptor hook returns a non-null value. If no adaptor hook returns a non-null value then the adaptor will perform the default behavior.

Specified by:
mapLocationToURLConnection in interface AdaptorHook
Parameters:
location - a bundle location string to be converted to a URLConnection
Returns:
the URLConnection converted from the bundle location or null.

matchDNChain

public boolean matchDNChain(java.lang.String pattern,
                            java.lang.String[] dnChain)

installCompositeBundle

public CompositeBundle installCompositeBundle(java.util.Map frameworkConfig,
                                              java.lang.String location,
                                              java.util.Map compositeManifest)
                                       throws BundleException
Description copied from interface: CompositeBundleFactory
Installs a CompositeBundle. The composite bundle has a new child Framework associated with it and a surrogate bundle which is installed in the child framework. Composite bundles share packages and services between the parent framework they are installed in and the child framework.

The following steps are required to create a composite bundle:

  1. If a bundle containing the same location string is already installed and the Bundle object is a CompositeBundle, then that composite bundle is returned; otherwise a BundleException is thrown indicating that an incompatible bundle is already installed at the specified location.
  2. The composite bundle's associated resources are allocated. The associated resources minimally consist of a unique identifier and a persistent storage area. If this step fails, a BundleException is thrown.
  3. The compositeManifest map is used to provide the headers for the composite bundle and its surrogate bundle.

    If composite manifest map does not contain the following header(s) then a BundleException is thrown:

    • Bundle-SymbolicName the symbolic name used for the composite bundle and its surrogate bundle.

    The composite manifest map may optionally contain the following header(s):

    • Bundle-Version the bundle version used for the composite bundle and its surrogate bundle.
    • Import-Package the packages which are imported from the parent framework by the composite bundle and are exported to the child framework by the surrogate bundle.
    • Export-Package the packages which are imported from the child framework by the surrogate bundle and are exported to the parent framework by the composite bundle.
    • CompositeServiceFilter-Import the service filters which are acquired from the parent framework by the composite bundle and are registered in the child framework by the surrogate bundle.
    • CompositeServiceFilter-Export the service filters which are acquired from the child framework by the surrogate bundle and are registered in the parent framework by the composite bundle.
    • Bundle-ManifestVersion the bundle manifest version. If this header is not specified then the default is to use version 2. A BundleException is thrown if this header is specified and the version is less than 2.
    • Require-Bundle a bundle from the parent which is required by the child. Support for this header is experimental: a BundleException should be thrown if the header is present and the framework doesn't support it.

    The composite manifest map must not contain the following headers. If a composite manifest map does contain one of the following headers then a BundleException is thrown:
    Bundle-ActivationPolicy
    Bundle-Activator
    Bundle-ClassPath
    Bundle-Localization
    Bundle-NativeCode
    Fragment-Host
    DynamicImport-Package

  4. A child framework is created which uses a storage area associated with the composite bundle's persistent storage. The framework configuration property org.osgi.framework.storage, if specified, is ignored.
  5. The child framework is initialized (see Framework.init()).
  6. A surrogate bundle is created and installed into the child framework.
  7. The composite bundle's state is set to INSTALLED.
  8. A bundle event of type BundleEvent.INSTALLED is fired for the composite bundle.
  9. The CompositeBundle object for the new composite bundle is returned.

Specified by:
installCompositeBundle in interface CompositeBundleFactory
Parameters:
frameworkConfig - A map containing configuration parameters used to initialize and launch the child framework.
location - The bundle location used for the composite and surrogate bundles.
compositeManifest - A map containing the manifest used to create the composite and surrogate bundles
Returns:
A new composite bundle in INSTALLED state.
Throws:
BundleException - If the composite manifest is invalid or there is some other problem with installing the composite bundle.
See Also:
Framework, CompositeBundle

getCompositeResolveHelper

public CompositeResolveHelper getCompositeResolveHelper(BundleDescription bundle)
Specified by:
getCompositeResolveHelper in interface CompositeResolveHelperRegistry

addClassPathEntry

public boolean addClassPathEntry(java.util.ArrayList cpEntries,
                                 java.lang.String cp,
                                 ClasspathManager hostmanager,
                                 BaseData sourcedata,
                                 java.security.ProtectionDomain sourcedomain)
Description copied from interface: ClassLoadingHook
Gets called by a classpath manager when looking for ClasspathEntry objects. This method allows a classloading hook to add additional ClasspathEntry objects

Specified by:
addClassPathEntry in interface ClassLoadingHook
Parameters:
cpEntries - the list of ClasspathEntry objects currently available for the requested classpath
cp - the name of the requested classpath
hostmanager - the classpath manager the requested ClasspathEntry is for
sourcedata - the source bundle data of the requested ClasspathEntry
sourcedomain - the source domain of the requested ClasspathEntry
Returns:
true if a ClasspathEntry has been added to cpEntries

createClassLoader

public BaseClassLoader createClassLoader(java.lang.ClassLoader parent,
                                         ClassLoaderDelegate delegate,
                                         BundleProtectionDomain domain,
                                         BaseData data,
                                         java.lang.String[] bundleclasspath)
Description copied from interface: ClassLoadingHook
Gets called by a base data during BundleData.createClassLoader(ClassLoaderDelegate, BundleProtectionDomain, String[]). The BaseData will call this method for each configured class loading hook until one data hook returns a non-null value. If no class loading hook returns a non-null value then a default implemenation of BundleClassLoader will be created.

Specified by:
createClassLoader in interface ClassLoadingHook
Parameters:
parent - the parent classloader for the BundleClassLoader
delegate - the delegate for the bundle classloader
domain - the domian for the bundle classloader
data - the BundleData for the BundleClassLoader
bundleclasspath - the classpath for the bundle classloader
Returns:
a newly created bundle classloader

findLibrary

public java.lang.String findLibrary(BaseData data,
                                    java.lang.String libName)
Description copied from interface: ClassLoadingHook
Gets called by a base data during BundleData.findLibrary(String). A base data will call this method for each configured class loading hook until one class loading hook returns a non-null value. If no class loading hook returns a non-null value then the base data will return null.

Specified by:
findLibrary in interface ClassLoadingHook
Parameters:
data - the base data to find a native library for.
libName - the name of the native library.
Returns:
The absolute path name of the native library or null.

getBundleClassLoaderParent

public java.lang.ClassLoader getBundleClassLoaderParent()
Description copied from interface: ClassLoadingHook
Gets called by the adaptor during FrameworkAdaptor.getBundleClassLoaderParent(). The adaptor will call this method for each configured class loading hook until one class loading hook returns a non-null value. If no class loading hook returns a non-null value then the adaptor will perform the default behavior.

Specified by:
getBundleClassLoaderParent in interface ClassLoadingHook
Returns:
the parent classloader to be used by all bundle classloaders or null.

initializedClassLoader

public void initializedClassLoader(BaseClassLoader baseClassLoader,
                                   BaseData data)
Description copied from interface: ClassLoadingHook
Gets called by a classpath manager at the end of ClasspathManager.initialize(). The classpath manager will call this method for each configured class loading hook after it has been initialized.

Specified by:
initializedClassLoader in interface ClassLoadingHook
Parameters:
baseClassLoader - the newly created bundle classloader
data - the BundleData associated with the bundle classloader

processClass

public byte[] processClass(java.lang.String name,
                           byte[] classbytes,
                           ClasspathEntry classpathEntry,
                           BundleEntry entry,
                           ClasspathManager manager)
Description copied from interface: ClassLoadingHook
Gets called by a classpath manager before defining a class. This method allows a class loading hook to process the bytes of a class that is about to be defined.

Specified by:
processClass in interface ClassLoadingHook
Parameters:
name - the name of the class being defined
classbytes - the bytes of the class being defined
classpathEntry - the ClasspathEntry where the class bytes have been read from.
entry - the BundleEntry source of the class bytes
manager - the class path manager used to define the requested class
Returns:
a modified array of classbytes or null if the original bytes should be used.

bundleChanged

public void bundleChanged(BundleEvent event)
Description copied from interface: BundleListener
Receives notification that a bundle has had a lifecycle change.

Specified by:
bundleChanged in interface BundleListener
Parameters:
event - The BundleEvent.


Copyright © 2007-2012 FuseSource, Corp.. All Rights Reserved.