OSGI, Servlets and JPA hello world / tutorial / example

I want to create a web application that is basically a calm web service serving json messages. I would like to keep it as simple as possible. I was thinking about using servlets (with annotations). JPA as a database layer is required - Toplink or Hibernate. It is desirable to work with Tomcat. I want the application to be divided into modules serving different functionality (auth service, customer service, etc.). And I would like to be able to update these modules without reinstalling the whole application on the server - for example eclipse plugins, the user is notified (when he enters the home url of the webapp) that an update is available, clicks it, and the application downloads and installs the updated module.

I think this functionality can be done with OSGI, but I can't find any example code or tutorial with a simple updatable hello world servlet providing some data from a database via jpa.

I'm looking for advice: - Is OSGI the right tool for this or can it be done with something simpler? - Where can I find some examples on the topic (or topics) I need for this project. - Which OSGI implementation would be the easiest for this task.

* My OSGI knowledge is basic. I know how bundles are described, I understand the concept of an OSGI container and what it does. I have never created an OSGI application yet.

+3


source to share


2 answers


I think OSGi fits well for what you are describing, yes. When you add servlets and JPA to the mix, you are looking at using what is known as Enterprise OSGi, which is a layer of functionality on top of mainstream OSGi. There are two main implementations, Apache Aries and Eclipse Gemini. They come pre-integrated on various servers, including Apache Geronimo, or you can flip your own stack. (I'm an Aries supporter.)

For a tutorial on web development using Aries, check out http://www.javabeat.net/articles/378-writing-an-osgi-web-application-1.html . Aries himself has a sample that you can download and play, apache.org/downloads/blogsample-0.3.html. However, this is a little more complex than Hello World and you may need a little more OSGi knowledge than your current level to make the most of it. As a starting point, I would recommend taking a look at the OSGi console (the sample blog uses equinox) to see what's going on on your system. For equinox, the ss command is most useful, and the bundle command is the one I use the most.



If you are looking for enterprise OSGi, servlet and JPA, you should find some helpful resources. There are several articles on developerWorks.

+4


source


If you want to keep it as simple as possible, you can use the OSGi framework with Jetty as the web engine, EclipseLink as the JPA engine, and Apache ACE as the OSGi distribution platform without any other OSGi functionality.

Some useful links:



+1


source







All Articles