Within the WEM Framework, you can develop custom REST resources as the Recommendation sample application demonstrate.
Topics:
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:
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.
This section includes the following topics:
The Recommendations sample application was created to guide you through the process of creating your own REST resources.
Figure 61-1 Recommendations Sample Application
Schema files: src/main/schema
elements.zip
contains a sample element, which is used by Satellite Server for caching purposes.
jaxb.binding
is a customization for the default JAXB bindings used during the bean generation process.
recommendation.xsd
is an XML schema for the RecommendationService
beans.
Java source files: src/main/java/ ... /sample
RecommendationResource
contains the REST resource implementation. It is used on both WebCenter Sites and Satellite Server.
RecommendationService
is an interface that provides the functionality for the RecommendationResource
class. 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 Java xjc
compiler. They are pre-packaged with the application. To regenerate beans (that is, when changing the recommendation.xsd
file), run generate
Ant's task from build.xml
.
LocalRecommendationService
is a local (WebCenter Sites) implementation for the RecommendationService
interface.
RemoteRecommendationService
is a remote (Satellite Server) implementation for the RecommendationService
interface.