49 Developing Custom REST Resources with WEM Framework
Within the WEM Framework, you can develop custom REST resources as the Recommendation sample application demonstrate.
Topics:
49.1 Creating REST Resources for WebCenter Sites and Satellite Server: Example
Through the Recommendation sample application you can learn how you can create REST resources for WebCenter Sites and Satellite Server.
The application registers a new REST resource sample/recommendations/<id> with GET and POST operations, which allow for retrieval and modification of static list recommendations. The application also demonstrates how it is possible to leverage the Satellite Server caching system.
Topics:
49.1.2 Testing the Recommendations Sample Application
You can test the Recommendations sample application as follows:
-
Use the existing static list recommendation ID (or create a new recommendation) for the URL
http://<hostname>:<port>/<contextpath>/REST/sample/recommendations/<recommendationid>. -
Use the same URL for both WebCenter Sites and Satellite Server installations. For example, use
http://localhost:8080/cs/REST/sample/recommendations/1266874492697. See the XML response for both WebCenter Sites and Satellite Server.
49.2 Creating REST Resources
This section includes the following topics:
49.2.1 About the Recommendations Sample Application's Structure
The Recommendations sample application was created to guide you through the process of creating your own REST resources.
Figure 49-1 Recommendations Sample Application

Description of "Figure 49-1 Recommendations Sample Application"
-
Schema files:
src/main/schema-
elements.zipcontains a sample element, which is used by Satellite Server for caching purposes. -
jaxb.bindingis a customization for the default JAXB bindings used during the bean generation process. -
recommendation.xsdis an XML schema for theRecommendationServicebeans.
-
-
Java source files:
src/main/java/ ... /sample-
RecommendationResourcecontains the REST resource implementation. It is used on both WebCenter Sites and Satellite Server. -
RecommendationServiceis an interface that provides the functionality for theRecommendationResourceclass. It is implemented differently, depending on where the resource is hosted: locally (on WebCenter Sites) or remotely (on Satellite Server). -
beans/*classes are generated using Javaxjccompiler. They are pre-packaged with the application. To regenerate beans (that is, when changing therecommendation.xsdfile), rungenerateAnt's task frombuild.xml. -
LocalRecommendationServiceis a local (WebCenter Sites) implementation for theRecommendationServiceinterface. -
RemoteRecommendationServiceis a remote (Satellite Server) implementation for theRecommendationServiceinterface.
-