Hi, On 10.05.2011 13:07, Adrian Crum wrote: > After thinking about this for a while, I came to the conclusion that the REST > servlet should have > its own request config file. REST request elements will be kept in their own > config file and that > file will be specified in web.xml.
Why reinvent the wheel? We integrated Enunciate in OFBiz for our REST API. It adheres to the REST principles, is actually quite comfortable to use and was not hard to integrate into OFBiz. And it generates a nice documentation for the API from your JavaDoc. :) Have a look at it here: http://enunciate.codehaus.org/getting_started.html I'll paste some code snippets to get you started. Just ask if you need more details. Enunciate brings its own web app, which is actually generated. So we put it in hot-deploy/api/build/web-app. We just added the webapp to ofbiz-component.xml: <webapp name="api" location="build/webapp/basic-app" mount-point="/api" app-bar-display="false" ... Then you have to integrate enunciate in the build process, the component's build.xml should contain something like that: <!-- we put the enunciate libraries here: --> <property name="enunciate.home" value="enunciate/enunciate-1.20" /> <property name="enunciate.config" value="config/enunciate.xml" /> <property name="build.main.dir" value="build/classes/basic-app" /> <property name="build.tmp.dir" value="build/tmp" /> <!-- override classes target to call enunciate --> <target name="classes" description="enunciate specific build step" depends="prepare"> <taskdef name="enunciate" classname="org.codehaus.enunciate.main.EnunciateTask"> <classpath refid="enunciate.classpath" /> </taskdef> <delete dir="${build.tmp.dir}" /> <mkdir dir="${build.tmp.dir}" /> <enunciate basedir="src/main" configFile="${enunciate.config}" verbose="true" scratchDir="${build.tmp.dir}" generateDir="build/gen-src" compileDir="build/classes" buildDir="build/webapp"> <include name="**/*.java" /> <classpath refid="enunciate.classpath" /> </enunciate> <javac16/> </target> In the enunciate config file we configured enunciate not to do the actual build itself, but let the OFBiz build system do this: <webapp doPackage="false" doLibCopy="false" doCompile="false" mergeWebXML="merge-web.xml"> We also have a servlet filter for authorization configured. And our Enunciate Services all inherit from a BaseService class which provides the OFBiz delegator and dispatcher: protected Delegator delegator = DelegatorFactory.getDelegator("default"); protected LocalDispatcher dispatcher = GenericDispatcher.getLocalDispatcher("api", delegator); In the Enunciate methods we can then call OFBiz services with dispatcher.runSync() and access the OFBiz database using the usual Delegator. So our mapping from OFBiz services to the REST paradigm is done in Java code, no XML configuration necessary here :-) Regards Martin