The System Service delivers information about essential system attributes of the host computer, such as OS, VM, and OSGi framework. In addition, you can retrieve information about the runtime status of the framework.
The interface of the System Service is com.prosyst.util.system.SystemService
and you can call it using the conventional techniques defined by the OSGi Framework
Specification.
import org.osgi.framework.BundleContext; |
General properties involve the framework system properties, the attributes
of the operating system (OS) and virtual machine (VM) currently running the
framework. To retrieve such data, call the getProperties method
of the System Service for the preferred type of information:
SystemService.FRAMEWORK - about the frameworkSystemService.JVM - about the virtual machineSystemService.OS - about the operating systemSystemService.ALL - all the above propertiesFor example to request the attributes of the VM, call getProperties(SystemService.JVM).
The getProperties method returns a java.util.Dictionary
with the following string key/value pairs:
org.osgi.framework.versionorg.osgi.framework.vendormbs.product.versionmbs.framework.build.versionmbs.outputmbs.boot.bootfilembs.securitymbs.storage.implmbs.storage.rootmbs.storage.nativeorg.osgi.framework.languagembs.serialNumberNote: org.osgi.framework.*
system properties are defined in the OSGi Service Platform Core Specification. The ones
starting with the mbs keyword are intended for the ProSyst
mBS framework and are described in the "System
Properties" document.
java.vendor.url system property java.version system property java.vendor system property. org.osgi.framework.os.name system property org.osgi.framework.os.version system property org.osgi.framework.os.processor system property.Listing 2 uses the System Service from Listing 1 to read framework properties.
. . . |
Runtime information, provided by the System Service, includes active threads,
active classpath, consumed memory and current gateway platform. These parameters
are wrapped by a com.prosyst.util.system.RuntimeInfo object. You
can apply a filter on a RuntimeInfo to retrieve runtime information
only of a particular type. In case you are interested only in one runtime parameter,
you can save memory and CPU time. The method to invoke is getRuntimeInfo(byte)
with one of the following constants as argument:
SystemService.CLASSPATH - Updates only the information about
the classpath.SystemService.MEMORY - Retrieves information only about memory
usage.SystemService.PLATFORM - Gets information about the platform,
which hosts the framework.SystemService.THREADS - Gets data only about the currently
active threads.SystemService.ALL - Gets information about all runtime parameters.Then, you can read only that field of the RuntimeInfo instance,
which you are interested in. For example, if you created a RuntimeInfo
object about used memory, then you only get the value of the memoryUsage
field.
The threads of each bundle running in the framework operate in a separate thread
group (see the "Framework
Architecture" document for more details about bundles and threads).
By calling the activeThreads variable of RuntimeInfo,
you inspect active threads by thread group, that is, by bundle. Bundles' thread
groups are ThreadGroupInfo objects. For each ThreadGroupInfo
you can list active threads (use activeThreads) and obtain information
about sub groups of the current one (use subGroupsInfo).
You can implement a class, which contacts the operating system for getting the used and free space on the hard disk or on another storage. This information will be provided on checking the runtime information about the platform (when calling getRuntimeInfo(SystemService.PLATFORM)) or about the entire system (when calling getRuntimeInfo(SystemService.ALL)).
Such a class is called Native Platform Informer.
A Native Platform Informer must implement the following methods:
public static long getFreeSpace() - Return the free space on the disk public static long getUsedSpace() - Return the used space on the disk public static long getAllSpace() - Return the total size of the disk Finally, to make the System Service use your Native Platform Informer, add the informer class to the system classpath or export it in a bundle, and set the mbs.platform.informer system property to the class name.
Remote PMP-enabled frameworks can
refer to and invoke the methods of the System Service interface because the
service also implements com.prosyst.util.io.Remote which enables
this access. For example, the mConsole
uses PMP to show the information available through the System Service to the
framework administrator.
The System Service plugs commands as a group called info into the command set of the Parser Service.
The commands of the info group offer information about essential runtime parameters of the OSGi framework, such as current OS and VM.
|
| Parser Service | Socket Factory and Event Interfaces |