Both the AbstractAtomFeedView class and the AbstractRssFeedView class inherit from the AbstractFeedView base class and are used to pass Atom and RSS feed views, respectively. They are based on the ROME project and are in the org.springframework.web.servlet.view package.feed.

AbstractAtomFeedView requires you to implement the buildFeedEntries() method and optionally override the buildFeedMetadata() method (the default implementation is empty). The following example shows how to do this:

Java
public class SampleContentAtomView extends AbstractAtomFeedView {
    @Override
    protected void buildFeedMetadata(Map<String, Object> model,
            Feed feed, HttpServletRequest request) {
        /// implementation omitted
    }
    @Override
    protected List<Entry> buildFeedEntries(Map<String, Object> model,
            HttpServletRequest request, HttpServletResponse response) throws Exception {
        /// implementation omitted
    }
}
Kotlin
class SampleContentAtomView : AbstractAtomFeedView() {
    override fun buildFeedMetadata(model: Map<String, Any>,
            feed: Feed, request: HttpServletRequest) {
        /// implementation omitted
    }
    override fun buildFeedEntries(model: Map<String, Any>,
            request: HttpServletRequest, response: HttpServletResponse): List<Entry> {
        /// implementation omitted
    }
}

Similar requirements apply to the implementation of AbstractRssFeedView, as shown in the following example:

Java
public class SampleContentRssView extends AbstractRssFeedView {
    @Override
    protected void buildFeedMetadata(Map<String, Object> model,
            Channel feed, HttpServletRequest request) {
        /// implementation omitted
    }
    @Override
    protected List<Item> buildFeedItems(Map<String, Object> model,
            HttpServletRequest request, HttpServletResponse response) throws Exception {
        /// implementation omitted
    }
}
Kotlin
class SampleContentRssView : AbstractRssFeedView() {
    override fun buildFeedMetadata(model: Map<String, Any>,
                                feed: Channel, request: HttpServletRequest) {
        /// implementation omitted
    }
    override fun buildFeedItems(model: Map<String, Any>,
            request: HttpServletRequest, response: HttpServletResponse): List<Item> {
        /// implementation omitted
    }
}

The buildFeedItems() and buildFeedEntries() methods send an HTTP request if you need to access regional settings. The HTTP response is sent only to set cookies or other HTTP headers. The channel is automatically written to the response object after the method returns.

For an example of creating an Atom channel view, see post Aleph Arendsen in the Spring team.