public class Framework extends Object implements EventPublisher, Runnable
Modifier and Type | Field and Description |
---|---|
protected boolean |
active
Has the framework been started
|
protected FrameworkAdaptor |
adaptor
FrameworkAdaptor specific functions.
|
protected static AliasMapper |
aliasMapper
The AliasMapper used to alias OS Names.
|
protected static int |
BATCHEVENT_BEGIN |
protected static int |
BATCHEVENT_END |
protected static int |
BUNDLEEVENT |
protected static int |
BUNDLEEVENTSYNC |
protected BundleRepository |
bundles
The bundles installed in the framework
|
boolean |
compatibiltyBootDelegation |
boolean |
contextBootDelegation |
protected EventManager |
eventManager
EventManager for event delivery.
|
protected static int |
FRAMEWORKEVENT |
protected PackageAdminImpl |
packageAdmin
Package Admin object.
|
static String |
PROP_EQUINOX_SECURITY |
static String |
PROP_FRAMEWORK_THREAD |
protected Properties |
properties
Framework properties object.
|
static String |
SECURITY_OSGI |
protected SecurityAdmin |
securityAdmin
PermissionAdmin and ConditionalPermissionAdmin impl.
|
protected StartLevelManager |
startLevelManager
Startlevel object.
|
protected InternalSystemBundle |
systemBundle
System Bundle object
|
static String |
THREAD_NORMAL |
Constructor and Description |
---|
Framework(FrameworkAdaptor adaptor)
Constructor for the Framework instance.
|
Modifier and Type | Method and Description |
---|---|
static Collection<BundleContext> |
asBundleContexts(Collection<? extends BundleContext> c)
Coerce the generic type of a collection from Collection
|
protected void |
checkAdminPermission(Bundle bundle,
String action)
Check for specific AdminPermission (RFC 73)
|
void |
close()
This method is called to destory the framework instance.
|
FrameworkAdaptor |
getAdaptor() |
protected AbstractBundle[] |
getAllBundles()
Retrieve a list of all installed bundles.
|
AbstractBundle |
getBundle(long id)
Retrieve the bundle that has the given unique identifier.
|
protected AbstractBundle |
getBundleByLocation(String location)
Locate an installed bundle with a given identity.
|
protected AbstractBundle[] |
getBundleBySymbolicName(String symbolicName)
Locate an installed bundle with a given symbolic name
|
List<AbstractBundle> |
getBundleBySymbolicName(String symbolicName,
Version version)
Retrieve the bundles that has the given symbolic name and version.
|
protected BundleRepository |
getBundles()
Retrieve the BundleRepository of all installed bundles.
|
protected File |
getDataFile(AbstractBundle bundle,
String filename)
Creates a
File object for a file in the persistent
storage area provided for the bundle by the framework. |
ClassLoaderDelegateHook[] |
getDelegateHooks() |
static Field |
getField(Class<?> clazz,
Class<?> type,
boolean instance) |
PackageAdminImpl |
getPackageAdmin() |
String |
getProperty(String key)
Retrieve the value of the named environment property.
|
protected String |
getProperty(String key,
String def)
Retrieve the value of the named environment property.
|
ServiceRegistry |
getServiceRegistry() |
BundleContextImpl |
getSystemBundleContext() |
protected void |
initializeProperties(Properties adaptorProperties)
Initialize the System properties by copying properties from the adaptor
properties object.
|
protected void |
installSecurityManager()
This is necessary for running from a JXE, otherwise the SecurityManager
is set much later than we would like!
|
protected AbstractBundle |
installWorker(String location,
PrivilegedExceptionAction<AbstractBundle> action,
BundleContext origin)
Worker method to install a bundle.
|
protected AbstractBundle |
installWorkerPrivileged(String location,
URLConnection source,
AccessControlContext callerContext,
BundleContextImpl origin)
Worker method to install a bundle.
|
protected boolean |
isActive()
This method return the state of the framework.
|
boolean |
isBootDelegationPackage(String name) |
boolean |
isRefreshDuplicateBSNAllowed() |
boolean |
isServiceAssignableTo(Bundle registrant,
Bundle client,
String className,
Class<?> serviceClass)
Used by ServiceReferenceImpl for isAssignableTo
|
void |
launch()
Start the framework.
|
<K,V,E> ListenerQueue<K,V,E> |
newListenerQueue() |
void |
publishBundleEvent(int type,
Bundle bundle)
Deliver a BundleEvent to SynchronousBundleListeners (synchronous).
|
void |
publishBundleEventPrivileged(BundleEvent event) |
void |
publishFrameworkEvent(int type,
Bundle bundle,
Throwable throwable)
Deliver a FrameworkEvent.
|
void |
publishFrameworkEvent(int type,
Bundle bundle,
Throwable throwable,
FrameworkListener... listeners) |
void |
publishFrameworkEventPrivileged(FrameworkEvent event,
FrameworkListener... callerListeners) |
protected void |
resumeBundle(AbstractBundle bundle)
Resume a bundle.
|
void |
run() |
protected Object |
setProperty(String key,
String value)
Set a system property.
|
void |
shutdown(int eventType)
Stop the framework.
|
protected boolean |
suspendBundle(AbstractBundle bundle,
boolean lock)
Suspend a bundle.
|
FrameworkEvent |
waitForStop(long timeout) |
public static final String PROP_FRAMEWORK_THREAD
public static final String THREAD_NORMAL
public static final String PROP_EQUINOX_SECURITY
public static final String SECURITY_OSGI
protected volatile FrameworkAdaptor adaptor
protected Properties properties
protected volatile boolean active
protected BundleRepository bundles
protected volatile PackageAdminImpl packageAdmin
protected SecurityAdmin securityAdmin
protected StartLevelManager startLevelManager
protected static final int BUNDLEEVENT
protected static final int BUNDLEEVENTSYNC
protected static final int FRAMEWORKEVENT
protected static final int BATCHEVENT_BEGIN
protected static final int BATCHEVENT_END
protected volatile EventManager eventManager
protected InternalSystemBundle systemBundle
public final boolean contextBootDelegation
public final boolean compatibiltyBootDelegation
protected static AliasMapper aliasMapper
public Framework(FrameworkAdaptor adaptor)
public FrameworkAdaptor getAdaptor()
public ClassLoaderDelegateHook[] getDelegateHooks()
public ServiceRegistry getServiceRegistry()
protected void initializeProperties(Properties adaptorProperties)
protected boolean isActive()
public void close()
public void launch()
public void shutdown(int eventType)
public String getProperty(String key)
org.osgi.framework.version
org.osgi.framework.vendor
org.osgi.framework.language
org.osgi.framework.os.name
org.osgi.framework.os.version
org.osgi.framework.processor
Note: These last four properties are used by the Bundle-NativeCode
manifest header's matching algorithm for selecting native code.
key
- The name of the requested property.null
if
the property is undefined.protected String getProperty(String key, String def)
org.osgi.framework.version
org.osgi.framework.vendor
org.osgi.framework.language
org.osgi.framework.os.name
org.osgi.framework.os.version
org.osgi.framework.processor
Note: These last four properties are used by the Bundle-NativeCode
manifest header's matching algorithm for selecting native code.
key
- The name of the requested property.def
- A default value is the requested property is not present.protected Object setProperty(String key, String value)
key
- The name of the property to set.value
- The value to set.protected AbstractBundle installWorker(String location, PrivilegedExceptionAction<AbstractBundle> action, BundleContext origin) throws BundleException
location
- The location identifier of the bundle to install.action
- A PrivilegedExceptionAction which calls the real worker.AbstractBundle
of the installed bundle.BundleException
- If the action throws an error.protected AbstractBundle installWorkerPrivileged(String location, URLConnection source, AccessControlContext callerContext, BundleContextImpl origin) throws BundleException
location
- The location identifier of the bundle to install.source
- The URLConnection from which the bundle will be read.callerContext
- The caller access control contextorigin
- The origin bundle context that is installing the the bundleAbstractBundle
of the installed bundle.BundleException
- If the provided stream cannot be read.public AbstractBundle getBundle(long id)
id
- The identifier of the bundle to retrieve.AbstractBundle
object, or null
if the
identifier doesn't match any installed bundle.public BundleContextImpl getSystemBundleContext()
public PackageAdminImpl getPackageAdmin()
public List<AbstractBundle> getBundleBySymbolicName(String symbolicName, Version version)
symbolicName
- The symbolic name of the bundle to retrieveversion
- The version of the bundle to retrieveAbstractBundle
that match the symbolic name and versionprotected BundleRepository getBundles()
protected AbstractBundle[] getAllBundles()
AbstractBundle
objects, one object per installed
bundle.protected void resumeBundle(AbstractBundle bundle)
bundle
- Bundle to resume.protected boolean suspendBundle(AbstractBundle bundle, boolean lock)
bundle
- Bundle to suspend.lock
- true if state change lock should be held when returning from
this method.protected AbstractBundle getBundleByLocation(String location)
location
- string for the bundleprotected AbstractBundle[] getBundleBySymbolicName(String symbolicName)
symbolicName
- The symbolic name for the bundleprotected File getDataFile(AbstractBundle bundle, String filename)
File
object for a file in the persistent
storage area provided for the bundle by the framework. If the adaptor
does not have file system support, this method will return null
.
A File
object for the base directory of the persistent
storage area provided for the context bundle by the framework can be
obtained by calling this method with the empty string ("") as the
parameter.
protected void checkAdminPermission(Bundle bundle, String action)
protected void installSecurityManager()
public void publishFrameworkEvent(int type, Bundle bundle, Throwable throwable)
publishFrameworkEvent
in interface EventPublisher
type
- FrameworkEvent type.bundle
- Affected bundle or null for system bundle.throwable
- Related exception or null.FrameworkEvent
public void publishFrameworkEvent(int type, Bundle bundle, Throwable throwable, FrameworkListener... listeners)
public void publishFrameworkEventPrivileged(FrameworkEvent event, FrameworkListener... callerListeners)
public void publishBundleEvent(int type, Bundle bundle)
type
- BundleEvent type.bundle
- Affected bundle or null.public void publishBundleEventPrivileged(BundleEvent event)
public static Collection<BundleContext> asBundleContexts(Collection<? extends BundleContext> c)
c
- Collection to be coerced.public <K,V,E> ListenerQueue<K,V,E> newListenerQueue()
public FrameworkEvent waitForStop(long timeout) throws InterruptedException
InterruptedException
public boolean isServiceAssignableTo(Bundle registrant, Bundle client, String className, Class<?> serviceClass)
registrant
- Bundle registering serviceclient
- Bundle desiring to use serviceclassName
- class name to useserviceClass
- class of original service objectpublic boolean isBootDelegationPackage(String name)
public boolean isRefreshDuplicateBSNAllowed()
Copyright © 2007–2018 The Apache Software Foundation. All rights reserved.