Easy ColdSpring in Model-Glue

来源:互联网 发布:微博mac版下载 编辑:程序博客网 时间:2024/05/20 09:43

from:  http://clearsoftware.net

Dave Ross and Chris Scott are doing an _amazing_ job with the ColdSpring project. For those of you who aren't familiar with Spring, it's a Java framework that provides a number of services such as IoC (like ConfigBeans in Model-Glue), Aspect Oriented Programming, and ORM functionality amongst many things. Right now, ColdSpring is at 0.2.1 and provides IoC and Aspect Oriented functionality.

Summary for the impatient - how to use ColdSpring seamlessly Model-Glue in four steps:

 

ColdSpring is very nice, and Dave's done some nice work on Model-Glue integration that I decided to wrap into the framework itself, building some functionality into the Bleeding Edge Release of Model-Glue (svn://clearsoftware.net/clearsoftware.net/ModelGlue) that'll let you seamlessly use ColdSpring.

Just add the following line of code to your ModelGlue.xml file:

 

<setting name="beanFactoryLoader" value="ModelGlue.Core.ColdSpringLoader" />

Then change the beanMappings setting to your ColdSpring .xml file:

 

<setting name="beanMappings" value="/modelgluesamples/coldspring/config/beans/AllBeans.xml" />

Once that's done, if you do getModelGlue().getConfigBean(), instead of passing the filename of an XML file to get, just pass the ID of the ColdSpring bean to load.

If you get the latest M-G BER, you'll notice there's a modelgluesamples/coldspring app that shows it in action. The thing just _worked_ on the first try.

Credit goes to Dave - he basically wrote the code to do it all, I just used the pluggable part of Model-Glue 1.0 to make it go.

Note: There are things to think about when using ColdSpring as the native bean factory in Model-Glue. You won't be able to use existing ChiliBean beans unless you create the ChiliBean BeanFactory by hand, so it's not something to implement mid-project. However, it wouldn't be hard to move ChiliBean XML files into a ColdSpring XML doc.

 

  1. Get latest from the BER Subversion repo.
  2. Add <setting name="beanFactoryLoader" value="ModelGlue.Core.ColdSpringLoader" /> to your ModelGlue.xml
  3. Change the beanMappings setting to the path to your ColdSpring xml: <setting name="beanMappings" value="/modelgluesamples/coldspring/config/beans/AllBeans.xml" />
  4. Instead of GetModelGlue().GetConfigBean("myBeanFileName.xml"), use GetModelGlue.GetConfigBean("ColdSpringBeanId")
原创粉丝点击