I saw a lot of questions about RESTful WebServices in JEE6, so i wanted to share this example solution with you, which show how easy you can implemet a RESTful Webservice.
At first create a new Dynamic Web Project and add Glassfish 4 as new runtime, then follow this text.
In our example application we have a entity class called Item, which holds a name, price and amount. In this example we do not have a database behind, so we have no @Entity Annotation.
Class Item:
Now we need to implement a SessionBean, which does all the business logic stuff for us, so here is the ItemsBean:
To give glassfish the advise to initiate Jersey to provide RESTful WebService features we need to create a "Configuration class", here it is:
And last but not least the ItemService himself, who has some methods which we can call from outside to get different resource presentations..
This is a very nice way to set up a RESTful Webservice i think, former, when i used Glassfish 3, up to now i also use glassfish 3, and it is a little more work to do, so i think with glassfish 4 and Java 7 it become more easier now.
I hope this helps someone, i used this as a example in a uiversity exercise.
You can find the example code on GitHub: https://github.com/PatrickOtt/RESTful_WS_Example