Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 0.1
-
Fix Version/s: 0.4
-
Component/s: Configuration
-
Labels:None
Description
Support scripting of the Spring application context using Groovy meta programming. At the moment all current implementations of this don't take advantage of the groovy meta facility, hence end up with a robust syntax rather than somethingl ike this:
import org.apache.commons.dbcp.*
import org.springframework.orm.hibernate3.*
class ApplicationContext {
@Property beans = {
def ds = dataSource('destroy-method':'close',BasicDataSource.class)
def sf = sessionFactory(LocalSessionFactoryBean.class)
{ configurationClass("org.hibernate.cfg.AnnotationConfiguration") hibernateProperties ['hibernate.dialect' : 'org.hibernate.dialect.MySQLDialect'] dataSource(ds) }
}
}
This is the equivalent of the Spring xml:
<beans>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost/testDb</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>admin</value>
</property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
</beans>
Issue Links
- is depended upon by
-
GRAILS-347
Refactor current plug-in code to match proposal
-
The above proposal is deprecated in favour of the proposal outlined here:
http://grails.org/The+Plug-in+System