Category Archives: java

ROME sightings

A couple of new, very impressive ROME apps have been announced over the last few days.

Firstly, there was OpenVision TV's new I/ON Internet Video Console, which looks to be a very nice movie player that allows you to subscibe to movie channels.

Secondly, it was announced that the Beta My AOL feeds uses ROME. Currently the UI for this seems to be a little buggy (I can't add a new feed to it for instance), but when it works it is really, really good. Without a doubt it is a better aggregator than Google's iGoogle page or Yahoo's MyYahoo (which are both really only suitable for traditional news headlines). It would be better to compare it with MSN's Start.com, which is actually usable as a proper aggregator.

Delta-Encoded Feed Support in Rome

The Rome Fetcher now supports RFC3229 Delta-Encoded feeds (in CVS). The Rome Fetcher already supports GZipped feeds and conditional get. Hopefully, this additional feature should ease the burden on syndication client authors.

There are test cases in CVS, but I have failed to find any real world servers to test the delta-encoding support against, so any stories of succesful use (because obviously there could not possibly be any bugs…) would be appreciated.

Retrieving GMail Atom feed with Rome

Those of you with a GMail account might like this. It retrieves the GMail
Atom feed of you inbox status using the Rome Syndication libraries (Grab Rome 0.4 and Rome Fetcher 0.4 from http://rome.dev.java.net). You'll need to edit the BasicAuthenticator
class to set your username and password.

Gmail currently doesn't support conditional-gets or ETags, so unfortunately
it has to retrieve the entire feed each time.

public class Main {       
	public static void main(String args[] ) throws IllegalArgumentException, 
	MalformedURLException, IOException, FeedException, FetcherException {
		FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance();
		FeedFetcher fetcher = new HttpURLFeedFetcher(feedInfoCache);
		java.net.Authenticator.setDefault(new BasicAuthenticator()); // turn on authentication
		SyndFeed feed = fetcher.retrieveFeed(new URL("https://gmail.google.com/gmail/feed/atom"));
		System.out.println(feed.getTitle());
		int feedSize = feed.getEntries().size();
		System.out.println("Contains " + feedSize + " items");
		for (Iterator iter = feed.getEntries().iterator(); iter.hasNext(); )
		{
			SyndEntry entry = (SyndEntry) iter.next();
			System.out.println(entry.getTitle());
			System.out.println("\t excerpt: " +
					entry.getDescription().getValue());
		}
		while (true) {
			try {
				Thread.sleep(1000 * 60 * 10); // check every 10 minutes
			} catch (InterruptedException e) {
				// ignore } System.err.print("Retrieving..");
				feed = fetcher.retrieveFeed(new
						URL("https://gmail.google.com/gmail/feed/atom"));
				System.err.println("Done.");
				int newFeedSize = feed.getEntries().size();
				// note that this won't detect new items if the feed size is at maximum
				if (feedSize != newFeedSize) {
					System.out.println("New messages detected. There are now " +
							newFeedSize + " items");
					int itemsToShow = newFeedSize - feedSize;                   
					int count = 0;
					for (Iterator iter = feed.getEntries().iterator();
					iter.hasNext();) {
						SyndEntry entry = (SyndEntry) iter.next();
						System.out.println(entry.getTitle());
						System.out.println("\t excerpt: " +
								entry.getDescription().getValue());
						count++;
						if (count >= itemsToShow) {
							break;
						}
					}                  
					feedSize = newFeedSize;
				}
			}
		}           
		static class BasicAuthenticator extends Authenticator {
			/**
			 * @see java.net.Authenticator#getPasswordAuthentication()
			 */
			protected PasswordAuthentication getPasswordAuthentication() {
				if ("gmail.google.com".equals(getRequestingHost())) {
					return new PasswordAuthentication("user.name", "password".toCharArray());
				} else {
					return null;
				}
			}
		}
	}

Rome Fetcher

The 0.3 release of the Rome Syndication Library marks the first release of the
Rome Fetcher.

This library provides a simple but useful implementation of a HTTP fetcher for RSS/Atom feeds. It supports
HTTP conditional gets (ie: last modified and ETag handling),
and enables users to follow the Atom aggregator behaviour recommendations.

As has been
noted
over the
last couple
of days syndication clients often ignore the finer points of feed retrieval. The Rome
Fetcher is designed to do the right thing in the simplest way possible.

It comes with a decent set of test cases (using an embedded Jetty instance) – although they are currently disabled as they crash Maven (I believe this is a Maven bug).

The other big selling point is that in introduces no new libraries above the requirements used by Rome (ie, JDom beta 10).

Rome HTTP Fetcher

As Pat
mentioned, I've done a http fetching library for Rome. It is now
checked in and available.

It supports HTTP conditional gets
(ie: last modified and ETag handling) and GZip encoded feeds.
It should enable user to write aggregators that follow the
Atom aggregator behaviour recommendations.

Some docs are available (although
this will probably move).

If you are interested, please give it a go and report issues on the Wiki or on the Rome dev mailing list.

Some tips for customising Maven built websites

Struggling to work out how to customise your Maven built website? Here's
a few thing I've figured out. All this is actually documented on the Maven site, but I found it a little
hard to find.

The first thing I wanted to do was include some custom pages on my site. To do this, you need to create an
“xdocs” directory in the root of your project, and put the files you want to end up on your site in there. Anything
except .xml files will be copied to the target/docs directory, which allows you to use images or plain HTML files. If
you want your pages to be generated in the same style as the rest of the Maven generated pages, you need to use a format
called xdocs. The xdocs format is (somewhat) documented on
the Jakarta site
(ie, there is an example file). In my experience so far, it is basically a cut down, xmlised version
of html.

Now you can run maven site:generate and your new page will be generated. However, it will not show up on
the menu yet. To do that you will need to create a file called navigation.xml in your xdocs directory. The format
for this file is documented on the Maven site. I needed to leave out the
encoding from the example for it to work for me, however.

navigation.xml also controls what Maven calls the “navigation bar”. This is the bar across the top of the page,
that typically has a link to the Maven site at the top right side. To modify that, create a “links” section inside the body
of navigation.xml.

Here's an example navigation.xml:



<?xml version="1.0"?>
<project name="${project}">
	<title>Classifier4J</title>
	<body>
		<links>
			<item name="Sourceforge"  href="http://sourceforge.net/" />
			<item name="Blog"  href="http://www.mackmo.com/nick/blog/"/>
		</links>
		<menu>
			<item name="Home" href="index.html" >
				<item name="Usage" href="usage.html" />
				<item name="Applications" href="applications.html" />
				<item name="Download" href="download.html" />
			</item>
		</menu>
		<!-- footer will be placed above the (c) -->
		<footer>
			<a href="http://sourceforge.net/projects/classifier4j">
			<img src="http://sourceforge.net/sflogo.php?group_id=72748"
			border="0" alt="sf logo"/>
			</a>
		</footer>
	</body>
</project>


Now I'm trying to figure out how to customise the Checkstyle plug-in settings…

Some links I found useful:

Then and Now

In the spirit of Jeremy's then vs now post, here is my
version (since I'm 27, turning 28 in a month and… actually I don't need a reason to do this.). 10 years ago I was in my
final year of high-school.

Then:So what did you do today?
Now:Worked through a bit of a security audit, (somewhat regretfully) turned down a job offer and put off lots of questions until tomorrow.
Then:You still procrastinate, then?
Now:Not too much anymore – but the questions were boring.
Then:Is work fun? Do they pay you a lot? Are there cool computers? Do you have to wear a tie?
Now:Work is fun sometime, but not as often as I'd like. They pay okay, but I have a mortgage. The computers aren't that interesting,
but I have to wear a tie.
Then:So work sux, then?
Now:No, there are lots of the smartest people I've ever met at work. I just don't like what I do at the moment.
Then:What's that, then?
Now:I'm a team leader for a team of 7 Java developers. We work on a financial web application.
Then:So you do lots of coding then?
Now:I wish! I spend all my time managing my team.
Then:You!!! – a manager?!?!?
Now:Exactly.
Then:But you could never do that.
Now:Well, my team keeps getting bigger and everyone elses gets smaller. Weird, isn't it?
Then:So you are just some manager dude. You can't code for shit, then.
Now:I'd kick you ass *S*
Then:Do you have a girlfriend?
Now:I married her :-)
Then:So what should I do differently?
Now:Not much – things turn out pretty good. Maybe if you finished a couple of those project you start it would be okay,
though!

I'm Back

It never rains but it pours…. Due to circumstances that weren't really beyond my control but were
neglected by me BadMagicNumber now has a new home. My email address has changed as well – nick at mackmo dot com.

I didn't loose all my blog posts, but the permalinks dates and order of them are obviously stuffed up. I have no intention of
fixing that, though.

On the positive side I am now running at a site with Java Support, so I am using
Blojsom, and might be able to do some other funky
stuff. I'm impressed with Blojsom so far – I did myself the template to figure out how a few
thing hung together.

There may be some teething problems while I sort things out. In particular there seem to be connectivity issues which I'm
keeping my eye on.