I'm very new to the whole OO world, so please bear with me!

 

I'm playing around with ColdSpring on a new intranet site for my company.
It's one of the larger projects I've worked on in terms of the number of
CFC's and dependencies, so I figured it'd be a good fit for testing out
ColdSpring.  

 

The problem I'm running in to is that I'm unsure whether I should be
specifying my dependencies as constructor-arg's or as properties.  In some
cases, I don't have a choice (Domains is dependent on Contracts, and
Contracts is also dependent on Domains, so I have to use the <property> tag
there).  But I was wondering if there's a "golden rule" to follow for which
ones to use (when you have the luxury of choosing)?  Right now, I'm getting
the feeling that I'll be better off using the <property> tag for all my
dependencies, then I wouldn't even need to be aware of inter-dependent
beans.

 

Here's my config.xml file, if that helps people understand:

 

<!-- File loaded by ColdSpring to perform dependency injection -->

<beans>

                <!-- Put definitions for your own beans and services here
-->

                <bean id="Domains" class="Components.Domains"
singleton="true">

                                <constructor-arg
name="datasource"><value>cfCIS</value></constructor-arg>

                                

                                <constructor-arg name="statusesCFC"><ref
bean="DomainStatuses" /></constructor-arg>

                                <constructor-arg name="registrarsCFC"><ref
bean="DomainRegistrars" /></constructor-arg>

                                <constructor-arg name="typesCFC"><ref
bean="DomainTypes" /></constructor-arg>

                                <!-- Some Beans are dependent on the very
same beans that depend on them.  CS to crashes when you try to wire
inter-dependent beans using the contstructor-arg parameter - as it cannot
instantiate two CFC's that both require eachother to be constructed.  This
is solved by allowing the CFC's to be created and then after that, then
setting the properties. -->

                                <property name="emailsCFC"><ref
bean="DomainEmails" /></property>

                                <property name="measurementsCFC"><ref
bean="DomainMeasurements" /></property>

                                <property name="recordsCFC"><ref
bean="DomainRecords" /></property>

                                <property name="contractsCFC"><ref
bean="Contracts" /></property>

                </bean>

                <bean id="Clients" class="Components.Clients"
singleton="true">

                                <constructor-arg
name="datasource"><value>cfCIS</value></constructor-arg>

                                <constructor-arg name="managersCFC"><ref
bean="Managers" /></constructor-arg>

                </bean>

                <bean id="ClientContacts" class="Components.ClientContacts"
singleton="true">

                                <constructor-arg
name="datasource"><value>cfCIS</value></constructor-arg>

                                <constructor-arg name="clientsCFC"><ref
bean="Clients" /></constructor-arg>

                </bean>

                <bean id="Contracts" class="Components.Contracts"
singleton="true">

                                <constructor-arg
name="datasource"><value>cfCIS</value></constructor-arg>

                                <constructor-arg name="clientsCFC"><ref
bean="Clients" /></constructor-arg>

                                <constructor-arg name="plansCFC"><ref
bean="HostingPlans" /></constructor-arg>

                                <constructor-arg name="passwordsCFC"><ref
bean="ContractPasswords" /></constructor-arg>

                                <property name="domainsCFC"><ref
bean="Domains" /></property>

                </bean>

                <bean id="ContractPasswords"
class="Components.ContractPasswords" singleton="true">

                                <constructor-arg
name="datasource"><value>cfCIS</value></constructor-arg>

                                <!--<constructor-arg
name="contractsCFC"><ref bean="Contracts" /></constructor-arg>-->

                </bean>

                <bean id="DomainEmails" class="Components.DomainEmails"
singleton="true">

                                <constructor-arg
name="datasource"><value>cfCIS</value></constructor-arg>

                                <property name="domainsCFC"><ref
bean="Domains" /></property>

                </bean>

                <bean id="DomainMeasurements"
class="Components.DomainMeasurements" singleton="true">

                                <constructor-arg
name="datasource"><value>cfCIS</value></constructor-arg>

                                <constructor-arg name="typesCFC"><ref
bean="MeasurementTypes" /></constructor-arg>

                                <property name="domainsCFC"><ref
bean="Domains" /></property>

                </bean>

                <bean id="DomainRecords" class="Components.DomainRecords"
singleton="true">

                                <constructor-arg
name="datasource"><value>cfCIS</value></constructor-arg>

                                <property name="domainsCFC"><ref
bean="Domains" /></property>

                </bean>

                <!-- non-dependent CFCs -->

                <bean id="Managers" class="Components.Managers"
singleton="true">

                                <constructor-arg
name="datasource"><value>cfCIS</value></constructor-arg>

                </bean>

                <bean id="HostingPlans" class="Components.HostingPlans"
singleton="true">

                                <constructor-arg
name="datasource"><value>cfCIS</value></constructor-arg>

                </bean>

                <bean id="DomainTypes" class="Components.DomainTypes"
singleton="true">

                                <constructor-arg
name="datasource"><value>cfCIS</value></constructor-arg>

                </bean>

                <bean id="Servers" class="Components.Servers"
singleton="true">

                                <constructor-arg
name="datasource"><value>cfCIS</value></constructor-arg>

                </bean>

                <bean id="DomainRegistrars"
class="Components.DomainRegistrars" singleton="true">

                                <constructor-arg
name="datasource"><value>cfCIS</value></constructor-arg>

                </bean>

                <bean id="DomainStatuses" class="Components.DomainStatuses"
singleton="true">

                                <constructor-arg
name="datasource"><value>cfCIS</value></constructor-arg>

                </bean>

                <bean id="MeasurementTypes"
class="Components.MeasurementTypes" singleton="true">

                                <constructor-arg
name="datasource"><value>cfCIS</value></constructor-arg>

                </bean>

                <!-- Service Beans -->

                <bean id="Soap" class="Services.Soap" singleton="true">

                </bean>

                <bean id="DNS" class="Services.DNS" singleton="true">

                                <constructor-arg
name="dnsServer"><value>dns://192.168.0.2</value></constructor-arg>

                                <constructor-arg name="domainsCFC"><ref
bean="Domains" /></constructor-arg>

                                <constructor-arg name="recordsCFC"><ref
bean="DomainRecords" /></constructor-arg>

                </bean>

                <bean id="DomainServices" class="Services.DomainServices"
singleton="true">

                                <constructor-arg
name="datasource"><value>cfCIS</value></constructor-arg>

                                <constructor-arg name="domainsCFC"><ref
bean="Domains" /></constructor-arg>

                                <constructor-arg name="serversCFC"><ref
bean="Servers" /></constructor-arg>

                                <constructor-arg name="emailsCFC"><ref
bean="DomainEmails" /></constructor-arg>

                                <constructor-arg name="measurementsCFC"><ref
bean="DomainMeasurements" /></constructor-arg>

                                <constructor-arg name="dnsCFC"><ref
bean="DNS" /></constructor-arg>

                                <constructor-arg name="soapCFC"><ref
bean="Soap" /></constructor-arg>

                </bean>

</beans>

 

Thanks for taking the time to read all that!

 

Jonathon

 

 

Reply via email to