I apologize if this is the wrong list (I only see coldspring-dev), let
me know if there is a better place to ask general questions.

After checking the archives, reading the documentation, and spinning
my wheels for a bit I still seem to be having problems getting the
autowire functionality to work on an existing app which is not in an
established framework.

I'm currently modifying an old application which uses it's own
framework (a very basic MVC front controller with all of the model
CFC's being implemented in design patterns.. it runs a process rather
than it being a traditional web app and at the time there wasn't a
good lightweight framework to use for said app) to use Coldspring for
IoC and I seem to be missing something.  I've implemented ColdSpring
before without any problems in a Model-Glue app, but this is the first
time I've used it on it's own outside of Mach-II or Model-Glue and it
seems that the autowire functionality isn't working correctly.

Before I go into too much detail, I'll ask the simple question-- am I
incorrectly assuming that autowiring works outside of the Mach-II and
Model-Glue frameworks in Coldspring?  If so, that would explain the
problem I'm having obviously.  ;)  And if that's also true, I assume
I'd need to write something to handle autowiring of a generic CFC
instance?

Otherwise, keep reading...

I'm loading ColdSpring in the init() method of a Factory CFC which
essentially manages the instances of the factory objects used in the
application.  It basically just has a constructor, a bunch of
mutator/accessor methods, and a single method which handles caching of
these objects (which is not used when in "development mode").  This is
what the init() method looks like:

<cffunction name="init" returntype="WEB-INF.cftags.component"
hint="Constructor">
        <cfset var BeanPath = "pathremoved" />
        <cfset 
setBeanFactory(createObject("component","coldspring.beans.DefaultXmlBeanFactory").init())
/>
        <cfset getBeanFactory().loadBeansFromXmlFile(BeanPath,true)/>
        <cfreturn this />
</cffunction>

The same component contains a bunch of mutators/accessors for each of
the beans such as this (xml config snippet for said bean prefaces it
as well):

<bean id="APIFactory"
class="ReportSystem.com.ia.reportsystem.api.APIFactory"
autowire="byName">
        <property name="Config">
                <ref bean="Config"/>
        </property>
</bean>

<cffunction name="getAPIFactory" returntype="WEB-INF.cftags.component"
hint="Returns the value for APIFactory" output="false">
        <cfreturn Variables.APIFactory />
</cffunction>

<cffunction name="setAPIFactory" returntype="void" hint="Sets the
value for APIFactory" output="false">
        <cfargument name="APIFactory" hint="The value of APIFactory"
type="WEB-INF.cftags.component" required="true" />
        <cfset Variables.APIFactory = Arguments.APIFactory />
</cffunction>

ColdSpring is parsing my XML file correctly, if I do a
getBeanFactory().getBean("APIFactory") (or any other bean for that
matter) the bean(s) are returned correctly, however they are not
getting set automagically via the autowiring functionality (FWIW,
previously the 'autowire' attribute was not being set in the XML
config.. decided to try it out with no luck).  So essentially once the
app is loaded and tries to call an instance of an object from a
getXXX() method, it does not exist and an error is thrown.

Anyhow, I'm probably doing something obviously wrong that I don't seem
to be catching with my own eyes or perhaps just have a
misunderstanding of something, so I thought I'd check to see if anyone
had a minute or two take a look...

Thanks In Advance,

- Brandon

--
http://devnulled.com

Reply via email to