On Aug 4, 2008, at 3:18 PM, Patrik Nordwall wrote:
The only thing you have missed is that you have to qualify the expand
definitions, since they are not in the same file.
«EXPAND templates::Spring::txManager»
I would like that we improve sculptor with all good ideas. I think
using a
Spring data source configuration might be useful, even though I'm
still in
doubt for the location of the db password for a production scenario.
Please
add a request in jira, which you can assign to yourself. We should
make this
feature configurable using sculptor generator properties.
For production, you are correct - having the passwords in there might
not be the best approach... but it's pretty easy to have the
dataSource bean be defined either like this:
<bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/jdbc/somedatabase</value>
</property>
</bean>
or like this:
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
destroy-method="close">
<property name="driverClassName"
value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/
database"/>
<property name="username" value="user"/>
<property name="password" value="password"/>
</bean>
and in either case have it pulling the dataSource bean from another
file makes it easy to swap between a local datasource or a JNDI one.
Here's the SpecialCases.xpt file that will generate a split-off file
to define the datasource in:
-----
«REM»
You can change code generation templates by using
Aspect-Oriented Programming features of oAW. You
can add AROUND advice in this file. Read
Sculptor Developer's Guide for more information.
«ENDREM»
«IMPORT sculptormetamodel»
«EXTENSION extensions::helper»
«EXTENSION extensions::properties»
«AROUND *::sessionFactory FOR Application»
«FILE name + "-DataSource.xml" TO_RESOURCES-»
«EXPAND Spring::header»
<bean id="«name»DataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
destroy-method="close">
<property name="driverClassName"
value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:
3306/«name»DS"/>
<property name="username" value="root"/>
<property name="password" value=""/>
</bean>
</beans>
«ENDFILE »
«FILE "SessionFactory.xml" TO_GEN_RESOURCES-»
«EXPAND Spring::header»
«IF isWar() -»
«EXPAND Spring::txManager»
«ENDIF -»
<import resource="«name»-DataSource.xml"/>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="«name»DataSource"/>
</property>
«EXPAND Spring::hibernateProperties»
«EXPAND Spring::hibernateMappingResources»
<property name="entityInterceptor">
<ref bean="auditInterceptor" />
</property>
</bean>
<bean id="auditInterceptor" class="«auditInterceptorClass()»"/>
</beans>
«ENDFILE »
«ENDAROUND»
«AROUND
*::sessionFactory
::hibernateProperties::hibernateConnectionDatasourceProperties FOR
Application»
«REM»
We replace the datasource with a reference to our bean... so we
don't put this property in
«ENDREM»
«ENDAROUND»
---
We haven't created Fornax accounts/permissions for you yet. Maybe it
is time
to do that?
/Patrik
Might be... Although I still haven't got anything to check in :)
Ryan
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Fornax-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fornax-developer