public class CompositeConfigurator extends Object implements SynchronousBundleListener, HookConfigurator, AdaptorHook, ClassLoadingHook, CompositeBundleFactory, CompositeResolveHelperRegistry
COMPOSITE_SERVICE_FILTER_EXPORT, COMPOSITE_SERVICE_FILTER_IMPORT
Constructor and Description |
---|
CompositeConfigurator() |
public void addHooks(HookRegistry hookRegistry)
HookConfigurator
addHooks
in interface HookConfigurator
hookRegistry
- the hook registry used to add hookspublic void addProperties(Properties properties)
AdaptorHook
FrameworkAdaptor.getProperties()
.
This method allows an adaptor hook to add property values to the adaptor
properties object.addProperties
in interface AdaptorHook
properties
- the adaptor properties object.public FrameworkLog createFrameworkLog()
AdaptorHook
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.createFrameworkLog
in interface AdaptorHook
public void frameworkStart(BundleContext context) throws BundleException
AdaptorHook
FrameworkAdaptor.frameworkStart(BundleContext)
.
This method allows an adaptor hook to execute code when the framework is starting
(e.g. to register services).frameworkStart
in interface AdaptorHook
context
- the system bundle contextBundleException
public void frameworkStop(BundleContext context)
AdaptorHook
FrameworkAdaptor.frameworkStop(BundleContext)
.
This method allows an adaptor hook to execute code when the framework is stopped
(e.g. to unregister services).frameworkStop
in interface AdaptorHook
context
- the system bundle contextpublic void frameworkStopping(BundleContext context)
AdaptorHook
FrameworkAdaptor.frameworkStopping(BundleContext)
.
This method allows an adaptor hook to execute code when the framework is about to start
the shutdown process.frameworkStopping
in interface AdaptorHook
context
- the system bundle contextpublic void handleRuntimeError(Throwable error)
AdaptorHook
FrameworkAdaptor.handleRuntimeError(Throwable)
.
The adaptor will call this method for each configured adaptor hook.handleRuntimeError
in interface AdaptorHook
error
- the unexpected error that occured.public void initialize(BaseAdaptor initAdaptor)
AdaptorHook
FrameworkAdaptor.initialize(EventPublisher)
.
This method allows an adaptor hook to save the adaptor object for later.initialize
in interface AdaptorHook
initAdaptor
- the adaptor object associated with this AdaptorHook.public URLConnection mapLocationToURLConnection(String location)
AdaptorHook
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.mapLocationToURLConnection
in interface AdaptorHook
location
- a bundle location string to be converted to a URLConnectionpublic CompositeBundle installCompositeBundle(Map frameworkConfig, String location, Map compositeManifest) throws BundleException
CompositeBundleFactory
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:
CompositeBundle
, then that
composite bundle is returned; otherwise a BundleException
is thrown indicating that an incompatible bundle is already installed at the
specified location.BundleException
is thrown.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
org.osgi.framework.storage
,
if specified, is ignored.Framework.init()
).
BundleEvent.INSTALLED
is fired for the
composite bundle.
CompositeBundle
object for the new composite
bundle is returned.
installCompositeBundle
in interface CompositeBundleFactory
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 bundlesBundleException
- If the composite manifest is invalid or there is
some other problem with installing the composite bundle.Framework
,
CompositeBundle
public CompositeResolveHelper getCompositeResolveHelper(BundleDescription bundle)
getCompositeResolveHelper
in interface CompositeResolveHelperRegistry
public boolean addClassPathEntry(ArrayList cpEntries, String cp, ClasspathManager hostmanager, BaseData sourcedata, ProtectionDomain sourcedomain)
ClassLoadingHook
addClassPathEntry
in interface ClassLoadingHook
cpEntries
- the list of ClasspathEntry objects currently available for the requested classpathcp
- the name of the requested classpathhostmanager
- the classpath manager the requested ClasspathEntry is forsourcedata
- the source bundle data of the requested ClasspathEntrysourcedomain
- the source domain of the requested ClasspathEntrypublic BaseClassLoader createClassLoader(ClassLoader parent, ClassLoaderDelegate delegate, BundleProtectionDomain domain, BaseData data, String[] bundleclasspath)
ClassLoadingHook
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.createClassLoader
in interface ClassLoadingHook
parent
- the parent classloader for the BundleClassLoaderdelegate
- the delegate for the bundle classloaderdomain
- the domian for the bundle classloaderdata
- the BundleData for the BundleClassLoaderbundleclasspath
- the classpath for the bundle classloaderpublic String findLibrary(BaseData data, String libName)
ClassLoadingHook
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.findLibrary
in interface ClassLoadingHook
data
- the base data to find a native library for.libName
- the name of the native library.public ClassLoader getBundleClassLoaderParent()
ClassLoadingHook
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.getBundleClassLoaderParent
in interface ClassLoadingHook
public void initializedClassLoader(BaseClassLoader baseClassLoader, BaseData data)
ClassLoadingHook
ClasspathManager.initialize()
.
The classpath manager will call this method for each configured class loading hook after it
has been initialized.initializedClassLoader
in interface ClassLoadingHook
baseClassLoader
- the newly created bundle classloaderdata
- the BundleData associated with the bundle classloaderpublic byte[] processClass(String name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager)
ClassLoadingHook
processClass
in interface ClassLoadingHook
name
- the name of the class being definedclassbytes
- the bytes of the class being definedclasspathEntry
- the ClasspathEntry where the class bytes have been read from.entry
- the BundleEntry source of the class bytesmanager
- the class path manager used to define the requested classpublic void bundleChanged(BundleEvent event)
BundleListener
bundleChanged
in interface BundleListener
event
- The BundleEvent
.Copyright © 2007–2018 The Apache Software Foundation. All rights reserved.