Parsing an RSS feed

To read in an RSS feed you have to provide basically two things: a source from where to read the feed (URL, File, InputStream or Reader) and a ChannelBuilder which builds the news channel object model. Currently two ChannelBuilder are available: one in-memory (see de.nava.informa.impl.basic.ChannelBuilder) and the other one using the Hibernate O/R mapping mechansim to persist the data in a relational database (see de.nava.informa.impl.hibernate.ChannelBuilder). The following code fragment demonstrates the usage:

import de.nava.informa.core.ChannelIF;
import de.nava.informa.impl.basic.ChannelBuilder;
import de.nava.informa.parsers.FeedParser;
File inpFile = new File("javanews.xml");
ChannelIF channel = FeedParser.parse(new ChannelBuilder(), inpFile);

Further information about the channel object can be found in the JavaDoc for ChannelIF.

Parsing an OPML descriptor

To read in a OPML (Outline processor markup language) you can use code as follows:

import de.nava.informa.parsers.OPMLParser;
// parse inpFile file and return a collection of FeedIF objects
Collection feeds = OPMLParser.parse(inpFile);

This provides a convenient facility to read in a collection of FeedIF objects which might be helpful for retrieving news channels.

Build your own channel object model

For creating your own news channel object model in-memory, look at following example:

ChannelIF channel = builder.createChannel(chanName);
channel.setDescription("Test Channel: " + chanName);
ItemIF item1 = builder.createItem(channel, "Item 1 for " + chanName,
                                  "First in line", new URL(""));
ItemIF item2 = builder.createItem(channel, "Item 2 for " + chanName,
                                  "Second in line", new URL(""));

If you like to make use of the persistent backend using de.nava.informa.impl.hibernate.ChannelBuilder you can achieve the above with:

SessionHandler handler = SessionHandler.getInstance();
Session session = handler.getSession();
ChannelBuilder builder = new ChannelBuilder(session);
Transaction tx = null;
try {
  tx = session.beginTransaction();
  ChannelIF channel = builder.createChannel(chanName);
  channel.setDescription("Test Channel: " + chanName);
  ItemIF item1 = builder.createItem(channel, "Item 1 for " + chanName,
                                    "First in line", new URL(""));
  ItemIF item2 = builder.createItem(channel, "Item 2 for " + chanName,
                                    "Second in line", new URL(""));
catch (HibernateException he) {
  logger.warn("trying to rollback the transaction");
  if (tx != null) tx.rollback();
  throw he;
finally {

Index and search news items

Please look at ChannelIndexer and ChannelSearcher in the meantime or find more information about the usage inside the test cases (directory: test/src/de/nava/informa/search).

Serialize channel as RSS

Some day you might want to export a news channel to a file. The informa library does support writing a news channel to RSS 0.91 and 1.0 formats. Please look at the following example:

import de.nava.informa.core.ChannelExporterIF;
import de.nava.informa.exporters.RSS_1_0_Exporter;
ChannelExporterIF exporter = new RSS_1_0_Exporter("myfeed.rdf");
// assuming you have a ChannelIF object available as channel

Sorting of news items

Please see the question in the FAQ.

Managing updates

There are two utility classes provided by the Informa API which are

  • UpdateChannelTask using the Push-approach (registering event listeners) and
  • FeedManager using the Pull-approach (suitable for web pages, i.e.)

Hibernate configuration

The Hibernate 2 library files are provided with the informa distribution. If you do not want to use the Hypersonic SQL database, you have to make sure that you include any files required for JDBC connectivity to the database in the classpath. The first file that to investigate is the file. Place this file in your classpath so that Hibernate can find it at runtime. This file contains the runtime settings that Hibernate will use when it is started up. Here is an example:


There are also DDLs (for MySQL, PostgreSQL and HSQL) for the tables needed by Informa's hibernate backend provided with the distribution under the directory sql.