Search code examples
javaspringjakarta-eeosgiosgi-bundle

How to Use the same object among 3 different osgi bundles that is 3 different java plugin projects


Iam using OSGI framework for my project and iam using Core Java.

There are 3 bundles 1.Interface bundle 2. Implementer bundle(Implements the interface) 3. APP bundle(call the interface methods and we set values to below object)

I have a INTERFACE bundle with below methods

public int addDevice(String Devtype, RegInfo reginfo);

public int modifyDevice(String Devicetype,int deviceID,RegInfo reginfo);

Then iam implementing the above methods in the IMPLEMENTER bundle.From the above as you can see there is a RegInfo object which contains setters and getters.So i will get values set in the APP bundle from the object using getters and use it internally.

Then i need to set values to the RegInfo object in the APP bundle.

I want to share the common RegInfo object among all three bundles. Please note 3 bundles means 3 different java plugin projects all together.

Thanks in advance.


Solution

  • I would then assume RegInfo is a type in the API package holding the interface. So the APP bundle would construct and configure a RegInfo object and pass it via the interface to the class implementing the interface.

    You don't mention using OSGi services, but this is the recommended way for the implementor bundle to make its implementation of the interface available to consumers. The app bundle would then lookup the service and use it.

    RegInfo sounds like it should be a DTO type.