Interface Framework
-
@ProviderType public interface Framework extends Bundle
A Framework instance. A Framework is also known as a System Bundle.Framework instances are created using a
FrameworkFactory. The methods of this interface can be used to manage and control the created framework instance.
-
-
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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <A> Aadapt(java.lang.Class<A> type)Adapt this Framework to the specified type.java.util.Enumeration<java.net.URL>findEntries(java.lang.String path, java.lang.String filePattern, boolean recurse)Returnsnullas a framework implementation does not have a proper bundle from which to return entries.longgetBundleId()Returns the Framework unique identifier.java.net.URLgetEntry(java.lang.String path)Returnsnullas a framework implementation does not have a proper bundle from which to return an entry.java.util.Enumeration<java.lang.String>getEntryPaths(java.lang.String path)Returnsnullas a framework implementation does not have a proper bundle from which to return entry paths.longgetLastModified()Returns the time when the set of bundles in this framework was last modified.java.lang.StringgetLocation()Returns the Framework location identifier.java.lang.StringgetSymbolicName()Returns the symbolic name of this Framework.voidinit()Initialize this Framework.voidinit(FrameworkListener... listeners)Initialize this Framework.voidstart()Start this Framework.voidstart(int options)Start this Framework.voidstop()Stop this Framework.voidstop(int options)Stop this Framework.voiduninstall()The Framework cannot be uninstalled.voidupdate()Stop and restart this Framework.voidupdate(java.io.InputStream in)Stop and restart this Framework.FrameworkEventwaitForStop(long timeout)Wait until this Framework has completely stopped.-
Methods inherited from interface org.osgi.framework.Bundle
getBundleContext, getDataFile, getHeaders, getHeaders, getRegisteredServices, getResource, getResources, getServicesInUse, getSignerCertificates, getState, getVersion, hasPermission, loadClass
-
-
-
-
Method Detail
-
init
void init() throws BundleException
Initialize this Framework.This method performs the same function as calling
init(FrameworkListener...)with no framework listeners.- Throws:
BundleException- If this Framework could not be initialized.java.lang.SecurityException- If the Java Runtime Environment supports permissions and the caller does not have the appropriateAdminPermission[this,EXECUTE]or if there is a security manager already installed and theConstants.FRAMEWORK_SECURITYconfiguration property is set.- See Also:
init(FrameworkListener...)
-
init
void init(FrameworkListener... listeners) throws BundleException
Initialize 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 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.
- 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.java.lang.SecurityException- If the Java Runtime Environment supports permissions and the caller does not have the appropriateAdminPermission[this,EXECUTE]or if there is a security manager already installed and theConstants.FRAMEWORK_SECURITYconfiguration property is set.- Since:
- 1.2
- Have generated a new
-
waitForStop
FrameworkEvent waitForStop(long timeout) throws java.lang.InterruptedException
Wait until this Framework has completely stopped. Thestopandupdatemethods on a Framework performs an asynchronous stop of the Framework. This method can be used to wait until the asynchronous stop of this Framework has completed. This method will only wait if called when this Framework is in theBundle.STARTING,Bundle.ACTIVE, orBundle.STOPPINGstates. Otherwise it will return immediately.A Framework Event is returned to indicate why this Framework has stopped.
- Parameters:
timeout- Maximum number of milliseconds to wait until this Framework has completely stopped. A value of zero will wait indefinitely.- 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_SYSTEM_REFRESHED- The Framework has been stopped because of a refresh operation on the system bundle. A new class loader must be used to restart the Framework.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 another thread interrupted the current thread before or while the current thread was waiting for this Framework to completely stop. The interrupted status of the current thread is cleared when this exception is thrown.java.lang.IllegalArgumentException- If the value of timeout is negative.
-
start
void start() throws BundleExceptionStart this Framework.The following steps are taken to start this Framework:
- If this Framework is not in the
Bundle.STARTINGstate,initializethis Framework. - All installed bundles must be started in accordance with each
bundle's persistent autostart setting. This means some bundles
will not be started, some will be started with eager activation
and some will be started with their declared activation policy.
The start level of this Framework is moved to the start level specified
by the
beginning start levelframework property, as described in the Start Level Specification. If this framework property is not specified, then the start level of this Framework is moved to start level one (1). Any exceptions that occur during bundle starting must be wrapped in aBundleExceptionand then published as a framework event of typeFrameworkEvent.ERROR - This Framework's state is set to
Bundle.ACTIVE. - A framework event of type
FrameworkEvent.STARTEDis fired
- Specified by:
startin interfaceBundle- Throws:
BundleException- If this Framework could not be started.java.lang.SecurityException- If the caller does not have the appropriateAdminPermission[this,EXECUTE], and the Java Runtime Environment supports permissions.- See Also:
- "Start Level Specification"
- If this Framework is not in the
-
start
void start(int options) throws BundleExceptionStart this Framework.Calling this method is the same as calling
start(). There are no start options for the Framework.- Specified by:
startin interfaceBundle- Parameters:
options- Ignored. There are no start options for the Framework.- Throws:
BundleException- If this Framework could not be started.java.lang.SecurityException- If the caller does not have the appropriateAdminPermission[this,EXECUTE], and the Java Runtime Environment supports permissions.- See Also:
start()
-
stop
void stop() throws BundleException
Stop this Framework.The method returns immediately to the caller after initiating the following steps to be taken on another thread.
- This Framework's state is set to
Bundle.STOPPING. - All installed bundles must be stopped without changing each bundle's
persistent autostart setting. The start level of this Framework is
moved to start level zero (0), as described in the Start Level
Specification. Any exceptions that occur during bundle stopping must
be wrapped in a
BundleExceptionand then published as a framework event of typeFrameworkEvent.ERROR - Unregister all services registered by this Framework.
- Event handling is disabled.
- This Framework's state is set to
Bundle.RESOLVED. - All resources held by this Framework are released. This includes threads, bundle class loaders, open files, etc.
- Notify all threads that are waiting at
waitForStopthat the stop operation has completed.
After being stopped, this Framework may be discarded, initialized or started.
- Specified by:
stopin interfaceBundle- Throws:
BundleException- If stopping this Framework could not be initiated.java.lang.SecurityException- If the caller does not have the appropriateAdminPermission[this,EXECUTE], and the Java Runtime Environment supports permissions.- See Also:
- "Start Level Specification"
- This Framework's state is set to
-
stop
void stop(int options) throws BundleException
Stop this Framework.Calling this method is the same as calling
stop(). There are no stop options for the Framework.- Specified by:
stopin interfaceBundle- Parameters:
options- Ignored. There are no stop options for the Framework.- Throws:
BundleException- If stopping this Framework could not be initiated.java.lang.SecurityException- If the caller does not have the appropriateAdminPermission[this,EXECUTE], and the Java Runtime Environment supports permissions.- See Also:
stop()
-
uninstall
void uninstall() throws BundleExceptionThe Framework cannot be uninstalled.This method always throws a BundleException.
- Specified by:
uninstallin interfaceBundle- Throws:
BundleException- This Framework cannot be uninstalled.java.lang.SecurityException- If the caller does not have the appropriateAdminPermission[this,LIFECYCLE], and the Java Runtime Environment supports permissions.- See Also:
Bundle.stop()
-
update
void update() throws BundleExceptionStop and restart this Framework.The method returns immediately to the caller after initiating the following steps to be taken on another thread.
- Specified by:
updatein interfaceBundle- Throws:
BundleException- If stopping and restarting this Framework could not be initiated.java.lang.SecurityException- If the caller does not have the appropriateAdminPermission[this,LIFECYCLE], and the Java Runtime Environment supports permissions.- See Also:
Bundle.update(InputStream)
-
update
void update(java.io.InputStream in) throws BundleExceptionStop and restart this Framework.Calling this method is the same as calling
update()except that any provided InputStream is immediately closed.- Specified by:
updatein interfaceBundle- Parameters:
in- Any provided InputStream is immediately closed before returning from this method and otherwise ignored.- Throws:
BundleException- If stopping and restarting this Framework could not be initiated.java.lang.SecurityException- If the caller does not have the appropriateAdminPermission[this,LIFECYCLE], and the Java Runtime Environment supports permissions.- See Also:
Bundle.stop(),Bundle.start()
-
getBundleId
long getBundleId()
Returns the Framework unique identifier. This Framework is assigned the unique identifier zero (0) since this Framework is also a System Bundle.- Specified by:
getBundleIdin interfaceBundle- Returns:
- 0.
- See Also:
Bundle.getBundleId()
-
getLocation
java.lang.String getLocation()
Returns the Framework location identifier. This Framework is assigned the unique location "System Bundle" since this Framework is also a System Bundle.- Specified by:
getLocationin interfaceBundle- Returns:
- The string "
System Bundle". - Throws:
java.lang.SecurityException- If the caller does not have the appropriateAdminPermission[this,METADATA], and the Java Runtime Environment supports permissions.- See Also:
Bundle.getLocation(),Constants.SYSTEM_BUNDLE_LOCATION
-
getSymbolicName
java.lang.String getSymbolicName()
Returns the symbolic name of this Framework. The symbolic name is unique for the implementation of the framework. However, the symbolic name "system.bundle" must be recognized as an alias to the implementation-defined symbolic name since this Framework is also a System Bundle.- Specified by:
getSymbolicNamein interfaceBundle- Returns:
- The symbolic name of this Framework.
- See Also:
Bundle.getSymbolicName(),Constants.SYSTEM_BUNDLE_SYMBOLICNAME
-
getEntryPaths
java.util.Enumeration<java.lang.String> getEntryPaths(java.lang.String path)
Returnsnullas a framework implementation does not have a proper bundle from which to return entry paths.- Specified by:
getEntryPathsin interfaceBundle- Parameters:
path- Ignored.- Returns:
nullas a framework implementation does not have a proper bundle from which to return entry paths.
-
getEntry
java.net.URL getEntry(java.lang.String path)
Returnsnullas a framework implementation does not have a proper bundle from which to return an entry.
-
getLastModified
long getLastModified()
Returns the time when the set of bundles in this framework was last modified. The set of bundles is considered to be modified when a bundle 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- Returns:
- The time when the set of bundles in this framework was last modified.
-
findEntries
java.util.Enumeration<java.net.URL> findEntries(java.lang.String path, java.lang.String filePattern, boolean recurse)Returnsnullas a framework implementation does not have a proper bundle from which to return entries.- Specified by:
findEntriesin interfaceBundle- Parameters:
path- Ignored.filePattern- Ignored.recurse- Ignored.- Returns:
nullas a framework implementation does not have a proper bundle from which to return entries.
-
adapt
<A> A adapt(java.lang.Class<A> type)
Adapt this Framework to the specified type.Adapting this Framework to the specified type may require certain checks, including security checks, to succeed. If a check does not succeed, then this Framework cannot be adapted and
nullis returned. If this Framework is notinitialized, thennullis returned if the specified type is one of the OSGi defined types to which a system bundle can be adapted.- Specified by:
adaptin interfaceBundle- Type Parameters:
A- The type to which this Framework is to be adapted.- Parameters:
type- Class object for the type to which this Framework is to be adapted.- Returns:
- The object, of the specified type, to which this Framework has
been adapted or
nullif this Framework cannot be adapted
-
-