Class Felix
- java.lang.Object
-
- org.apache.felix.framework.BundleImpl
-
- org.apache.felix.framework.Felix
-
- All Implemented Interfaces:
java.lang.Comparable<Bundle>,Bundle,BundleReference,Framework,BundleRevisions
public class Felix extends BundleImpl implements Framework
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classFelix.RefreshHelperSimple class that is used in refreshPackages() to embody the refresh logic in order to keep the code clean.private static classFelix.StartLevelTuple(package private) classFelix.SystemBundleActivator
-
Field Summary
-
Fields inherited from interface org.osgi.framework.Bundle
ACTIVE, INSTALLED, RESOLVED, SIGNERS_ALL, SIGNERS_TRUSTED, START_ACTIVATION_POLICY, START_TRANSIENT, STARTING, STOP_TRANSIENT, STOPPING, UNINSTALLED
-
-
Constructor Summary
Constructors Constructor Description Felix(java.util.Map configMap)This constructor creates a framework instance with a specified Map of configuration properties.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) java.lang.String_getLocation()(package private) voidacquireBundleLock(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) booleanacquireGlobalLock()Attempts to acquire the global lock.(package private) voidacquireInstallLock(java.lang.String location)(package private) voidactivateBundle(BundleImpl bundle, boolean fireEvent)<A> Aadapt(java.lang.Class<A> type)Adapt this bundle to the specified type.(package private) voidaddBundleListener(BundleImpl bundle, BundleListener l)(package private) voidaddFrameworkListener(BundleImpl bundle, FrameworkListener l)(package private) voidaddServiceListener(BundleImpl bundle, ServiceListener l, java.lang.String f)Implementation for BundleContext.addServiceListener().(package private) voidblackListHook(ServiceReference sr)(package private) booleanbundleHasPermission(BundleImpl bundle, java.lang.Object obj)private static java.lang.StringcleanMavenVersion(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) voidclose()private BundleActivatorcreateBundleActivator(Bundle impl)private java.util.MapcreateUnmodifiableMap(java.util.Map mutableMap)(package private) java.util.EnumerationfindBundleEntries(BundleImpl bundle, java.lang.String path, java.lang.String filePattern, boolean recurse)Implementation for Bundle.findEntries().(package private) java.util.EnumerationfindBundleEntries(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) voidfireBundleEvent(int type, Bundle bundle)Fires bundle events.(package private) voidfireBundleEvent(int type, Bundle bundle, Bundle origin)(package private) voidfireFrameworkEvent(int type, Bundle bundle, java.lang.Throwable throwable)Fires bundle events.private voidfireServiceEvent(ServiceEvent event, java.util.Dictionary oldProps)Fires service events.private voidforgetUninstalledBundle(BundleImpl bundle)(package private) intgetActiveStartLevel()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 ofServiceReferenceobjects 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) BundlegetBundle(long id)Retrieves a bundle by its identifier and avoids bundles hooks.(package private) BundlegetBundle(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) BundlegetBundle(java.lang.String location)Retrieves a bundle from its location.(package private) BundlegetBundle(BundleContext bc, long id)Implementation for BundleContext.getBundle().(package private) java.net.URLgetBundleEntry(BundleImpl bundle, java.lang.String name)Implementation for Bundle.getEntry().(package private) java.util.EnumerationgetBundleEntryPaths(BundleImpl bundle, java.lang.String path)Implementation for Bundle.getEntryPaths().(package private) java.util.DictionarygetBundleHeaders(BundleImpl bundle, java.lang.String locale)Get bundle headers and resolve any localized strings from resource bundles.longgetBundleId()Returns this bundle's unique identifier.(package private) ServiceReference[]getBundleRegisteredServices(BundleImpl bundle)(package private) java.net.URLgetBundleResource(BundleImpl bundle, java.lang.String name)Implementation for Bundle.getResource().(package private) java.util.EnumerationgetBundleResources(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) intgetBundleStartLevel(Bundle bundle)Returns the start level for the specified bundle; this method implements functionality for the Start Level service.(package private) java.net.URLStreamHandlergetBundleStreamHandler()(package private) java.util.MapgetConfig()(package private) java.lang.ObjectgetContentHandlerService(java.lang.String mimeType)(package private) java.io.FilegetDataFile(BundleImpl bundle, java.lang.String s)(package private) BundleRevisionDependenciesgetDependencies()(package private) java.util.Collection<Bundle>getDependencyClosure(java.util.Collection<Bundle> targets)(package private) ExportedPackage[]getExportedPackages(java.lang.String pkgName)Returns the exported packages associated with the specified package name.(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 voidgetExportedPackages(Bundle bundle, java.util.List list)Adds any current active exported packages from the specified bundle to the passed in list.(package private) FelixgetFramework()private static java.lang.StringgetFrameworkVersion()Read the framework version from the property file.<S> java.util.Set<ServiceReference<S>>getHooks(java.lang.Class<S> hookClass)(package private) java.util.Set<Bundle>getImportingBundles(BundleImpl exporter, BundleCapability cap)(package private) intgetInitialBundleStartLevel()Returns the start level into which newly installed bundles will be placed by default; this method implements functionality for the Start Level service.longgetLastModified()Returns the time when this bundle was last modified.(package private) LoggergetLogger()private longgetNextId()intgetPersistentState()(package private) java.lang.StringgetProperty(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) StatefulResolvergetResolver()(package private) SecurityProvidergetSecurityProvider()(package private) <S> SgetService(Bundle bundle, ServiceReference<S> ref, boolean isPrototype)(package private) ServiceReference[]getServiceReferences(BundleImpl bundle, java.lang.String className, java.lang.String expr, boolean checkAssignable)Retrieves an array ofServiceReferenceobjects based on calling bundle, service class name, and filter expression.(package private) java.lang.ObjectgetSignerMatcher(BundleImpl bundle, int signersType)(package private) intgetStartLevel(int defaultLevel)Overrides standard BundleImpl.getStartLevel() behavior to always return zero for the system bundle.(package private) java.lang.ObjectgetStreamHandlerService(java.lang.String protocol)booleanhasPermission(java.lang.Object obj)Determines if this bundle has the specified permissions.(package private) booleanimpliesBundlePermission(BundleProtectionDomain bundleProtectionDomain, java.security.Permission permission, boolean direct)voidinit()Initialize this Framework.voidinit(FrameworkListener... listeners)Initialize this Framework.private voidinitializeFrameworkProperties()(package private) BundleinstallBundle(Bundle origin, java.lang.String location, java.io.InputStream is)(package private) booleanisBundleActivationPolicyUsed(Bundle bundle)Returns whether the bundle is using its declared activation policy; this is an method implementation for the Start Level service.(package private) booleanisBundlePersistentlyStarted(Bundle bundle)Returns whether a bundle is persistently started; this is an method implementation for the Start Level service.(package private) booleanisHookBlackListed(ServiceReference sr)(package private) java.lang.ClassloadBundleClass(BundleImpl bundle, java.lang.String name)Implementation for Bundle.loadClass().private voidloadFromDefaultIfNotDefined(java.util.Properties defaultProperties, java.lang.String propertyName)private longloadNextId()Generated the next valid bundle identifier.private voidloadPrefixFromDefaultIfNotDefined(java.util.Map configMap, java.util.Properties defaultProperties, java.lang.String prefix)private voidpopulateDependentGraph(BundleImpl exporter, java.util.Set<Bundle> set)private voidrefreshBundle(BundleImpl bundle)(package private) voidrefreshPackages(java.util.Collection<Bundle> targets, FrameworkListener[] listeners)(package private) ServiceRegistrationregisterService(BundleContextImpl context, java.lang.String[] classNames, java.lang.Object svcObj, java.util.Dictionary dict)Implementation for BundleContext.registerService().(package private) voidreleaseBundleLock(BundleImpl bundle)Releases the bundle's lock.(package private) voidreleaseGlobalLock()Releases the global lock.(package private) voidreleaseInstallLock(java.lang.String location)private BundlereloadBundle(BundleArchive ba)private voidrememberUninstalledBundle(BundleImpl bundle)(package private) voidremoveBundleListener(BundleImpl bundle, BundleListener l)(package private) voidremoveFrameworkListener(BundleImpl bundle, FrameworkListener l)(package private) voidremoveServiceListener(BundleImpl bundle, ServiceListener l)Implementation for BundleContext.removeServiceListener().private voidresolveBundleRevision(BundleRevision revision)(package private) booleanresolveBundles(java.util.Collection<Bundle> targets)(package private) voidsetActiveStartLevel(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) voidsetBundleProtectionDomain(BundleImpl bundleImpl, BundleRevisionImpl revisionImpl)(package private) voidsetBundleStartLevel(Bundle bundle, int startLevel)Sets the start level of the specified bundle; this method implements functionality for the Start Level service.(package private) voidsetBundleStateAndNotify(BundleImpl bundle, int state)(package private) voidsetInitialBundleStartLevel(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) voidsetLastModified(long l)voidsetPersistentStateActive()voidsetPersistentStateInactive()voidsetPersistentStateUninstalled()(package private) voidsetSecurityProvider(SecurityProvider securityProvider)(package private) voidsetStartLevel(int level)Overrides standard BundleImpl.setStartLevel() behavior to always throw an exception since the system bundle's start level cannot be changed.(package private) voidsetURLHandlersActivator(URLHandlersActivator urlHandlersActivator)voidstart()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).voidstart(int options)Starts this bundle.(package private) voidstartBundle(BundleImpl bundle, int options)Implementation for Bundle.start().voidstop()This method asynchronously shuts down the framework, it must be called at the end of a session in order to shutdown all active bundles.voidstop(int options)Stops this bundle.(package private) voidstopBundle(BundleImpl bundle, boolean record)java.lang.StringtoString()(package private) booleanungetService(Bundle bundle, ServiceReference ref, java.lang.Object srvObj)voiduninstall()Uninstalls this bundle.(package private) voiduninstallBundle(BundleImpl bundle)voidupdate()Updates this bundle.voidupdate(java.io.InputStream is)Updates this bundle from anInputStream.(package private) voidupdateBundle(BundleImpl bundle, java.io.InputStream is)FrameworkEventwaitForStop(long timeout)This method will cause the calling thread to block until the framework shuts down.-
Methods inherited from class org.apache.felix.framework.BundleImpl
__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, unlock
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.osgi.framework.Bundle
getBundleContext, getDataFile, getHeaders, getHeaders, getRegisteredServices, getResource, getResources, getServicesInUse, getSignerCertificates, getState, getVersion, loadClass
-
Methods inherited from interface org.osgi.framework.launch.Framework
findEntries, getEntry, getEntryPaths, getLocation, getSymbolicName
-
-
-
-
Field Detail
-
m_secureAction
static final SecureAction m_secureAction
-
m_extensionManager
private final ExtensionManager m_extensionManager
-
m_fwkWiring
private final FrameworkWiringImpl m_fwkWiring
-
m_fwkStartLevel
private final FrameworkStartLevelImpl m_fwkStartLevel
-
m_logger
private final Logger m_logger
-
m_configMap
private final java.util.Map m_configMap
-
m_configMutableMap
private final java.util.Map m_configMutableMap
-
m_resolver
private final StatefulResolver m_resolver
-
m_bundleLock
private final java.lang.Object[] m_bundleLock
-
m_globalLockWaitersList
private final java.util.List m_globalLockWaitersList
-
m_globalLockThread
private java.lang.Thread m_globalLockThread
-
m_globalLockCount
private int m_globalLockCount
-
m_installRequestMap
private final java.util.Map m_installRequestMap
-
m_installRequestLock_Priority1
private final java.lang.Object[] m_installRequestLock_Priority1
-
m_installedBundles
private volatile java.util.Map[] m_installedBundles
-
LOCATION_MAP_IDX
private static final int LOCATION_MAP_IDX
- See Also:
- Constant Field Values
-
IDENTIFIER_MAP_IDX
private static final int IDENTIFIER_MAP_IDX
- See Also:
- Constant Field Values
-
m_uninstalledBundles
private volatile java.util.List<BundleImpl> m_uninstalledBundles
-
m_dependencies
private final BundleRevisionDependencies m_dependencies
-
m_activeStartLevel
private volatile int m_activeStartLevel
-
m_targetStartLevel
private volatile int m_targetStartLevel
-
m_startLevelBundles
private final java.util.SortedSet<Felix.StartLevelTuple> m_startLevelBundles
-
m_cache
private BundleCache m_cache
-
m_activatorList
java.util.List m_activatorList
-
m_nextId
private long m_nextId
-
m_nextIdLock
private final java.lang.Object m_nextIdLock
-
m_registry
private final ServiceRegistry m_registry
-
m_dispatcher
private final EventDispatcher m_dispatcher
-
m_bundleStreamHandler
private final java.net.URLStreamHandler m_bundleStreamHandler
-
m_bootPkgs
private final java.lang.String[] m_bootPkgs
-
m_bootPkgWildcards
private final boolean[] m_bootPkgWildcards
-
m_shutdownGate
private volatile ThreadGate m_shutdownGate
-
m_securityManager
private java.lang.SecurityManager m_securityManager
-
m_securityDefaultPolicy
private volatile boolean m_securityDefaultPolicy
-
m_systemBundleClassCache
private final java.util.Map<java.lang.Class,java.lang.Boolean> m_systemBundleClassCache
-
m_securityProvider
private volatile SecurityProvider m_securityProvider
-
m_urlHandlersActivator
private volatile URLHandlersActivator m_urlHandlersActivator
-
-
Constructor Detail
-
Felix
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):
- org.osgi.framework.storage - Sets the directory to use as the bundle cache; by default bundle cache directory is felix-cache in the current working directory. The value should be a valid directory name. The directory name can be either absolute or relative. Relative directory names are relative to the current working directory. The specified directory will be created if it does not exist.
- org.osgi.framework.storage.clean - Determines whether the bundle cache is flushed. The value can either be "none" or "onFirstInit", where "none" does not flush the bundle cache and "onFirstInit" flushes the bundle cache when the framework instance is first initialized. The default value is "none".
- felix.cache.rootdir - Sets the root directory to use to calculate the bundle cache directory for relative directory names. If org.osgi.framework.storage is set to a relative name, by default it is relative to the current working directory. If this property is set, then it will be calculated as being relative to the specified root directory.
- felix.cache.filelimit - The integer value of this string sets an upper limit on how many files the cache will open. The default value is zero, which means there is no limit.
- felix.cache.locking - Enables or disables bundle cache locking, which is used to prevent concurrent access to the bundle cache. This is enabled by default, but on older/smaller JVMs file channel locking is not available; set this property to false to disable it.
- felix.cache.bufsize - Sets the buffer size to be used by the cache; the default value is 4096. The integer value of this string provides control over the size of the internal buffer of the disk cache for performance reasons.
- org.osgi.framework.system.packages - Specifies a comma-delimited list of packages that should be exported via the System Bundle from the parent class loader. The framework will set this to a reasonable default. If the value is specified, it replaces any default value.
- org.osgi.framework.system.packages.extra - Specifies a comma-delimited list of packages that should be exported via the System Bundle from the parent class loader in addition to the packages in org.osgi.framework.system.packages. The default value is empty. If a value is specified, it is appended to the list of default or specified packages in org.osgi.framework.system.packages.
- org.osgi.framework.bootdelegation - Specifies a comma-delimited list of packages that should be made implicitly available to all bundles from the parent class loader. It is recommended not to use this property since it breaks modularity. The default value is empty.
- felix.systembundle.activators - A List of BundleActivator instances that are started/stopped when the System Bundle is started/stopped. The specified instances will receive the System Bundle's BundleContext when invoked.
- felix.log.logger - An instance of Logger that the framework uses as its default logger.
- felix.log.level - An integer value indicating the degree of logging reported by the framework; the higher the value the more logging is reported. If zero ('0') is specified, then logging is turned off completely. The log levels match those specified in the OSGi Log Service (i.e., 1 = error, 2 = warning, 3 = information, and 4 = debug). The default value is 1.
- org.osgi.framework.startlevel.beginning - The initial start level of the framework once it starts execution; the default value is 1.
- felix.startlevel.bundle - The default start level for newly installed bundles; the default value is 1.
- felix.service.urlhandlers - Flag to indicate whether to activate the URL Handlers service for the framework instance; the default value is "true". Activating the URL Handlers service will result in the URL.setURLStreamHandlerFactory() and URLConnection.setContentHandlerFactory() being called.
- felix.fragment.validation - Determines if installing unsupported fragment bundles throws an exception or logs a warning. Possible values are "exception" or "warning". The default value is "exception".
- felix.security.defaultpolicy - Flag to indicate whether to consult the default java securtiy policy if no security extension is present. The default value is "false".
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.
- Parameters:
configMap- A map for obtaining configuration properties, may be null.
-
-
Method Detail
-
getLogger
Logger getLogger()
-
getConfig
java.util.Map getConfig()
-
getResolver
StatefulResolver getResolver()
-
getDependencies
BundleRevisionDependencies getDependencies()
-
getBundleStreamHandler
java.net.URLStreamHandler getBundleStreamHandler()
-
getBootPackages
java.lang.String[] getBootPackages()
-
getBootPackageWildcards
boolean[] getBootPackageWildcards()
-
createUnmodifiableMap
private java.util.Map createUnmodifiableMap(java.util.Map mutableMap)
-
close
void close()
- Overrides:
closein classBundleImpl
-
getFramework
Felix getFramework()
- Overrides:
getFrameworkin classBundleImpl
-
adapt
public <A> A adapt(java.lang.Class<A> type)
Description copied from interface:BundleAdapt this bundle to the specified type.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
nullis returned.- Specified by:
adaptin interfaceBundle- Specified by:
adaptin interfaceFramework- Overrides:
adaptin classBundleImpl- Type Parameters:
A- The type to which this bundle is to be adapted.- Parameters:
type- Class object for the type to which this bundle is to be adapted.- Returns:
- The object, of the specified type, to which this bundle has been
adapted or
nullif this bundle cannot be adapted to the specified type.
-
getBundleId
public long getBundleId()
Description copied from interface:BundleReturns this bundle's unique identifier. This bundle is assigned a unique identifier by the Framework when it was installed in the OSGi environment.A bundle's unique identifier has the following attributes:
- Is unique and persistent.
- Is a
long. - Its value is not reused for another bundle, even after a bundle is uninstalled.
- Does not change while a bundle remains installed.
- Does not change when a bundle is updated.
This method must continue to return this bundle's unique identifier while this bundle is in the
UNINSTALLEDstate.- Specified by:
getBundleIdin interfaceBundle- Specified by:
getBundleIdin interfaceFramework- Overrides:
getBundleIdin classBundleImpl- Returns:
- The unique identifier of this bundle.
- See Also:
Bundle.getBundleId()
-
getLastModified
public long getLastModified()
Description copied from interface:BundleReturns the time when this bundle was last modified. A bundle is considered to be modified when it is installed, updated or uninstalled.The time value is the number of milliseconds since January 1, 1970, 00:00:00 UTC.
- Specified by:
getLastModifiedin interfaceBundle- Specified by:
getLastModifiedin interfaceFramework- Overrides:
getLastModifiedin classBundleImpl- Returns:
- The time when this bundle was last modified.
-
setLastModified
void setLastModified(long l)
- Overrides:
setLastModifiedin classBundleImpl
-
_getLocation
java.lang.String _getLocation()
- Overrides:
_getLocationin classBundleImpl
-
getPersistentState
public int getPersistentState()
- Overrides:
getPersistentStatein classBundleImpl
-
setPersistentStateInactive
public void setPersistentStateInactive()
- Overrides:
setPersistentStateInactivein classBundleImpl
-
setPersistentStateActive
public void setPersistentStateActive()
- Overrides:
setPersistentStateActivein classBundleImpl
-
setPersistentStateUninstalled
public void setPersistentStateUninstalled()
- Overrides:
setPersistentStateUninstalledin classBundleImpl
-
getStartLevel
int getStartLevel(int defaultLevel)
Overrides standard BundleImpl.getStartLevel() behavior to always return zero for the system bundle.- Overrides:
getStartLevelin classBundleImpl- Parameters:
defaultLevel- This parameter is ignored by the system bundle.- Returns:
- Always returns zero.
-
setStartLevel
void setStartLevel(int level)
Overrides standard BundleImpl.setStartLevel() behavior to always throw an exception since the system bundle's start level cannot be changed.- Overrides:
setStartLevelin classBundleImpl- Parameters:
level- This parameter is ignored by the system bundle.- Throws:
java.lang.IllegalArgumentException- Always throws exception since system bundle's start level cannot be changed.
-
hasPermission
public boolean hasPermission(java.lang.Object obj)
Description copied from interface:BundleDetermines if this bundle has the specified permissions.If the Java Runtime Environment does not support permissions, this method always returns
true.permissionis of typeObjectto avoid referencing thejava.security.Permissionclass 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.- Specified by:
hasPermissionin interfaceBundle- Overrides:
hasPermissionin classBundleImpl- Parameters:
obj- The permission to verify.- Returns:
trueif this bundle has the specified permission or the permissions possessed by this bundle imply the specified permission;falseif this bundle does not have the specified permission orpermissionis not aninstanceofjava.security.Permission.
-
init
public void init() throws BundleExceptionDescription copied from interface:FrameworkInitialize this Framework.This method performs the same function as calling
Framework.init(FrameworkListener...)with no framework listeners.- Specified by:
initin interfaceFramework- Throws:
BundleException- If this Framework could not be initialized.- See Also:
Framework.init(FrameworkListener...)
-
init
public void init(FrameworkListener... listeners) throws BundleException
Description copied from interface:FrameworkInitialize this Framework. After calling this method, this Framework must:- Have generated a new
framework UUID. - Be in the
Bundle.STARTINGstate. - Have a valid Bundle Context.
- Be at start level 0.
- Have event handling enabled.
- Have reified Bundle objects for all installed bundles.
- Have registered any framework services. For example,
ConditionalPermissionAdmin. - Be
adaptableto the OSGi defined types to which a system bundle can be adapted. - Have called the
startmethod of the extension bundle activator for all resolved extension bundles.
This Framework will not actually be started until
startis called.This method does nothing if called when this Framework is in the
Bundle.STARTING,Bundle.ACTIVEorBundle.STOPPINGstates.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.
- Specified by:
initin interfaceFramework- Parameters:
listeners- 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.- Throws:
BundleException- If this Framework could not be initialized.- See Also:
Framework.init(org.osgi.framework.FrameworkListener[])
- Have generated a new
-
setBundleProtectionDomain
void setBundleProtectionDomain(BundleImpl bundleImpl, BundleRevisionImpl revisionImpl) throws java.lang.Exception
- Throws:
java.lang.Exception
-
start
public void start() throws BundleExceptionThis 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). If the init() was not explicitly invoked before calling this method, then it will be implicitly invoked before starting the framework.- Specified by:
startin interfaceBundle- Specified by:
startin interfaceFramework- Overrides:
startin classBundleImpl- Throws:
BundleException- if any error occurs.- See Also:
Bundle.start(int)
-
start
public void start(int options) throws BundleExceptionDescription copied from interface:BundleStarts this bundle.If this bundle's state is
UNINSTALLEDthen anIllegalStateExceptionis thrown.If the current start level is less than this bundle's start level:
- If the
Bundle.START_TRANSIENToption is set, then aBundleExceptionis thrown indicating this bundle cannot be started due to the Framework's current start level. - Otherwise, the Framework must set this bundle's persistent autostart
setting to Started with declared activation if the
Bundle.START_ACTIVATION_POLICYoption 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:
- If this bundle is in the process of being activated or deactivated
then this method must wait for activation or deactivation to complete
before continuing. If this does not occur in a reasonable time, a
BundleExceptionis thrown to indicate this bundle was unable to be started. - If the
Bundle.START_TRANSIENToption is not set then set this bundle's autostart setting to Started with declared activation if theBundle.START_ACTIVATION_POLICYoption 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. - If this bundle's state is
ACTIVEthen this method returns immediately. - If this bundle's state is not
RESOLVED, an attempt is made to resolve this bundle. If the Framework cannot resolve this bundle, aBundleExceptionis thrown. - If the
Bundle.START_ACTIVATION_POLICYoption is set and this bundle's declared activation policy islazythen:- If this bundle's state is
STARTINGthen this method returns immediately. - This bundle's state is set to
STARTING. - A bundle event of type
BundleEvent.LAZY_ACTIVATIONis fired. - This method returns immediately and the remaining steps will be followed when this bundle's activation is later triggered.
- If this bundle's state is
- This bundle's state is set to
STARTING. - A bundle event of type
BundleEvent.STARTINGis fired. - The
BundleActivator.start(BundleContext)method of this bundle'sBundleActivator, if one is specified, is called. If theBundleActivatoris invalid or throws an exception then:- This bundle's state is set to
STOPPING. - A bundle event of type
BundleEvent.STOPPINGis fired. - Any services registered by this bundle must be unregistered.
- Any services used by this bundle must be released.
- Any listeners registered by this bundle must be removed.
- This bundle's state is set to
RESOLVED. - A bundle event of type
BundleEvent.STOPPEDis fired. - A
BundleExceptionis then thrown.
- This bundle's state is set to
- This bundle's state is set to
ACTIVE. - A bundle event of type
BundleEvent.STARTEDis fired.
getState()in {INSTALLED,RESOLVED} or {INSTALLED,RESOLVED,STARTING} if this bundle has a lazy activation policy.
- Bundle autostart setting is modified unless the
Bundle.START_TRANSIENToption 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.
- Depending on when the exception occurred, bundle autostart setting is
modified unless the
Bundle.START_TRANSIENToption was set. getState()not in {STARTING,ACTIVE}.
- Specified by:
startin interfaceBundle- Specified by:
startin interfaceFramework- Overrides:
startin classBundleImpl- Parameters:
options- The options for starting this bundle. SeeBundle.START_TRANSIENTandBundle.START_ACTIVATION_POLICY. The Framework must ignore unrecognized options.- Throws:
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, andBundleException.ACTIVATOR_ERROR.- See Also:
Framework.start()
- If the
-
stop
public void stop() throws BundleExceptionThis method asynchronously shuts down the framework, it must be called at the end of a session in order to shutdown all active bundles.- Specified by:
stopin interfaceBundle- Specified by:
stopin interfaceFramework- Overrides:
stopin classBundleImpl- Throws:
BundleException- BundleException types thrown by this method include:BundleException.STATECHANGE_ERRORandBundleException.ACTIVATOR_ERROR.- See Also:
Bundle.start(int)
-
stop
public void stop(int options) throws BundleExceptionDescription copied from interface:BundleStops this bundle.The following steps are required to stop a bundle:
- If this bundle's state is
UNINSTALLEDthen anIllegalStateExceptionis thrown. - If this bundle is in the process of being activated or deactivated
then this method must wait for activation or deactivation to complete
before continuing. If this does not occur in a reasonable time, a
BundleExceptionis thrown to indicate this bundle was unable to be stopped. - If the
Bundle.STOP_TRANSIENToption 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. - If this bundle's state is not
STARTINGorACTIVEthen this method returns immediately. - This bundle's state is set to
STOPPING. - A bundle event of type
BundleEvent.STOPPINGis fired. - If this bundle's state was
ACTIVEprior to setting the state toSTOPPING, theBundleActivator.stop(BundleContext)method of this bundle'sBundleActivator, if one is specified, is called. If that method throws an exception, this method must continue to stop this bundle and aBundleExceptionmust be thrown after completion of the remaining steps. - Any services registered by this bundle must be unregistered.
- Any services used by this bundle must be released.
- Any listeners registered by this bundle must be removed.
- If this bundle's state is
UNINSTALLED, because this bundle was uninstalled while theBundleActivator.stopmethod was running, aBundleExceptionmust be thrown. - This bundle's state is set to
RESOLVED. - A bundle event of type
BundleEvent.STOPPEDis fired.
getState()in {ACTIVE}.
- Bundle autostart setting is modified unless the
Bundle.STOP_TRANSIENToption was set. getState()not in {ACTIVE,STOPPING}.BundleActivator.stophas been called and did not throw an exception.
- Bundle autostart setting is modified unless the
Bundle.STOP_TRANSIENToption was set.
- Specified by:
stopin interfaceBundle- Specified by:
stopin interfaceFramework- Overrides:
stopin classBundleImpl- Parameters:
options- The options for stopping this bundle. SeeBundle.STOP_TRANSIENT. The Framework must ignore unrecognized options.- Throws:
BundleException- BundleException types thrown by this method include:BundleException.STATECHANGE_ERRORandBundleException.ACTIVATOR_ERROR.- See Also:
Framework.stop()
- If this bundle's state is
-
waitForStop
public FrameworkEvent waitForStop(long timeout) throws java.lang.InterruptedException
This method will cause the calling thread to block until the framework shuts down.- Specified by:
waitForStopin interfaceFramework- Parameters:
timeout- A timeout value.- Returns:
- A Framework Event indicating the reason this method returned. The
following
FrameworkEventtypes 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.
- Throws:
java.lang.InterruptedException- If the thread was interrupted.
-
uninstall
public void uninstall() throws BundleExceptionDescription copied from interface:BundleUninstalls this bundle.This method causes the Framework to notify other bundles that this bundle is being uninstalled, and then puts this bundle into the
UNINSTALLEDstate. 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.refreshBundlesmethod has been called or the Framework is relaunched.The following steps are required to uninstall a bundle:
- If this bundle's state is
UNINSTALLEDthen anIllegalStateExceptionis thrown. - If this bundle's state is
ACTIVE,STARTINGorSTOPPING, this bundle is stopped as described in theBundle.stopmethod. IfBundle.stopthrows an exception, a Framework event of typeFrameworkEvent.ERRORis fired containing the exception. - This bundle's state is set to
UNINSTALLED. - A bundle event of type
BundleEvent.UNINSTALLEDis fired. - This bundle and any persistent storage area provided for this bundle by the Framework are removed.
getState()not in {UNINSTALLED}.
getState()in {UNINSTALLED}.- This bundle has been uninstalled.
getState()not in {UNINSTALLED}.- This Bundle has not been uninstalled.
- Specified by:
uninstallin interfaceBundle- Specified by:
uninstallin interfaceFramework- Overrides:
uninstallin classBundleImpl- Throws:
BundleException- 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_ERROR- See Also:
Bundle.stop()
- If this bundle's state is
-
update
public void update() throws BundleExceptionDescription copied from interface:BundleUpdates this bundle.This method performs the same function as calling
Bundle.update(InputStream)with anullInputStream.- Specified by:
updatein interfaceBundle- Specified by:
updatein interfaceFramework- Overrides:
updatein classBundleImpl- Throws:
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, andBundleException.ACTIVATOR_ERROR.- See Also:
Bundle.update(InputStream)
-
update
public void update(java.io.InputStream is) throws BundleExceptionDescription copied from interface:BundleUpdates this bundle from anInputStream.If the specified
InputStreamisnull, the Framework must create theInputStreamfrom which to read the updated bundle by interpreting, in an implementation dependent manner, this bundle'sBundle-UpdateLocationManifest 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.refreshBundlesmethod has been has been called or the Framework is relaunched.The following steps are required to update a bundle:
- If this bundle's state is
UNINSTALLEDthen anIllegalStateExceptionis thrown. - If this bundle's state is
ACTIVE,STARTINGorSTOPPING, this bundle is stopped as described in theBundle.stopmethod. IfBundle.stopthrows an exception, the exception is rethrown terminating the update. - The updated version of this bundle is read from the input stream and
installed. If the Framework is unable to install the updated version of
this bundle, the original version of this bundle must be restored and a
BundleExceptionmust be thrown after completion of the remaining steps. - This bundle's state is set to
INSTALLED. - If the updated version of this bundle was successfully installed, a
bundle event of type
BundleEvent.UPDATEDis fired. - If this bundle's state was originally
ACTIVE, the updated bundle is started as described in theBundle.startmethod. IfBundle.startthrows an exception, a Framework event of typeFrameworkEvent.ERRORis fired containing the exception.
getState()not in {UNINSTALLED}.
getState()in {INSTALLED,RESOLVED,ACTIVE}.- This bundle has been updated.
getState()in {INSTALLED,RESOLVED,ACTIVE}.- Original bundle is still used; no update occurred.
- Specified by:
updatein interfaceBundle- Specified by:
updatein interfaceFramework- Overrides:
updatein classBundleImpl- Parameters:
is- TheInputStreamfrom which to read the new bundle ornullto indicate the Framework must create the input stream from this bundle'sBundle-UpdateLocationManifest 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.- Throws:
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, andBundleException.ACTIVATOR_ERROR.- See Also:
Bundle.stop(),Bundle.start()
- If this bundle's state is
-
toString
public java.lang.String toString()
- Overrides:
toStringin classBundleImpl
-
getActiveStartLevel
int getActiveStartLevel()
Returns the active start level of the framework; this method implements functionality for the Start Level service.- Returns:
- The active start level of the framework.
-
setActiveStartLevel
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. The security and parameter check are done in the StartLevel service implementation because this method is called on a separate thread and the caller's thread would already be gone if we did the checks in this method. This method should not be called directly.- Parameters:
requestedLevel- The new start level of the framework.
-
getInitialBundleStartLevel
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.- Returns:
- The default start level for newly installed bundles.
-
setInitialBundleStartLevel
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.- Parameters:
startLevel- The new default start level for newly installed bundles.- Throws:
java.lang.IllegalArgumentException- If the specified start level is not greater than zero.java.security.SecurityException- If the caller does not have AdminPermission.
-
getBundleStartLevel
int getBundleStartLevel(Bundle bundle)
Returns the start level for the specified bundle; this method implements functionality for the Start Level service.- Parameters:
bundle- The bundle to examine.- Returns:
- The start level of the specified bundle.
- Throws:
java.lang.IllegalArgumentException- If the specified bundle has been uninstalled.
-
setBundleStartLevel
void setBundleStartLevel(Bundle bundle, int startLevel)
Sets the start level of the specified bundle; this method implements functionality for the Start Level service.- Parameters:
bundle- The bundle whose start level is to be modified.startLevel- The new start level of the specified bundle.- Throws:
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.
-
isBundlePersistentlyStarted
boolean isBundlePersistentlyStarted(Bundle bundle)
Returns whether a bundle is persistently started; this is an method implementation for the Start Level service.- Parameters:
bundle- The bundle to examine.- Returns:
- true if the bundle is marked as persistently started, false otherwise.
- Throws:
java.lang.IllegalArgumentException- If the specified bundle has been uninstalled.
-
isBundleActivationPolicyUsed
boolean isBundleActivationPolicyUsed(Bundle bundle)
Returns whether the bundle is using its declared activation policy; this is an method implementation for the Start Level service.- Parameters:
bundle- The bundle to examine.- Returns:
- true if the bundle is using its declared activation policy, false otherwise.
- Throws:
java.lang.IllegalArgumentException- If the specified bundle has been uninstalled.
-
getBundleHeaders
java.util.Dictionary getBundleHeaders(BundleImpl bundle, java.lang.String locale)
Get bundle headers and resolve any localized strings from resource bundles.- Parameters:
bundle-locale-- Returns:
- localized bundle headers dictionary.
-
getBundleResource
java.net.URL getBundleResource(BundleImpl bundle, java.lang.String name)
Implementation for Bundle.getResource().
-
getBundleResources
java.util.Enumeration getBundleResources(BundleImpl bundle, java.lang.String name)
Implementation for Bundle.getResources().
-
getBundleEntry
java.net.URL getBundleEntry(BundleImpl bundle, java.lang.String name)
Implementation for Bundle.getEntry().
-
getBundleEntryPaths
java.util.Enumeration getBundleEntryPaths(BundleImpl bundle, java.lang.String path)
Implementation for Bundle.getEntryPaths().
-
findBundleEntries
java.util.Enumeration findBundleEntries(BundleImpl bundle, java.lang.String path, java.lang.String filePattern, boolean recurse)
Implementation for Bundle.findEntries().
-
findBundleEntries
java.util.Enumeration findBundleEntries(BundleRevision revision, java.lang.String path, java.lang.String filePattern, boolean recurse)
Implementation for BundleWiring.findEntries().
-
getBundleRegisteredServices
ServiceReference[] getBundleRegisteredServices(BundleImpl bundle)
-
getBundleServicesInUse
ServiceReference[] getBundleServicesInUse(Bundle bundle)
-
bundleHasPermission
boolean bundleHasPermission(BundleImpl bundle, java.lang.Object obj)
-
loadBundleClass
java.lang.Class loadBundleClass(BundleImpl bundle, java.lang.String name) throws java.lang.ClassNotFoundException
Implementation for Bundle.loadClass().- Throws:
java.lang.ClassNotFoundException
-
startBundle
void startBundle(BundleImpl bundle, int options) throws BundleException
Implementation for Bundle.start().- Throws:
BundleException
-
activateBundle
void activateBundle(BundleImpl bundle, boolean fireEvent) throws BundleException
- Throws:
BundleException
-
updateBundle
void updateBundle(BundleImpl bundle, java.io.InputStream is) throws BundleException
- Throws:
BundleException
-
stopBundle
void stopBundle(BundleImpl bundle, boolean record) throws BundleException
- Throws:
BundleException
-
uninstallBundle
void uninstallBundle(BundleImpl bundle) throws BundleException
- Throws:
BundleException
-
getProperty
java.lang.String getProperty(java.lang.String key)
Implementation for BundleContext.getProperty(). Returns environment property associated with the framework.- Parameters:
key- The name of the property to retrieve.- Returns:
- The value of the specified property or null.
-
reloadBundle
private Bundle reloadBundle(BundleArchive ba) throws BundleException
- Throws:
BundleException
-
installBundle
Bundle installBundle(Bundle origin, java.lang.String location, java.io.InputStream is) throws BundleException
- Throws:
BundleException
-
getBundle
Bundle getBundle(java.lang.String location)
Retrieves a bundle from its location.- Parameters:
location- The location of the bundle to retrieve.- Returns:
- The bundle associated with the location or null if there is no bundle associated with the location.
-
getBundle
Bundle getBundle(BundleContext bc, long id)
Implementation for BundleContext.getBundle(). Retrieves a bundle from its identifier.- Parameters:
id- The identifier of the bundle to retrieve.- Returns:
- The bundle associated with the identifier or null if there is no bundle associated with the identifier.
-
getBundle
Bundle getBundle(long id)
Retrieves a bundle by its identifier and avoids bundles hooks.- Returns:
- The bundle associated with the identifier or null.
-
getBundles
Bundle[] getBundles(BundleContext bc)
Implementation for BundleContext.getBundles(). Retrieves all installed bundles.- Returns:
- An array containing all installed bundles or null if there are no installed bundles.
-
getBundles
Bundle[] getBundles()
Retrieves all installed bundles and avoids bundles hooks.- Returns:
- An array containing all installed bundles or null if there are no installed bundles.
-
addBundleListener
void addBundleListener(BundleImpl bundle, BundleListener l)
-
removeBundleListener
void removeBundleListener(BundleImpl bundle, BundleListener l)
-
addServiceListener
void addServiceListener(BundleImpl bundle, ServiceListener l, java.lang.String f) throws InvalidSyntaxException
Implementation for BundleContext.addServiceListener(). Adds service listener to the listener list so that is can listen forServiceEvents.- Parameters:
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.- Throws:
InvalidSyntaxException
-
removeServiceListener
void removeServiceListener(BundleImpl bundle, ServiceListener l)
Implementation for BundleContext.removeServiceListener(). Removes service listeners from the listener list.- Parameters:
bundle- The context bundle of the listenerl- The service listener to remove from the listener list.
-
addFrameworkListener
void addFrameworkListener(BundleImpl bundle, FrameworkListener l)
-
removeFrameworkListener
void removeFrameworkListener(BundleImpl bundle, FrameworkListener l)
-
registerService
ServiceRegistration registerService(BundleContextImpl context, java.lang.String[] classNames, java.lang.Object svcObj, java.util.Dictionary dict)
Implementation for BundleContext.registerService(). Registers a service for the specified bundle bundle.- Parameters:
classNames- A string array containing the names of the classes under which the new service is available.svcObj- The service object orServiceFactory.dict- A dictionary of properties that further describe the service or null.- Returns:
- A
ServiceRegistrationobject or null.
-
getServiceReferences
ServiceReference[] getServiceReferences(BundleImpl bundle, java.lang.String className, java.lang.String expr, boolean checkAssignable) throws InvalidSyntaxException
Retrieves an array ofServiceReferenceobjects based on calling bundle, service class name, and filter expression. Optionally checks for isAssignable to make sure that the service can be cast to the- Parameters:
bundle- Calling BundleclassName- Service Classname ornullfor allexpr- Filter Criteria ornull- Returns:
- Array of ServiceReference objects that meet the criteria
- Throws:
InvalidSyntaxException
-
getAllowedServiceReferences
ServiceReference[] getAllowedServiceReferences(BundleImpl bundle, java.lang.String className, java.lang.String expr, boolean checkAssignable) throws InvalidSyntaxException
Retrieves Array ofServiceReferenceobjects based on calling bundle, service class name, optional filter expression, and optionally filters further on the version. If running under aSecurityManager, checks that the calling bundle has permissions to see the service references and removes references that aren't.- Parameters:
bundle- Calling BundleclassName- Service Classname ornullfor allexpr- Filter Criteria ornullcheckAssignable-trueto check for isAssignable,falseto return all versions- Returns:
- Array of ServiceReference objects that meet the criteria
- Throws:
InvalidSyntaxException
-
getService
<S> S getService(Bundle bundle, ServiceReference<S> ref, boolean isPrototype)
-
ungetService
boolean ungetService(Bundle bundle, ServiceReference ref, java.lang.Object srvObj)
-
getDataFile
java.io.File getDataFile(BundleImpl bundle, java.lang.String s)
-
isHookBlackListed
boolean isHookBlackListed(ServiceReference sr)
-
blackListHook
void blackListHook(ServiceReference sr)
-
getHooks
public <S> java.util.Set<ServiceReference<S>> getHooks(java.lang.Class<S> hookClass)
-
getBundle
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. If the class was not loaded from a bundle or was loaded by a bundle in another framework instance, then null is returned.- Parameters:
clazz- the class for which to find its associated bundle.- Returns:
- the bundle associated with the specified class or null if the class was not loaded by a bundle or its associated bundle belongs to a different framework instance.
-
getExportedPackages
ExportedPackage[] getExportedPackages(java.lang.String pkgName)
Returns the exported packages associated with the specified package name. This is used by the PackageAdmin service implementation.- Parameters:
pkgName- The name of the exported package to find.- Returns:
- The exported package or null if no matching package was found.
-
getExportedPackages
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.- Parameters:
b- The bundle whose exported packages are to be retrieved or null if the exported packages of all bundles are to be retrieved.- Returns:
- An array of exported packages.
-
getExportedPackages
private void getExportedPackages(Bundle bundle, java.util.List list)
Adds any current active exported packages from the specified bundle to the passed in list.- Parameters:
bundle- The bundle from which to retrieve exported packages.list- The list to which the exported packages are added
-
getImportingBundles
java.util.Set<Bundle> getImportingBundles(BundleImpl exporter, BundleCapability cap)
-
getRequiringBundles
java.util.Set<Bundle> getRequiringBundles(BundleImpl bundle)
-
resolveBundles
boolean resolveBundles(java.util.Collection<Bundle> targets)
-
resolveBundleRevision
private void resolveBundleRevision(BundleRevision revision) throws BundleException
- Throws:
BundleException
-
refreshPackages
void refreshPackages(java.util.Collection<Bundle> targets, FrameworkListener[] listeners)
-
getDependencyClosure
java.util.Collection<Bundle> getDependencyClosure(java.util.Collection<Bundle> targets)
-
populateDependentGraph
private void populateDependentGraph(BundleImpl exporter, java.util.Set<Bundle> set)
-
getRemovalPendingBundles
java.util.Collection<Bundle> getRemovalPendingBundles()
-
getSecurityProvider
SecurityProvider getSecurityProvider()
-
setSecurityProvider
void setSecurityProvider(SecurityProvider securityProvider)
-
getSignerMatcher
java.lang.Object getSignerMatcher(BundleImpl bundle, int signersType)
-
impliesBundlePermission
boolean impliesBundlePermission(BundleProtectionDomain bundleProtectionDomain, java.security.Permission permission, boolean direct)
-
createBundleActivator
private BundleActivator createBundleActivator(Bundle impl) throws java.lang.Exception
- Throws:
java.lang.Exception
-
refreshBundle
private void refreshBundle(BundleImpl bundle) throws java.lang.Exception
- Throws:
java.lang.Exception
-
fireFrameworkEvent
void fireFrameworkEvent(int type, Bundle bundle, java.lang.Throwable throwable)Fires bundle events.
-
fireBundleEvent
void fireBundleEvent(int type, Bundle bundle)Fires bundle events.- Parameters:
type- The type of bundle event to fire.bundle- The bundle associated with the event.
-
fireServiceEvent
private void fireServiceEvent(ServiceEvent event, java.util.Dictionary oldProps)
Fires service events.- Parameters:
event- The service event to fire.reg- The service registration associated with the service object.
-
initializeFrameworkProperties
private void initializeFrameworkProperties()
-
loadFromDefaultIfNotDefined
private void loadFromDefaultIfNotDefined(java.util.Properties defaultProperties, java.lang.String propertyName)
-
loadPrefixFromDefaultIfNotDefined
private void loadPrefixFromDefaultIfNotDefined(java.util.Map configMap, java.util.Properties defaultProperties, java.lang.String prefix)
-
getFrameworkVersion
private static java.lang.String getFrameworkVersion()
Read the framework version from the property file.- Returns:
- the framework version as a string.
-
cleanMavenVersion
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. In short this method attempts to map a Maven version to an OSGi version as well as possible.- Parameters:
sb- The version to be cleaned- Returns:
- The cleaned version
-
loadNextId
private long loadNextId()
Generated the next valid bundle identifier.
-
getNextId
private long getNextId()
-
rememberUninstalledBundle
private void rememberUninstalledBundle(BundleImpl bundle)
-
forgetUninstalledBundle
private void forgetUninstalledBundle(BundleImpl bundle)
-
acquireInstallLock
void acquireInstallLock(java.lang.String location) throws BundleException- Throws:
BundleException
-
releaseInstallLock
void releaseInstallLock(java.lang.String location)
-
setBundleStateAndNotify
void setBundleStateAndNotify(BundleImpl bundle, int state)
-
acquireBundleLock
void acquireBundleLock(BundleImpl bundle, int desiredStates) throws java.lang.IllegalStateException
This method acquires the lock for the specified bundle as long as the bundle is in one of the specified states. If it is not, an exception is thrown. Bundle state changes will be monitored to avoid deadlocks.- Parameters:
bundle- The bundle to lock.desiredStates- Logically OR'ed desired bundle states.- Throws:
java.lang.IllegalStateException- If the bundle is not in one of the specified desired states.
-
releaseBundleLock
void releaseBundleLock(BundleImpl bundle)
Releases the bundle's lock.- Parameters:
bundle- The bundle whose lock is to be released.- Throws:
java.lang.IllegalStateException- If the calling thread does not own the bundle lock.
-
acquireGlobalLock
boolean acquireGlobalLock()
Attempts to acquire the global lock. Will also promote a bundle lock to the global lock, if the calling thread already holds a bundle lock. Since it is possible to deadlock when trying to acquire the global lock while holding a bundle lock, this method may fail if a potential deadlock is detected. If the calling thread does not hold a bundle lock, then it will wait indefinitely to acquire the global.- Returns:
- true if the global lock was successfully acquired, false otherwise.
-
releaseGlobalLock
void releaseGlobalLock()
Releases the global lock.- Throws:
java.lang.IllegalStateException- If the calling thread does not own the global lock.
-
setURLHandlersActivator
void setURLHandlersActivator(URLHandlersActivator urlHandlersActivator)
-
getStreamHandlerService
java.lang.Object getStreamHandlerService(java.lang.String protocol)
-
getContentHandlerService
java.lang.Object getContentHandlerService(java.lang.String mimeType)
-
findProviders
java.util.Collection<BundleCapability> findProviders(Requirement requirement)
-
-