steveohara / j2mod

Enhanced Modbus library implemented in the Java programming language
Apache License 2.0
267 stars 111 forks source link

Support as OSGi Bundle #15

Closed amitjoy closed 6 years ago

amitjoy commented 8 years ago

It would be helpful if you can provide this library as an OSGi bundle so that it can be made available in lots of OSGi based frameworks.

steveohara commented 8 years ago

Which j2mod package(s) did you have in mind to expose in the bundle?

amitjoy commented 8 years ago

I believe it would be better to expose all the necessary packages which contain classes needed to write Modbus client code.

steveohara commented 8 years ago

Amit, that isn't practical or actually that helpful for OSGi in my opinion. I think exposing the Façade package makes sense as it aggregates a lot of boilerplate but creating interfaces for all the constituents just adds cruft to the library.

amitjoy commented 8 years ago

You are right that facade package can be the most preferred one to be exposed but as j2mod is an advanced version of jamod, people still can use the old classes to do the same stuff. I would suggest you to expose all the relevant packages except the utilities if present.

amitjoy commented 8 years ago

I am just wondering if there is any plan of providing this library as an OSGi bundle?

steveohara commented 8 years ago

Hi Amit, I'm afraid I'm fully committed to other things at the moment but I would welcome any patches so please feel free to put a pull request together. Otherwise, it will have to wait a little while until I can back to j2mod

julie-ab commented 8 years ago

@amitjoy - I've been fully occupied with my day job, but if you can explain what's involved I may have more free time than Steve.

amitjoy commented 8 years ago

@steveohara I understand. I am also a bit busy recently. I would try to convert j2mod as an OSGi bundle so that people using OSGi can make use of this library as an OSGi bundle.

@julie-ab My idea is to incorporate j2mod in Java- and OSGi-based IoT Frameworks and that's why, it would be good to make it available as a standalone OSGi bundle. If j2mod needs any dependency, it would contain that dependency within the bundle jar as its bundle classpath and in the same time, the bundle jar would expose its public packages so that people can make use of only the j2mod classes. So, the bundle can be used as a simple library jar as well as an OSGi bundle.

Let me know if you are interested into my idea.

cnoelle commented 6 years ago

Any plans to merge this? Would be great to have OSGi support in j2mod.

By the way, follwing up on the discussion above, exporting all packages seems to be the only sensible thing to do here, since applications may need to access classes from all packages. The commit does exactly that.

steveohara commented 6 years ago

Code merged into snapshot