<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Spring Dynamic Language Support and a Groovy DSL</title>
	<atom:link href="http://blog.springsource.org/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.springsource.org/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/</link>
	<description>The voice of SpringSource</description>
	<lastBuildDate>Wed, 08 Feb 2012 17:31:53 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
	<item>
		<title>By: ShriKant Vashishtha</title>
		<link>http://blog.springsource.org/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/comment-page-1/#comment-202265</link>
		<dc:creator>ShriKant Vashishtha</dc:creator>
		<pubDate>Thu, 15 Sep 2011 08:38:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/#comment-202265</guid>
		<description>Excellent blog. I am trying to use the same to apply the AOP Around advice on top of existing Grails domain objects (for instance webalbum.Album in my case) available in main ApplicationContext as follows:

[groovy]
bb.beans {
    xmlns aop:&quot;http://www.springframework.org/schema/aop&quot;

    album(Album)
    theAroundAspect(TheAspect)

    aop {
        config(&quot;proxy-target-class&quot;:true) {
            aspect( id:&quot;myAspect&quot;, ref:&quot;theAroundAspect&quot; ) {
                around method:&quot;invoke&quot;, pointcut: &quot;execution(* webalbum.Album.*())&quot;
            }
        }
    }
}
[/groovy]

I merged these two ApplicationContext as follows:

[groovy]
def mainContext = grailsApplication.getMainContext()
def appCtx = bb.createApplicationContext()
addBeanDefinitions(appCtx, mainContext)
[/groovy]

where addBeanDefinitions() is as follows:

[groovy]
private void addBeanDefinitions(ApplicationContext context, ApplicationContext mainContext) {
    DefaultListableBeanFactory scriptBeanFactory = context.autowireCapableBeanFactory
    for (name in  scriptBeanFactory.getBeanDefinitionNames()) {
        BeanDefinition definition = scriptBeanFactory.getBeanDefinition(name)
        mainContext.autowireCapableBeanFactory.registerBeanDefinition(name, definition)
    }
}
[/groovy]

The problem is AOP in this case doesn&#039;t work on webalbum.Album domain object. However if I include Album object in BeanBuilder and use it from the ApplicationContext created with BeanBuilder, AOP works. Merge operation doesn&#039;t. Anything I am missing here?</description>
		<content:encoded><![CDATA[<p>Excellent blog. I am trying to use the same to apply the AOP Around advice on top of existing Grails domain objects (for instance webalbum.Album in my case) available in main ApplicationContext as follows:</p>
<pre class="brush: groovy; title: ; notranslate">
bb.beans {
    xmlns aop:&quot;<a href="http://www.springframework.org/schema/aop&#038;quot" rel="nofollow">http://www.springframework.org/schema/aop&#038;quot</a>;

    album(Album)
    theAroundAspect(TheAspect)

    aop {
        config(&quot;proxy-target-class&quot;:true) {
            aspect( id:&quot;myAspect&quot;, ref:&quot;theAroundAspect&quot; ) {
                around method:&quot;invoke&quot;, pointcut: &quot;execution(* webalbum.Album.*())&quot;
            }
        }
    }
}
</pre>
<p>I merged these two ApplicationContext as follows:</p>
<pre class="brush: groovy; title: ; notranslate">
def mainContext = grailsApplication.getMainContext()
def appCtx = bb.createApplicationContext()
addBeanDefinitions(appCtx, mainContext)
</pre>
<p>where addBeanDefinitions() is as follows:</p>
<pre class="brush: groovy; title: ; notranslate">
private void addBeanDefinitions(ApplicationContext context, ApplicationContext mainContext) {
    DefaultListableBeanFactory scriptBeanFactory = context.autowireCapableBeanFactory
    for (name in  scriptBeanFactory.getBeanDefinitionNames()) {
        BeanDefinition definition = scriptBeanFactory.getBeanDefinition(name)
        mainContext.autowireCapableBeanFactory.registerBeanDefinition(name, definition)
    }
}
</pre>
<p>The problem is AOP in this case doesn&#039;t work on webalbum.Album domain object. However if I include Album object in BeanBuilder and use it from the ApplicationContext created with BeanBuilder, AOP works. Merge operation doesn&#039;t. Anything I am missing here?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://blog.springsource.org/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/comment-page-1/#comment-119451</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Wed, 03 Sep 2008 05:43:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/#comment-119451</guid>
		<description>The issue SPR-4903 has been resolved (in 2.5.5-20080630-542) and the problem with circular reference disappeared. Spring community was really fast to deal with!

Another problem I&#039;ve observed with BeanBuilder DSL combined with XML ApplicationContext is double instantiation of the beans described by DSL inside XML. If you insert some debug output to JavaMessenger constructor you will see what I mean.

That&#039;s happening because of BeanBuilder&#039;s createApplicationContext method calls refresh() on created context and there is no way to call this method without context refreshing (BeanBuilder&#039;s API lack?).

I resolved this problem by overriding BeanBuilder&#039;s createRuntimeSpringConfiguration method to return my own implementation (extension) of DefaultRuntimeSpringConfiguration which in its turn skips refresh() in getApplicationContext:

[code]
public class MyBeanBuilder extends BeanBuilder {
    protected RuntimeSpringConfiguration createRuntimeSpringConfiguration(
                                     ApplicationContext parent, ClassLoader classLoader) {
        return new MyRuntimeSpringConfiguration(parent, classLoader);
    }
}
[/code]

[code]
public class MyRuntimeSpringConfiguration extends DefaultRuntimeSpringConfiguration {

  public MyRuntimeSpringConfiguration(ApplicationContext parent, ClassLoader classLoader) {
        super(parent, classLoader);
  }

  public ApplicationContext getApplicationContext() {
      initialiseApplicationContext();
      registerBeansWithContext(context);
      //context.refresh();
      return context;
  }
}
[/code]

Thanks!</description>
		<content:encoded><![CDATA[<p>The issue SPR-4903 has been resolved (in 2.5.5-20080630-542) and the problem with circular reference disappeared. Spring community was really fast to deal with!</p>
<p>Another problem I&#039;ve observed with BeanBuilder DSL combined with XML ApplicationContext is double instantiation of the beans described by DSL inside XML. If you insert some debug output to JavaMessenger constructor you will see what I mean.</p>
<p>That&#039;s happening because of BeanBuilder&#039;s createApplicationContext method calls refresh() on created context and there is no way to call this method without context refreshing (BeanBuilder&#039;s API lack?).</p>
<p>I resolved this problem by overriding BeanBuilder&#039;s createRuntimeSpringConfiguration method to return my own implementation (extension) of DefaultRuntimeSpringConfiguration which in its turn skips refresh() in getApplicationContext:</p>
<pre class="brush: plain; title: ; notranslate">
public class MyBeanBuilder extends BeanBuilder {
    protected RuntimeSpringConfiguration createRuntimeSpringConfiguration(
                                     ApplicationContext parent, ClassLoader classLoader) {
        return new MyRuntimeSpringConfiguration(parent, classLoader);
    }
}
</pre>
<pre class="brush: plain; title: ; notranslate">
public class MyRuntimeSpringConfiguration extends DefaultRuntimeSpringConfiguration {

  public MyRuntimeSpringConfiguration(ApplicationContext parent, ClassLoader classLoader) {
        super(parent, classLoader);
  }

  public ApplicationContext getApplicationContext() {
      initialiseApplicationContext();
      registerBeansWithContext(context);
      //context.refresh();
      return context;
  }
}
</pre>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Syer</title>
		<link>http://blog.springsource.org/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/comment-page-1/#comment-109118</link>
		<dc:creator>Dave Syer</dc:creator>
		<pubDate>Mon, 09 Jun 2008 06:59:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/#comment-109118</guid>
		<description>If you could create a simple example and post it in a JIRA issue, someone could have a look at the circular reference problem.  (If you do that, please post back the JIRA issue number here as well.)</description>
		<content:encoded><![CDATA[<p>If you could create a simple example and post it in a JIRA issue, someone could have a look at the circular reference problem.  (If you do that, please post back the JIRA issue number here as well.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://blog.springsource.org/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/comment-page-1/#comment-109113</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Mon, 09 Jun 2008 03:46:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/#comment-109113</guid>
		<description>Blog engine eliminated the tag from my previous comment: &lt;aop:config/&gt;</description>
		<content:encoded><![CDATA[<p>Blog engine eliminated the tag from my previous comment: &lt;aop:config/&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://blog.springsource.org/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/comment-page-1/#comment-109112</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Mon, 09 Jun 2008 03:42:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/#comment-109112</guid>
		<description>Great post and very useful knowledge!

BeanBuilder&#039;s DSL offers very comfortable way to define beans.
I tried sample and it works just fine!
But adding  into spring configurations reveals some problems in the framework: it can not create customizer bean and fails with &quot;Requested bean is currently in creation: Is there an unresolvable circular reference?&quot; exception.
I tried the last Spring snapshot (2.5.5 20080606) - result is the same.
So, currently there is no way for use DSL together with AOP.

Thank you,
Alex</description>
		<content:encoded><![CDATA[<p>Great post and very useful knowledge!</p>
<p>BeanBuilder&#039;s DSL offers very comfortable way to define beans.<br />
I tried sample and it works just fine!<br />
But adding  into spring configurations reveals some problems in the framework: it can not create customizer bean and fails with &#034;Requested bean is currently in creation: Is there an unresolvable circular reference?&#034; exception.<br />
I tried the last Spring snapshot (2.5.5 20080606) &#8211; result is the same.<br />
So, currently there is no way for use DSL together with AOP.</p>
<p>Thank you,<br />
Alex</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SpringSource Team Blog &#187; Spring .NET 1.1 and container configuration</title>
		<link>http://blog.springsource.org/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/comment-page-1/#comment-84847</link>
		<dc:creator>SpringSource Team Blog &#187; Spring .NET 1.1 and container configuration</dc:creator>
		<pubDate>Fri, 04 Jan 2008 22:36:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/#comment-84847</guid>
		<description>[...] One thing to keep in mind is that core container is not dependent on XML based object definitions. The container has its own internal object model for these definitions. As such, object definitions can come from a variety of formats. Particularly enticing, from what I’ve read so far, is to configure exception handling advice using the DSL toolkit. Other interesting approaches for configuration are to use a scripting language DSL (see this post for Spring Java + Groovy integration). At the end of the day, the goal is to let you pick among multiple configuration approaches for the task at hand. [...]</description>
		<content:encoded><![CDATA[<p>[...] One thing to keep in mind is that core container is not dependent on XML based object definitions. The container has its own internal object model for these definitions. As such, object definitions can come from a variety of formats. Particularly enticing, from what I’ve read so far, is to configure exception handling advice using the DSL toolkit. Other interesting approaches for configuration are to use a scripting language DSL (see this post for Spring Java + Groovy integration). At the end of the day, the goal is to let you pick among multiple configuration approaches for the task at hand. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Weerasak.com &#187; Article: Spring Dynamic Language Support and a Groovy DSL</title>
		<link>http://blog.springsource.org/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/comment-page-1/#comment-75988</link>
		<dc:creator>Weerasak.com &#187; Article: Spring Dynamic Language Support and a Groovy DSL</dc:creator>
		<pubDate>Wed, 05 Dec 2007 14:55:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/#comment-75988</guid>
		<description>[...] Spring Dynamic Language Support and a Groovy DSL by Dave Syer  Since the introduction of Spring dynamic laguage support in Spring 2.0 it has been an attractive integration point for Groovy, and Groovy provides a rich environment for defining Domain Specific Languages (DSL). But the examples of Groovy integration in the Spring reference manual are limited in scope and do not show the features in Spring that are targeted at DSL integration. In this article I show how to use those features and as an example we add bean definitions to an existing ApplicationContext with a Groovy DSL from the Grails distribution. [...]</description>
		<content:encoded><![CDATA[<p>[...] Spring Dynamic Language Support and a Groovy DSL by Dave Syer  Since the introduction of Spring dynamic laguage support in Spring 2.0 it has been an attractive integration point for Groovy, and Groovy provides a rich environment for defining Domain Specific Languages (DSL). But the examples of Groovy integration in the Spring reference manual are limited in scope and do not show the features in Spring that are targeted at DSL integration. In this article I show how to use those features and as an example we add bean definitions to an existing ApplicationContext with a Groovy DSL from the Grails distribution. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan Scheidt</title>
		<link>http://blog.springsource.org/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/comment-page-1/#comment-75241</link>
		<dc:creator>Stefan Scheidt</dc:creator>
		<pubDate>Mon, 03 Dec 2007 08:41:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/#comment-75241</guid>
		<description>Hi Dave,

thanks for this interesting post. I&#039;m quite interested in using Grails BeanBuilder, mainly in combination with XML-based bean definition files, e.g. for aop/tx-namespace based configuration of AOP or TX. What I would like most is something like JavaConfigs ConfigurationBeanPostProcessor for BeanBuilder. That would be even nicer then your suggestion, I think.

Regards and again thanks for your post!
Stefan</description>
		<content:encoded><![CDATA[<p>Hi Dave,</p>
<p>thanks for this interesting post. I&#039;m quite interested in using Grails BeanBuilder, mainly in combination with XML-based bean definition files, e.g. for aop/tx-namespace based configuration of AOP or TX. What I would like most is something like JavaConfigs ConfigurationBeanPostProcessor for BeanBuilder. That would be even nicer then your suggestion, I think.</p>
<p>Regards and again thanks for your post!<br />
Stefan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Graeme Rocher</title>
		<link>http://blog.springsource.org/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/comment-page-1/#comment-74157</link>
		<dc:creator>Graeme Rocher</dc:creator>
		<pubDate>Fri, 30 Nov 2007 12:33:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/#comment-74157</guid>
		<description>Hi Dave,

Nice post, just a few corrections/comments. We have created a separate jar called grails-spring-*.jar that contains only the BeanBuilder and its supporting classes. So you no longer need Grails core. Also it does now work without the servlet dependencies and there are two BeanBuilders: BeanBuilder and WebBeanBuilder. The latter extends BeanBuilder and takes a ServletContext etc.

All of this will be available officially in Grails 1.0 RC2, which will be out in the next week or so.

Also it should be noted that you can use BeanBuilder standalone without the need to embedd within XML if you want to take the Groovy DSL use further.

Again, great post.

Cheers,
Graeme</description>
		<content:encoded><![CDATA[<p>Hi Dave,</p>
<p>Nice post, just a few corrections/comments. We have created a separate jar called grails-spring-*.jar that contains only the BeanBuilder and its supporting classes. So you no longer need Grails core. Also it does now work without the servlet dependencies and there are two BeanBuilders: BeanBuilder and WebBeanBuilder. The latter extends BeanBuilder and takes a ServletContext etc.</p>
<p>All of this will be available officially in Grails 1.0 RC2, which will be out in the next week or so.</p>
<p>Also it should be noted that you can use BeanBuilder standalone without the need to embedd within XML if you want to take the Groovy DSL use further.</p>
<p>Again, great post.</p>
<p>Cheers,<br />
Graeme</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Configure Spring using Grails DSL at Fragmental.tw</title>
		<link>http://blog.springsource.org/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/comment-page-1/#comment-73873</link>
		<dc:creator>Configure Spring using Grails DSL at Fragmental.tw</dc:creator>
		<pubDate>Fri, 30 Nov 2007 00:52:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/11/29/spring-dynamic-language-support-and-a-groovy-dsl/#comment-73873</guid>
		<description>[...] Dave Syer wrote a post on how you can use Grails&#8217; DSL to configure the Spring Framework even without using Grails as your application framework. It is nice to see that Spring folks are writing about the benefits of LOP in configuration but I really think that Spring still needs a lot of changes to be on the right track. [...]</description>
		<content:encoded><![CDATA[<p>[...] Dave Syer wrote a post on how you can use Grails&#039; DSL to configure the Spring Framework even without using Grails as your application framework. It is nice to see that Spring folks are writing about the benefits of LOP in configuration but I really think that Spring still needs a lot of changes to be on the right track. [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

