Class Felix

    • Field Detail

      • 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_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
      • m_uninstalledBundles

        private volatile java.util.List<BundleImpl> m_uninstalledBundles
      • m_activeStartLevel

        private volatile int m_activeStartLevel
      • m_targetStartLevel

        private volatile int m_targetStartLevel
      • m_activatorList

        java.util.List m_activatorList
      • m_nextId

        private long m_nextId
      • m_nextIdLock

        private final java.lang.Object m_nextIdLock
      • 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
    • 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()
      • getBundleStreamHandler

        java.net.URLStreamHandler getBundleStreamHandler()
      • getBootPackages

        java.lang.String[] getBootPackages()
      • getBootPackageWildcards

        boolean[] getBootPackageWildcards()
      • createUnmodifiableMap

        private java.util.Map createUnmodifiableMap​(java.util.Map mutableMap)
      • adapt

        public <A> A adapt​(java.lang.Class<A> type)
        Description copied from interface: Bundle
        Adapt 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 null is returned.

        Specified by:
        adapt in interface Bundle
        Specified by:
        adapt in interface Framework
        Overrides:
        adapt in class BundleImpl
        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 null if this bundle cannot be adapted to the specified type.
      • getBundleId

        public long getBundleId()
        Description copied from interface: Bundle
        Returns 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 UNINSTALLED state.

        Specified by:
        getBundleId in interface Bundle
        Specified by:
        getBundleId in interface Framework
        Overrides:
        getBundleId in class BundleImpl
        Returns:
        The unique identifier of this bundle.
        See Also:
        Bundle.getBundleId()
      • getLastModified

        public long getLastModified()
        Description copied from interface: Bundle
        Returns 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:
        getLastModified in interface Bundle
        Specified by:
        getLastModified in interface Framework
        Overrides:
        getLastModified in class BundleImpl
        Returns:
        The time when this bundle was last modified.
      • getStartLevel

        int getStartLevel​(int defaultLevel)
        Overrides standard BundleImpl.getStartLevel() behavior to always return zero for the system bundle.
        Overrides:
        getStartLevel in class BundleImpl
        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:
        setStartLevel in class BundleImpl
        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: Bundle
        Determines if this bundle has the specified permissions.

        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.

        Specified by:
        hasPermission in interface Bundle
        Overrides:
        hasPermission in class BundleImpl
        Parameters:
        obj - The permission to verify.
        Returns:
        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.
      • init

        public void init​(FrameworkListener... listeners)
                  throws BundleException
        Description copied from interface: Framework
        Initialize this Framework. After calling this method, this Framework must:
        • Have generated a new framework UUID.
        • Be in the Bundle.STARTING state.
        • 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 adaptable to the OSGi defined types to which a system bundle can be adapted.
        • Have called the 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.

        Specified by:
        init in interface Framework
        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[])
      • setBundleProtectionDomain

        void setBundleProtectionDomain​(BundleImpl bundleImpl,
                                       BundleRevisionImpl revisionImpl)
                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • start

        public void start()
                   throws BundleException
        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). If the init() was not explicitly invoked before calling this method, then it will be implicitly invoked before starting the framework.
        Specified by:
        start in interface Bundle
        Specified by:
        start in interface Framework
        Overrides:
        start in class BundleImpl
        Throws:
        BundleException - if any error occurs.
        See Also:
        Bundle.start(int)
      • start

        public void start​(int options)
                   throws BundleException
        Description copied from interface: Bundle
        Starts this 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:

        • If the 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.
        • Otherwise, the Framework must set this bundle's persistent 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'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:

        1. 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 BundleException is thrown to indicate this bundle was unable to be started.
        2. If the 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.
        3. If this bundle's state is ACTIVE then this method returns immediately.
        4. If this bundle's state is not RESOLVED, an attempt is made to resolve this bundle. If the Framework cannot resolve this bundle, a BundleException is thrown.
        5. If the Bundle.START_ACTIVATION_POLICY option is set and this bundle's declared activation policy is lazy then:
          • If this bundle's state is STARTING then this method returns immediately.
          • This bundle's state is set to STARTING.
          • A bundle event of type BundleEvent.LAZY_ACTIVATION is fired.
          • This method returns immediately and the remaining steps will be followed when this bundle's activation is later triggered.
        6. This bundle's state is set to STARTING.
        7. A bundle event of type BundleEvent.STARTING is fired.
        8. The 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:
          • This bundle's state is set to STOPPING.
          • A bundle event of type BundleEvent.STOPPING is 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.STOPPED is fired.
          • A BundleException is then thrown.
        9. This bundle's state is set to ACTIVE.
        10. A bundle event of type BundleEvent.STARTED is fired.
        Preconditions
        • getState() in { INSTALLED, RESOLVED } or { INSTALLED, RESOLVED, STARTING } if this bundle has a lazy activation policy.
        Postconditions, no exceptions thrown
        • Bundle autostart setting is modified unless the 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.
        Postconditions, when an exception is thrown
        • Depending on when the exception occurred, bundle autostart setting is modified unless the Bundle.START_TRANSIENT option was set.
        • getState() not in { STARTING, ACTIVE }.
        Specified by:
        start in interface Bundle
        Specified by:
        start in interface Framework
        Overrides:
        start in class BundleImpl
        Parameters:
        options - The options for starting this bundle. See Bundle.START_TRANSIENT and Bundle.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, and BundleException.ACTIVATOR_ERROR.
        See Also:
        Framework.start()
      • stop

        public void stop​(int options)
                  throws BundleException
        Description copied from interface: Bundle
        Stops this bundle.

        The following steps are required to stop a bundle:

        1. If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
        2. 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 BundleException is thrown to indicate this bundle was unable to be stopped.
        3. If the 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.
        4. If this bundle's state is not STARTING or ACTIVE then this method returns immediately.
        5. This bundle's state is set to STOPPING.
        6. A bundle event of type BundleEvent.STOPPING is fired.
        7. If this bundle's state was 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.
        8. Any services registered by this bundle must be unregistered.
        9. Any services used by this bundle must be released.
        10. Any listeners registered by this bundle must be removed.
        11. If this bundle's state is UNINSTALLED, because this bundle was uninstalled while the BundleActivator.stop method was running, a BundleException must be thrown.
        12. This bundle's state is set to RESOLVED.
        13. A bundle event of type BundleEvent.STOPPED is fired.
        Preconditions
        • getState() in { ACTIVE }.
        Postconditions, no exceptions thrown
        • Bundle autostart setting is modified unless the Bundle.STOP_TRANSIENT option was set.
        • getState() not in { ACTIVE, STOPPING }.
        • BundleActivator.stop has been called and did not throw an exception.
        Postconditions, when an exception is thrown
        Specified by:
        stop in interface Bundle
        Specified by:
        stop in interface Framework
        Overrides:
        stop in class BundleImpl
        Parameters:
        options - The options for stopping this bundle. See Bundle.STOP_TRANSIENT. The Framework must ignore unrecognized options.
        Throws:
        BundleException - BundleException types thrown by this method include: BundleException.STATECHANGE_ERROR and BundleException.ACTIVATOR_ERROR.
        See Also:
        Framework.stop()
      • 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:
        waitForStop in interface Framework
        Parameters:
        timeout - A timeout value.
        Returns:
        A Framework Event indicating the reason this method returned. The following 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.
        Throws:
        java.lang.InterruptedException - If the thread was interrupted.
      • uninstall

        public void uninstall()
                       throws BundleException
        Description copied from interface: Bundle
        Uninstalls this 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:

        1. If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
        2. If this bundle's state is 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.
        3. This bundle's state is set to UNINSTALLED.
        4. A bundle event of type BundleEvent.UNINSTALLED is fired.
        5. This bundle and any persistent storage area provided for this bundle by the Framework are removed.
        Preconditions
        • getState() not in { UNINSTALLED }.
        Postconditions, no exceptions thrown
        • getState() in { UNINSTALLED }.
        • This bundle has been uninstalled.
        Postconditions, when an exception is thrown
        • getState() not in { UNINSTALLED }.
        • This Bundle has not been uninstalled.
        Specified by:
        uninstall in interface Bundle
        Specified by:
        uninstall in interface Framework
        Overrides:
        uninstall in class BundleImpl
        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()
      • update

        public void update​(java.io.InputStream is)
                    throws BundleException
        Description copied from interface: Bundle
        Updates this bundle from an InputStream.

        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:

        1. If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
        2. If this bundle's state is 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.
        3. 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 BundleException must be thrown after completion of the remaining steps.
        4. This bundle's state is set to INSTALLED.
        5. If the updated version of this bundle was successfully installed, a bundle event of type BundleEvent.UPDATED is fired.
        6. If this bundle's state was originally 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.
        Preconditions
        • getState() not in { UNINSTALLED }.
        Postconditions, no exceptions thrown
        • getState() in { INSTALLED, RESOLVED, ACTIVE }.
        • This bundle has been updated.
        Postconditions, when an exception is thrown
        • getState() in { INSTALLED, RESOLVED, ACTIVE }.
        • Original bundle is still used; no update occurred.
        Specified by:
        update in interface Bundle
        Specified by:
        update in interface Framework
        Overrides:
        update in class BundleImpl
        Parameters:
        is - 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.
        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, and BundleException.ACTIVATOR_ERROR.
        See Also:
        Bundle.stop(), Bundle.start()
      • 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().
      • 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
      • 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.
      • 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.
      • 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 for ServiceEvents.
        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 listener
        l - The service listener to remove from the listener list.
      • 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 or ServiceFactory.
        dict - A dictionary of properties that further describe the service or null.
        Returns:
        A ServiceRegistration object or null.
      • getServiceReferences

        ServiceReference[] getServiceReferences​(BundleImpl bundle,
                                                java.lang.String className,
                                                java.lang.String expr,
                                                boolean checkAssignable)
                                         throws InvalidSyntaxException
        Retrieves an array of 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 the
        Parameters:
        bundle - Calling Bundle
        className - Service Classname or null for all
        expr - Filter Criteria or null
        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 of 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.
        Parameters:
        bundle - Calling Bundle
        className - Service Classname or null for all
        expr - Filter Criteria or null
        checkAssignable - true to check for isAssignable, false to return all versions
        Returns:
        Array of ServiceReference objects that meet the criteria
        Throws:
        InvalidSyntaxException
      • getDataFile

        java.io.File getDataFile​(BundleImpl bundle,
                                 java.lang.String s)
      • 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
      • getRequiringBundles

        java.util.Set<Bundle> getRequiringBundles​(BundleImpl bundle)
      • resolveBundles

        boolean resolveBundles​(java.util.Collection<Bundle> targets)
      • 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()
      • 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.
      • fireBundleEvent

        void fireBundleEvent​(int type,
                             Bundle bundle,
                             Bundle origin)
      • 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)
      • 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)