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.
A target template defines a URL template structure that your implementation class can use to build URLs. For details of the target template, and how it is defined in the Atom plug-in framework configuration file, refer to the target-template topic.
You can access a target template from the requestContext object, which is passed to the methods that your implementation class inherits from the ServiceRegistryFeedAdapter class.
Example
This example uses a target template called "AccountTemplate" that has the following definition in the Atom plug-in framework configuration file:
<target-template>
<template-name>AccountTemplate</template-name>
<template>{target_base}/account/{account_number}</template>
</target-template>
The following getFeed method substitutes the value "ABC123" for the {account_number} variable in the definition. The variable {target_base} is replaced automatically with the root of the request URL. The resulting URL has the form "http://hostname:port/ServiceRegistryFeeds/context-root/account/ABC123".
public ResponseContext getFeed(RequestContext requestContext) {
.
.
.
Map<String,String> params = new HashMap<String,String>();
params.put("account_number", "ABC123");
String absoluteUrl = requestContext.absoluteUrlFor("AccountTemplate", params);
.
.
.
}