Init method is for specifying an object initializer, which is called
when the object has been constructed and had all it's properties set.
In CF-land, we use 'init' as a constructor, but Java (which Spring was
designed for) has real constructors. So the course of events looks
like this:
- beanFactory.getBean("myBean");
- myBean is created with CreateObject()
- myBean has init() called, if present, passing in any
constructor-arg values specified in the XML
- myBean has properties set (via setXXX) for any property values
specified in the XML
- myBean has the method listed as it's init-method in the XML invoked
with no arguments
- beanFactory returns the myBean instance
Obviously if myBean is a singleton, this only happens on the first
invocation; subsequent invocations only execute the first and last
steps.
Spring also has an interfance named InitializingBean which has a
afterPropertiesSet method that behaves in much the same way (it's
called after properties are set). The main difference is that
init-method is specified in the XML (and therefore the bean can't
assume it'll fire, unless it stipulates in it's usage contract that it
MUST be called), while the InitializingBean interface is specified in
code and Spring will guarantee is called, regardless of the XML
configuration (or misconfiguration).
cheers,
barneyb
On 7/9/07, Brian Kotek <[EMAIL PROTECTED]> wrote:
I've never heard of this init-method thing. To get ColdSpring to inject your
Articles component you just need a setter in your Category component.
ColdSpring matches the name of the property to the setter (so property
Articles looks for setter setArticles). So make sure in your XML the name of
the property matches the name used in the setter.
<cffunction name="setArticles" access="public" returntype="void"
hint="Articles setter">
<cfargument name="articlesCFC" type="Components.Articles "
required="true" />
<cfset Variables.articlesCFC = arguments.articlesCFC />
</cffunction>
--
Barney Boisvert
[EMAIL PROTECTED]
http://www.barneyb.com/
Got Gmail? I have 100 invites.