Graeme Rocher's Blog
Thought's about software, Grails, Java, web development and anything else that comes to mind.
Thursday, January 05, 2012
Thursday, December 15, 2011
Grails 2.0 Released!
Wednesday, April 13, 2011
Grails on Cloud Foundry
Foundry which we hope will become the premier deployment model for
Grails (and Spring, Ruby, Node.js etc.) applications in the the
future. If you missed the presentation checkout the YouTube recording.
It represents the culmination of a huge amount of work within VMware and we're super excited about the potential it has to completely revolutionize deployment models for Grails applications in the future.
Here are some further resources specific to Grails users:
Website: http://www.cloudfoundry.com/
Wiki & Sample applications: https://github.com/SpringSource/cloudfoundry-samples/wiki/Grails
Plugin Documentation: http://grails-plugins.github.
Signups are currently on a first come first serve basis under a limited beta programme.
Friday, April 16, 2010
Reading i18n messages from the database with Grails
class Message {
String code
Locale locale
String text
}
class DatabaseMessageSource extends AbstractMessageSource {
protected MessageFormat resolveCode(String code, Locale locale) {
Message msg = Message.findByCodeAndLocale(code, locale)
def format
if(msg) {
format = new MessageFormat(msg.text, msg.locale)
}
else {
format = new MessageFormat(code, locale )
}
return format;
}
}
beans = {
messageSource(DatabaseMessageSource)
}
@Immutable
class MessageKey implements Serializable {
String code
Locale locale
}
beans = {
messageCache(EhCacheFactoryBean) {
timeToLive = 500
// other cache properties
}
messageSource(DatabaseMessageSource) {
messageCache = messageCache
}
}
class DatabaseMessageSource extends AbstractMessageSource {
Ehcache messageCache
@Override
protected MessageFormat resolveCode(String code, Locale locale) {
def key = new MessageKey(code,locale)
def format = messageCache.get(key)?.value
if(!format) {
Message msg = Message.findByCodeAndLocale(code, locale)
if(msg) {
format = new MessageFormat(msg.text, msg.locale)
}
else {
format = new MessageFormat(code, locale)
}
messageCache.put new Element(key, format)
return format
}
return format;
}
}
Thursday, September 17, 2009
Grails - dependency resolution done right
You could use the Grails Maven plugin, but that forced you to use, heavin forbid, Maven. We also shipped with basic Ant + Ivy support, but it was only really designed to be used for automation with continuous integration servers that support Ant and not at development time.
With Grails 1.2 this all changes with the introduction of Grails' dependency resolution DSL, which you can use to define your dependencies. Built on Ivy we have now eliminated one of the last remnants of XML usage in the Grails framework:
dependencies {Grails takes application defined dependencies (defined in grails-app/conf/BuildConfig.groovy) and merges them with dependencies defined in the framework or any installed plugins. If there are conflicts you can exclude dependencies inherited from the framework or you can override plugin dependencies.
runtime 'com.mysql:mysql-connector-java:5.1.5'
test 'junit:junit:3.8.2'
}
By default Grails will only resolve dependencies against your Grails installation but you can enable remote repository resolution easily:
repositories {If you're addicted to your pom.xml file then we have even added the ability to read dependencies from the pom.xml instead of using the DSL. All in all, Grails 1.2 will give you significantly better control over dependencies and how they are resolved.
mavenCentral()
mavenRepo "http://repository.codehaus.org"
}
We're still on track to release Grails 1.2 by the end of the month, but if you want to hear more about it I'll be talking about Grails 1.2 at upcoming events such as JAOO (Denmark), SpringOne2GX (New Orleans, USA) and the Grails eXchange (London). See you there!
Thursday, May 21, 2009
Grails 1.1.1, Gr8conf, AppEngine and other happenings
All in all it felt more like a No Fluff event, which can only be described as a good thing. Right before the conference we released Grails 1.1.1 which is mainly a bug fix release, but the exciting part is the new Google AppEngine plugin which works with Grails 1.1.1
The plugin takes the heavy lifting out of configuring a Grails application for usage on AppEngine by automatically configuring the AppEngine development environment and a JDO persistence layer (JPA is coming too soon). You get reloading out of the box too, so Grails + AppEngine is really the most productive environment for developing JVM applications for AppEngine.
One missing feature from the AppEngine support right now is GORM (you have to use the raw JDO APIs). However, we are hard at work developing GORM-JPA (and potentially GORM-JDO) which will bring most of the features of GORM on top of standard JPA.
GORM-JPA is not the only exciting thing happening right now in the Grails plugin front. We are working with Adobe on integrating Flex and BlazeDS closely with Spring. The results of that can be seen in the recent Spring/BlazeDS integration 1.0 Rc2 release. The next phase is to build on top of that for the Grails plugin which is on my todo list to complete soon. Exciting times.
The plugin community itself continues to flourish, checkout these:
- It is now finally possible to write Grails applications for different Portals such as Liferay and Pluto thanks to the Portlets plugins.
- There is an excellent new plugin that embeds an LDAP server into Grails for easily testing LDAP
- The Flex Scaffold plugin let's you generated complete CRUD applications using Grails and Adobe Flex
- The Build Test Data plugin let's you quickly create dummy test data
- Using the Spring WS plugin writing SOAP web services, feels more like writing REST service. Easy and painless.
Tuesday, March 10, 2009
Grails 1.1 Released
Nice to see how Twitter is abuzz with the news (note live results, link will change overtime) right now. Other than that we are now planning the launch of the Grails.org plugin portal. To support that I have been writing a few plugins for Grails. It is niceto actually write Grails apps/plugins rather than work on the internals all the time.
Anyway the result is 2 new plugins called Commentable and Taggable that allow you to generically tag and comment on domain instances. I also have a new blog plugin in the works which will power the new Grails.org blog when that is ready. Actually its already available, but I need to document it better, and I'll save that for another post.
As for beyond Grails 1.1, we are now at the planning phase, but there are loads of things we are considering from OSGi to JCR to Cloud computing. Exciting times.