Introduction To Groovy And Grails - SpringPeople

12
© SpringPeople Software Private Limited, All Rights Reserved. © SpringPeople Software Private Limited, All Rights Reserved. Introduction to

Transcript of Introduction To Groovy And Grails - SpringPeople

© SpringPeople Software Private Limited, All Rights Reserved. © SpringPeople Software Private Limited, All Rights Reserved.

Introduction to

© SpringPeople Software Private Limited, All Rights Reserved.

What is Groovy?

Groovy is a dynamic, object-oriented language for the Java Virtual Machine, which builds on the strengths of Java but has additional features inspired by languages such as Python, Ruby, and Smalltalk.

© SpringPeople Software Private Limited, All Rights Reserved.

What is Grails?

Grails is an open source web application framework that leverages the Groovy language and complements Java web development. Grails is a standalone development environment that can hide all configuration details or allow integration of Java business logic. It provides easy-to-use tools to build web applications in Groovy.

© SpringPeople Software Private Limited, All Rights Reserved.

Grails Architecture

© SpringPeople Software Private Limited, All Rights Reserved.

Groovy Testing

• Groovy is a scripting language that is executed as Java Byte Code.

• This allows a Mix & Match between Groovy and Java Code.

• Groovy comes with an AntBuilder that allows execution of Ant scripts from usual Groovy code. This capability allows executing WebTests, since WebTests are usual Ant tasks.

• By executing WebTest from a Groovy script, you can fully leverage both the variety of WebTest steps and the sophisticated language means of Groovy for structuring your tests.

© SpringPeople Software Private Limited, All Rights Reserved.

Grails Controller

• A controller fulfils the C in the Model View Controller (MVC) pattern and is responsible for handling web requests. In Grails a controller is a class with a name that ends in the convention "Controller" and lives in the grails-app/controllers directory. A controller can be created with the create-controller

Command: grails create-controller org.bookstore.hello

© SpringPeople Software Private Limited, All Rights Reserved.

Manage Databases

• Grails is really easy to get started with on green-field projects because the domain model defines the database schema, so you don't have to worry about that side of things. But what if you need to work against an existing database? In that case, you have to carefully map the domain classes yourself. If you have a large schema, that could take a while.

• What about when new versions of your application go live? You can't limit the application to the original schema used for the first version, otherwise it wouldn't be able to evolve properly. You have to be able to migrate the schema and also any existing data. Both of these scenarios have corresponding plugins that can help solve the problems.

© SpringPeople Software Private Limited, All Rights Reserved.

• Remember to check in your migrations.

• You can preview changelogs and changesets

• Always check your migrations

• Resetting locks

• You can use Sql to assign default values to new columns

Data migration tips & tricks

© SpringPeople Software Private Limited, All Rights Reserved.

Grails Service Layer

• Grails defines the notion of a service layer. The Grails team discourages the embedding of core application logic inside controllers, as it does not promote reuse and a clean separation of concerns. Services in Grails are the place to put the majority of the logic in your application, leaving controllers responsible for handling request flow with redirects and so on.

Command: grails create-service helloworld.simple

© SpringPeople Software Private Limited, All Rights Reserved.

How you can master Groovy and Grails?

Become an expert in 4 days.

World class Groovy And Grails training by the industry experts.

More Details

© SpringPeople Software Private Limited, All Rights Reserved.

Suggested Audience & Other Details

• Prerequisites: Experience with developing application using Java, Basic web technologies such as HTML and HTTP

• Suggested Audience: – This training is designed for developers and architects interested in

Groovy and Grails.

• Duration – 4 Days

Syllabus

© SpringPeople Software Private Limited, All Rights Reserved.

For further info/assistance contact

[email protected]

+91 80 656 79700

www.springpeople.com

Our Partners