Configuration

The configuration of the REST API consists in the deployment of jar libraries to the classpath and the configuration of the servlet in the /WEB-INF/web.xml . After it's configured, all persistent classes are automatically exposed via RESTful HTTP interface.

Libraries

DataNucleus REST API requires the libraries: DataNucleus core, DataNucleus rest, Flexjson, and the JDO API. These libraries must be in the classpath. In war files, these libraries are deployed under the folder /WEB-INF/lib/ .

web.xml

The DataNucleus REST Servlet class implementation is org.datanucleus.rest.RestServlet . It has to be configured in the /WEB-INF/web.xml file, and it takes one initialisation parameter.

Parameter Description
persistence-context A named PMF/persistence-unit configuration
<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">

    <servlet>
        <servlet-name>DataNucleus</servlet-name>
        <servlet-class>org.datanucleus.rest.RestServlet</servlet-class>
        <init-param>
            <param-name>persistence-context</param-name>
            <param-value>transactions-optional</param-value>
        </init-param>	     
    </servlet>
    
    <servlet-mapping>
        <servlet-name>DataNucleus</servlet-name>
        <url-pattern>/dn/*</url-pattern>
    </servlet-mapping>
  
...
</web-app>