The Artima Developer Community
Sponsored Link

Java Community News
Introduction to Grails

3 replies on 1 page. Most recent reply: Aug 17, 2010 7:07 AM by Sigma Infosolutions

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

Introduction to Grails Posted: Mar 6, 2007 3:43 PM
Reply to this message Reply
Summary
In a recent article, Object Computing's Jeff Brown describes the Grails application framework, providing a short tutorial on how to take advantage of Grails' preference for convention over configuration.
Advertisement

Ruby on Rails was the first significant Web application framework to favor convention over configuration: By following a large set of sensible defaults in every Web application layer, developers can get a Rails application up and running very quickly.

Rails' approach has been refreshing to Java developers fatigued by the need to rely on complex XML files to put even the simplest application in place. Although Java EE 5's use of annotations has reduced the need for explicit configuration, other Java frameworks go even further in embracing conventions in place of configuration.

One such framework is Grails, which, as its name suggests, is heavily influenced by Rails. Using Groovy instead of Ruby, Grails attempts to tie together Java technologies as diverse as Hibernate, Spring, and Sitemesh into a coherent whole.

Jeff Brown's recent article in Object Computing's March issue, Introduction To Grails, provides a quick introduction to Grails, including an tutorial example Grails application. Brown notes that:

Coding By Convention results in very little configuration being required in a typical Grails application... For example, in a Grails application a typical HTTP request will be handled by some controller and the controller will then render some view back to the client. There is no configuration file necessary to map a request to a specific controller and no configuration file is involved in deciding which view corresponds to that particular request. All of that can be managed by following some basic conventions.

Brown shows how Grails' Rails-like command-line generators can create a basic application scaffold:

Grails provides a number of command line actions that may be invoked as arguments to the "grails" command. The command to create a new application is called create-app. The create-app command accepts an argument that is the name of the application to be created.

The article also walks through a basic example using Grails' object-relational layer for persistent domain classes, Groovy Object Relational Mapping, or GORM:

In many ways a Grails application revolves around the domain classes (also known as model classes)... These are the things that are typically stored in the database... A Grails domain class may also declare validation constraints to help impose business rules. Validation constraints may be added to a domain class in the form of a static closure property named "constraints".

The [following] method ... invoked here is one of the many dynamic methods that Grails adds to all domain classes:

def list = {
        if(!params.max)params.max = 10
        [ personList: Person.list( params ) ]
 }

This closure is returning a Map that has 1 entry in it. The key for that entry is personList and the value associated with that key is a list of Person objects returned from the Person.list(params) call. [The original] Person class did not define a list() method.

Many of Grails' most code-reducing features seem to be the result of Groovy language features, such as closures. That's similar to how Rails makes good use of Ruby features, such as the ability to add methods to a class at runtime.

To what extent do you think Java applications' more involved configuration requirements are the result of Java the language? What Java language features do you think would help build more dynamic Web frameworks in Java?


Leo Lipelis

Posts: 111
Nickname: aeoo
Registered: Apr, 2006

Re: Introduction to Grails Posted: Mar 6, 2007 4:13 PM
Reply to this message Reply
I think part of it is due to something in Java itself. And part of it is the mental influence brought over by the type of person attracted to Java.

A person who has used Python for a long time and then learned Java is going to write different Java from a person who's been doing lots of VB 6.0 and then coming over to Java, and all this will be yet more different from someone who's been writing lots of Scheme or Forth, etc.

Why is something like a dynamic proxy such an arcane and "advanced" thing in Java? Why is it not trivial and newbie? Why is it advanced? Most Java programmers in the real world (not on this site perhaps) don't even know what a dynamic proxy is. And it's funny. Is that good or bad? Because of that feature was totally easy to use and natural, maybe it wouldn't merit its own term even. What I'm saying is that Java is not made to encourage free thinking. And yet a freely thinking person can use Java effectively.

For example, why do such ugly frameworks like Struts and JSF become popular? Everyone (almost) can see in retrospect (sometimes it takes 10 years) that they were ugly. But why don't people see it instantly?

I think Java brings some of this on. But most of it is brought on by the culture that's swarming around Java. Java, especially in business institutions, gets "institutionalized". Thinking is highly discouraged. Creativity is punished. Ugliness is seen as expedient. That type of cultural nonsense kills Java more than Java itself.

Java can be a better language for sure. But no matter how perfect it became, if people who prefer big-yet-cheap, baroque-yet-popular, overwrought-yet-familiar, bulky-yet-predictable, nonsensical-yet-prestigious, ugly-yet-expedient are attracted to Java -- what can you do??

I think a huge problem comes from the fact that Java is used by very psychologically ill, reactionary, crusty business institutions for business. The judgments that people make in business environment are warped and removed from reality (ironic...because business should serve to ground decisions in reality, but it does the opposite with software). It doesn't have to be like that. There is a possibility of health. But people have to wake up to it in their own sweet time.

Joao Pedrosa

Posts: 114
Nickname: dewd
Registered: Dec, 2005

Re: Introduction to Grails Posted: Mar 6, 2007 4:54 PM
Reply to this message Reply
I think Java is like the Cinderella and needs to be rescued by some "prince".

> To what extent do you think Java applications' more involved configuration requirements are the result of Java the language?

I think Java is very similar to the "systems programming languages" of the old days, like C++. In this regard, Java probably has pushed the limits of what those languages could do in a very business oriented environment, hence the ugly result could have happened to anyone of them. Even C# is not free of it, and the difference is that C# is still improving, despite being years in the market place. The jury is still out with regards to C#.

> What Java language features do you think would help build more dynamic Web frameworks in Java?

Interpretation and expressiveness. Java needs easy executable code, which if possible could work as a catalyzer for better APIs done by third parties. Programming Java is like programming DLLs in Windows. It needs to become more like programming Excel formulas. :-)

But like Martin Fowler said, it's likely a job for more dynamic languages to create most of what applications need, while Java could be used for the things it was meant to in the first place. Sun's adoption of JRuby is a good sign, even though it's a pollemic subject.

Sigma Infosolutions

Posts: 2
Nickname: sigmainfo
Registered: Aug, 2010

Grails Weceem CMS Plugin Posted: Aug 17, 2010 7:07 AM
Reply to this message Reply
Hi ,

My Problem is that I am using grails Weceem CMS Plugin .
I want to combine Jsecurity plugin with this weceem cms plugin.
how to do it ?

Please help me to find the solution.

Regards
DINESH T

Flat View: This topic has 3 replies on 1 page
Topic: Oracle Sues Google over Java Patents Previous Topic   Next Topic Topic: Acegi and J2EE Security

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use