permaculture playing cards*
The moose likes Spring and the fly likes Spring in Action - other programming languages? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring in Action - other programming languages?" Watch "Spring in Action - other programming languages?" New topic
Author

Spring in Action - other programming languages?

Piotr Kalinowski
Greenhorn

Joined: Feb 09, 2011
Posts: 2

Dear Author,

In a sample chapter of your book one can read that it is possible to reduce XML size by using annotations or Java-based configuration. My question is: what about other languages, especially those running on JVM? Is it possible to configure Spring with such languages, e.g. Groovy? Is it possible to completely replace XML with some scripting language? Do you think it would be a good idea, or just an alternative for "XML-haters"?

Thanks,
Piotr
Craig Walls
author
Ranch Hand

Joined: Sep 19, 2003
Posts: 301
You can certainly replace XML or JavaConfig with Groovy. In fact, that's what the Groovy configuration stuff from Grails does. I've also seen other similar efforts to configure Spring in other languages, including one awhile back called Springy that let you configure it in Ruby.

I don't cover those in the book, though. Even so, they're great configuration options to consider. I especially like the Groovy configuration stuff. Configuring in Java or Groovy (or any other language) rather than XML buys you a lot of benefits, including less of a dependence on string identifiers, more type safety, testability of the configuration themselves, and the ability to write intelligent configuration (configuration that takes advantage of language constructs to do more than just simply create objects and set properties...make decisions, loop, etc).

Spring in Action - Unleash POJO power in your applications!
Modular Java - Discover the secret weapon to modularity on the Java platform!
XDoclet in Action - Your complete guide to code generation with XDoclet.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Craig Walls wrote:You can certainly replace XML or JavaConfig with Groovy. In fact, that's what the Groovy configuration stuff from Grails does. I've also seen other similar efforts to configure Spring in other languages, including one awhile back called Springy that let you configure it in Ruby.

I don't cover those in the book, though. Even so, they're great configuration options to consider. I especially like the Groovy configuration stuff. Configuring in Java or Groovy (or any other language) rather than XML buys you a lot of benefits, including less of a dependence on string identifiers, more type safety, testability of the configuration themselves, and the ability to write intelligent configuration (configuration that takes advantage of language constructs to do more than just simply create objects and set properties...make decisions, loop, etc).


I did not quite understand this. replace XML or JavaConfig with Groovy?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Piotr Kalinowski
Greenhorn

Joined: Feb 09, 2011
Posts: 2

Craig Walls wrote:You can certainly replace XML or JavaConfig with Groovy. In fact, that's what the Groovy configuration stuff from Grails does. I've also seen other similar efforts to configure Spring in other languages, including one awhile back called Springy that let you configure it in Ruby.
(...)


Thank you very much for the answer. I am a novice in Spring. I am working on my first project that uses this framework and still learning it. Groovy and Grails seem to be quite interesting - I hope I will have time to learn them, too.
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Joe Harry wrote:
Craig Walls wrote:You can certainly replace XML or JavaConfig with Groovy. In fact, that's what the Groovy configuration stuff from Grails does. I've also seen other similar efforts to configure Spring in other languages, including one awhile back called Springy that let you configure it in Ruby.

I don't cover those in the book, though. Even so, they're great configuration options to consider. I especially like the Groovy configuration stuff. Configuring in Java or Groovy (or any other language) rather than XML buys you a lot of benefits, including less of a dependence on string identifiers, more type safety, testability of the configuration themselves, and the ability to write intelligent configuration (configuration that takes advantage of language constructs to do more than just simply create objects and set properties...make decisions, loop, etc).


I did not quite understand this. replace XML or JavaConfig with Groovy?

Same here


Learning and Learning!-- Java all the way!
Craig Walls
author
Ranch Hand

Joined: Sep 19, 2003
Posts: 301
Although not part of Spring (yet anyway), the Grails folks have a thing called the Grails BeanBuilder (http://www.grails.org/doc/1.4.x/guide/14.%20Grails%20and%20Spring.html#14.4%20The%20BeanBuilder%20DSL%20Explained) that lets you express a Spring configuration with a Groovy-based DSL. Although part of the Grails project, it can be used outside of Grails as well.

At one time there were plans to make this part of Spring 3.1. But now it looks like it's in the 3.2 backlog. See https://jira.springsource.org/browse/SPR-7123 for more details.
 
Consider Paul's rocket mass heater.
 
subject: Spring in Action - other programming languages?
 
Similar Threads
Expert Spring MVC and Web Flow by Seth Ladd et al
Delegation Vs Aggregation and Composition
Using characters like quote, ampersand in xml
Spring: Byte array to xml
Accessing the host name,method and class used by the webservice