Binding development question - HTTP server recommendation

I hope this is the right place to post this question. If there is a better place let me know and I can repost it there.

I am developing a binding for the Samsung Smartthings Hub. I have to have an http sever to receive messages from the hub. I am currently using the It is working well and is part of the core rt.jar but is a “restricted” api. This has required adding @SuppressWarnings(“restriction”) annotations and the pom.xml has:





Is this OK or should I use a different HTTP server? If a different one is prefered what is it and can you point me to a binding that is currently using it effectively?


Bob R

Could you use the built-in OSGi HttpService and register a servlet on an endpoint you define? If so, then there would be no reason to fire up another HTTP server. There are examples here of servlets using Declarative Services to reference the HttpService and register servlets. This is also a good example.

I had a similar issue which disappeared when I changed my Eclipse JDK to the right version.

Hey Bob,

Yes, definitely go for @watou’s suggestion - we already run a web server, so it does not make sense to fire up another one.
Do you require to provide a specific url for the SmartThings hub on the server? Or are you free to define the url (.i.e. having the servlet registered at http://<openhabhost>:8080/callback/smartthings or similar)?

Daniel:Thank you very much for responding. My project and Eclipse JDK is set to Java 1,8. I see there are updates available for Eclipse and it has been a while since I’ve pulled the OpenHAB projects so I will do that soon. I do like the idea of using the existing servlet engine and have been implementing that. Thanks again for responding.

Thank you very much for the reply. This feels to me exactly how it should be done. I apologize for the slow response but I have been busy working on it and currently have it running. But, the implementation is fairly convoluted.I largely pattened what I did after the hueemulation reference you suggested. The hueemulation servlet gets the device id as part of the message and is therefore able to use the ItemRegistry to update the item. In my case Smartthings sends: deviceName, deviceType (i.e. contact, switch, etc) and deviceState (on, off, open, etc). The Smartthing deviceName is not correspond to the Item name therefore I can’t use the ItemRegistry. The Things get the deviceName as a property during creation. But, I don’t find a way for the servlet to get something that can let me look through all of the things for the deviceName. Am I missing something here? What I’ve done is create events in the servlet. In the ThingHandlerFactory I handle the events and am able to get a list id the Things via a reference to the Bridge handler. If you would be willing to look at my code I could post it in my GitHub account and give you a better explanation of exactly what I’ve done. Thanks again for your help.
BTW I’ve been writing Java since v 0.9 but this is my first exposure to OSGi and I am finding it very interesting.

Kai - Yes I can control the ip and port Smartthings sends it’s response to. See my response the @watou. I am using the servlet engine. Thanks for your help.