Alfresco Webscripts with Groovy (Daniel Gradecak)

April 16th, 2008

Groovy is becoming the Enterprise glue.

Daniel Gradecak writes:

I decided to see how Alfresco could be integrated with Groovy.

Alfresco introduced a while ago the “webscripts”, with that they added a powerful scripting API based on JavaScript and the Rhino engine. When you add FreeMarker templates to that, what you could get is a nice output that you could customize to be some JSON data, XML or whatever suites you. That is amazing but I was not that happy as we have to wait for Alfresco to expose more of their services via the scripting API. Adding Groovy capabilities to any application and not only to Alfresco seems “natural” and I think that it helps in prototyping without having to recompile.

I took the groovy.servlet.GroovyServlet implementation and added a few lines that allows to configure a Spring bean as servlet parameters and to make them available in the groovy scripts.
The code is not yet published somewhere as a forge project but you can find it here. All you have to do is have Spring and Spring MVC on your classpath (Alfresco already has it) add Groovy libraries (groovy-all is a good solution, at least version 1.5.x) and configure your web.xml with the Groovy servlet that I am providing, an example could be found here. That example is using spring’s DispatcherServlet but you could use the GroovyServlet as any other servlet, directly in your web.xml. If your are also using the DispatcherServlet then you have to configure it correctly as shown here.

Once you are done with those configuration just add the desired beans to the servlet configuration and you are on “rails” with Alfresco.

The samples provided here are using the ServiceRegistry bean and it is mapped in Groovy as registry, so to get any other Alfresco service you have to start from there. But you are free to map whatever bean you want.

Although, some people are saying that there are problems using Alfresco beans with Groovy, I did not have those problems till now, but I am not saying it will happen.

Tags:

Grails Gets Me Excited About Java Again (Ryan Headley)

, April 16th, 2008

Ryan Headley writes:

For a number of weeks now, my primary 8 to 5 job has been working with Grails as well as attempting to bring someone from the .Net world along with me. I’ll say he’s coming along, though seems to be doing things in the straight out “Java” way, which is fine when working with Groovy/Grails…matter of fact, I think its a selling point.

Now where one would think that Groovy should be easier to learn, there are still loads more “recipes” on the net for traditional Java and this is where my colleague is getting his information. In a way it bothers me that he doesn’t seem to want to learn to do things the “Groovy” way, I find myself not so worried about since I know it will run (its Java after all). That’s a beautiful thing when you think about it. He can learn from real world Java examples, and then adapt them to the Groovy way of doing things. Now, I’m not a .Net guy and I don’t pretend to be, but he keeps mentioning that he’s not used to all of this “blackbox stuff” going on. (Referring to all the nifty things Grails does for you) so I think that is why he is doing things the more traditional way…because its familiar. And it works!

I can’t say enough about my experience with Grails thus far. Grails makes me want to go out and find good..scratch that…CHEAP Java hosting. Not that I want to abandon PHP, I’m still a PHP guy, but Grails has got me excited about Java again. The layers are still there but for 80-plus percent of the folks out there, Grails does the right thing for you and you needn’t worry about your hibernate configuration, or your Spring setup, etc. (To be honest, I could hardly fight my way through that sort of thing anyway, which is probably why I’m digging the Grails thing).

It works, and its concise (at least when compared to its mother language). I’m pretty sure that I’m beginning to annoy my fellow colleagues that are still working on traditional Java. I’ll be working away on something in the Groovy/Grails world and come across something that just makes me giddy, and I feel a smile form on my face, and perhaps even get the giggles. Then I’ll have to run over to anyone who will listen and say “Check this out…” I’m pretty sure there gonna move me to the basement and turn the light out, (”I believe you have my thtapler”).

I’ve been complaning alot about people griping an not giving examples, so here’s a quick example of how you’d read in a form and populate an object in grails…are you ready?:

In the controller–(example, saving a person)

person.properties = params
person.save()

Are ya kidding me? Thats all I had to do? What if I’m sending parameters from my form that the object doesn’t have? It doesn’t care, it just won’t do anything with it. How’s that for getting something done.

Sure, scaffolding is cool, helps ya hit the ground running, but there’s oh so much more than that. Again, I can’t say enough about it, and I’m only just starting out with it.  The current project isn’t exaclty HUGE or enterprise level (yet), but it will grow to be bigger than its current implentation and new features will be getting added for a long time to come, so I’m sure there will be a number of rants as well. For now however, I’ll remain sitting back in my chair at work, quietly giggling…hope that doesn’t make me creepy!

Finally, if you are at all interested in the Groovy/Grails world, I HIGHLY recommend “Groovy Recipes” by Scott Davis. If you’ve ever heard Scott speak, (and enjoyed it like I did), then you’ll love the book because its written just as he speaks. Clear and concise, (much like the language the book covers…) and delivered very well. Perhaps I’ll have to give it a full review in the near future.

Anyway, I’ve sucked up enough time today…gotta go get my giggle on…

Tags: ,

Consilidation in the Open Source Java Stacks? (Dion Almaer)

, April 15th, 2008

Dion Almaer writes:

Dealing with Java CIOs

I was talking to a friend that does a lot of work in the realm of Open Source Java. He is someone who talks to people high up in the chain, and discussed how a lot of the CIO folks are getting a bit confused with the offerings. They had gotten used to JBoss. And, now they get Spring. But, they keep getting bombarded with more things. Next they had Mule, and Groovy.

Get some of these guys in a discussion about Mule vs. ServiceMix and they froth. Spring did something smart via Spring Integration, but maybe it is time for some consolidation? SpringSource + MuleSource + G2One? SpringyMule?

One Response to “Consilidation in the Open Source Java Stacks?”

  1. Stephan Schmidt Says:
    In June 2007 I wrote as a comment to someones blog post:

    “I believe the Java stack started with Apache incubating alot of projects and incorporating even more (like lucene). JBoss followed by buying open source developers (Hibernate, the King) and Spring almost started as a stack.

    Obviously in the last years all stack providers aimed to complete their stack and reduce the risk that their users would switch to another stack or incorporate technologies from another stack.

    Beside Apache I think you forget the Grails stack. From my feeling it’s much faster growing then the JRoR stack.”

    One year later I still believe this is the way things flow in open source Java land.

    Peace
    -stephan

Tags: ,

Grails Podcast #52 (Glen Smith & Sven Haiges)

April 14th, 2008



Grails Podcast #52 Glen Smith & Sven Haiges covers the following:

Tags:

Grails Plugin for Deploying to Amazon EC2 (Chris Richardson)

April 14th, 2008

Chris Richardson has created a Grails plugin for deploying to Amazon EC2:

Cloud Tools now includes a plugin for deploying Grails applications to Amazon’s Elastic Compute Cloud (EC2). Like the Cloud tools Maven plugin, this plugin makes deploying a web application to EC2 extremely easy. It currently provides the following Grails scripts:

  • cloud-tools-deploy - Launches EC2 instances (MySQL master and slaves, tomcats and Apache) and deploys the web application
  • cloud-tools-describe - Displays information about the instances
  • cloud-tools-redeploy - Redeploys the web application
  • cloud-tools-stop  - Terminates the EC2 instances

I plan to release it in the next few days but in the meantime please contact me if you would like to try it out.

Comments:

1. Graeme Rocher left…

Monday, 7 April 2008 8:03 am

Awesome Chris! Let me know if you want to release it into the Grails central repo at plugins.grails.org

2. Dustin Whitney left…

Sunday, 13 April 2008 3:59 pm :: http://dustinwhitney.blogspot.com

Fantastic! I am totally going to use this!

Tags:

Spring WebFlow is Easier With Grails (Ken Rimple)

, April 11th, 2008

Ken Rimple explains the basics of Spring WebFlow and concludes that Spring WebFlow is easier with Grails.

He begins:

Everyone has had to code an application at some point where they were forced into a particular set of navigational flows. There are a few ui-centric workflow packages out there, including Open Symphony’s OSWorkflow, and Spring’s WebFlow. Other developers at my shop have worked with WebFlow and were pleased with its features. But did you know that Grails embeds WebFlow and makes it available within its controllers automatically?

He covers the basics of WebFlow:

For a thorough introduction to Spring Webflow, I suggest visiting the SpringSource site. However, in general, webflows can be broken up into distinct components:

  • State - This is a ‘definable moment’ within the webflow, such as a View State, where the application is waiting on user input.
  • Transition - An event, often fired by a user taking an action, that moves the webflow from one state to another.
  • Action - Code that can be performed within a transition, or on the start or ending of a given State
  • View - A (GSP) page that is rendered during a ‘view state’.
  • Flow Scope - A semi-session-like container that lives for the life of the webflow. Data captured from one view to the next

He concludes:

Without too much more ceremony, I can simply say that although Spring WebFlows are a great feature, and take a lot of pain out of implementing flow-based application logic, they are made even easier by Grails.

For more Flow goodness, check out the grails documentation page on it.

Tags: ,

Groovy & Grails Support on Google App Engine?

April 10th, 2008

Google

We were pretty stunned at how many requests for Groovy and Grails support on Google’s AppEngine are coming in: http://code.google.com/p/googleappengine/issues/detail?id=1

Tags:

Grails in a ‘Cloud’

April 10th, 2008

These days, the new generation of computing, so called ‘cloud computing’, where the infrastructure of the entire data centers is outsourced, abstracted, and hosted somewhere in the ‘cloud’ (on the Internet), is getting hugely popular. In a nutshell, it provides a so called ‘low barrier to entry’ for smaller internet companies to make their presence on the Internet market place without spending a fortune and ridiculous amount of time and energy buying their own hardware and maintaining their own data centers.

Amazon EC2 service hugely popularized this type of computing and early this week, Google jumped on the bandwagon with their App Engine exposing the power of their computing infrastructure, as well as the entire web development stack (Python-based - what else did you expect from Google) :-) to the army of ordinary, but creative software development minds.

After the announcement, Google has received feedback from developers requesting support for different programming languages/frameworks, and among Perl and Ruby, the requests for Java/Groovy/Grails are overwhelming.

Now that we have a rock-solid RAD web framework for Java (Grails that is), we are just missing the last piece of the puzzle: a rock-solid and affordable Grails hosting in a ‘cloud’. The demand seems to be there. Hint, hint for ambitious start up companies :-)

Tags:

March Madness: Java Tournament Championship (AudibleSmirk Blog)

, April 9th, 2008

Audible Smirk has done something amusing, intriguing, and possibly useful. They created a tournament for Java frameworks, similar to the NCAA Basketball Tournament.

Read the rest of this entry »

Tags: ,

Glen Smith: Somersaulting into Grails (GroovyZone)

April 8th, 2008

GroovyZone has an interview with Glen Smith, an early adopter and active contributor to Grails. I have excerpted five questions and answers that were of a high level nature.

Q. You are an early adopter of Grails, how do you see it now that it has achieved 1.0 status ?

A. I remember writing an email to Graeme [Rocher - Grails project lead] sometime around Grails 0.2 saying “Do you realise what you’ve done!?! You have just changed the whole game of Java webapps!”. Grails is no doubt going to be one of those disruptive technologies that forever changes how we build Java web apps going forward. The framework was awesome *then*, and a year and a half later we have something incredibly powerful.

Someone asked me the other day “But hasn’t Grails just gone 1.0, isn’t it immature?”. I can only say that it’s the most feature-filled 1.0 that I’ve ever seen! I shipped my first apps on 0.2 HEAD, and Grails could probably have gone 1.0 at the 0.3 stage. There was certainly pressure for that at the time, but the team was adamant that they would ship it when it was feature complete, and not be hassled into 1.0. It’s a testament to their stickability that they kept to that vision. It was worth the wait.

Q. Do you have a preferred set of Grails plugins ?

A. If I was marooned on a desert island, what Grails plugins would I take with me?

RichUI would be in there for sure. The set of UI plugins in there are just very slick, and I’m a big believer that slick matters. People don’t buy the steak, they buy the sizzle. All that.

I also love Searchable - that thing is just awesome. Those two are my favorite general purpose, meat-and-potatoes plugins. Both have great docs, and I’ve had good success with both getting things out the door quickly.

In the “more niche” plugin space, the GoogleCharts plugin just rocks. I use that for Stats charting in Gravl. In the “next plugin I’m trying out” list, I really like the look of the DBUnit plugin, that’s definitely on my list as I ramp up my testing kungfoo.

Q. What would you like to see in a future version of Grails ?

A. I think the whole plugin space is still evolving and has lots of cool things ahead. Dependency resolution around plugins would be nice. It would be nice to be able to declare that my project “depends” on RichUI, and not have to checkin RichUI code into my plugins folder - just let Grails download it and install it. Would make distributing projects a little easier.

I think that unit testing support is still in the early days. I’ve just finished a series discussing unit testing on my blog, and the framework support for it is still a little scratchy. I know the guys are working on stuff there (including integrated CI servers), and there’s JIRAs in about mocking support, so that will no doubt be there soon.

It’s hard to think of anything else. The Grails project velocity is so high, the quickest way to get stuff done is to just a raise a JIRA. Everything I’ve asked for has always turned up in a dot release with a month or two!

One thing I would like to see is more Groovy/Grails “community” sites built using Grails. The Ruby and Rails guys have really done great work building community sites, and I think it’s the next logical step for us in growing the platform. Get busy people!

Q. What would you like to see in a future version of Groovy ?

A. Anonymous Inner classes! Particularly when interacting with Java libraries I find the lack of Inner classes frustrating. There’s always workarounds, but it would be nice to able to do it as I do it in Java - much easier on the mental model.

I’d also like to see parentheses optional when invoking methods with no arguments. It would make writing DSLs a lot more expressive if we could totally get rid of those pesky parentheses. Again there are workarounds, but having this “just work” would be very cool (it’s probably a ton of grammar work, but it would still be nice :-)

Q. Do you have some tips for people starting with Grails ?

A. The absolute best way to learn Grails is on the job. Download the distro, do the quickstart from the manual, and start on that pet project you’ve been putting off for years. Let you Groovy and Grails kungfu increase while you’re working on a real project, rather than trying to learn a thousand things before you start. It’s so addictive you’ll be motivated to learn more as your project powers on.

Once you’re underway and ready to learn more about Groovy, grab a copy of Groovy In Action to really understand some of the finer points of Groovy. It will also help you get more idiomatic in your Groovy approach to things. On the Grails side, grab a copy of Graeme’s Definitive Guide to Grails (the 2nd edition is due mid year, and will be worth the wait). It’s a great book for learning Grails.

Tags: