Tuesday, November 25, 2008

Quote of Tomorrow via RSS

The latest release of Q2OH went live last night and now it truly delivers the Quote of Tomorrow. Each night a quote is chosen at random and added to the new RSS feed. It uses the Feeds plugin and the Quartz plugin to make it happen and both are remarkable. Here is what it took to create and schedule a job as part of a Grails app:

class FeedSeedJob {

def quoteService

def cronExpression = "1 0 0 * * ?"
def group = "QotdGroup"

def execute() {
def qotd = quoteService.getQotdQuote()
println "QOTD is ${qotd.content}"
}
}

I honestly don't know how it could be any easier.

Thursday, November 20, 2008

Today's Timestamp is Tomorrow's Date

I have been working on a RSS feed for Q2OH. The Feeds plugin makes it as easy as I can imagine. I have run into a quirk or two with data formats that have nothing at all to do with the plugin. It seems my Dates are Timestamps. Grails does such a good job of things just working that I never noticed before. Trying to format a Timestamp is not exactly the same as formatting a Date. Also, when an API needs a Date, it may choke on a Timestamp. This makes sense and once understood is not too huge a stumbling block. However I noticed one thing that I found interesting and works in my favor. Incrementing a Timestamp seems to turn it into a Date.

Since Q2OH is the Quote of Tomorrow, in the feed entry I add a day to the field that holds the day the quote was added to the feed. In the Domain Class Quote, qotd is a Date. Here is the entire code necessary to create the feed:

class FeedsController {

def rss = {
render(feedType:"rss", feedVersion:"2.0") {
title = "Q2OH >> Quote of Tomorrow"
link = "http://host:port/app/rss/feed"
description = "The Quote of Tomorrow"

Quote.findAllByQotdIsNotNull().each() { quote ->
entry("Quote for ${quote.qotd + 1}") {
link = "http://host:port/app/quote/display/${quote.id}"
author = quote.author
publishedDate = (java.util.Date) quote.qotd
quote.content // return the content
}
}
}
}
}

This results in an entry title of : Quote for Fri Nov 21 10:22:50 EST 2008

Originally the code was:
    entry("Quote for ${quote.qotd}") {

That had an entry title of: Quote for 2008-11-20 10:22:50.0

So if you ask me, tomorrow looks better than today.

Wednesday, November 12, 2008

I Can Empathize

Jan has a good point in this post... jan blog: It is very expensive to work with Grails. I got lucky when I found free hosting for a year. More accurately I was in the right place at the right time. If I hadn't already been experimenting with OpenSolaris and GlassFish for hosting Grails applications with a MySQL database, I wouldn't have seen the offer for a year of free hosting from OStatic. If I hadn't seen the offer I wouldn't have signed up and meet the requirements to get the free hosting. I have a VPS with 512 MB RAM. Even with the large size of a Grails .war file it will deploy multiple applications. I would like to try using shared libraries to be able to make very small .war files and host lots of applications. I haven't been able to get that to work on GlassFish V2 and most of the documentation I am finding for this feature is for GlassFish V3 Prelude. My hosting provider doesn't support V3 Prelude at this time so I'm not able to go that route just yet. When you consider it only costs $20 a month to host a full blown Java app that seems very reasonable. But how many $20's a month does it take to become unreasonable? I'm lucky, I still have 10 months to worry about how to pay the monthly hosting bill and I expect by then I will be able to find a provider supporting GlassFish V3, I'll have figured shared libraries out, and the economics of hosting a bunch of little applications will be reasonable.

Tuesday, November 11, 2008

SpringSource Gets Groovy

Wow! Big news this morning that SpringSource has acquired G2One, Inc. Read the press release and see what this means to the community. It seems to me that Rod Johnson is big on Grails. That is very exciting. All kinds of goodness should come out of this including improvements to the Eclipse support for Groovy and Grails. That is great news. Although I have been getting along just fine with NetBeans 6.5 it is important for the framework to have quality tooling, especially on Eclipse.

Thursday, November 6, 2008

Q2OH is now live!

Thanks to Ed's perseverance, Q2OH is now live and can be found at http://www.q2oh.com. You are all welcome to check it out, amaze your friends with a quote or just use it as a tool to procrastinate on your work.

Wednesday, November 5, 2008

What About GroovyMag Dave?

Kickin' down the cobblestones: Don't you hate blog posts about blogging?

I was reading through the first ever issue of GroovyMag and ran across a link to Dave Klein's blog. Having not read it in awhile I followed the link and found he was lacking an excuse for not blogging more often.

@Dave - Maybe it has something to do with the excellent contributions to the magazine?

Two More Failures

Two more issues with the production server have been resolved. First, GlassFish JVM settings were modified to make it actually work with only 512MB memory when deploying large .war files. I changed -client to -server and I reduced the max from 512 to 384. Not on the first try mind you. My first guess was to increase the perm gen but then nothing else would run on the server. It also took a lot of research to figure out how to have OpenSolaris forward http requests on port 80 to GlassFish running on port 8080. Most of the information I was initially finding was for using iptables on Linux. OpenSolaris doesn't have iptables and the previous way of using the inetd.conf file is no longer correct. So it took forever to find what is a very easy change. Enable ipfilter like so:

svcadm enable network/ipfilter
Then create an ipnat.conf file in the /etc/ipf directory with the following contents:

rdr xnf0 your.ip.add.ress/32 port 80 -> 127.0.0.1 port 8080 tcp

Load the file by using the -f attribute with ipnat:

ipnat -f /etc/ipf/ipnat.conf

Now the application can be deployed. But... in an effort to shrink the .war file, which was originally just short of 30 MB, I took out the fun features. This has left Q2OH an extremely simple application. So Q2OH 1.0 will be the Internet's simplest application.

Tuesday, November 4, 2008

I'm So Glad I Bought a Color Laser Printer

I can't wait to print out the first issue of GroovyMag. This looks like just the sort of resource I can use. I'm happy to support a quality publication like this and I look forward to purchasing future issues. Once I've actually read it I'll be sure to write a review.