Java Persistence API (JPA) abstracts the database interactions and treats them as objects rather than simply queries. Since these queries are now objects, the principles of Object-Oriented Programming (OOP) can come into play including, encapsulation, abstraction, inheritance, and polymorphism. Persistence in the java language is actually not a new concept at all. Many implementations have been created in the past including, EDJ, JDO, Hibernate, and Toplink to name a few. JPA was designed with the idea of simplifying the Enterprise JavaBean (EJB) programming model.
There are many ways to implement a RESTful service, but what if you need to do it in Java and you use Netbeans? I recently had a project like this and it was quite an experience to get my enviorment up and working. With Java, there are just so many ways to do it that it starts to look like too much to handle. Well it is actually easier than you think. Let's dive in..
First, fire up Netbeans and create a new Maven Web Application project. Give it a name of you choosing.
Restful architectures are often used to create client/server network environments. REST, which stands for representational state transfer, is a simpler alternative to SOAP and WSDL services, but still maintains great features like platform-independence and language independence. REST services explicitly use HTTP methods when implementing their calls, therefore any good API should support the basic GET, POST, PUT, and DELETE methods. Along with knowing the HTTP methods you must understand the HTTP status codes as well.
Using the services module in Drupal to expose CRUD operations on nodes is a great way to expose RESTful service from Drupal. All you have to do is to enable rest_server sub-module and create a REST server in it. Now you start fetching your nodes in XML, JSON or many other formats. Now for testing, the 'curl' command line browser was used to make HTTP requests in an automated fashion. Making read-only requests to fetch nodes as JSON was easy.