org.apache.felix.framework
Class Felix

java.lang.Object
  extended by org.apache.felix.framework.Felix
All Implemented Interfaces:
org.osgi.framework.Bundle, org.osgi.framework.launch.Framework

public class Felix
extends java.lang.Object
implements org.osgi.framework.launch.Framework


Nested Class Summary
 class Felix.FelixResolver
           
 
Field Summary
 
Fields inherited from interface org.osgi.framework.Bundle
ACTIVE, INSTALLED, RESOLVED, SIGNERS_ALL, SIGNERS_TRUSTED, START_ACTIVATION_POLICY, START_TRANSIENT, STARTING, STOP_TRANSIENT, STOPPING, UNINSTALLED
 
Constructor Summary
Felix(java.util.Map configMap)
           This constructor creates a framework instance with a specified Map of configuration properties.
 
Method Summary
 java.util.Enumeration findEntries(java.lang.String path, java.lang.String filePattern, boolean recurse)
           
 org.osgi.framework.BundleContext getBundleContext()
           
 long getBundleId()
           
 java.net.URL getEntry(java.lang.String name)
           
 java.util.Enumeration getEntryPaths(java.lang.String path)
           
 java.util.Dictionary getHeaders()
           
 java.util.Dictionary getHeaders(java.lang.String locale)
           
 long getLastModified()
           
 java.lang.String getLocation()
           
 int getPersistentState()
           
 org.osgi.framework.ServiceReference[] getRegisteredServices()
          Returns an array of service references corresponding to the bundle's registered services.
 java.net.URL getResource(java.lang.String name)
          Returns a URL to a named resource in the bundle.
 java.util.Enumeration getResources(java.lang.String name)
           
 org.osgi.framework.ServiceReference[] getServicesInUse()
           
 java.util.Map getSignerCertificates(int signersType)
           
 int getState()
           
 java.lang.String getSymbolicName()
           
 org.osgi.framework.Version getVersion()
           
 boolean hasPermission(java.lang.Object obj)
           
 void init()
          This method initializes the framework, which is comprised of resolving the system bundle, reloading any cached bundles, and activating the system bundle.
 java.lang.Class loadClass(java.lang.String name)
           
 void setPersistentStateActive()
           
 void setPersistentStateInactive()
           
 void setPersistentStateUninstalled()
           
 void start()
          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).
 void start(int options)
           
 void stop()
          This method asynchronously shuts down the framework, it must be called at the end of a session in order to shutdown all active bundles.
 void stop(int options)
           
 java.lang.String toString()
           
 void uninstall()
           
 void update()
           
 void update(java.io.InputStream is)
           
 org.osgi.framework.FrameworkEvent waitForStop(long timeout)
          This method will cause the calling thread to block until the framework shuts down.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.osgi.framework.launch.Framework
getLocation, getSymbolicName
 
Methods inherited from interface org.osgi.framework.Bundle
findEntries, getBundleContext, getEntry, getEntryPaths, getHeaders, getHeaders, getRegisteredServices, getResource, getResources, getServicesInUse, getSignerCertificates, getState, getVersion, loadClass
 

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):

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

getBundleId

public long getBundleId()
Specified by:
getBundleId in interface org.osgi.framework.Bundle
Specified by:
getBundleId in interface org.osgi.framework.launch.Framework

getLastModified

public long getLastModified()
Specified by:
getLastModified in interface org.osgi.framework.Bundle

getPersistentState

public int getPersistentState()

setPersistentStateInactive

public void setPersistentStateInactive()

setPersistentStateActive

public void setPersistentStateActive()

setPersistentStateUninstalled

public void setPersistentStateUninstalled()

hasPermission

public boolean hasPermission(java.lang.Object obj)
Specified by:
hasPermission in interface org.osgi.framework.Bundle

init

public void init()
          throws org.osgi.framework.BundleException
This method initializes the framework, which is comprised of resolving the system bundle, reloading any cached bundles, and activating the system bundle. The framework is left in the Bundle.STARTING state and reloaded bundles are in the Bundle.INSTALLED state. After successfully invoking this method, getBundleContext() will return a valid BundleContext for the system bundle. To finish starting the framework, invoke the start() method.

Specified by:
init in interface org.osgi.framework.launch.Framework
Throws:
org.osgi.framework.BundleException - if any error occurs.

start

public void start()
           throws org.osgi.framework.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 org.osgi.framework.Bundle
Specified by:
start in interface org.osgi.framework.launch.Framework
Throws:
org.osgi.framework.BundleException - if any error occurs.

start

public void start(int options)
           throws org.osgi.framework.BundleException
Specified by:
start in interface org.osgi.framework.Bundle
Specified by:
start in interface org.osgi.framework.launch.Framework
Throws:
org.osgi.framework.BundleException

stop

public void stop()
          throws org.osgi.framework.BundleException
This method asynchronously shuts down the framework, it must be called at the end of a session in order to shutdown all active bundles.

Specified by:
stop in interface org.osgi.framework.Bundle
Specified by:
stop in interface org.osgi.framework.launch.Framework
Throws:
org.osgi.framework.BundleException

stop

public void stop(int options)
          throws org.osgi.framework.BundleException
Specified by:
stop in interface org.osgi.framework.Bundle
Specified by:
stop in interface org.osgi.framework.launch.Framework
Throws:
org.osgi.framework.BundleException

waitForStop

public org.osgi.framework.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 org.osgi.framework.launch.Framework
Parameters:
timeout - A timeout value.
Throws:
java.lang.InterruptedException - If the thread was interrupted.

uninstall

public void uninstall()
               throws org.osgi.framework.BundleException
Specified by:
uninstall in interface org.osgi.framework.Bundle
Specified by:
uninstall in interface org.osgi.framework.launch.Framework
Throws:
org.osgi.framework.BundleException

update

public void update()
            throws org.osgi.framework.BundleException
Specified by:
update in interface org.osgi.framework.Bundle
Specified by:
update in interface org.osgi.framework.launch.Framework
Throws:
org.osgi.framework.BundleException

update

public void update(java.io.InputStream is)
            throws org.osgi.framework.BundleException
Specified by:
update in interface org.osgi.framework.Bundle
Specified by:
update in interface org.osgi.framework.launch.Framework
Throws:
org.osgi.framework.BundleException

toString

public java.lang.String toString()

getBundleContext

public org.osgi.framework.BundleContext getBundleContext()
Specified by:
getBundleContext in interface org.osgi.framework.Bundle

getEntry

public java.net.URL getEntry(java.lang.String name)
Specified by:
getEntry in interface org.osgi.framework.Bundle

getEntryPaths

public java.util.Enumeration getEntryPaths(java.lang.String path)
Specified by:
getEntryPaths in interface org.osgi.framework.Bundle

findEntries

public java.util.Enumeration findEntries(java.lang.String path,
                                         java.lang.String filePattern,
                                         boolean recurse)
Specified by:
findEntries in interface org.osgi.framework.Bundle

getHeaders

public java.util.Dictionary getHeaders()
Specified by:
getHeaders in interface org.osgi.framework.Bundle

getHeaders

public java.util.Dictionary getHeaders(java.lang.String locale)
Specified by:
getHeaders in interface org.osgi.framework.Bundle

getLocation

public java.lang.String getLocation()
Specified by:
getLocation in interface org.osgi.framework.Bundle

getResource

public java.net.URL getResource(java.lang.String name)
Returns a URL to a named resource in the bundle.

Specified by:
getResource in interface org.osgi.framework.Bundle
Returns:
a URL to named resource, or null if not found.

getResources

public java.util.Enumeration getResources(java.lang.String name)
                                   throws java.io.IOException
Specified by:
getResources in interface org.osgi.framework.Bundle
Throws:
java.io.IOException

getRegisteredServices

public org.osgi.framework.ServiceReference[] getRegisteredServices()
Returns an array of service references corresponding to the bundle's registered services.

Specified by:
getRegisteredServices in interface org.osgi.framework.Bundle
Returns:
an array of service references or null.

getServicesInUse

public org.osgi.framework.ServiceReference[] getServicesInUse()
Specified by:
getServicesInUse in interface org.osgi.framework.Bundle

getState

public int getState()
Specified by:
getState in interface org.osgi.framework.Bundle

getSymbolicName

public java.lang.String getSymbolicName()
Specified by:
getSymbolicName in interface org.osgi.framework.Bundle

getVersion

public org.osgi.framework.Version getVersion()
Specified by:
getVersion in interface org.osgi.framework.Bundle

getSignerCertificates

public java.util.Map getSignerCertificates(int signersType)
Specified by:
getSignerCertificates in interface org.osgi.framework.Bundle

loadClass

public java.lang.Class loadClass(java.lang.String name)
                          throws java.lang.ClassNotFoundException
Specified by:
loadClass in interface org.osgi.framework.Bundle
Throws:
java.lang.ClassNotFoundException


Copyright © 2010. All Rights Reserved.