Transfer and coldspring

1 view
Skip to first unread message

Chris Blackwell

unread,
Nov 19, 2008, 2:48:35 PM11/19/08
to transf...@googlegroups.com
Hi

I have transfer setup up in my applications coldspring, and i'm wondering whether its ok to ask cs to create an instance of transfer.com.Transfer using the factory-bean/factory-method attributes, rather than having to do transferFactory.getTransfer() everywhere.  I have the following bean definitions for transfer

<beans>   
   
    <bean id="transferConfiguration" class="transfer.com.config.Configuration">
        <constructor-arg name="datasourcePath"><value>/config/transfer/Datasource.xml</value></constructor-arg>
        <constructor-arg name="configPath"><value>/config/transfer/Transfer.xml</value></constructor-arg>
        <constructor-arg name="definitionPath"><value>/model/data</value></constructor-arg>
    </bean>
   
    <bean id="transferFactory" class="transfer.TransferFactory">
        <constructor-arg name="configuration"><ref bean="transferConfiguration" /></constructor-arg>
    </bean>

    <bean id="transfer" class="transfer.com.Transfer"
        factory-bean="transferFactory"
        factory-method="getTransfer">
    </bean>

</beans>

Is that a reasonable way to go ?

cheers, Chris

Jared Rypka-Hauer

unread,
Nov 19, 2008, 4:03:50 PM11/19/08
to transf...@googlegroups.com
Absolutely. Transfer is still used by most applications as a
singleton, so having CS respond to getBean("Transfer") is a perfectly
viable (and even recommended) approach to having a ColdSpring managed
way of getting to Transfer.

In this role, Transfer is acting as a factory to access your domain
objects.

J

On Nov 19, 2008, at 1:48 PM, Chris Blackwell wrote:

> Hi
>
> I have transfer setup up in my applications coldspring, and i'm
> wondering whether its ok to ask cs to create an instance of
> transfer.com.Transfer using the factory-bean/factory-method
> attributes, rather than having to do transferFactory.getTransfer()

> everywhere. I have the following bean definitions for transfer ...

Paul Marcotte

unread,
Nov 19, 2008, 4:07:54 PM11/19/08
to transf...@googlegroups.com
Chris,

Absolutely.  I would also recommend bean definitions for...

<bean id="datasource" factory-bean="transferFactory" factory-method="getDatasource" />
   
<bean id="transaction" factory-bean="transferFactory" factory-method="getTransaction" />

Paul
--
Paul Marcotte
Fancy Bread - in the heart or in the head?
http://www.fancybread.com

Bob Silverberg

unread,
Nov 19, 2008, 4:29:43 PM11/19/08
to transf...@googlegroups.com
And while you're at it, you may want to add:

<bean id="TDOBeanInjectorObserver"
class="path.to.TDOBeanInjectorObserver" lazy-init="false">
<constructor-arg name="transfer"><ref bean="transfer" /></constructor-arg>
<constructor-arg
name="afterCreateMethod"><value>Setup</value></constructor-arg>
<property name="beanInjector">
<ref bean="beanInjector" />
</property>
</bean>

<bean id="beanInjector" class="path.to.BeanInjector">
<constructor-arg name="debugMode"><value>false</value></constructor-arg>
</bean>

Which will allow your Transfer Objects to be autowired via Brian's
BeanInjector (http://coldspringutils.riaforge.org/). It may seem a
bit complicated at first, but you'll probably find you need it
eventually.

Bob
--
Bob Silverberg
www.silverwareconsulting.com
Reply all
Reply to author
Forward
0 new messages