eclipse-archived / californium.core

Californium project
86 stars 69 forks source link

add a BundleActivator to start/stop a ManagedServer #25

Closed donsez closed 8 years ago

donsez commented 9 years ago

This pull request proposes to add a BundleActivator to the californium-osgi bundle/project in order to start/stop a ManagedServer when the bundle is started/stopped. Requires the bundle http://central.maven.org/maven2/org/osgi/org.osgi.compendium/5.0.0/org.osgi.compendium-5.0.0.jar (and probably previous versions of it). The bundle has been tested with the Apache Felix Framework version 4.4.1 .

donsez commented 9 years ago

This pull requested is completed by a new module containing an example of bundle registering two Resource in order to try the californium-osgi bundle.

mkovatsc commented 9 years ago

Unfortunately, I am not an active OSGi user... @sophokles73 what is your opinion on this pull request?

sophokles73 commented 9 years ago

Hi Didier,

thanks a lot for your pull request! It's nice to see other people also having an interest in OSGi support for Californium :-) When I originally created the ManagedServer I also thought about providing a BundleActivator but then refrained from it because there is no way of preventing the server being started once you deploy the bundle to an OSGi container. Thus, even if you only want to use Californium's CoAP client classes, you still would run a server as well. I do not think that this is desirable in general, thus the current bundle only contains the ManagedServer class, but in order to run a server you will need to instantiate it by means of e.g. a Blueprint configuration or an activator in another (fragment) bundle. Thus, I would actually advise against adding the activator to the Californium OSGi bundle. Does that make any sense to you guys?

Kai

mkovatsc commented 9 years ago

This definitely makes sense. I believe many services will actually have client-only functionality to orchestrate devices running servers in the field. Having to start a server is not desired in this case.

I think it would be very nice, though, to have a cf-osgi example that shows best practices to start server, client, or both! (SInce there is one in the pull request...)

donsez commented 9 years ago

i understand. I will move the Managed Server activator into a separate bundle in order to provide an OSGi server example.

mkovatsc commented 9 years ago

@donsez Sorry for the long wait! What is the status of this, any updates? :) I am still missing the examples to start client-only services. Once this is clear, I would like to ask Kai to make an OSGi sanity check, since I am not very experienced with it.

sophokles73 commented 8 years ago

Since there has not been any activity for several months now, I conclude that there is not much interest in this anymore... Therefore, I will close this PR now.