Brian - good questions. My situation is a bit unusual. I'm working on the
frameworks chapter in the next version of the CFWACK book. We're using a
Derby database which is not supported by Reactor. But in my Model-Glue:
Unity example, I'd still like to provide the reader with a coldspring.xml
config that looks like what they'll see in their first M-G-:U app. I also
need to keep my sample apps simpe due to space limitations and consideration
of the reader's experience level. So, I've got a simple example, with only a
couple objects, that doesn't really reflect a real-world app and I want to
explain how Reactor is employed w/o being able to actually use it.
Yeah...kinda goofy.
 
Meanwhile, I did come up with what seems like a bit more elegant solution,
given the situation. In my coldspring.xml, I include the
reactorConfiguration bean and define the DSN as a property there. Then when
configuring my app's bean, I just use a factory-bean to grab the DSN value
from the reactorConfiguration bean.
 
<bean id="contact" class="ows.54.MGcontactMgr.model.contact">
  <constructor-arg name="dsn">
    <bean factory-bean="reactorConfiguration" factory-method="getDSN" />
  </constructor-arg>
</bean>

 

  _____  

From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of Brian Kotek
Sent: Tuesday, July 10, 2007 8:28 AM
To: [email protected]
Subject: [coldspring-dev] Newbie ColdSpring question


Leon, there are sort of two issues here. When not using Reactor, I acutally
prefer to use a configuration CFC and inject the CFC into the components
that need it. This way I can wrap up all sorts of good information beyond
just the data source name. Things like server name, development mode (dev
mode or production mode?), paths, mappings, whatever. Anything that might
change from, say, my local system, to the staging server, to the production
server. 

However, is there a reason why anything outside of your Reactor objects
would need the data source name? I could see it maybe on an existing app
that was having Reactor added onto it, but in a new app? You might want to
reassess whether non-Reactor CFCs should know anything about the database. 




On 7/9/07, Leon Chalnick <[EMAIL PROTECTED]> wrote: 

Howdy,

I'm working on my first Model-Glue: Unity app and am wondering about the
best way to configure my beans with a datasource name. I'm hoping someone on
this list has experience with Model-Glue's implementation of CS and can 
point me in the right direction.

<bean id="contact" class="MGcontactMgr.model.contact">
        <constructor-arg name="dsn"><value>ows</value></constructor-arg> 
</bean>
<bean id="contactGateway" class="MGcontactMgr.model.contactGateway">
        <constructor-arg name="dsn"><value>ows</value></constructor-arg> 
</bean>

I have the dsn already defined in my reactorConfiguration bean (below),
seems rather clumsy to have to spell it out again this way.

<bean id="reactorConfiguration" class=" reactor.config.config">
        <constructor-arg name="pathToConfigXml">
          <value>/MGcontactMgr/config/Reactor.xml</value>
        </constructor-arg>
        <property name="dsn"><value>myContactMgr</value></property> 
        ...
</bean>

So my first question is...is there a more elegant way to pull the dsn
property from the reactorConfiguration bean and pass it to my other beans
that need it?

Second...is this the appropriate place to be passing the dsn to beans that 
will interact with the database? Seems like a better place to do it than in
my controller.cfc...

TIA!

--Leon





Reply via email to