feed

You use the feed element in the Atom plug-in framework configuration file to define a single feed within a feed application.

The feed element is required; you can define as many feed elements as you want.

The feed element contains the following child elements:
Element Description
description A description of the feed; this element is optional.
display-name A display name for the feed; this element is optional.
feed-name The name of the feed; this name must be unique within the feed application. This element is required.
feed-class The implementation class for the feed. This class must be loaded into WSRR in a plug-in JAR file; see Loading an Atom application JAR file for more information. This element is required.
init-param An initialization parameter that is passed to the implementation class. The parameter is stored in the FeedConfig object, which is made available to the implementation class; for details of accessing an initialization parameter in the feed implementation class, see Accessing initialization parameters. This element is optional; you can define as many init-param elements as you want.
The init-param element contains the following child elements:
description
A description of the initialization parameter; this element is optional.
param-name
The name of the initialization parameter; the name must be unique within the feed. This element is required.
param-value
The value of the initialization parameter; this element is required.
feed-mapping You use the feed-mapping element to define mapping rules, in the form of regular expressions, that are used to match an incoming HTTP request to this feed, and to call the appropriate method. This element is optional; you can define as many feed-mapping elements as you want.

The atom plug-in framework attempts to match an incoming HTTP request to the mapping rules strictly in the order that you define them in the configuration file. As soon as a match is found, the request is routed to the feed in which that feed-mapping element is defined, and the corresponding feed-mapping settings determine how the request is processed. This can help to simplify the regular expressions that you define, because it means that you can safely use more general expressions, that might match several different URIs, provided that you define them after more specific expressions.

The feed-mapping element contains the following child elements:
regex-pattern
A regular expression that is used to match an incoming HTTP request; if an HTTP request matches the regular expression, it is routed to this feed. For details of the regular expression syntax, see http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html#sum.
The regex-pattern element has a target type attribute that specifies the type of Atom resource that is returned in response to an HTTP request that matches the specified regular expression. The target-type attribute must have one of the following values:
  • "SERVICE": Service document
  • "COLLECTION": Feed document
  • "ENTRY": Entry document
  • "MEDIA": Media resource
  • "CATEGORIES": Category document
The value of the target-type attribute determines which method is called in the feed implementation class; see Creating an Atom feed implementation class for more information.
regex-field
If you define one or more regex-field elements, then when the regular expression is matched against HTTP request URL, the values of the captured groups that are identified in the regular expression are stored automatically in fields of the names specified. Your feed application can then easily obtain the values of the captured groups from these fields without having to parse the URL.
You can, for example, use regex-fields to obtain the successive parts of the HTTP request URL, between the "/" characters.
For an illustration of the use of the regex-field element, see the example in this topic. For details of accessing the field values in the feed application, see Accessing regex field values.
This element is optional.

Example

This example defines an Atom feed called "EndpointsFeed" whose implementation class is com.ibm.serviceregistry.feeds.ExampleFeed.

An initialization parameter, called "debug", is passed to the implementation class, with a value of "false".

If the context root for the application in which this feed is defined is "/WSRR/service", an HTTP request URL of the form "http://hostname:port/ServiceRegistryFeeds//WSRR/service/endpoints" is routed to this feed, and an Atom feed document is returned.

If the context root for the application in which this feed is defined is "/WSRR/service", an HTTP request URL of the form "http://hostname:port/ServiceRegistryFeeds//WSRR/service/endpoints/AccountCreation/online" is routed to this feed. "AccountCreation" is stored in a field called "endpoint_name", and "online" is stored in a field called "endpoint_status". An Atom entry document is returned.

<feed>
  <description>A feed that returns online service endpoints</description>
  <display-name>Service endpoints feed</display-name>
  <feed-name>EndpointsFeed</feed-name>
  <feed-class>com.ibm.serviceregistry.feeds.ExampleFeed</feed-class>

  <init-param>
    <description>Debug flag</description>
    <param-name>debug</param-name>
    <param-value>false</param-value>
  </init-param>

  <feed-mapping>
    <regex-pattern
      target-type="COLLECTION">
      /endpoints
    </regex-pattern>
  </feed-mapping>

  <feed-mapping>
    <regex-pattern
      target-type="ENTRY">
      /endpoints/(\w+)/(\w+)
    </regex-pattern>
    <regex-field>endpoint_name</regex-field>
    <regex-field>endpoint_status</regex-field>

  </feed-mapping>

</feed>