Thursday, 22 August 2013

OSGI Bundle provides a service that requires a class object defined in the host application

OSGI Bundle provides a service that requires a class object defined in the
host application

Here's the situation:
In my host application, I have a class HostApplicationClass which uses a
service provided by a bundle. The class is as the following:
public class HostApplicationClass {
public static void main(String [] args)
{
//setup OSGI framework
service.getService(this); //this is not the exact syntax, just for
simplicity
}
}
Note that the above class is passing an object of it to the method
implemented by the service.
In my bundle, I have the interface:
public interface SERVICE
{
public void getService(HostApplicationClass object);
}
The problem is that, the bundle won't compile (and might not execute the
service) unless the class HostApplicationClass is available as part of the
bundle. So the question is, should the bundle define the class
HostApplicationClass? Or should it define an interface called
HostApplicationClass? How to manage such issue?

No comments:

Post a Comment