Rejuvenation of the news feed

With the upcoming release of Spring 3.0.0 comes support for news feeds. That's a good reason to have a look at Pebble's implementation details... The next release of Spring comes with an AbstractRssFeedView. A good reason to rejuvenate Pebble's XmlView:

public abstract class XmlView extends JspView {
  ...
}

One reason why the JspView cannot be removed is the RSS news feed.

At the time of writing this Pebble instance is based on Spring version 2.5.x. I did't want to move completely forward to a milestone release. With some small changes to the AbstractRssFeedView and related classes the brand new RssView now serves the RSS news feed.

public class RssView extends AbstractRssFeedView {
  protected void buildFeedMetadata(Map<String, Object> model, Channel feed, HttpServletRequest request) {

    feed.setTitle(blog.getName());
    feed.setDescription(blog.getDescription());
    feed.setLink(blog.getUrl());
  }
...
protected List<Item> buildFeedItems(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response)
        throws Exception {

  List<Item> items = new ArrayList<Item>();

  List blogEntries = (List) model.get(Constants.BLOG_ENTRIES);
  for (BlogEntry blogEntry : blogEntries) {
    Item item = new Item();
    item.setTitle(blogEntry.getTitle());
    item.setAuthor(blogEntry.getAuthor());
    item.setPubDate(blogEntry.getDate());
    item.setLink(blogEntry.getPermalink());

    Description description = new Description();
    ...
    items.add(item);
  }
  return items;
}

The FeedAction in modern Spring-mvc 2.5 style is the link between Model and View:

@Controller
public class FeedAction {

  @RequestMapping("/feed.action")
  public ModelAndView process(HttpServletRequest request, HttpServletResponse response) {

    ModelAndView mav = new ModelAndView("rssBlogEntriesView");
    ...
  }
...
}

With a little bit of glue written in XML...

<bean id="beanNameViewResolver" class="org.springframework.web.servlet.view.BeanNameViewResolver">
  <property name="order" value="1" />
</bean>

<bean id="rssBlogEntriesView" class="net.sourceforge.pebble.web.view.impl.RssView" />

the RSS news feed is up and running. ;-) Hooray!

This post is the last post of a series about an OSGi experiment: Migrate a monolith to a modular OSGi application architecture.

The Beginning of an OSGi Experiment

Building OSGi ready pebble with Maven

Third time it's a charm

Extracting the first OSGi bundle

Extract the DAO layer

Adding the listener aspect

Extracting the E-Mail Service

Adding an OSGi command (Equinox)

The tale of a sitemesh experiment

In the middle of an OSGi experiment/series/pebble/In the middle of an OSGi experiment.md

Rejuvenation of the news feed


Header cover Photo by Matthew Henry from Burst