Aug 31st, 2011, 10:46 PM
Embedding RESTFul web service using Spring MVC as a component to a swing application
I am developing a Swing application using Spring. This application uses an application context to wire in various components. This is working nicely.
However I want one of the components (implementing my interface DeviceListener) to be a RESTful web service, exposed using Spring MVC.
Now all the examples I have seen talk about doing this with the intention of publishing a web app as a war file. What I want to do is have my DeviceListener component start up a servlet that uses Spring MVC.
So to clarify
I have my Spring Application Context defined in defaultApplicationContext.xml
My main method creates the application context from this file and then tells the appropriate bean to start up (this works already).
The part I am working on now is having the implementation of DeviceListener wired into the defaultApplicationContext start up a web server that, as the name suggests, listens for devices. These devices may be smart phones or other computers. I want these devices to announce their presence by calling the RESTFul web service deviceListener will expose.
So the question, how to I set up and expose this web service without a web.xml and outside of the normal web app file structure.
I know I can embed jetty into my application, however all the examples of setting up an embedded instance of Spring MVC seem to be missing part of the puzzle as they don't work.
Has anyone managed to do this, or does anyone have any other suggestions about how I would go about this??
If you have done this preferably with Jetty 6, could you give me a sample of how you set up you server?
Any help would be appreciated.
Tags for this Thread