Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.osgi.framework.launch;
 
 
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.

Version:
$Revision: 6542 $
ThreadSafe:
 
 public interface Framework extends Bundle {

Initialize this Framework. After calling this method, this Framework must:
  • Be in the org.osgi.framework.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, PackageAdmin, ConditionalPermissionAdmin, StartLevel.

This Framework will not actually be started until start is called.

This method does nothing if called when this Framework is in the org.osgi.framework.Bundle.STARTING, org.osgi.framework.Bundle.ACTIVE or org.osgi.framework.Bundle.STOPPING states.

Throws:
org.osgi.framework.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 appropriate AdminPermission[this,EXECUTE] or if there is a security manager already installed and the org.osgi.framework.Constants.FRAMEWORK_SECURITY configuration property is set.
 
 	void init() throws BundleException;

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 org.osgi.framework.Bundle.STARTING, org.osgi.framework.Bundle.ACTIVE, or org.osgi.framework.Bundle.STOPPING states. 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 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 affect.
  • 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 this Framework.

The following steps are taken to start this Framework:

  1. If this Framework is not in the org.osgi.framework.Bundle.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. If this Framework implements the optional Start Level Service Specification, then 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 Service 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 org.osgi.framework.BundleException and then published as a framework event of type org.osgi.framework.FrameworkEvent.ERROR
  3. This Framework's state is set to org.osgi.framework.Bundle.ACTIVE.
  4. A framework event of type org.osgi.framework.FrameworkEvent.STARTED is fired

Throws:
org.osgi.framework.BundleException If this Framework could not be started.
java.lang.SecurityException If the caller does not have the appropriate AdminPermission[this,EXECUTE], and the Java Runtime Environment supports permissions.
See also:
"Start Level Service Specification"
	void start() throws BundleException;

Start this Framework.

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

Parameters:
options Ignored. There are no start options for the Framework.
Throws:
org.osgi.framework.BundleException If this Framework could not be started.
java.lang.SecurityException If the caller does not have the appropriate AdminPermission[this,EXECUTE], and the Java Runtime Environment supports permissions.
See also:
start()
	void start(int optionsthrows BundleException;

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 org.osgi.framework.Bundle.STOPPING.
  2. All installed bundles must be stopped without changing each bundle's persistent autostart setting. If this Framework implements the optional Start Level Service Specification, then the start level of this Framework is moved to start level zero (0), as described in the Start Level Service Specification. Any exceptions that occur during bundle stopping must be wrapped in a org.osgi.framework.BundleException and then published as a framework event of type org.osgi.framework.FrameworkEvent.ERROR
  3. Unregister all services registered by this Framework.
  4. Event handling is disabled.
  5. This Framework's state is set to org.osgi.framework.Bundle.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.

Throws:
org.osgi.framework.BundleException If stopping this Framework could not be initiated.
java.lang.SecurityException If the caller does not have the appropriate AdminPermission[this,EXECUTE], and the Java Runtime Environment supports permissions.
See also:
"Start Level Service Specification"
	void stop() throws BundleException;

Stop this Framework.

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

Parameters:
options Ignored. There are no stop options for the Framework.
Throws:
org.osgi.framework.BundleException If stopping this Framework could not be initiated.
java.lang.SecurityException If the caller does not have the appropriate AdminPermission[this,EXECUTE], and the Java Runtime Environment supports permissions.
See also:
stop()
	void stop(int optionsthrows BundleException;

The Framework cannot be uninstalled.

This method always throws a BundleException.

Throws:
org.osgi.framework.BundleException This Framework cannot be uninstalled.
java.lang.SecurityException If the caller does not have the appropriate AdminPermission[this,LIFECYCLE], and the Java Runtime Environment supports permissions.
	void uninstall() throws BundleException;

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.

Throws:
org.osgi.framework.BundleException If stopping and restarting this Framework could not be initiated.
java.lang.SecurityException If the caller does not have the appropriate AdminPermission[this,LIFECYCLE], and the Java Runtime Environment supports permissions.
	void update() throws BundleException;

Stop and restart this Framework.

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

Parameters:
in Any provided InputStream is immediately closed before returning from this method and otherwise ignored.
Throws:
org.osgi.framework.BundleException If stopping and restarting this Framework could not be initiated.
java.lang.SecurityException If the caller does not have the appropriate AdminPermission[this,LIFECYCLE], and the Java Runtime Environment supports permissions.
	void update(InputStream inthrows BundleException;

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

	long getBundleId();

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

Returns:
The string "System Bundle".
Throws:
java.lang.SecurityException If the caller does not have the appropriate AdminPermission[this,METADATA], and the Java Runtime Environment supports permissions.
See also:
org.osgi.framework.Bundle.getLocation()
org.osgi.framework.Constants.SYSTEM_BUNDLE_LOCATION
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.

New to GrepCode? Check out our FAQ X