The mBS framework has two versions. Separation in two versions comes
from the opportunity for bundles to work with data files in two ways. In Standard
Version, standard I/O facilities from the java.io package for working
with files are used. In Connector Version, the OSGi IO Connector service is
used for operations with data files.
Contents:
In Standard Version, bundles store their data files by using the facilities
for working with files from the java.io package (by using RandomAccessFile,
FileInputStream and FileOutputStream).
Figure 1 shows the modules involved in the Standard Version of the framework:
bundles which work with data files through the API in the java.io
package; and the used storage implementation - storage on top of java.io.

Figure 1: Modules involved in the Standard Version of the
framework.
The JARs from the lib directory of the Framework Professional Edition Package which hold the components of the Standard Version are:
This version uses storage on top of java.io, whose implementation class is com.prosyst.mbs.impl.framework.module.storage.file.StorageImpl.
You work with data files with the means of the java.io API when
you are using the Standard Version of the framework.
You call the getDataFile method of the org.osgi.framework.BundleContext
object for your bundle. Then to manipulate the file, call FileInputStream,
FileOutputStream and RandomAccessFile on the returned
File object.
Note: Only bundles whose symbolic names are included in the mbs.storage.allowroot system property, are able to access the root directory of the framework storage by using the getDataFile method.
Listing 1 shows how a bundle creates a file called example.txt in its storage area and writes a simple string.
import org.osgi.framework.BundleActivator; import java.io.File; public class FileTester implements BundleActivator {
public void start(BundleContext bc) throws Exception {
public void stop(BundleContext bc) throws Exception {}
|
When the Connector Version of the framework is used, bundles store data through the OSGi IO Connector service. For more information about the usage of this service, refer to the description of the Connector Service Bundle.
Figure 2 shows the modules involved in the Connector Version of the framework:
bundles that use the OSGi IO Connector service to work with files; and the used
storage implementation, which can be storage on top of java.io
with Connector support or storage on top of MMFS with Connector support.

Figure 2: Modules involved in the Connector Version of the framework.
The JARs from the lib directory of the Framework Professional Edition Package which contain the Connector Version of the framework for a specific JVM are:
This framework version uses:
java.io with Connector support whose implementation
class is com.prosyst.mbs.impl.framework.module.storage.file.StorageImpl.com.prosyst.mbs.impl.framework.module.storage.mm.StorageImpl.When working with data files in the Connector Version:
getDataFile of the org.osgi.framework.BundleContext
object for your bundle.File object. The URI
has the following syntax:
file:/<pathname>[;<param>=<value>;<param>=<value>.
. .]
getPath method to the File object.Note: Only bundles whose symbolic names are included in the mbs.storage.allowroot system property, are able to access the root directory of the framework storage by using the getDataFile method.
Listing 2 creates a file example.txt in the default storage area of an arbitrary bundle. First a line is written in the file and afterwards the content of the file is read and printed in the system output.
import java.io.File; public class ConnectionFactoryTest implements BundleActivator {
public void start(BundleContext bc) {
public void stop(BundleContext bc) {}
|
Troubleshooting when using storage on top of MMFS: If you use java.io
facitilities, for example new FileInputStream or new FileOutputStream
to write/read data from the File object received from the getDataFile
of BundleContext, then the operations will not be executed properly
because of the underlying abstraction used by MMFS.
mBS bundles intended to operate on the Connector Version have the
mio suffix added to their archive names, for example db.jar -
for Standard version and dbmio.jar - for Connector Version. These bundles
import additionally the org.osgi.service.io package. Some of them
also import the javax.microedition.io and/or org.mbs.services.io
packages. Bundle developers may use the same naming convention for bundles working
with data files in the Connector Version of the framework.