Top Description Fields Methods
org.osgi.framework.launch

public Interface Framework

extends Bundle
Annotations
@ProviderType
Imports
java.io.InputStream, java.net.URL, java.util.Enumeration, org.osgi.annotation.versioning.ProviderType, org.osgi.framework.Bundle, .BundleException, .Constants, .FrameworkEvent, .FrameworkListener

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.

Author
$Id: bf960bdc39d19a780694a8cab5a555b3e0dc0fde $

Field Summary

Inherited from org.osgi.framework.Bundle:
ACTIVEINSTALLEDRESOLVEDSIGNERS_ALLSIGNERS_TRUSTEDSTART_ACTIVATION_POLICYSTART_TRANSIENTSTARTINGSTOP_TRANSIENTSTOPPINGUNINSTALLED

Method Summary

Modifier and TypeMethod and Description
public <
The type to which this Framework is to be adapted.
A
>
A

Returns:

The object, of the specified type, to which this Framework has been adapted or null if this Framework cannot be adapted
adapt
(Class<A>
Class object for the type to which this Framework is to be adapted.
type
)

Redeclares org.osgi.framework.Bundle.adapt.

Adapt this Framework to the specified type.

public Enumeration<URL>

Returns:

null as a framework implementation does not have a proper bundle from which to return entries.
findEntries
(String
Ignored.
path
,
String
Ignored.
filePattern
,
boolean
Ignored.
recurse
)

Redeclares org.osgi.framework.Bundle.findEntries.

Returns null as a framework implementation does not have a proper bundle from which to return entries.

public long

Returns:

0.
getBundleId
()

Redeclares org.osgi.framework.Bundle.getBundleId.

Returns the Framework unique identifier.

public URL

Returns:

null as a framework implementation does not have a proper bundle from which to return an entry.
getEntry
(String
Ignored.
path
)

Redeclares org.osgi.framework.Bundle.getEntry.

Returns null as a framework implementation does not have a proper bundle from which to return an entry.

public Enumeration<String>

Returns:

null as a framework implementation does not have a proper bundle from which to return entry paths.
getEntryPaths
(String
Ignored.
path
)

Redeclares org.osgi.framework.Bundle.getEntryPaths.

Returns null as a framework implementation does not have a proper bundle from which to return entry paths.

public long

Returns:

The time when the set of bundles in this framework was last modified.
getLastModified
()

Redeclares org.osgi.framework.Bundle.getLastModified.

Returns the time when the set of bundles in this framework was last modified.

public String

Returns:

The string "System Bundle".
getLocation
()

Redeclares org.osgi.framework.Bundle.getLocation.

Returns the Framework location identifier.

public String

Returns:

The symbolic name of this Framework.
getSymbolicName
()

Redeclares org.osgi.framework.Bundle.getSymbolicName.

Returns the symbolic name of this Framework.

public void
init()

Initialize this Framework.

public void
init(FrameworkListener...
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.
listeners
)

Initialize this Framework.

public void
start()

Redeclares org.osgi.framework.Bundle.start.

Start this Framework.

public void
start(int
Ignored. There are no start options for the Framework.
options
)

Redeclares org.osgi.framework.Bundle.start.

Start this Framework.

public void
stop()

Redeclares org.osgi.framework.Bundle.stop.

Stop this Framework.

public void
stop(int
Ignored. There are no stop options for the Framework.
options
)

Redeclares org.osgi.framework.Bundle.stop.

Stop this Framework.

public void
uninstall()

Redeclares org.osgi.framework.Bundle.uninstall.

The Framework cannot be uninstalled.

public void
update()

Redeclares org.osgi.framework.Bundle.update.

Stop and restart this Framework.

public void
update(InputStream
Any provided InputStream is immediately closed before returning from this method and otherwise ignored.
in
)

Redeclares org.osgi.framework.Bundle.update.

Stop and restart this Framework.

public FrameworkEvent

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_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.
waitForStop
(long
Maximum number of milliseconds to wait until this Framework has completely stopped. A value of zero will wait indefinitely.
timeout
)

Wait until this Framework has completely stopped.

Inherited from org.osgi.framework.Bundle:
getBundleContextgetDataFilegetHeadersgetHeadersgetRegisteredServicesgetResourcegetResourcesgetServicesInUsegetSignerCertificatesgetStategetVersionhasPermissionloadClass

Method Detail

adaptback to summary
public <A> A adapt(Class<A> type)

Redeclares org.osgi.framework.Bundle.adapt.

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 null is returned. If this Framework is not initialized, then null is returned if the specified type is one of the OSGi defined types to which a system bundle can be adapted.

Parameters
<A>
The type to which this Framework is to be adapted.
type:Class<A>

Class object for the type to which this Framework is to be adapted.

Returns:A

The object, of the specified type, to which this Framework has been adapted or null if this Framework cannot be adapted

Annotations
@Override
findEntriesback to summary
public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse)

Redeclares org.osgi.framework.Bundle.findEntries.

Returns null as a framework implementation does not have a proper bundle from which to return entries.

Parameters
path:String

Ignored.

filePattern:String

Ignored.

recurse:boolean

Ignored.

Returns:Enumeration<URL>

null as a framework implementation does not have a proper bundle from which to return entries.

Annotations
@Override
getBundleIdback to summary
public long getBundleId()

Redeclares org.osgi.framework.Bundle.getBundleId.

Returns the Framework unique identifier. This Framework is assigned the unique identifier zero (0) since this Framework is also a System Bundle.

Returns:long

0.

Annotations
@Override
See Also
Bundle#getBundleId()
getEntryback to summary
public URL getEntry(String path)

Redeclares org.osgi.framework.Bundle.getEntry.

Returns null as a framework implementation does not have a proper bundle from which to return an entry.

Parameters
path:String

Ignored.

Returns:URL

null as a framework implementation does not have a proper bundle from which to return an entry.

Annotations
@Override
getEntryPathsback to summary
public Enumeration<String> getEntryPaths(String path)

Redeclares org.osgi.framework.Bundle.getEntryPaths.

Returns null as a framework implementation does not have a proper bundle from which to return entry paths.

Parameters
path:String

Ignored.

Returns:Enumeration<String>

null as a framework implementation does not have a proper bundle from which to return entry paths.

Annotations
@Override
getLastModifiedback to summary
public long getLastModified()

Redeclares org.osgi.framework.Bundle.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.

Returns:long

The time when the set of bundles in this framework was last modified.

Annotations
@Override
getLocationback to summary
public String getLocation()

Redeclares org.osgi.framework.Bundle.getLocation.

Returns the Framework location identifier. This Framework is assigned the unique location "System Bundle" since this Framework is also a System Bundle.

Returns:String

The string "System Bundle".

Annotations
@Override
Exceptions
SecurityException:
If the caller does not have the appropriate AdminPermission[this,METADATA], and the Java Runtime Environment supports permissions.
See Also
Bundle#getLocation(), Constants#SYSTEM_BUNDLE_LOCATION
getSymbolicNameback to summary
public String getSymbolicName()

Redeclares org.osgi.framework.Bundle.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.

Returns:String

The symbolic name of this Framework.

Annotations
@Override
See Also
Bundle#getSymbolicName(), Constants#SYSTEM_BUNDLE_SYMBOLICNAME
initback to summary
public void init() throws BundleException

Initialize this Framework.

This method performs the same function as calling init(FrameworkListener...) with no framework listeners.

Exceptions
BundleException:
If this Framework could not be initialized.
SecurityException:
If the Java Runtime Environment supports permissions and the caller does not have the appropriate AdminPermission[this,EXECUTE] or if there is a security manager already installed and the Constants#FRAMEWORK_SECURITY configuration property is set.
See Also
init(FrameworkListener...)
initback to summary
public 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 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 STARTING, ACTIVE or STOPPING states.

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:FrameworkListener[]

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.

Exceptions
BundleException:
If this Framework could not be initialized.
SecurityException:
If the Java Runtime Environment supports permissions and the caller does not have the appropriate AdminPermission[this,EXECUTE] or if there is a security manager already installed and the Constants#FRAMEWORK_SECURITY configuration property is set.
Since
1.2
startback to summary
public void start() throws BundleException

Redeclares org.osgi.framework.Bundle.start.

Start this Framework.

The following steps are taken to start this Framework:

  1. If this Framework is not in the STARTING state, initialize this Framework.
  2. 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 level framework 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 a BundleException and then published as a framework event of type FrameworkEvent#ERROR
  3. This Framework's state is set to ACTIVE.
  4. A framework event of type FrameworkEvent#STARTED is fired
Annotations
@Override
Exceptions
BundleException:
If this Framework could not be started.
SecurityException:
If the caller does not have the appropriate AdminPermission[this,EXECUTE], and the Java Runtime Environment supports permissions.
See Also
Start Level Specification
startback to summary
public void start(int options) throws BundleException

Redeclares org.osgi.framework.Bundle.start.

Start this Framework.

Calling this method is the same as calling start(). There are no start options for the Framework.

Parameters
options:int

Ignored. There are no start options for the Framework.

Annotations
@Override
Exceptions
BundleException:
If this Framework could not be started.
SecurityException:
If the caller does not have the appropriate AdminPermission[this,EXECUTE], and the Java Runtime Environment supports permissions.
See Also
start()
stopback to summary
public void stop() throws BundleException

Redeclares org.osgi.framework.Bundle.stop.

Stop this Framework.

The method returns immediately to the caller after initiating the following steps to be taken on another thread.

  1. This Framework's state is set to STOPPING.
  2. 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 BundleException and then published as a framework event of type FrameworkEvent#ERROR
  3. Unregister all services registered by this Framework.
  4. Event handling is disabled.
  5. This Framework's state is set to RESOLVED.
  6. All resources held by this Framework are released. This includes threads, bundle class loaders, open files, etc.
  7. Notify all threads that are waiting at waitForStop that the stop operation has completed.

After being stopped, this Framework may be discarded, initialized or started.

Annotations
@Override
Exceptions
BundleException:
If stopping this Framework could not be initiated.
SecurityException:
If the caller does not have the appropriate AdminPermission[this,EXECUTE], and the Java Runtime Environment supports permissions.
See Also
Start Level Specification
stopback to summary
public void stop(int options) throws BundleException

Redeclares org.osgi.framework.Bundle.stop.

Stop this Framework.

Calling this method is the same as calling stop(). There are no stop options for the Framework.

Parameters
options:int

Ignored. There are no stop options for the Framework.

Annotations
@Override
Exceptions
BundleException:
If stopping this Framework could not be initiated.
SecurityException:
If the caller does not have the appropriate AdminPermission[this,EXECUTE], and the Java Runtime Environment supports permissions.
See Also
stop()
uninstallback to summary
public void uninstall() throws BundleException

Redeclares org.osgi.framework.Bundle.uninstall.

The Framework cannot be uninstalled.

This method always throws a BundleException.

Annotations
@Override
Exceptions
BundleException:
This Framework cannot be uninstalled.
SecurityException:
If the caller does not have the appropriate AdminPermission[this,LIFECYCLE], and the Java Runtime Environment supports permissions.
updateback to summary
public void update() throws BundleException

Redeclares org.osgi.framework.Bundle.update.

Stop and restart this Framework.

The method returns immediately to the caller after initiating the following steps to be taken on another thread.

  1. Perform the steps in the stop() method to stop this Framework.
  2. Perform the steps in the start() method to start this Framework.
Annotations
@Override
Exceptions
BundleException:
If stopping and restarting this Framework could not be initiated.
SecurityException:
If the caller does not have the appropriate AdminPermission[this,LIFECYCLE], and the Java Runtime Environment supports permissions.
updateback to summary
public void update(InputStream in) throws BundleException

Redeclares org.osgi.framework.Bundle.update.

Stop and restart this Framework.

Calling this method is the same as calling update() except that any provided InputStream is immediately closed.

Parameters
in:InputStream

Any provided InputStream is immediately closed before returning from this method and otherwise ignored.

Annotations
@Override
Exceptions
BundleException:
If stopping and restarting this Framework could not be initiated.
SecurityException:
If the caller does not have the appropriate AdminPermission[this,LIFECYCLE], and the Java Runtime Environment supports permissions.
waitForStopback to summary
public FrameworkEvent waitForStop(long timeout) throws InterruptedException

Wait until this Framework has completely stopped. The stop and update methods 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 the STARTING, ACTIVE, or STOPPING states. Otherwise it will return immediately.

A Framework Event is returned to indicate why this Framework has stopped.

Parameters
timeout:long

Maximum number of milliseconds to wait until this Framework has completely stopped. A value of zero will wait indefinitely.

Returns:FrameworkEvent

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_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.
Exceptions
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.
IllegalArgumentException:
If the value of timeout is negative.