Thursday, May 29, 2008

Groovy SQL - That was easy


I got the chance today to get my hands dirty with GSQL (Groovy's Built in support for SQL), and I must say that it was rather easy. What I needed to do was connect to an embedded Derby database, parse a file, and populate the table with the results. Not to hard right. So, here is what my data looked like in the file I needed to parse:


2008/04/06,pubsubproxy,6166,4061
2008/04/07,pubsubproxy,6166,4061
2008/04/08,pubsubproxy,6170,4061
2008/04/09,pubsubproxy,6170,4061
2008/04/10,pubsubproxy,6170,4061
2008/04/11,pubsubproxy,6170,4061
2008/04/12,pubsubproxy,6170,4061
2008/04/13,pubsubproxy,6170,4061
2008/04/14,pubsubproxy,6170,4061

The best part about this was as I read each line in the file I added the data to the dataset for the table I was populating. The following shows a quick example of how to do this:

static parseData(path) {
println("parsing data for the following path: $path")
setDBSystemDir()
def loc = new File(path)

//Get an instance to the derby database
def sql = Sql.newInstance("jdbc:derby:dashboard;create=true", "org.apache.derby.jdbc.EmbeddedDriver")

//For Each line in the file, split the line based on the comma
loc.splitEachLine(',') {fields ->
def pid = fields[1]
def locResult = Double.parseDouble(fields[2])
def tloc = Double.parseDouble(fields[3])
def timeStamp = getDate(fields[0])

//Get the linesofcode dataset from the database
def ds = sql.dataSet("linesofcode")
//Add the properties from the current line in the file to the dataset.
ds.add(
PID:pid,
TIMESTAMP:timeStamp,
LOC:locResult,
TLOC:tloc,
)
}
println "Done Parsing Data"
}
So as you can see the first thing I do is get a new instance to my database:

def sql = Sql.newInstance("jdbc:derby:dashboard;create=true", "org.apache.derby.jdbc.EmbeddedDriver")

Next is the best part. I loop over each line in the file, splitting the line based of the "," and then dive right in poplulating my dataset with ds.add().

That was easy right? I thought so.

Thursday, May 8, 2008

JavaOne Day Two - All about SOA

As you can tell from my title I spent the bulk of my day attending sessions geared towards SOA. I have to say that the day started out fantastic when I attended the Integration Profile for Glassfish v3. This TS was given by Keith Babo and Andi Egloff of Sun and they did a phenomenal job of introducing us to Project Fuji, Sun's next generation integration runtime. I was pleasantly surprised to see when Keith gave the demo that they used a couple of the binding components that we, Gestalt, had developed. The good news is that Keith has put up a screencast of the demo he showed this morning that shows of Project Fuji, and also our RSS and XMPP components. Project Fuji and Glassfish ESB look very promising and I will be following them closely.

The rest of the day I spent my time going to various sessions on SOA. There is still a lot of talk about whether or not SCA is competing with JBI, or are they compliments. To be honest I'm still not sure my self, but we will see how it plays out.

I ended the day with the JBI 2.0 BOF. I really like the way the expert group is approaching this. They are doing a code first spec. What the heck does that mean? Basically what they are doing is going to be putting out code to the community implementing their ideas and gauges the communities feedback. Once they get the feedback they need then they will put it into the spec. I think this approach is better in that it will get the community involved in helping drive the specification, we just need to contribute and provide the expert group the feedback.

Well, that's a short and sweet for today, I'll try and get something up again tomorrow.

Wednesday, May 7, 2008

JavaOne - Day One

I know it's a day late, but I thought I would try and get this down for anyone who cares. JavaOne kicked off with a bang in the morning with the General Session in the morning. We were all greeted with some rockin music and dancers performing on stage. Half way through James Goosling graced us with his presence and launched T-Shirts into the crowd. Rich Green of Sun gave the talk and really focused on Java and how it runs everywhere with sample from Amazon, Sony Ericson, a very cool Facebook application, and concluded with a demo from Neil Young (Yeah, the rocker Neil Young). All in all, it was a very good start to JavaOne.

After the General Session I started hitting up some of the technical sessions. I hit up JRuby at first to see how that project is progressing. I must say, it's coming along really nice. The biggest take away was the IDE support that NetBeans is providing, it's really nice and improving every day.

I was also fortunate enough to get invited to listen in on the JBI expert group. I must say I was rather impressed with what was discussed. The biggest take away was make sure you keep track of JBI and keep an eye on it over the coming months, I know I will be watching very closely.

The next session I went to was upcoming Java language changes. Some of the highlights were the following:

  • Multi-catch statements
  • Safe re-throw
  • Modular programming
  • Annotations enhancement
The biggest focus was on the additional support for annotations.

Next up was secure mashups with OpenAjax. This was of particular interest to me since my team is current working on some mashup technologies. The stuff that OpenAjax is putting out is definitely worth keeping tabs on.

Finally to end the day I attended the Grails in depth session. I know that I have a particulair interest in Groovy and Grails, but I've got to say that Grails freaking rocks. If your team is doing Agile development and need to get quick rapid proof of concepts done, then you really need to take a good hard look at Grails. With its use of industry standards such as Hibernate and Spring, and the 40+ plugins that have been developed you'd be almost crazy to start from scratch and have to write all of that stuff yourself.

All in all it was a good first day, now I've got to get ready for day two. I'll try and get that up tonight or first thing tomorrow morning.

Tuesday, May 6, 2008

Pre JavaOne

Well, I'm fortunate enough to be in San Francisco for this years JavaOne confrence. I'm going to try and update my blog throughout the day on some of the highlights. Last night I went to the G2One meetup and listend to Guillaume Laforge give the state of the union on the Groovy and Grails community. There is a lot of excitement around booth of these communities and rightfully so. They are really cranking and getting a solid community behind them. Some interesting takeways from last night:

  • Groovy is going to be making several releases of the coming months, hoping to get to 2.0 by the end of the year.
  • Groovy has really been focusing on their performance and plans to improve it even more.
  • Grails has some really nice new features coming down the pipe for 1.1
Some other tidbids include
  • Look for support for Groovy/Grails in NetBeans 6.5
  • LinkedIn is using Grails to build one of their new services and been really happy with it and it's integration with their legacy systems.
  • Contegix has selected Grails as their platform of choice and talked about why.
It was a good start last night, and thanks to the G2One and NFJS folks for throwing a really nice function. More to come today on Day one at the concfrence.