Class RssFeed

java.lang.Object
com.oorian.HttpFile
com.oorian.rss.RssFeed

public abstract class RssFeed extends com.oorian.HttpFile
Abstract base class for serving RSS 2.0 feeds from an Oorian application.

Extend this class and annotate with @Page to expose an RSS feed endpoint. Implement the single abstract method createChannel() to build the channel with items.

RssFeed handles the HTTP content type (application/rss+xml), XML declaration, RSS root element with version and namespace attributes, and serialization to the response.

Supported RSS Extensions:

Namespace declarations are only added when the corresponding features are used.

Usage:


 @Page("/feed")
 public class BlogFeed extends RssFeed
 {
     @Override
     protected RssChannel createChannel()
     {
         RssChannel channel = new RssChannel("My Blog", "https://example.com", "Latest posts");
         channel.setLanguage("en-us")
                .setAtomSelfLink("https://example.com/feed");

         channel.addItem(new RssItem("First Post", "https://example.com/post-1", "Summary text"));
         return channel;
     }
 }
 
Since:
0.1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new RssFeed instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract RssChannel
    Creates and returns the RSS channel for this feed.
    protected void
    Builds the RSS XML document from the channel returned by createChannel().
    protected void
    Appends the RSS XML document to the output buffer.

    Methods inherited from class com.oorian.HttpFile

    addResponseHeader, create, getCacheControl, getDocumentUrl, getFullUrl, getHost, getHttpRequest, getOriginalParameters, getParameter, getParameterAsFloat, getParameterAsInt, getParameterAsLong, getParameterAsShort, getParameters, getParametersAFloat, getParametersAsInt, getParametersAsLong, getParametersAsShort, getParameterValues, getPath, getServletPath, getSessionId, getUrl, getUrlParameters, getWebResponse, hasParameter, hasUrlParams, initializeFile, isWritten, onCreated, onWriteComplete, setCacheControl, setCharacterEncoding, setContentType, setResponseHeader, setUrlParameters, toString, toString, write

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • RssFeed

      public RssFeed()
      Creates a new RssFeed instance.
  • Method Details

    • createFile

      protected void createFile()
      Builds the RSS XML document from the channel returned by createChannel().

      Constructs the <rss> root element with version 2.0 and conditionally adds the atom and content namespace declarations based on usage.

      Specified by:
      createFile in class com.oorian.HttpFile
    • toString

      protected void toString(StringBuilder sb)
      Appends the RSS XML document to the output buffer.
      Specified by:
      toString in class com.oorian.HttpFile
      Parameters:
      sb - The StringBuilder to append XML content to.
    • createChannel

      protected abstract RssChannel createChannel()
      Creates and returns the RSS channel for this feed.

      Subclasses must implement this method to build the channel, set its metadata, and add items. This method is called once per request during createFile().

      Returns:
      The configured RssChannel for this feed.