public class Felix extends BundleImpl implements Framework
| Modifier and Type | Class and Description |
|---|---|
private class |
Felix.RefreshHelper
Simple class that is used in refreshPackages() to embody
the refresh logic in order to keep the code clean.
|
private static class |
Felix.StartLevelTuple |
(package private) class |
Felix.SystemBundleActivator |
| Modifier and Type | Field and Description |
|---|---|
private static int |
IDENTIFIER_MAP_IDX |
private static int |
LOCATION_MAP_IDX |
(package private) java.util.List |
m_activatorList |
private int |
m_activeStartLevel |
private java.lang.String[] |
m_bootPkgs |
private boolean[] |
m_bootPkgWildcards |
private java.lang.Object[] |
m_bundleLock |
private java.net.URLStreamHandler |
m_bundleStreamHandler |
private BundleCache |
m_cache |
private java.util.Map<java.lang.String,java.lang.Object> |
m_configMap |
private java.util.Map<java.lang.String,java.lang.Object> |
m_configMutableMap |
private BundleRevisionDependencies |
m_dependencies |
private EventDispatcher |
m_dispatcher |
private ExtensionManager |
m_extensionManager |
private FrameworkStartLevelImpl |
m_fwkStartLevel |
private FrameworkWiringImpl |
m_fwkWiring |
private int |
m_globalLockCount |
private java.lang.Thread |
m_globalLockThread |
private java.util.List<java.lang.Thread> |
m_globalLockWaitersList |
private java.util.Map[] |
m_installedBundles |
private java.lang.Object[] |
m_installRequestLock_Priority1 |
private java.util.Map<java.lang.String,java.lang.String> |
m_installRequestMap |
private Logger |
m_logger |
private long |
m_nextId |
private java.lang.Object |
m_nextIdLock |
private ServiceRegistry |
m_registry |
private StatefulResolver |
m_resolver |
(package private) static SecureAction |
m_secureAction |
private boolean |
m_securityDefaultPolicy |
private java.lang.SecurityManager |
m_securityManager |
private SecurityProvider |
m_securityProvider |
private ThreadGate |
m_shutdownGate |
private java.util.SortedSet<Felix.StartLevelTuple> |
m_startLevelBundles |
private java.util.Map<java.lang.Class,java.lang.Boolean> |
m_systemBundleClassCache |
private int |
m_targetStartLevel |
private java.util.List<BundleImpl> |
m_uninstalledBundles |
private URLHandlersActivator |
m_urlHandlersActivator |
ACTIVE, INSTALLED, RESOLVED, SIGNERS_ALL, SIGNERS_TRUSTED, START_ACTIVATION_POLICY, START_TRANSIENT, STARTING, STOP_TRANSIENT, STOPPING, UNINSTALLED| Constructor and Description |
|---|
Felix(java.util.Map configMap)
This constructor creates a framework instance with a specified Map
of configuration properties.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) java.lang.String |
_getLocation() |
(package private) void |
acquireBundleLock(BundleImpl bundle,
int desiredStates)
This method acquires the lock for the specified bundle as long as the
bundle is in one of the specified states.
|
(package private) boolean |
acquireGlobalLock()
Attempts to acquire the global lock.
|
(package private) void |
acquireInstallLock(java.lang.String location) |
(package private) void |
activateBundle(BundleImpl bundle,
boolean fireEvent) |
<A> A |
adapt(java.lang.Class<A> type)
Adapt this bundle to the specified type.
|
(package private) void |
addBundleListener(BundleImpl bundle,
BundleListener l) |
(package private) void |
addFrameworkListener(BundleImpl bundle,
FrameworkListener l) |
(package private) void |
addServiceListener(BundleImpl bundle,
ServiceListener l,
java.lang.String f)
Implementation for BundleContext.addServiceListener().
|
(package private) boolean |
bundleHasPermission(BundleImpl bundle,
java.lang.Object obj) |
private static java.lang.String |
cleanMavenVersion(java.lang.StringBuffer sb)
The main purpose of this method is to turn a.b.c-SNAPSHOT into a.b.c.SNAPSHOT
it can also deal with a.b-SNAPSHOT and turns it into a.b.0.SNAPSHOT and
will leave the dash in a.b.c.something-else, as it's valid in that last example.
|
(package private) void |
close() |
private BundleActivator |
createBundleActivator(Bundle impl) |
private java.util.Map |
createUnmodifiableMap(java.util.Map mutableMap) |
(package private) java.util.Enumeration |
findBundleEntries(BundleImpl bundle,
java.lang.String path,
java.lang.String filePattern,
boolean recurse)
Implementation for Bundle.findEntries().
|
(package private) java.util.Enumeration |
findBundleEntries(BundleRevision revision,
java.lang.String path,
java.lang.String filePattern,
boolean recurse)
Implementation for BundleWiring.findEntries().
|
(package private) java.util.Collection<BundleCapability> |
findProviders(Requirement requirement) |
(package private) void |
fireBundleEvent(int type,
Bundle bundle)
Fires bundle events.
|
(package private) void |
fireBundleEvent(int type,
Bundle bundle,
Bundle origin) |
(package private) void |
fireFrameworkEvent(int type,
Bundle bundle,
java.lang.Throwable throwable)
Fires bundle events.
|
private void |
fireServiceEvent(ServiceEvent event,
java.util.Dictionary oldProps)
Fires service events.
|
private void |
forgetUninstalledBundle(BundleImpl bundle) |
(package private) int |
getActiveStartLevel()
Returns the active start level of the framework; this method
implements functionality for the Start Level service.
|
(package private) ServiceReference[] |
getAllowedServiceReferences(BundleImpl bundle,
java.lang.String className,
java.lang.String expr,
boolean checkAssignable)
Retrieves Array of
ServiceReference objects based on calling bundle, service class name,
optional filter expression, and optionally filters further on the version. |
(package private) java.lang.String[] |
getBootPackages() |
(package private) boolean[] |
getBootPackageWildcards() |
(package private) Bundle |
getBundle(BundleContext bc,
long id)
Implementation for BundleContext.getBundle().
|
(package private) Bundle |
getBundle(java.lang.Class clazz)
This method returns the bundle associated with the specified class if
the class was loaded from a bundle from this framework instance.
|
(package private) Bundle |
getBundle(long id)
Retrieves a bundle by its identifier and avoids bundles hooks.
|
(package private) Bundle |
getBundle(java.lang.String location)
Retrieves a bundle from its location.
|
(package private) java.net.URL |
getBundleEntry(BundleImpl bundle,
java.lang.String name)
Implementation for Bundle.getEntry().
|
(package private) java.util.Enumeration |
getBundleEntryPaths(BundleImpl bundle,
java.lang.String path)
Implementation for Bundle.getEntryPaths().
|
(package private) java.util.Dictionary |
getBundleHeaders(BundleImpl bundle,
java.lang.String locale)
Get bundle headers and resolve any localized strings from resource bundles.
|
long |
getBundleId()
Returns this bundle's unique identifier.
|
(package private) ServiceReference[] |
getBundleRegisteredServices(BundleImpl bundle) |
(package private) java.net.URL |
getBundleResource(BundleImpl bundle,
java.lang.String name)
Implementation for Bundle.getResource().
|
(package private) java.util.Enumeration |
getBundleResources(BundleImpl bundle,
java.lang.String name)
Implementation for Bundle.getResources().
|
(package private) Bundle[] |
getBundles()
Retrieves all installed bundles and avoids bundles hooks.
|
(package private) Bundle[] |
getBundles(BundleContext bc)
Implementation for BundleContext.getBundles().
|
(package private) ServiceReference[] |
getBundleServicesInUse(Bundle bundle) |
(package private) int |
getBundleStartLevel(Bundle bundle)
Returns the start level for the specified bundle; this method
implements functionality for the Start Level service.
|
(package private) java.net.URLStreamHandler |
getBundleStreamHandler() |
(package private) java.util.Map |
getConfig() |
(package private) java.lang.Object |
getContentHandlerService(java.lang.String mimeType) |
(package private) java.io.File |
getDataFile(BundleImpl bundle,
java.lang.String s) |
(package private) BundleRevisionDependencies |
getDependencies() |
(package private) java.util.Collection<Bundle> |
getDependencyClosure(java.util.Collection<Bundle> targets) |
(package private) ExportedPackage[] |
getExportedPackages(Bundle b)
Returns an array of all actively exported packages from the specified
bundle or if the specified bundle is null an array
containing all actively exported packages by all bundles.
|
private void |
getExportedPackages(Bundle bundle,
java.util.List list)
Adds any current active exported packages from the specified bundle
to the passed in list.
|
(package private) ExportedPackage[] |
getExportedPackages(java.lang.String pkgName)
Returns the exported packages associated with the specified
package name.
|
(package private) Felix |
getFramework() |
private static java.lang.String |
getFrameworkVersion()
Read the framework version from the property file.
|
(package private) HookRegistry |
getHookRegistry() |
(package private) java.util.Set<Bundle> |
getImportingBundles(BundleImpl exporter,
BundleCapability cap) |
(package private) int |
getInitialBundleStartLevel()
Returns the start level into which newly installed bundles will
be placed by default; this method implements functionality for
the Start Level service.
|
long |
getLastModified()
Returns the time when this bundle was last modified.
|
(package private) Logger |
getLogger() |
private long |
getNextId() |
int |
getPersistentState() |
(package private) java.lang.String |
getProperty(java.lang.String key)
Implementation for BundleContext.getProperty().
|
(package private) java.util.Collection<Bundle> |
getRemovalPendingBundles() |
(package private) java.util.Set<Bundle> |
getRequiringBundles(BundleImpl bundle) |
(package private) StatefulResolver |
getResolver() |
(package private) SecurityProvider |
getSecurityProvider() |
(package private) <S> S |
getService(Bundle bundle,
ServiceReference<S> ref,
boolean isServiceObjetcs) |
(package private) ServiceReference[] |
getServiceReferences(BundleImpl bundle,
java.lang.String className,
java.lang.String expr,
boolean checkAssignable)
Retrieves an array of
ServiceReference objects based on calling bundle,
service class name, and filter expression. |
(package private) java.lang.Object |
getSignerMatcher(BundleImpl bundle,
int signersType) |
(package private) int |
getStartLevel(int defaultLevel)
Overrides standard BundleImpl.getStartLevel() behavior to
always return zero for the system bundle.
|
(package private) java.lang.Object |
getStreamHandlerService(java.lang.String protocol) |
boolean |
hasPermission(java.lang.Object obj)
Determines if this bundle has the specified permissions.
|
(package private) boolean |
impliesBundlePermission(BundleProtectionDomain bundleProtectionDomain,
java.security.Permission permission,
boolean direct) |
void |
init()
Initialize this Framework.
|
void |
init(FrameworkListener... listeners)
Initialize this Framework.
|
private void |
initializeFrameworkProperties() |
(package private) Bundle |
installBundle(Bundle origin,
java.lang.String location,
java.io.InputStream is) |
(package private) boolean |
isBundleActivationPolicyUsed(Bundle bundle)
Returns whether the bundle is using its declared activation policy;
this is an method implementation for the Start Level service.
|
(package private) boolean |
isBundlePersistentlyStarted(Bundle bundle)
Returns whether a bundle is persistently started; this is an
method implementation for the Start Level service.
|
(package private) java.lang.Class |
loadBundleClass(BundleImpl bundle,
java.lang.String name)
Implementation for Bundle.loadClass().
|
private void |
loadFromDefaultIfNotDefined(java.util.Properties defaultProperties,
java.lang.String propertyName) |
private long |
loadNextId()
Generated the next valid bundle identifier.
|
private void |
loadPrefixFromDefaultIfNotDefined(java.util.Map configMap,
java.util.Properties defaultProperties,
java.lang.String prefix) |
private void |
populateDependentGraph(BundleImpl exporter,
java.util.Set<Bundle> set) |
private void |
refreshBundle(BundleImpl bundle) |
(package private) void |
refreshPackages(java.util.Collection<Bundle> targets,
FrameworkListener[] listeners) |
(package private) ServiceRegistration |
registerService(BundleContextImpl context,
java.lang.String[] classNames,
java.lang.Object svcObj,
java.util.Dictionary dict)
Implementation for BundleContext.registerService().
|
(package private) void |
releaseBundleLock(BundleImpl bundle)
Releases the bundle's lock.
|
(package private) void |
releaseGlobalLock()
Releases the global lock.
|
(package private) void |
releaseInstallLock(java.lang.String location) |
private Bundle |
reloadBundle(BundleArchive ba) |
private void |
rememberUninstalledBundle(BundleImpl bundle) |
(package private) void |
removeBundleListener(BundleImpl bundle,
BundleListener l) |
(package private) void |
removeFrameworkListener(BundleImpl bundle,
FrameworkListener l) |
(package private) void |
removeServiceListener(BundleImpl bundle,
ServiceListener l)
Implementation for BundleContext.removeServiceListener().
|
private void |
resolveBundleRevision(BundleRevision revision) |
(package private) boolean |
resolveBundles(java.util.Collection<Bundle> targets) |
(package private) void |
setActiveStartLevel(int requestedLevel,
FrameworkListener[] listeners)
Implements the functionality of the setStartLevel()
method for the StartLevel service, but does not do the security or
parameter check.
|
(package private) void |
setBundleProtectionDomain(BundleRevisionImpl revisionImpl) |
(package private) void |
setBundleStartLevel(Bundle bundle,
int startLevel)
Sets the start level of the specified bundle; this method
implements functionality for the Start Level service.
|
(package private) void |
setBundleStateAndNotify(BundleImpl bundle,
int state) |
(package private) void |
setInitialBundleStartLevel(int startLevel)
Sets the default start level into which newly installed bundles
will be placed; this method implements functionality for the Start
Level service.
|
(package private) void |
setLastModified(long l) |
void |
setPersistentStateActive() |
void |
setPersistentStateInactive() |
void |
setPersistentStateUninstalled() |
(package private) void |
setSecurityProvider(SecurityProvider securityProvider) |
(package private) void |
setStartLevel(int level)
Overrides standard BundleImpl.setStartLevel() behavior to
always throw an exception since the system bundle's start level cannot
be changed.
|
(package private) void |
setURLHandlersActivator(URLHandlersActivator urlHandlersActivator) |
void |
start()
This method starts the framework instance, which will transition the
framework from start level 0 to its active start level as specified in
its configuration properties (1 by default).
|
void |
start(int options)
Starts this bundle.
|
(package private) void |
startBundle(BundleImpl bundle,
int options)
Implementation for Bundle.start().
|
void |
stop()
This method asynchronously shuts down the framework, it must be called at the
end of a session in order to shutdown all active bundles.
|
void |
stop(int options)
Stops this bundle.
|
(package private) void |
stopBundle(BundleImpl bundle,
boolean record) |
java.lang.String |
toString() |
(package private) boolean |
ungetService(Bundle bundle,
ServiceReference ref,
java.lang.Object srvObj) |
void |
uninstall()
Uninstalls this bundle.
|
(package private) void |
uninstallBundle(BundleImpl bundle) |
void |
update()
Updates this bundle.
|
void |
update(java.io.InputStream is)
Updates this bundle from an
InputStream. |
(package private) void |
updateBundle(BundleImpl bundle,
java.io.InputStream is) |
FrameworkEvent |
waitForStop(long timeout)
This method will cause the calling thread to block until the framework
shuts down.
|
__setState, _getBundleContext, addRevision, checkAdapt, closeAndDelete, compareTo, findEntries, getActivator, getArchive, getBundle, getBundleContext, getCurrentLocalizedHeader, getDataFile, getEntry, getEntryPaths, getHeaders, getHeaders, getLocation, getLockingThread, getProtectionDomain, getRegisteredServices, getResource, getResources, getRevisions, getServicesInUse, getSignerCertificates, getState, getSymbolicName, getVersion, hasRevision, isDeclaredActivationPolicyUsed, isExtension, isLockable, isRemovalPending, isStale, loadClass, lock, refresh, revise, rollbackRevise, setActivator, setBundleContext, setDeclaredActivationPolicyUsed, setPersistentStateStarting, unlockclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitfindEntries, getEntry, getEntryPaths, getLocation, getSymbolicNamegetBundleContext, getDataFile, getHeaders, getHeaders, getRegisteredServices, getResource, getResources, getServicesInUse, getSignerCertificates, getState, getVersion, loadClassstatic final SecureAction m_secureAction
private final ExtensionManager m_extensionManager
private final FrameworkWiringImpl m_fwkWiring
private final FrameworkStartLevelImpl m_fwkStartLevel
private final Logger m_logger
private final java.util.Map<java.lang.String,java.lang.Object> m_configMap
private final java.util.Map<java.lang.String,java.lang.Object> m_configMutableMap
private final StatefulResolver m_resolver
private final java.lang.Object[] m_bundleLock
private final java.util.List<java.lang.Thread> m_globalLockWaitersList
private java.lang.Thread m_globalLockThread
private int m_globalLockCount
private final java.util.Map<java.lang.String,java.lang.String> m_installRequestMap
private final java.lang.Object[] m_installRequestLock_Priority1
private volatile java.util.Map[] m_installedBundles
private static final int LOCATION_MAP_IDX
private static final int IDENTIFIER_MAP_IDX
private volatile java.util.List<BundleImpl> m_uninstalledBundles
private final BundleRevisionDependencies m_dependencies
private volatile int m_activeStartLevel
private volatile int m_targetStartLevel
private final java.util.SortedSet<Felix.StartLevelTuple> m_startLevelBundles
private BundleCache m_cache
java.util.List m_activatorList
private long m_nextId
private final java.lang.Object m_nextIdLock
private final ServiceRegistry m_registry
private final EventDispatcher m_dispatcher
private final java.net.URLStreamHandler m_bundleStreamHandler
private final java.lang.String[] m_bootPkgs
private final boolean[] m_bootPkgWildcards
private volatile ThreadGate m_shutdownGate
private java.lang.SecurityManager m_securityManager
private volatile boolean m_securityDefaultPolicy
private final java.util.Map<java.lang.Class,java.lang.Boolean> m_systemBundleClassCache
private volatile SecurityProvider m_securityProvider
private volatile URLHandlersActivator m_urlHandlersActivator
public Felix(java.util.Map configMap)
This constructor creates a framework instance with a specified Map of configuration properties. Configuration properties are used internally by the framework to alter its default behavior. The configuration properties should have a String key and an Object value. The passed in Map is copied by the framework and all keys are converted to Strings.
Configuration properties are generally the sole means to configure the framework's default behavior; the framework does not typically refer to any system properties for configuration information. If a Map is supplied to this method for configuration properties, then the framework will consult the Map instance for any and all configuration properties. It is possible to specify a null for the configuration property map, in which case the framework will use its default behavior in all cases.
The following configuration properties can be specified (properties starting with "felix" are specific to Felix, while those starting with "org.osgi" are standard OSGi properties):
The Main class implements some functionality for default property file handling, which makes it possible to specify configuration properties and framework properties in files that are automatically loaded when starting the framework. If you plan to create your own framework instance, you may be able to take advantage of the features it provides; refer to its class documentation for more information.
The framework is not actually started until the start() method is called.
configMap - A map for obtaining configuration properties,
may be null.Logger getLogger()
java.util.Map getConfig()
StatefulResolver getResolver()
BundleRevisionDependencies getDependencies()
java.net.URLStreamHandler getBundleStreamHandler()
java.lang.String[] getBootPackages()
boolean[] getBootPackageWildcards()
private java.util.Map createUnmodifiableMap(java.util.Map mutableMap)
void close()
close in class BundleImplFelix getFramework()
getFramework in class BundleImplpublic <A> A adapt(java.lang.Class<A> type)
Bundle
Adapting this bundle to the specified type may require certain checks,
including security checks, to succeed. If a check does not succeed, then
this bundle cannot be adapted and null is returned.
adapt in interface Bundleadapt in interface Frameworkadapt in class BundleImplA - The type to which this bundle is to be adapted.type - Class object for the type to which this bundle is to be
adapted.null if this bundle cannot be adapted to the
specified type.public long getBundleId()
BundleA bundle's unique identifier has the following attributes:
long.
This method must continue to return this bundle's unique identifier while
this bundle is in the UNINSTALLED state.
getBundleId in interface BundlegetBundleId in interface FrameworkgetBundleId in class BundleImplBundle.getBundleId()public long getLastModified()
BundleThe time value is the number of milliseconds since January 1, 1970, 00:00:00 UTC.
getLastModified in interface BundlegetLastModified in interface FrameworkgetLastModified in class BundleImplvoid setLastModified(long l)
setLastModified in class BundleImpljava.lang.String _getLocation()
_getLocation in class BundleImplpublic int getPersistentState()
getPersistentState in class BundleImplpublic void setPersistentStateInactive()
setPersistentStateInactive in class BundleImplpublic void setPersistentStateActive()
setPersistentStateActive in class BundleImplpublic void setPersistentStateUninstalled()
setPersistentStateUninstalled in class BundleImplint getStartLevel(int defaultLevel)
getStartLevel in class BundleImpldefaultLevel - This parameter is ignored by the system bundle.void setStartLevel(int level)
setStartLevel in class BundleImpllevel - This parameter is ignored by the system bundle.java.lang.IllegalArgumentException - Always throws exception since system
bundle's start level cannot be changed.public boolean hasPermission(java.lang.Object obj)
Bundle
If the Java Runtime Environment does not support permissions, this method
always returns true.
permission is of type Object to avoid referencing the
java.security.Permission class directly. This is to allow the
Framework to be implemented in Java environments which do not support
permissions.
If the Java Runtime Environment does support permissions, this bundle and
all its resources including embedded JAR files, belong to the same
java.security.ProtectionDomain; that is, they must share the same
set of permissions.
hasPermission in interface BundlehasPermission in class BundleImplobj - The permission to verify.true if this bundle has the specified permission or the
permissions possessed by this bundle imply the specified
permission; false if this bundle does not have the
specified permission or permission is not an
instanceof java.security.Permission.public void init()
throws BundleException
Framework
This method performs the same function as calling
Framework.init(FrameworkListener...) with no framework listeners.
init in interface FrameworkBundleException - If this Framework could not be initialized.Framework.init(FrameworkListener...)public void init(FrameworkListener... listeners) throws BundleException
Frameworkframework UUID.
Bundle.STARTING state.ConditionalPermissionAdmin.adaptable to the OSGi defined types to which
a system bundle can be adapted.start method of the extension bundle
activator for all resolved extension bundles.
This Framework will not actually be started until start
is called.
This method does nothing if called when this Framework is in the
Bundle.STARTING, Bundle.ACTIVE or Bundle.STOPPING states.
All framework events fired by this method method are also delivered to the specified FrameworkListeners in the order they are specified before returning from this method. After returning from this method the specified listeners are no longer notified of framework events.
init in interface Frameworklisteners - Zero or more listeners to be notified when framework
events occur while initializing the framework. The specified
listeners do not need to be otherwise registered with the
framework. If a specified listener is registered with the
framework, it will be notified twice for each framework event.BundleException - If this Framework could not be initialized.Framework.init(org.osgi.framework.FrameworkListener[])void setBundleProtectionDomain(BundleRevisionImpl revisionImpl) throws java.lang.Exception
java.lang.Exceptionpublic void start()
throws BundleException
start in interface Bundlestart in interface Frameworkstart in class BundleImplBundleException - if any error occurs.Bundle.start(int)public void start(int options)
throws BundleException
Bundle
If this bundle's state is UNINSTALLED then an
IllegalStateException is thrown.
If the current start level is less than this bundle's start level:
Bundle.START_TRANSIENT option is set, then a
BundleException is thrown indicating this bundle cannot be
started due to the Framework's current start level.Bundle.START_ACTIVATION_POLICY option is set or
Started with eager activation if not set.When the Framework's current start level becomes equal to or more than this bundle's start level, this bundle will be started.
Otherwise, the following steps are required to start this bundle:
BundleException is thrown to indicate this bundle was unable to
be started.Bundle.START_TRANSIENT option is not set then set this
bundle's autostart setting to Started with declared activation
if the Bundle.START_ACTIVATION_POLICY option is set or
Started with eager activation if not set. When the Framework is
restarted and this bundle's autostart setting is not Stopped,
this bundle must be automatically started.ACTIVE then this method returns
immediately.RESOLVED, an attempt is made to
resolve this bundle. If the Framework cannot resolve this bundle, a
BundleException is thrown.Bundle.START_ACTIVATION_POLICY option is set and this
bundle's declared activation policy is lazy then:
STARTING then this method returns
immediately.STARTING.BundleEvent.LAZY_ACTIVATION is fired.STARTING.BundleEvent.STARTING is fired.BundleActivator.start(BundleContext) method of this
bundle's BundleActivator, if one is specified, is called. If the
BundleActivator is invalid or throws an exception then:
STOPPING.BundleEvent.STOPPING is fired.RESOLVED.BundleEvent.STOPPED is fired.BundleException is then thrown.ACTIVE.BundleEvent.STARTED is fired.getState() in { INSTALLED, RESOLVED
} or { INSTALLED, RESOLVED,
STARTING } if this bundle has a lazy activation policy.Bundle.START_TRANSIENT option was set.getState() in { ACTIVE } unless the
lazy activation policy was used.BundleActivator.start() has been called and did not throw an
exception unless the lazy activation policy was used.Bundle.START_TRANSIENT option was set.getState() not in { STARTING, ACTIVE
}.start in interface Bundlestart in interface Frameworkstart in class BundleImploptions - The options for starting this bundle. See
Bundle.START_TRANSIENT and Bundle.START_ACTIVATION_POLICY. The
Framework must ignore unrecognized options.BundleException - If this bundle could not be started.
BundleException types thrown by this method include:
BundleException.START_TRANSIENT_ERROR,
BundleException.NATIVECODE_ERROR,
BundleException.RESOLVE_ERROR,
BundleException.STATECHANGE_ERROR, and
BundleException.ACTIVATOR_ERROR.Framework.start()public void stop()
throws BundleException
stop in interface Bundlestop in interface Frameworkstop in class BundleImplBundleException - BundleException types thrown by this method
include: BundleException.STATECHANGE_ERROR and
BundleException.ACTIVATOR_ERROR.Bundle.start(int)public void stop(int options)
throws BundleException
BundleThe following steps are required to stop a bundle:
UNINSTALLED then an
IllegalStateException is thrown.BundleException is thrown to indicate this bundle was unable to
be stopped.Bundle.STOP_TRANSIENT option is not set then then set this
bundle's persistent autostart setting to to Stopped. When the
Framework is restarted and this bundle's autostart setting is
Stopped, this bundle must not be automatically started.STARTING or ACTIVE then
this method returns immediately.STOPPING.BundleEvent.STOPPING is fired.ACTIVE prior to setting the state
to STOPPING, the BundleActivator.stop(BundleContext)
method of this bundle's BundleActivator, if one is specified, is
called. If that method throws an exception, this method must continue to
stop this bundle and a BundleException must be thrown after
completion of the remaining steps.UNINSTALLED, because this bundle
was uninstalled while the BundleActivator.stop method was
running, a BundleException must be thrown.RESOLVED.BundleEvent.STOPPED is fired.getState() in { ACTIVE }.Bundle.STOP_TRANSIENT option was set.getState() not in { ACTIVE, STOPPING
}.BundleActivator.stop has been called and did not throw an
exception.Bundle.STOP_TRANSIENT option was set.stop in interface Bundlestop in interface Frameworkstop in class BundleImploptions - The options for stopping this bundle. See
Bundle.STOP_TRANSIENT. The Framework must ignore unrecognized
options.BundleException - BundleException types thrown by this method
include: BundleException.STATECHANGE_ERROR and
BundleException.ACTIVATOR_ERROR.Framework.stop()public FrameworkEvent waitForStop(long timeout) throws java.lang.InterruptedException
waitForStop in interface Frameworktimeout - A timeout value.FrameworkEvent types may be returned by this
method.
STOPPED - This Framework has
been stopped. STOPPED_UPDATE - This
Framework has been updated which has shutdown and will now
restart.STOPPED_BOOTCLASSPATH_MODIFIED - This Framework has been stopped
and a bootclasspath extension bundle has been installed or
updated. The VM must be restarted in order for the changed boot
class path to take effect. ERROR - The Framework
encountered an error while shutting down or an error has occurred
which forced the framework to shutdown. WAIT_TIMEDOUT - This
method has timed out and returned before this Framework has
stopped.java.lang.InterruptedException - If the thread was interrupted.public void uninstall()
throws BundleException
Bundle
This method causes the Framework to notify other bundles that this bundle
is being uninstalled, and then puts this bundle into the
UNINSTALLED state. The Framework must remove any resources
related to this bundle that it is able to remove.
If this bundle has exported any packages, the Framework must continue to
make these packages available to their importing bundles until the
FrameworkWiring.refreshBundles method has been called or the Framework
is relaunched.
The following steps are required to uninstall a bundle:
UNINSTALLED then an
IllegalStateException is thrown.ACTIVE, STARTING or
STOPPING, this bundle is stopped as described in the
Bundle.stop method. If Bundle.stop throws an exception, a
Framework event of type FrameworkEvent.ERROR is fired containing
the exception.UNINSTALLED.BundleEvent.UNINSTALLED is fired.getState() not in { UNINSTALLED }.getState() in { UNINSTALLED }.getState() not in { UNINSTALLED }.uninstall in interface Bundleuninstall in interface Frameworkuninstall in class BundleImplBundleException - If the uninstall failed. This can occur if
another thread is attempting to change this bundle's state and
does not complete in a timely manner. BundleException types
thrown by this method include:
BundleException.STATECHANGE_ERRORBundle.stop()public void update()
throws BundleException
Bundle
This method performs the same function as calling
Bundle.update(InputStream) with a null InputStream.
update in interface Bundleupdate in interface Frameworkupdate in class BundleImplBundleException - If this bundle could not be updated.
BundleException types thrown by this method include:
BundleException.READ_ERROR,
BundleException.DUPLICATE_BUNDLE_ERROR,
BundleException.MANIFEST_ERROR,
BundleException.NATIVECODE_ERROR,
BundleException.RESOLVE_ERROR,
BundleException.STATECHANGE_ERROR, and
BundleException.ACTIVATOR_ERROR.Bundle.update(InputStream)public void update(java.io.InputStream is)
throws BundleException
BundleInputStream.
If the specified InputStream is null, the Framework must
create the InputStream from which to read the updated bundle by
interpreting, in an implementation dependent manner, this bundle's
Bundle-UpdateLocation Manifest
header, if present, or this bundle's original location.
If this bundle's state is ACTIVE, it must be stopped before the
update and started after the update successfully completes.
If this bundle has exported any packages that are imported by another
bundle, these packages must remain exported until the
FrameworkWiring.refreshBundles method has been has been called or the
Framework is relaunched.
The following steps are required to update a bundle:
UNINSTALLED then an
IllegalStateException is thrown.ACTIVE, STARTING or
STOPPING, this bundle is stopped as described in the
Bundle.stop method. If Bundle.stop throws an exception,
the exception is rethrown terminating the update.BundleException must be thrown after completion of the remaining
steps.INSTALLED.BundleEvent.UPDATED is fired.ACTIVE, the updated
bundle is started as described in the Bundle.start method. If
Bundle.start throws an exception, a Framework event of type
FrameworkEvent.ERROR is fired containing the exception.getState() not in { UNINSTALLED }.getState() in { INSTALLED, RESOLVED,
ACTIVE }.getState() in { INSTALLED, RESOLVED,
ACTIVE }.update in interface Bundleupdate in interface Frameworkupdate in class BundleImplis - The InputStream from which to read the new bundle or
null to indicate the Framework must create the input
stream from this bundle's Bundle-UpdateLocation Manifest header, if present, or this
bundle's original location. The input stream must always be closed
when this method completes, even if an exception is thrown.BundleException - If this bundle could not be updated.
BundleException types thrown by this method include:
BundleException.READ_ERROR,
BundleException.DUPLICATE_BUNDLE_ERROR,
BundleException.MANIFEST_ERROR,
BundleException.NATIVECODE_ERROR,
BundleException.RESOLVE_ERROR,
BundleException.STATECHANGE_ERROR, and
BundleException.ACTIVATOR_ERROR.Bundle.stop(),
Bundle.start()public java.lang.String toString()
toString in class BundleImplint getActiveStartLevel()
void setActiveStartLevel(int requestedLevel,
FrameworkListener[] listeners)
requestedLevel - The new start level of the framework.int getInitialBundleStartLevel()
void setInitialBundleStartLevel(int startLevel)
startLevel - The new default start level for newly installed
bundles.java.lang.IllegalArgumentException - If the specified start
level is not greater than zero.java.security.SecurityException - If the caller does not
have AdminPermission.int getBundleStartLevel(Bundle bundle)
bundle - The bundle to examine.java.lang.IllegalArgumentException - If the specified
bundle has been uninstalled.void setBundleStartLevel(Bundle bundle, int startLevel)
bundle - The bundle whose start level is to be modified.startLevel - The new start level of the specified bundle.java.lang.IllegalArgumentException - If the specified
bundle is the system bundle or if the bundle has been
uninstalled.java.security.SecurityException - If the caller does not
have AdminPermission.boolean isBundlePersistentlyStarted(Bundle bundle)
bundle - The bundle to examine.java.lang.IllegalArgumentException - If the specified
bundle has been uninstalled.boolean isBundleActivationPolicyUsed(Bundle bundle)
bundle - The bundle to examine.java.lang.IllegalArgumentException - If the specified
bundle has been uninstalled.java.util.Dictionary getBundleHeaders(BundleImpl bundle, java.lang.String locale)
bundle - locale - java.net.URL getBundleResource(BundleImpl bundle, java.lang.String name)
java.util.Enumeration getBundleResources(BundleImpl bundle, java.lang.String name)
java.net.URL getBundleEntry(BundleImpl bundle, java.lang.String name)
java.util.Enumeration getBundleEntryPaths(BundleImpl bundle, java.lang.String path)
java.util.Enumeration findBundleEntries(BundleImpl bundle, java.lang.String path, java.lang.String filePattern, boolean recurse)
java.util.Enumeration findBundleEntries(BundleRevision revision, java.lang.String path, java.lang.String filePattern, boolean recurse)
ServiceReference[] getBundleRegisteredServices(BundleImpl bundle)
ServiceReference[] getBundleServicesInUse(Bundle bundle)
boolean bundleHasPermission(BundleImpl bundle, java.lang.Object obj)
java.lang.Class loadBundleClass(BundleImpl bundle, java.lang.String name) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundExceptionvoid startBundle(BundleImpl bundle, int options) throws BundleException
BundleExceptionvoid activateBundle(BundleImpl bundle, boolean fireEvent) throws BundleException
BundleExceptionvoid updateBundle(BundleImpl bundle, java.io.InputStream is) throws BundleException
BundleExceptionvoid stopBundle(BundleImpl bundle, boolean record) throws BundleException
BundleExceptionvoid uninstallBundle(BundleImpl bundle) throws BundleException
BundleExceptionjava.lang.String getProperty(java.lang.String key)
key - The name of the property to retrieve.private Bundle reloadBundle(BundleArchive ba) throws BundleException
BundleExceptionBundle installBundle(Bundle origin, java.lang.String location, java.io.InputStream is) throws BundleException
BundleExceptionBundle getBundle(java.lang.String location)
location - The location of the bundle to retrieve.Bundle getBundle(BundleContext bc, long id)
id - The identifier of the bundle to retrieve.Bundle getBundle(long id)
Bundle[] getBundles(BundleContext bc)
Bundle[] getBundles()
void addBundleListener(BundleImpl bundle, BundleListener l)
void removeBundleListener(BundleImpl bundle, BundleListener l)
void addServiceListener(BundleImpl bundle, ServiceListener l, java.lang.String f) throws InvalidSyntaxException
ServiceEvents.bundle - The bundle that registered the listener.l - The service listener to add to the listener list.f - The filter for the listener; may be null.InvalidSyntaxExceptionvoid removeServiceListener(BundleImpl bundle, ServiceListener l)
bundle - The context bundle of the listenerl - The service listener to remove from the listener list.void addFrameworkListener(BundleImpl bundle, FrameworkListener l)
void removeFrameworkListener(BundleImpl bundle, FrameworkListener l)
ServiceRegistration registerService(BundleContextImpl context, java.lang.String[] classNames, java.lang.Object svcObj, java.util.Dictionary dict)
classNames - A string array containing the names of the classes
under which the new service is available.svcObj - The service object or ServiceFactory.dict - A dictionary of properties that further describe the
service or null.ServiceRegistration object or null.ServiceReference[] getServiceReferences(BundleImpl bundle, java.lang.String className, java.lang.String expr, boolean checkAssignable) throws InvalidSyntaxException
ServiceReference objects based on calling bundle,
service class name, and filter expression. Optionally checks for isAssignable to
make sure that the service can be cast to thebundle - Calling BundleclassName - Service Classname or null for allexpr - Filter Criteria or nullInvalidSyntaxExceptionServiceReference[] getAllowedServiceReferences(BundleImpl bundle, java.lang.String className, java.lang.String expr, boolean checkAssignable) throws InvalidSyntaxException
ServiceReference objects based on calling bundle, service class name,
optional filter expression, and optionally filters further on the version.
If running under a SecurityManager, checks that the calling bundle has permissions to
see the service references and removes references that aren't.bundle - Calling BundleclassName - Service Classname or null for allexpr - Filter Criteria or nullcheckAssignable - true to check for isAssignable, false to return all versionsInvalidSyntaxException<S> S getService(Bundle bundle, ServiceReference<S> ref, boolean isServiceObjetcs)
boolean ungetService(Bundle bundle, ServiceReference ref, java.lang.Object srvObj)
java.io.File getDataFile(BundleImpl bundle, java.lang.String s)
HookRegistry getHookRegistry()
Bundle getBundle(java.lang.Class clazz)
clazz - the class for which to find its associated bundle.ExportedPackage[] getExportedPackages(java.lang.String pkgName)
pkgName - The name of the exported package to find.ExportedPackage[] getExportedPackages(Bundle b)
b - The bundle whose exported packages are to be retrieved
or null if the exported packages of all bundles are
to be retrieved.private void getExportedPackages(Bundle bundle, java.util.List list)
bundle - The bundle from which to retrieve exported packages.list - The list to which the exported packages are addedjava.util.Set<Bundle> getImportingBundles(BundleImpl exporter, BundleCapability cap)
java.util.Set<Bundle> getRequiringBundles(BundleImpl bundle)
boolean resolveBundles(java.util.Collection<Bundle> targets)
private void resolveBundleRevision(BundleRevision revision) throws BundleException
BundleExceptionvoid refreshPackages(java.util.Collection<Bundle> targets, FrameworkListener[] listeners)
java.util.Collection<Bundle> getDependencyClosure(java.util.Collection<Bundle> targets)
private void populateDependentGraph(BundleImpl exporter, java.util.Set<Bundle> set)
java.util.Collection<Bundle> getRemovalPendingBundles()
SecurityProvider getSecurityProvider()
void setSecurityProvider(SecurityProvider securityProvider)
java.lang.Object getSignerMatcher(BundleImpl bundle, int signersType)
boolean impliesBundlePermission(BundleProtectionDomain bundleProtectionDomain, java.security.Permission permission, boolean direct)
private BundleActivator createBundleActivator(Bundle impl) throws java.lang.Exception
java.lang.Exceptionprivate void refreshBundle(BundleImpl bundle) throws java.lang.Exception
java.lang.Exceptionvoid fireFrameworkEvent(int type,
Bundle bundle,
java.lang.Throwable throwable)
void fireBundleEvent(int type,
Bundle bundle)
type - The type of bundle event to fire.bundle - The bundle associated with the event.private void fireServiceEvent(ServiceEvent event, java.util.Dictionary oldProps)
event - The service event to fire.reg - The service registration associated with the service object.private void initializeFrameworkProperties()
private void loadFromDefaultIfNotDefined(java.util.Properties defaultProperties,
java.lang.String propertyName)
private void loadPrefixFromDefaultIfNotDefined(java.util.Map configMap,
java.util.Properties defaultProperties,
java.lang.String prefix)
private static java.lang.String getFrameworkVersion()
private static java.lang.String cleanMavenVersion(java.lang.StringBuffer sb)
sb - The version to be cleanedprivate long loadNextId()
private long getNextId()
private void rememberUninstalledBundle(BundleImpl bundle)
private void forgetUninstalledBundle(BundleImpl bundle)
void acquireInstallLock(java.lang.String location)
throws BundleException
BundleExceptionvoid releaseInstallLock(java.lang.String location)
void setBundleStateAndNotify(BundleImpl bundle, int state)
void acquireBundleLock(BundleImpl bundle, int desiredStates) throws java.lang.IllegalStateException
bundle - The bundle to lock.desiredStates - Logically OR'ed desired bundle states.java.lang.IllegalStateException - If the bundle is not in one of the
specified desired states.void releaseBundleLock(BundleImpl bundle)
bundle - The bundle whose lock is to be released.java.lang.IllegalStateException - If the calling thread does not
own the bundle lock.boolean acquireGlobalLock()
void releaseGlobalLock()
java.lang.IllegalStateException - If the calling thread does not
own the global lock.void setURLHandlersActivator(URLHandlersActivator urlHandlersActivator)
java.lang.Object getStreamHandlerService(java.lang.String protocol)
java.lang.Object getContentHandlerService(java.lang.String mimeType)
java.util.Collection<BundleCapability> findProviders(Requirement requirement)