Reputation: 2407
I developed a small EMF Project as OSGi Bundle. Now i'd like to use it on android with Apache Felix. EMF uses some of the standard java librarys. Like java.xml.xxx. Normally the OSGi system bundle exports these. But in my android case it looks like this:
System Bundle (0)
Bundle-Description = This bundle is system specific; it implements various system services.
Bundle-ManifestVersion = 2
Bundle-Name = System Bundle
Bundle-SymbolicName = org.apache.felix.framework
Bundle-Version = 4.1.0.SNAPSHOT
Export-Package = org.osgi.framework; version="1.6.0", org.osgi.framework.launch; version="1.0.0", org.osgi.framework.wiring; version="1.0.0", org.osgi.framework.startlevel; version="1.0.0", org.osgi.framework.hooks.bundle; version="1.0.0", org.osgi.framework.hooks.resolver; version="1.0.0", org.osgi.framework.hooks.service; version="1.1.0", org.osgi.framework.hooks.weaving; version="1.0.0", org.osgi.service.packageadmin; version="1.2.0", org.osgi.service.startlevel; version="1.1.0", org.osgi.service.url; version="1.0.0", org.osgi.util.tracker; version="1.5.0"
Export-Service = org.osgi.service.packageadmin.PackageAdmin,org.osgi.service.startlevel.StartLevel,org.osgi.service.url.URLHandlers
Provide-Capability =
This is nothing in contrast to the system bundle exports of a normal system bundle ;-) I don't know whether it plays a role: I'm starting Felix like this:
Properties configArg = new Properties();
File chacheDir = this.getFilesDir();
configArg.setProperty(Constants.FRAMEWORK_STORAGE, chacheDir.getAbsolutePath());
configArg.setProperty("osgi.shell.telnet.ip", ipadd);
configArg.setProperty("osgi.shell.telnet.port", "6666");
Felix felix = new Felix(configArg);
try{
felix.start();
...
The question is now, how do i get the missing standard java packages in the system bundle.
Upvotes: 1
Views: 1230
Reputation: 3641
The best solution I found is to replace the FRAMEWORK_SYSTEMPACKAGES
with the specific packages that are available in the Android platform. These are,
android.jar
for the device you're targeting,java.*
and junit.*
,org.osgi.*
packages that the system bundles exports normally.So, something like
String SYSTEM_PACKAGES =
"org.osgi.framework;version=\"1.6\"," +
// ...
"android," +
// ...
"javax.crypto," +
// ...
"org.apache.commons.logging";
Map<String, Object> config = new HashMap<String, Object>();
config.put(Constants.FRAMEWORK_SYSTEMPACKAGES, SYSTEM_PACKAGES);
Framework framework = new Felix(config);
framework.start();
Upvotes: 3