Creating an Atom feed implementation class
Your Atom feed implementation class contains code that performs actions in response to Atom HTTP requests.
Procedure
To create an Atom feed implementation class, complete the following steps:
- Open your chosen Java™ development tooling environment.
- Create a new Java project, with a name of your choice.
- Add ServiceRegistryClient.jar to the project build path. ServiceRegistryClient.jar is located in the <WSRR_HOME> directory; this is the directory in which you installed the WSRR files.
- Add abdera-0.4.0-incubating.jar to the project build path; abdera-0.4.0-incubating.jar is located in the <WSRR_HOME> directory.
- Create a Java class that extends the ServiceRegistryFeedAdapter class.
- Override one or more methods, depending on the actions
that your Atom feed implementation class performs. The available methods
are as follows:
Method Description deleteEntry Delete an entry from a collection. deleteMedia Delete a media resource from a collection. destroy The destroy method is called when the feed is being taken out of service. This can occur when the WSRR application is being stopped or when the configuration for a feed has been changed. In the case of a configuration change, all the feeds running within the feed container are taken out of service and replaced with new instances that reflect the most recent configuration data. extensionRequest Any request that is not covered by the other methods in this table is passed to the extensionRequest method. getCategories Return an Atom categories document. getEntry Return an entry from a collection. getFeed Return an Atom feed document for a collection. getMedia Return a media resource. getWorkspaces Return the list of workspaces that the feed contributes to the service document. headEntry Return metadata for an entry in a collection. headMedia Return metadata for a media resource. init The init method is called just after the feed has been created and prior to it going into service. The FeedConfig object is passed to the init method; if the feed is to make use of information contained within the FeedConfig object at some point during its lifetime, then it must store a reference to the object. optionsEntry Return the options for an entry in a collection. optionsMedia Return the options for a media resource. postEntry Add a new entry to a collection. putEntry Update an existing entry. postMedia Add a new media resource to a collection, resulting in the creation of a new media link entry. putMedia Update a media resource. - Export your project to a JAR file; the project can contain more than one Atom feed implementation class.
- Load your JAR file into WSRR; see Loading an Atom application JAR file.
- Amend the WSRR_ENDPOINT_URL_PREFIX environment variable, if necessary. The WSRR_ENDPOINT_URL_PREFIX WebSphere® Application Server environment variable is created by the WSRR deployment process. It is set to "http://hostname:port" or "https://hostname:port", depending on whether WSRR is secure or not. For a cluster it is defined at cluster scope to point to an arbitrary cluster member. If you are using a web server front end or IP Sprayer, you must update the value of WSRR_ENDPOINT_URL_PREFIX accordingly.
- Optional: Amend the WSRR_ENDPOINT_URL_ABSOLUTE environment
variable, if necessary. The WSRR_ENDPOINT_URL_ABSOLUTE WebSphere Application Server environment
variable is created by the WSRR deployment process. Note: From WSRR Version 8.0 and above, the URIs returned in the Atom feeds are relative URIs by default instead of using absolute URIs. Set the WSRR_ENDPOINT_URL_ABSOLUTE property to true to return to using absolute URIs.
Example
Further specific aspects of creating an Atom feed implementation class are described in the following subtopics:
- Accessing context parameters
From your Atom feed implementation class, you can access the values of context parameters that are defined in the Atom plug-in framework configuration file. - Accessing initialization parameters
From your Atom feed implementation class, you can access the values of initialization parameters that are defined in the Atom plug-in framework configuration file. - Accessing regex field values
From your Atom feed implementation class, you can access the values of regex fields that are defined in the Atom plug-in framework configuration file. - Using a target template
In your Atom feed implementation class, you can use the target templates that have been defined in the Atom plug-in framework configuration file. - The FeedConfig interface
You can use the FeedConfig interface in your feed implementation class to access the FeedContext object, and any initialization parameters for the feed. - The FeedContext interface
You can use the FeedContext interface in your feed implementation class to access the context parameters for the feed application, and to share attributes between feed implementation classes. - Formatting your Atom feed responses
By default, the XML content of your Atom feed responses is not formatted. However, you can configure the Atom plug-in framework to insert line breaks and indents automatically.
Parent topic: Atom plug-in framework