OSGi felix: Can I use a class between the host application and the package?

In my host application, I tried to implement a simple pushService, which is used to transfer an instance of a class named Vehicle to the OSGi world, providing a set and get method. To be able to use the service, I exported both the service interface and the Vehicle class to a jar file and imported this file into the package that the service should use.

Every time I tried to use the Vehicle class in my host application, which stimulates the felix framework, and the bunch, I got a connection error. After reading the next blog post ( http://frankkieviet.blogspot.com/2009/03/javalanglinkageerror-loader-constraint.html ) I understood why this error occurs. But I do not know how to solve my problem.

Is it possible to split a class between a host application and an OSGi example? Maybe I need to use reflection instead of importing a jar file? I looked at this library ( http://code.google.com/p/transloader/ ) and I'm not sure if this library can solve my problem or not ...

BR

Marcus

+3
1

, , -. Equinox ( , LAF osgi). , Felix : , Equinox.

UPDATE: -. , OSGi, . - - ; . , , , . / , . - , .

OSGi "org.osgi.framework.system.packages", ( ), ";". osgi, "org.osgi.framework" "org.osgi.packageadmin", "org.osgi.startlevel", "org.osgi.url".

, Felix ( Equinox)

Map<String, String> configMap = new HashMap<String, String();

configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES,
    "your.package;other.package;org.osgi.framework");

// setup other properties

Bundle systemBundle = new Felix(configMap, null);
systemBundle.start();

// Now you can use classes from "your.package" with explicity 
// declaring them as imports in bundles
+2

Source: https://habr.com/ru/post/1710769/


All Articles