Thursday, May 22, 2008

Resource File Loading in Grails

Loading a resource file using Grails isn't that obvious when you first attempt to do it. I finally figured out how to do that using the follwing code:

public String buildTemplate(def someBinding){
def template = ApplicationHolder.application.
parentContext.getResource("classpath:template.tmpl")
def engine = new SimpleTemplateEngine()
def template = engine.createTemplate(template.getFile()).make(someBinding)
return template.toString()
}

Obviously an import is needed to run the above code successfully

import org.codehaus.groovy.grails.commons.ApplicationHolder

Monday, April 14, 2008

Manage It! Your guide to modern project management


I'm currently reading Manage It an excellent book written by a fantastic woman Johanna Rothman. I've been doing IT project management for quite sometime now, reading this book though gives me lots of new ideas how to approach IT project management once again. Thank you Johanna

Sunday, April 13, 2008

Controller & Templates in Grails

The common way of using template in Grails is within a GSP page where a page is designed to be composed of different components, each component defined in a template.

In a GSP, one would write

<g:render template="orderDetailsTemplate"
mode:[orderItems:orderItems]/>


The other way however is to decide about the use of a template directly from a Controller:


class OrderController {
def list = {
def orderItems = OrderItem.list( params )
render(temlate:"orderDetailsTemplate"
model:[ orderItems: orderItems])
}
}


A good use-case of using the second way is when an ajax call is made from a GSP page and the result should update a div.

Thursday, January 17, 2008

Services in SOA Demystified

With the growing complexity of applications, and the urging need to write applications that will be exposed to the outside world sooner or later, I realized that defining only one service layer in an application is not enough. In the past, I tried to introduce Helper classes to do some of the heavy work for a service layer. It turned out though that the Helper itself could have been defined as a Service and reused elsewhere.

Now I started designing according to four categories of services:
  1. Human to Application Services
  2. Application to Application Services
  3. Aggregated core Services
  4. Core Services

Core Services
These are mainly data access services. These are the only services allowed to communicate with the data access layer.

Aggregated core services
These services combine and orchestrate other services to produce aggregated services.

Application to Application Services

These services are exposed as endpoints of the application. They are conversational, configured rather than coded and are data or event driver.

Human to Application Services

These services interact directly with humans, are message oriented and aligned closely with the real business processes.