A Groovy Time at JavaOne 2009

Monday, June 8th, 2009

Although there was a somewhat somber mood at JavaOne this year (thanks Oracle!), you couldn’t help but notice the awareness and general excitement for dynamic languages and in particular Groovy (here is some additional proof). And as my colleague Sten Anderson pointed out already, Groovy won the Script Bowl 2009 which was represented by the languages’ project manager Guillaume Laforge. Last year’s winner was JRuby due to a dazzling eye candy type of Demo, but of course, was a useless application for the real world like most demos are. I wouldn’t be suprised a bit to see Scala win it next year as it seems the momentum for it is growing.

A couple of us got the chance to walk back to the hotel one night with Guillaume who was very humble about the win and gave all the credit to the Griffon team for giving him a cool demo to show off. The demo is a Twitter meets Google Earth mash up called Twittersphere that actually was backed by NASA’s World Wind API. You can download the source code for the winning demo here. Very cool!

The next major Groovy event was the following night at the Griffon Birds of a Feather (BOF). Danno Ferrin and James Williams gave a thorough presentation about Griffon and what’s coming in the near future for 0.2 – such as runtime addons. For being a BOF and starting at 8:30 PM, there was a nice turnout which shows how popular Griffon is getting these days. Since Griffon builds on Grails 1.1, it is a very mature project despite the 0.1.1 version number. So, if you are needing to build a desktop-based RIA and JavaFX is not for you… check out Griffon. In fact, as we found out later, Danno Ferrin managed to deploy his Griffon based Twitter client Greet to the newly released Java Store less than 24 hours after the opening of the store.

After the Griffon BOF was over we stayed around and watched Scott Davis interview Guillaume Laforge for his ThirstyHead series and Guillaume talked about current and future state of everything Groovy. Watch it here.

The next big and well attended Groovy event was Dave Klein’s Grails Enterprise Integration Strategies BOF followed by a live recording of the Grails Podcast show. Dave gave a good presentation on how to configure a Grails application to communicate with older JEE standards such EJB 2 and JMS. He also described how his company used Grails and JSF together in one web app taking advantage of using partials to call out to a JSF component to render out some HTML. He later told us that none of that made it into production as they ripped out the cancer he called JSF.

The Groovy Podcast guys (Sven Haiges and Glen Smith) came onto the stage and interviewed a panel of guests for their 87th episode. The panel consisted of Scott Davis, Dierk Koenig of “Groovy in Action” fame, and the three Griffon committers mentioned above. It was an entertaining show and it was cool to be there since this was Glenn’s and Sven’s first show since meeting face-to-face at this years JavaOne. Listen to the episode here. Thanks to Bryan Williams, Sven and Glen unexpectedly got an excellent recording for their podcast.

As we were going to the Groovy related talks we were hoping to meet other Groovy/Grails User Group members from different parts of the world but unfortunately we did not. A couple of us at JavaOne were representing the Chicago Groovy User Group (CGUG) by wearing black shirts with the name and logo on them (we were pleased when we received some compliments on them).

All-in-all, going to the G3 sessions, and meeting some key contributors of this community made for a fun and exciting conference even though more Groovy related sessions would have made it perfect. We can only hope for more dynamic language support next year as Oracle takes the reins.


Bookmark and Share

posted by Bill Gloff

Mavenize Your Flex/AIR App

Monday, February 9th, 2009

I recently had a need to create a maven project that could compile my Flex application and package it up as an AIR app. After fighting with Flex-Mojos 2.x, I decided to try out the new 3.0-SNAPSHOT and finally got a successful compile and package. The main project page for Flex-Mojos can be found here.

Anyways here’s my full pom.xml. Make sure to take note of the following:

  • Lines 8-12 : Include a parent POM provided my the flex-mojo’s project. Makes it so that you do not have to include all the flex and air dependencies yourself.
  • Line 18 : Set the package to swf. Hopefully this can be fixed in the future because I’ve seen other posts about how you should be able to put aswf there for an AIR application but that did not work for me.
  • Lines 25-60 : Since the final artifact is a swf, you still need to run the adt command to convert it to an AIR package. I’ve taken this snippet of code from the following blog. Please take a look at that as it explains how this command expects a digital certificate to reside in the classes/cert directory and how the passwords work.
  • Lines 63-87 : New repository url for the flex-mojos project
  • Lines 93-96 : Need to specify where your Flex SDK lives so that the adt.jar can be executed during the package phase.

That should do it. Run mvn package and you should see an .air file in your root project directory. It’s not a perfect solution but at least it works. If you know anything I could change or improve on please let me know.

Bookmark and Share

posted by Bill Gloff

Choosing a Flex Architectural Framework

Friday, January 30th, 2009

If you’re working on a moderate to complex Flex/Air application I hope you are using some kind of MVC style framework to help with organizing your components and the interactions between them. If you do not use a framework, you will unknowingly be creating your own. This, consequently, makes it harder for others to get up to speed with any maintenance that will need to be completed, and you will be on the hook to create all the related documentation. Also, why re-invent the wheel when pre-existing frameworks, such as Cairngorm, PureMVC, Swiz, or Mate, already implement best practices and are field-tested? All you need to do is set aside a little time to learn them.

I’m currently working on a greenfield project where I have a Flex/AIR front-end talking to RESTful services provided by Groovy on Grails. I’m a few weeks into the project, but my latest challenge has been deciding on what MVC ActionScript/Flex framework to use. Let me attempt to tell you a little about my process thus far, in case you’re going through this yourself.

If you’ve done any Flex at all I’m sure you’ve heard about the market-leading framework Cairngorm. It’s currently the most popular choice for enterprise worthy applications. It took its inspirations from the Sun J2EE Blueprint Catalog and implemented all the Java based patterns in ActionScript (AS). Some of these well-known patterns are the Command, Front Controller, MVC, Singleton, Value Object, and the Delegate. I believe some reasons for the success of Cairngorm is because AS is very similar to Java with a little mix of JavaScript thrown in for good measure. Then, you add the fact that Adobe (and previously Macromedia) likes targeting server-side Java guys (LiveCycle Data Services anyone?), which should make them comfortable with Cairngorm once they get up to speed on Flex and AS. Since it’s been around for a long time there’s quite a bit of documentation on it (in blogs, as well as books), and even code generators, which attempt to speed up development time. In Flex Builder 4, which will be released later this year, Adobe will be integrating Cairngorm support into Flex Builder out of the box. Very appealing indeed!

I know PureMVC is getting a lot of hype lately as it enforces a strict MVC and has been ported to a lot of different platforms such as Java, AS, and even Objective C and Ruby. I haven’t used it, but I read up on it quite a bit. It seems a little awkward to me since it doesn’t take advantage of Flex binding. I know this is because it remains a language/platform independent framework that focuses on giving you a way to do MVC. I’m sure PureMVC has its merits though, and I believe I would enjoy it if a project I was working on already had it… same for Cairngorm. The only things I would look to add to each of those would be some good ole Inversion of Control Prana style (now called Spring ActionScript) to spice things up, and simplify some of the code.

The next framework I read up on was Swiz. This seems like a great combination of MVC and IOC, and it’s the only framework to use AS3 Metadata to wire up all your components. It is a very innovative approach with the only concern being maturity compared to Cairngorm and PureMVC. I probably would look into this one a bit more if it wasn’t for my first choice…

I started my project thinking that I’ll go with Cairngorm, but as you probably figured out, I changed my mind. This happened after I saw a demo of a Flex-based framework called Mate. In my opinion, Mate is one of the more lightweight frameworks out there. I say lightweight because it attempts to use native Flex events whereas in Cairngorm you are forced to have your events implement a Cairngorm interface. This is a dependency I do not care much for. Mate’s philosophy is to make your views oblivious to what is going on in the backend… from getting some data from your server to injecting those values into your model. You can have all your custom components be free of any references to any Mate related classes, which is a good sign for an MVC oriented framework. Mate has a concept that none of the other frameworks have that I find intriguing… maybe because its different from the J2EE inspired frameworks, and I am digging how it takes advantage of MXML, whereas the others use more ActionScript. Basically, the main concept of Mate is to define an Event Map, which is just a switchboard of what actions to invoke when a specific event is fired. This is where most of your server calls come into play and injecting the values into your Managers which are singleton based models for your views and also take advantage of bindings. This Event Map is all tag based, which I like, but since it’s all AS under the covers, you probably can implement your Event Map in a regular class if you prefer.

I’ve just begun really using Mate and I’m enjoying the process of wiring everything together. It seems well thought out and simple, but also elegant. I’m also enjoying the fact that I’m programming in more of an event-based language, which these frameworks promote, especially Mate. As I get further into my project I’ll try to give updates about how my experiences with Mate are transgressing.

To get a better comparison of these frameworks you should read the 5 part article “FrameworkQuest 2008“. It’s a great read seeing how Tony Hillerson went and developed the same Twitter application using these 4 different frameworks and discusses the benefits and weaknesses of each.

So go and find yourself a framework to use. I’m sure whichever one you pick will work out for the best… if not, well then there’s other options as you can see.

Bookmark and Share

posted by Bill Gloff

Groovy Dates Are Groovy

Thursday, January 8th, 2009

I recently came across a new tidbit of info while working with the Date class in the GDK and I thought I would point it out real quick. I wanted a easy way to compare two Date objects while disregarding time. One to represent today’s date and the other to represent a future date. So I took a look at the GDK docs for the Date class and I noticed that since version 1.5.7, Groovys’ Date now has a static parse(..) method and a instance format(..) method which worked out nice for me in terms of writing less code. Here is a snippet of my code:

def myFormat = 'MM/dd/yyyy'
if Date.parse(myFormat, '02/03/2009') >= Date.parse(myFormat, new Date().format('MM/dd/yyyy')) {...}

If you did Date comparisons using regular Java, you would know that you couldn’t get away with something like this. I’m loving Groovy more and more everyday.

If you have an even shorter or more succinct way of coding this simple comparison, please share it.

Bookmark and Share

posted by Bill Gloff

Chicago Groovy User Group

Tuesday, January 6th, 2009

I wanted to remind everyone that in one week from today, the Chicago Groovy User Group will have its inaugural meeting in the Chicago Loop. The featured speaker will be Sten Anderson from CITYTECH who will give a talk on using Groovy to create DSL’s. There will be free food and drinks available and a book raffle provided by CITYTECH. Please visit http://cgug.org for more information and to sign up for future notifications.

We have some cool ideas planned for upcoming meetings. Besides having nationally recognized speakers and authors stop by, we are also working on some informal code camps, as well as Lightning Talks where attendees will bring up their Grails related problem that we’ll discuss and solve as a group.

I am excited and looking forward to a great new year. And, what’s a better way than to start off by joining a new user group that’s focused on a great language and platform.

Bookmark and Share

posted by Bill Gloff

NFJS 2008 Wrap Up

Tuesday, November 25th, 2008

NFJS 2008 is in the bag. This years conference was pretty good overall. The sessions that are standing out for me more than others are Neal Ford’s “Test Driven Design” and his “Design Patterns in Dynamic Languages”. Both gave great tips on how to use dynamic languages to their fullest potential and just because you can code something one way in Java (e.g. maybe follow a design pattern such as the Strategy Pattern) does not mean you should code it in the same way in JRuby or Groovy since you often do not need to go to the same extent in adding more structure to your OO design as you would if you were using a dynamic language. Maybe in a future post I can elaborate more on that and give some examples.

Some other sessions I noted were Jeff Browns’ talk on Groovy and TDD and Andy Glover’s talks on Hudson CI and BDD using easyB. Hudson CI has come some ways since I last used it and was surprised by the number of useful plugins available for it. It’s reminding me of a similiar battle in the IDE wars where Eclipse has a ton of plugins for it (like Hudson) but then you have Cruise (Thoughtworks) or TeamCity (IntelliJ) where the community is not as big so the company gives you more out of the box. It will be interesting to see this play out.

 Then Andy Glover made me believe that easyB is the future of TDD as it makes it easier for the more non-technical folks in your organization be able to read your test cases and know whether or not something was coded to spec. I also think it will make doing test first design and development easier on the developer since it allows you to write out the requirement in English and write some code right next to it. After the tests are executed, a nice report gets created describing each test and whether it passed or failed.

I ended the conference by attending Stuart Halloway’s Java.NEXT talk. Let me just say that I really wished this would have been earlier in the day as it was a lot to digest. He talked about how Java the language is dead and that we should be making the shift over to functional langauges such as Scala and his favorite Clojure. If you cannot make this jump now, then at least start using Groovy or JRuby so you can start preparing yourself for the future. One eye opener for me was watching him transform an Ant XML build file that was about 30 lines of XML into a more readable Clojure script that was about 5 or so lines long and was more powerful than Ant could ever hope to be. Cool stuff!

Bookmark and Share

posted by Bill Gloff

No Fluff Just Stuff 2008

Friday, November 21st, 2008

It’s the weekend before Thanksgiving so you know what that means? NFJS is back in town. This year will be my third straight year in going and we’ll also have about ten of us from CITYTECH attending. It should be a fun weekend geeking out and hopefully learning some new and cool things. Last year’s conference really opened my eyes about Groovy and JRuby so I wonder what this year will bring.

For today’s sessions I am currently planning on attending Neal Ford’s TDD presentation, then either Design Patterns Reconsidered by Alex Miller or Techniques 2008 by Jared Richardson….hmmmm tough choice there. For the last set of sessions for the day (which leads into the keynote) Improving Code Quality by Nathaniel Schutta looks interesting to me since I believe everyone can improve in that area….yes even me.

I’ll give an update later on the ones I ended up going to and what I learned from them. We’re also talking about meeting up at the hotel lounge after the keynote dinner to compare notes and do some networking….stop by if you’re there!

Bookmark and Share

posted by Bill Gloff

Announcing the Chicago Groovy User Group

Thursday, November 20th, 2008

We consultants here at CITYTECH having been getting more and more into Groovy and Grails lately and the number of projects are growing. All of us here are also excited about the news that G2One was acquired by SpringSource as it will help us show that Groovy/Grails is a bonifide langauge and web framework that can be taken seriously in the enterprise.

So this brings me to the main reason for this blog post. It seems like Groovy and Grails is becoming very popular with the aforementioned acquisition, the recent release of a Groovy/Grails specific magazine, and the list of user groups is growing on http://grails.org/Community.

A few of us were surprised to not see a user group for Chicago so we went ahead and formed one: Chicago Groovy User Group. Our first meeting will be in January 2009 with the location being in the loop. More details are coming soon, so please visit the website and register your name and email so we can contact you when more info is posted. If you’re interested in speaking about a Groovy or Grails topic, or if you have any other questions, please contact info@cgug.org for more information.

Pass the word around and let’s get groovy!

Bookmark and Share

posted by Bill Gloff

Day CRX JNDI Lookup from a JBoss Seam App

Friday, August 29th, 2008

I just wanted to write up a quick note about an issue I recently had regarding looking up a JNDI resource from another Seam webapp in JBoss 4.2. I installed Day CRX as a war into a development JBoss server and followed all the directions that were given from Day’s documentation including changing the Java2ClassLoadingCompliance property to true in the /server/default/deploy/jbossweb-tomcat55.sar/META-INF/jboss-service.xml configuration file. According to Day “this is required to enable JNDI lookups of the CRX repository between webapps. The default for this attribute is false.”

After completing all the steps, I still could not do a lookup on that name (crx) as I would continously receive NameNotFoundExceptions no matter what I tried. At first I thought maybe my spring configuration was wrong, but I then noticed that Spring was finding it, and saw that the MemoryInitialContextFactory that Day uses was the one throwing the error. I was puzzled to say the least, but realized it had to be some kind of classloading issue.

To wrap this up, I finally got everything to work by doing two things. First I had to put the crx-shared-1.4.0.jar and the jcr-1.0.jar into the server/lib/endorsed folder and not the server/lib like the documenation stated. The other piece to this is Seam overwrites the Java2ClassLoadingCompliance property in a file called WEB-INF/jboss-web.xml and sets it to false. I ended up changing that to true and everything started to work.

If you know a reason why I shouldn’t do what I did or you know another way to get a successful JNDI lookup without having to set Java2ClassLoadingCompliance to true, then please let me know.

Technorati Tags: , , ,

Bookmark and Share

posted by Bill Gloff

New Chicago area Rails conference..

Saturday, May 31st, 2008

WindyCityRails - September 20, 2008 - I'm attending! Chicago’s local Rails User Group (Chicago Ruby) is putting together a one day mini conference called WindyCityRails on Saturday September 20, 2008 from 8am – 4pm. Entry fee is pretty cheap at $99 (beakfast, lunch and snacks also included) and looks like it will be well worth it. If you’re in or around Chicago and into Rails, sign up here.

Bookmark and Share

posted by Bill Gloff

CityTech Home