Dan, thanks for the example, that's precisely what I'm looking for. Thanks!

Phil

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Daniel Schmid
Sent: Wednesday, December 21, 2005 6:02 AM

To: [email protected]
Subject: [coldspring-dev] Dynamic Datasource

 

ben,

your correct.. of course I should be:

<cfset application.defaultProperties.dsvendor = "MySQL"/>
and
<property name="vendor"><value>${dsvendor}</value></property>

but don't reference it as
application.dsVendor. CS does the paramater matching for you.

you passed them in  with

cfset application.serviceFactory = createObject('component',                      'coldspring.beans.DefaultXmlBeanFactory').init(structnew(),application.defaultProperties)/>

as a struct and reference it with ${variable}

but be aware the the CS refGuide 0.5 mentions:
"Eventually this will be expanded/refactored into entire CFML _expression_ support."

hope that helps

- daniel

On 12/21/05, Baz <[EMAIL PROTECTED]> wrote:

Hey Dan,

 

Cool I didn't notice that actually – one question – you defined the Vendor as application.dsVendor but then referenced as ${vendor} in the XML. How does that work? Should it not have been originally called application.dsVendor?

 

Cheers,

Baz

 


From: [email protected] [mailto:[email protected]] On Behalf Of Daniel Schmid
Sent:
December 21, 2005 4:04 AM
To: [email protected]
Subject: [coldspring-dev] Dynamic Datasource

 

Baz,
You don't have to put database settings in the CS XML file.

Look at the examples provided with the coldspring 0.5 release.

In Application.cfm or Aplication.cfc

<cfset application.defaultProperties = structnew()/>
<!--- properties needed for rdbms storage --->
            <cfset application.defaultProperties.dsn = "myDSN"/>
            <cfset application.defaultProperties.dsvendor = "MySQL"/>

<cfset application.serviceFactory = createObject('component',                      'coldspring.beans.DefaultXmlBeanFactory').init(structnew(),application.defaultProperties)/>

in the Coldspring XML:
 <bean id="datasourceSettings" class="datasources">
        <property name="type"><value>${dstype}</value></property>
        <property name="datasourceName"><value>${dsn}</value></property>
        <property name="vendor"><value>${vendor}</value></property>       
    </bean>
</beans>

Daniel

On 12/20/05, Baz <[EMAIL PROTECTED]> wrote:


Hey Joe,

I heard it was bad security to put UN/PW info in the coldspring XML...

Cheers,
Baz

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Joe Rinehart
Sent:
December 20, 2005 1:52 PM
To: [email protected]
Subject: [coldspring-dev] Dynamic Datasource

(stops lurking)

Hey Phillip,

I'd define a bean to hold datasource information, and wire it to the
CFC that needs it.  That way, if datasource information need to
expand, you've got room to grow.

The XML would probably go a lot like this:

<bean id="SomeBeanNeedingDatasource"
class="tld.domain.SomeBeanNeedingDatasource">
  <constuctor-arg name="Datasource">
    <ref bean="Datasource" />
  </constructor>
</bean>

<bean id="Datasource" class="ModelGlue.Bean.CommonBeans.Datasource">
  <property name="DSN">
    <value>SomeDSN</value>
  </property>
  <property name="Username">
    <value>SomeUsername</value>
  </property>
  <property name="Password">
    <value>SomePassword</value>
  </property>
</bean>

Cheers,

Joe



--
Get Glued!
The Model-Glue ColdFusion Framework
http://www.model-glue.com




--
Daniel Schmid
Webarchitect
Seeeldstr. 305a
CH-8008 Zürich
www.danielschmid.name
+41 44 389 67 76




--
Daniel Schmid
Webarchitect
Seeeldstr. 305a
CH-8008 Zürich
www.danielschmid.name
+41 44 389 67 76


Reply via email to