|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ungoverned.oscar.Oscar
public class Oscar
Field Summary | |
---|---|
static int |
RUNNING_STATUS
|
static int |
STARTING_STATUS
|
static int |
STOPPING_STATUS
|
static int |
UNKNOWN_STATUS
|
Constructor Summary | |
---|---|
Oscar()
Creates an instance of Oscar where all configuration properties (e.g., profile name, profile directory, strictness, and embedded execution) are specified using system properties. |
|
Oscar(java.util.List activatorList)
Creates an instance of Oscar where all configuration properties (e.g., profile name, profile directory, strictness, and embedded execution) are specified using system properties. |
|
Oscar(java.util.Properties props)
Creates an instance of Oscar where all configuration properties (e.g., profile name, profile directory, strictness, and embedded execution) are specified in the supplied Properties instance. |
|
Oscar(java.util.Properties props,
java.util.List activatorList)
Creates an instance of Oscar where all configuration properties (e.g., profile name, profile directory, strictness, and embedded execution) are specified in the supplied Properties instance. |
Method Summary | |
---|---|
protected void |
addBundleListener(Bundle bundle,
BundleListener l)
Implementation for BundleContext.addBundleListener(). |
protected void |
addFrameworkListener(Bundle bundle,
FrameworkListener l)
Implementation for BundleContext.addFrameworkListener(). |
protected boolean |
addImport(Module module,
java.lang.Object target,
java.lang.Object version,
boolean force)
This method adds a import target to the IMPORTS_ATTR attribute array associated with the specified module. |
protected void |
addServiceListener(Bundle bundle,
ServiceListener l,
java.lang.String f)
Implementation for BundleContext.addServiceListener(). |
protected boolean |
bundleHasPermission(org.ungoverned.oscar.BundleImpl bundle,
java.lang.Object obj)
Implementation for Bundle.hasPermission(). |
static void |
debug(java.lang.String s)
|
static void |
error(java.lang.String s)
|
static void |
error(java.lang.String s,
java.lang.Throwable th)
|
protected Bundle |
getBundle(long id)
Implementation for BundleContext.getBundle(). |
protected java.io.File |
getBundleDataFile(org.ungoverned.oscar.BundleImpl bundle,
java.lang.String name)
Implementation for BundleContext.getDataFile(). |
protected java.util.Dictionary |
getBundleHeaders(org.ungoverned.oscar.BundleImpl bundle)
Implementation for Bundle.getHeaders(). |
protected long |
getBundleId(org.ungoverned.oscar.BundleImpl bundle)
Implementation for Bundle.getBundleId(). |
protected java.lang.String |
getBundleLocation(org.ungoverned.oscar.BundleImpl bundle)
Implementation for Bundle.getLocation(). |
protected ServiceReference[] |
getBundleRegisteredServices(org.ungoverned.oscar.BundleImpl bundle)
Implementation for Bundle.getRegisteredServices(). |
protected java.net.URL |
getBundleResource(org.ungoverned.oscar.BundleImpl bundle,
java.lang.String name)
Implementation for Bundle.getResource(). |
protected Bundle[] |
getBundles()
Implementation for BundleContext.getBundles(). |
protected ServiceReference[] |
getBundleServicesInUse(org.ungoverned.oscar.BundleImpl bundle)
Implementation for Bundle.getServicesInUse(). |
protected int |
getBundleStartLevel(Bundle bundle)
Returns the start level for the specified bundle; this method implements functionality for the Start Level service. |
protected int |
getBundleState(org.ungoverned.oscar.BundleImpl bundle)
Implementation for Bundle.getState(). |
java.lang.String |
getConfigProperty(java.lang.String name)
Oscar uses this method whenever it needs to access any configuration properties. |
protected ExportedPackage |
getExportedPackage(java.lang.String name)
Returns the exported package associated with the specified package name. |
protected ExportedPackage[] |
getExportedPackages(Bundle b)
Returns an array of all actively exported packages from the specified bundle or if the specified bundle is null an array containing all actively exported packages by all bundles. |
int |
getFrameworkStatus()
Returns the current status of Oscar; this information is used to determine which actions to perform during various execution activities. |
protected Bundle[] |
getImportingBundles(ExportedPackage ep)
|
protected int |
getInitialBundleStartLevel()
Returns the start level into which newly installed bundles will be placed by default; this method implements functionality for the Start Level service. |
protected java.lang.String |
getProperty(java.lang.String key)
Implementation for BundleContext.getProperty(). |
protected java.lang.Object |
getService(org.ungoverned.oscar.BundleImpl bundle,
ServiceReference ref)
Implementation for BundleContext.getService(). |
protected ServiceReference[] |
getServiceReferences(java.lang.String className,
java.lang.String expr)
Implementation for BundleContext.getServiceReferences(). |
protected int |
getStartLevel()
Returns the active start level of the framework; this method implements functionality for the Start Level service. |
protected Bundle[] |
getUsingBundles(ServiceReference ref)
Returns the bundles that are using the service referenced by the ServiceReference object. |
static void |
initializeSystemProperties()
Installs all system properties specified in the system property file associated with the Oscar installation; these properties will be accessible through System.getProperty() at run time. |
protected Bundle |
installBundle(java.lang.String location,
java.io.InputStream is)
Implementation for BundleContext.installBundle(). |
protected boolean |
isBundlePersistentlyStarted(Bundle bundle)
Returns whether a bundle is persistently started; this is an method implementation for the Start Level service. |
boolean |
isStrictOSGi()
Returns the framework flag that indicates whether Oscar is strictly adhering to the OSGi specification. |
protected void |
refreshPackages(Bundle[] targets)
|
protected ServiceRegistration |
registerService(org.ungoverned.oscar.BundleImpl bundle,
java.lang.String[] classNames,
java.lang.Object svcObj,
java.util.Dictionary dict)
Implementation for BundleContext.registerService(). |
protected void |
removeBundleListener(BundleListener l)
Implementation for BundleContext.removeBundleListener(). |
protected void |
removeFrameworkListener(FrameworkListener l)
Implementation for BundleContext.removeFrameworkListener(). |
protected void |
removeServiceListener(ServiceListener l)
Implementation for BundleContext.removeServiceListener(). |
protected void |
resolveBundle(org.ungoverned.oscar.BundleImpl bundle)
|
protected void |
servicePropertiesModified(ServiceRegistration reg)
Sets the properties associated with the given service registration. |
protected void |
setBundleStartLevel(Bundle bundle,
int startLevel)
Sets the start level of the specified bundle; this method implements functionality for the Start Level service. |
static void |
setDebug(java.io.PrintStream ps)
|
protected void |
setInitialBundleStartLevel(int startLevel)
Sets the default start level into which newly installed bundles will be placed; this method implements functionality for the Start Level service. |
protected void |
setProperty(java.lang.String key,
java.lang.String value)
Set the environment property associated with the container. |
protected void |
setStartLevelInternal(int requestedLevel)
Implements the functionality of the setStartLevel() method for the StartLevel service, but does not do the security or parameter check. |
void |
shutdown()
This method cleanly shuts down Oscar, it must be called at the end of a session in order to shutdown all active bundles. |
protected void |
startBundle(org.ungoverned.oscar.BundleImpl bundle)
Implementation for Bundle.start(). |
protected void |
stopBundle(org.ungoverned.oscar.BundleImpl bundle)
Implementation for Bundle.stop(). |
protected java.lang.Object |
ungetService(org.ungoverned.oscar.BundleImpl bundle,
ServiceReference ref)
Implementation for BundleContext.ungetService(). |
protected void |
ungetServices(org.ungoverned.oscar.BundleImpl bundle)
This is a utility method to release all services being used by the specified bundle. |
protected void |
uninstallBundle(org.ungoverned.oscar.BundleImpl bundle)
Implementation for Bundle.uninstall(). |
protected void |
unregisterService(org.ungoverned.oscar.BundleImpl bundle,
org.ungoverned.oscar.ServiceRegistrationImpl reg)
Unregisters a service for the specified bundle. |
protected void |
unregisterServices(org.ungoverned.oscar.BundleImpl bundle)
Unregisters all services for the specified bundle. |
protected void |
updateBundle(org.ungoverned.oscar.BundleImpl bundle,
java.io.InputStream is)
Implementation for Bundle.update(). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int UNKNOWN_STATUS
public static final int RUNNING_STATUS
public static final int STARTING_STATUS
public static final int STOPPING_STATUS
Constructor Detail |
---|
public Oscar()
Creates an instance of Oscar where all configuration properties (e.g., profile name, profile directory, strictness, and embedded execution) are specified using system properties. If the DefaulBundleCache is being used, then at a minimum a profile name or profile directory must be specified in the system properties.
System properties can be set using a system.properties file; refer to the usage document for more information.
For information on Oscar properties.
public Oscar(java.util.Properties props)
Creates an instance of Oscar where all configuration properties (e.g., profile name, profile directory, strictness, and embedded execution) are specified in the supplied Properties instance. If Properties is a null instance, then System.getProperty() is used to find all configuration properties. If the DefaulBundleCache is being used, then at a minimum a profile name or profile directory must be specified.
The following are framework configuration properties that can be specified in the Properties instance:
Besides the above framework properties, it is also possible to set properties for the bundle cache via the Oscar constructor. The available bundle cache properties depend on the cache implementation being used. For the properties of the default bundle cache, refer to the DefaulBundleCache API documentation. All of these properties can specified in one of three ways:
The system.properties file overwrites any property values specified on the command line. If a Properties instance is passed into Oscar's constructor, then all system properties are ignored and only the Properties instance is used to locate configuration property values.
props
- the properties used to initialize Oscar; may also
be null.public Oscar(java.util.List activatorList)
Creates an instance of Oscar where all configuration properties (e.g., profile name, profile directory, strictness, and embedded execution) are specified using system properties. If the DefaulBundleCache is being used, then at a minimum a profile name or profile directory must be specified in the system properties. This constructor accepts a list of BundleActivator instances that will be started/stopped by the System Bundle when the framework is started/stopped; this is useful for when Oscar is embedded into a host application that wants to provide services to the bundles inside of Oscar.
activatorList
- list of bundle activators to be started/stopped by
the system bundle; may also be nullFor information on Oscar properties.
public Oscar(java.util.Properties props, java.util.List activatorList)
Creates an instance of Oscar where all configuration properties (e.g., profile name, profile directory, strictness, and embedded execution) are specified in the supplied Properties instance. If Properties is a null instance, then System.getProperty() is used to find all configuration properties. If the DefaulBundleCache is being used, then at a minimum a profile name or profile directory must be specified in the system properties. This constructor also accepts a list of BundleActivator instances that will be started/stopped by the System Bundle when the framework is started/stopped; this is useful for when Oscar is embedded into a host application that wants to provide services to the bundles inside of Oscar.
props
- the properties used to initialize Oscar; may also
be null.activatorList
- list of bundle activators to be started/stopped by
the system bundle; may also be nullFor information on Oscar properties.
Method Detail |
---|
public java.lang.String getConfigProperty(java.lang.String name)
Oscar uses this method whenever it needs to access any configuration properties. This will look for a configuration property either in the system properties or in the configuration property map that was passed into the Oscar constructor; that is, Oscar will look in one place or the other, but not both. This approach was taken to simplify support for having multiple instances of Oscar in memory at the same time.
The approach is very simple. If no Properties instance was passed into the constructor, then this method only searches System.getProperty() to find property values. If a Properties instance was passed into the constructor, then it only searches the supplied instance. When creating multiple instances of Oscar, a Properties instance should be supplied to the constructor so that all instances do not end up using the same bundle cache directory.
name
- the name of the configuration property to retrieve.
public void shutdown()
protected int getStartLevel()
protected void setStartLevelInternal(int requestedLevel)
requestedLevel
- the new start level of the framework.protected int getInitialBundleStartLevel()
protected void setInitialBundleStartLevel(int startLevel)
startLevel
- the new default start level for newly installed
bundles.
java.lang.IllegalArgumentException
- if the specified start
level is not greater than zero.
java.security.SecurityException
- if the caller does not
have AdminPermission.protected int getBundleStartLevel(Bundle bundle)
bundle
- the bundle to examine.
java.lang.IllegalArgumentException
- if the specified
bundle has been uninstalled.protected void setBundleStartLevel(Bundle bundle, int startLevel)
bundle
- the bundle whose start level is to be modified.startLevel
- the new start level of the specified bundle.
java.lang.IllegalArgumentException
- if the specified
bundle is the system bundle or if the bundle has been
uninstalled.
java.security.SecurityException
- if the caller does not
have AdminPermission.protected boolean isBundlePersistentlyStarted(Bundle bundle)
bundle
- the bundle to examine.
java.lang.IllegalArgumentException
- if the specified
bundle has been uninstalled.public int getFrameworkStatus()
public boolean isStrictOSGi()
protected ExportedPackage getExportedPackage(java.lang.String name)
name
- the name of the exported package to find.
protected ExportedPackage[] getExportedPackages(Bundle b)
b
- the bundle whose exported packages are to be retrieved
or null if the exported packages of all bundles are
to be retrieved.
protected Bundle[] getImportingBundles(ExportedPackage ep)
protected void refreshPackages(Bundle[] targets)
protected boolean addImport(Module module, java.lang.Object target, java.lang.Object version, boolean force)
module
- the module whose IMPORTS_ATTR meta-data is to be modified.target
- the target to import.version
- the version of the target to import.force
- indicates whether to force the operation, even in the
case where the module will be invalidated.
protected long getBundleId(org.ungoverned.oscar.BundleImpl bundle)
protected java.util.Dictionary getBundleHeaders(org.ungoverned.oscar.BundleImpl bundle)
protected java.lang.String getBundleLocation(org.ungoverned.oscar.BundleImpl bundle)
protected java.net.URL getBundleResource(org.ungoverned.oscar.BundleImpl bundle, java.lang.String name)
protected ServiceReference[] getBundleRegisteredServices(org.ungoverned.oscar.BundleImpl bundle)
protected ServiceReference[] getBundleServicesInUse(org.ungoverned.oscar.BundleImpl bundle)
protected int getBundleState(org.ungoverned.oscar.BundleImpl bundle)
protected boolean bundleHasPermission(org.ungoverned.oscar.BundleImpl bundle, java.lang.Object obj)
protected void startBundle(org.ungoverned.oscar.BundleImpl bundle) throws BundleException
BundleException
protected void updateBundle(org.ungoverned.oscar.BundleImpl bundle, java.io.InputStream is) throws BundleException
BundleException
protected void stopBundle(org.ungoverned.oscar.BundleImpl bundle) throws BundleException
BundleException
protected void uninstallBundle(org.ungoverned.oscar.BundleImpl bundle) throws BundleException
BundleException
protected java.lang.String getProperty(java.lang.String key)
key
- the name of the property to retrieve.
protected void setProperty(java.lang.String key, java.lang.String value)
key
- the name of the property to set.value
- the value of the specified property.protected Bundle installBundle(java.lang.String location, java.io.InputStream is) throws BundleException
location
- the location string (URL) for the bundle.is
- input stream from which to read the bundle, can be null.
BundleException
- if any problems are encountered during installation.protected Bundle getBundle(long id)
id
- the identifier of the bundle to retrieve.
protected Bundle[] getBundles()
protected void addBundleListener(Bundle bundle, BundleListener l)
BundleEvent
s.
bundle
- the bundle that registered the listener.l
- the bundle listener to add to the listener list.protected void removeBundleListener(BundleListener l)
l
- the bundle listener to remove from the listener list.protected void addServiceListener(Bundle bundle, ServiceListener l, java.lang.String f) throws InvalidSyntaxException
ServiceEvent
s.
bundle
- the bundle that registered the listener.l
- the service listener to add to the listener list.f
- the filter for the listener; may be null.
InvalidSyntaxException
protected void removeServiceListener(ServiceListener l)
l
- the service listener to remove from the listener list.protected void addFrameworkListener(Bundle bundle, FrameworkListener l)
FrameworkEvent
s.
bundle
- the bundle that registered the listener.l
- the framework listener to add to the listener list.protected void removeFrameworkListener(FrameworkListener l)
l
- the framework listener to remove from the listener list.protected ServiceRegistration registerService(org.ungoverned.oscar.BundleImpl bundle, java.lang.String[] classNames, java.lang.Object svcObj, java.util.Dictionary dict)
clazzes
- a string array containing the names of the classes
under which the new service is available.svcObj
- the service object or ServiceFactory
.dict
- a dictionary of properties that further describe the
service or null.
ServiceRegistration
object or null.protected ServiceReference[] getServiceReferences(java.lang.String className, java.lang.String expr) throws InvalidSyntaxException
InvalidSyntaxException
protected java.lang.Object getService(org.ungoverned.oscar.BundleImpl bundle, ServiceReference ref)
protected java.lang.Object ungetService(org.ungoverned.oscar.BundleImpl bundle, ServiceReference ref)
protected java.io.File getBundleDataFile(org.ungoverned.oscar.BundleImpl bundle, java.lang.String name) throws java.lang.IllegalStateException
java.lang.IllegalStateException
protected void resolveBundle(org.ungoverned.oscar.BundleImpl bundle) throws BundleException
BundleException
protected void servicePropertiesModified(ServiceRegistration reg)
protected Bundle[] getUsingBundles(ServiceReference ref)
protected void unregisterService(org.ungoverned.oscar.BundleImpl bundle, org.ungoverned.oscar.ServiceRegistrationImpl reg)
reg
- the service registration for the service to unregister.protected void unregisterServices(org.ungoverned.oscar.BundleImpl bundle)
protected void ungetServices(org.ungoverned.oscar.BundleImpl bundle)
bundle
- the bundle whose services are to be released.public static void initializeSystemProperties()
public static void setDebug(java.io.PrintStream ps)
public static void debug(java.lang.String s)
public static void error(java.lang.String s)
public static void error(java.lang.String s, java.lang.Throwable th)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |