Tuesday, October 30, 2007

I've been keeping my mouth shut!!!!

Well since my beloved Wolverines started out 0-2, I've been keeping my mouth shut this football season. I think it's time I start to talk some smack again. My only fear is that once I do, my teams will fall a great defeat to a lesser opponent, but hey who cares.

So after Michigan's dismal start, they have now reeled off 7 wins in a row. Granted the Big 10 isn't so good this year, but we have been winning despites some critical injuries. Last week Big Blue pulled a win out with their starting running back and quarterback on the sidelines in street clothes. Buckeyes beware!

On another note, I never brag about my second favorite team, but this year I have to. The University of Kansas is playing some football. I don't care what everyone is saying about how weak their schedule is, that fact is they are 8-0. They have beaten Colorado, K-State, and Texas A&M on the road. Years past the we couldn't win a game on the road. You can say what you want about the Jayhawks and their weak schedule, but the fact remains that they have a damn good defense (5th in the Nation I believe), and an offense that can put points on the board against any team in the country. I'm not saying they are going to win the National Championship (For one, the BCS would never allow a team like KU to be in the title came, but that's a whole other topic for discussion), but I wouldn't be surprised if they rolled into Arrowhead Stadium on November 24th looking to win the Big 12 North and a shot at the Big 12 title.

With all the fun of college football, we sometimes forget that college basketball is right around the corner. My Jayhawks kick off the season on Thursday with an exhibition game against Pittsburg State. Rock Chalk Jayhawk.

I think it's going to be a good year for my Jayhawks, hopefully the basketball team can start out like the football team and end with a National Championship.

Ok, enough sports talk. I'll get back to blogging about tech stuff next time. I'm hoping to work through some more Groovy examples, and get some of those up here. Until next time....Rock Chalk Jayhawk...Go KU!

Wednesday, October 10, 2007

Two Minute Drill for Groovy

I know I promised more on Groovy, and I will get some more examples up here. However, one of my co-workers, Joe Kueser, just posted a great blog about Groovy. Basically Joe's Blog, "What Makes Groovy So...Groovy?", is a two minute read that provides a great summary of a lot of the features in Groovy. Be sure to check out Joe's Two Minute Drill.

Saturday, October 6, 2007

Converting Dom to Groovy Code

I've been looking into and learning a little Groovy on the side. One of the things I'm most interested in is learning how to use the MarkupBuilder provided by Groovy. Essentially this, in my opinion, is a much better way to parse and construct XML. As a developer I use XML almost daily. First I'm looking at integrating this into my unit tests. Today I stumbled on the DomToGroovy class and found this pretty cool. I was trying to figure out how to construct XML using Groovy. I knew what the XML looked liked, so using the DomToGroovy class I could get a good idea what the Groovy code would look like that I needed to write. Below is a sample of how to do this, and I recommend the GroovyConsole to test with.


import javax.xml.parsers.DocumentBuilderFactory
import org.codehaus.groovy.tools.xml.DomToGroovy

def xmlExample = """
<jbi:message tns="http://j2ee.netbeans.org/wsdl/rssWsdl"
type="tns:rssWsdlOperationRequest" version="1.0"
jbi="http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper">
<jbi:part>
<entrylist xmlns="http://xml.netbeans.org/schema/1.0/extensions/rssbc">
<entry>
<title>Entry 1</title>
<link>http://localhost:8000/rss/feed/entry1<link>
<description>First Entry</description>
<publishdate>Dec 7, 1976</publishdate>
</entry>
<entry>
<title>Entry 2</title>
<link>http://localhost:8000/rss/feed/entry2<link>
<description>Second Entry</description>
<publishdate>Dec. 7, 1976</publishdate>
</entry>
</entrylist>
</jbi:part>
</jbi:message>
"""

def builder = DocumentBuilderFactory.newInstance().newDocumentBuilder()
def inputStream = new ByteArrayInputStream(xmlExample.bytes)
def document = builder.parse(inputStream)
def output = new StringWriter()
def converter = new DomToGroovy(new PrintWriter(output))

converter.print(document)
println output.toString()

The output essentially shows you what the Groovy code would look like to construct the XML that we provided.

jbi:message(type:'tns:rssWsdlOperationRequest', version:'1.0',
xmlns:jbi:'http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper',
xmlns:tns:'http://j2ee.netbeans.org/wsdl/rssWsdl') {
jbi:part) {
EntryList(xmlns:'http://xml.netbeans.org/schema/1.0/extensions/rssbc') {
Entry) {
title('Entry 1')
link('http://localhost:8000/rss/feed/entry1')
description('First Entry')
publishDate('Dec 7, 1976')
}
Entry) {
title('Entry 2')
link('http://localhost:8000/rss/feed/entry2')
description('Second Entry')
publishDate('Dec. 7, 1976')
}
}
}
}

I think this is a pretty slick way to quickly generate a code sample so that you can quickly get started. More to come on Groovy later......