spring groovy

haidaoxianzi 2012-09-21

在spring和groovy整合中,如何将groovy脚本配置到spring 的xml中:

1、参考内容:

http://static.springsource.org/spring/docs/2.0.x/reference/dynamic-language.html

2、本地实例:

<?xmlversion="1.0"encoding="GBK"?>

<beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:lang="http://www.springframework.org/schema/lang"

xsi:schemaLocation="

http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.0.xsd

http://www.springframework.org/schema/langhttp://www.springframework.org/schema/lang/spring-lang-2.0.xsd">

<!--下发任务定时任务,对下发是不的任务进行重新下发-->

<lang:groovyid="deliverParser"

script-source="/modules/penguin.ability.deliver/META-INF/services/groovyscript/com/sihuatech/ability/deliver/script/groovy/parser/PublishTaskParser.groovy">

</lang:groovy>

<lang:groovyid="deliverTaskTrigger"

script-source="/modules/penguin.ability.deliver/META-INF/services/groovyscript/com/sihuatech/ability/deliver/trigger/DeliverTaskTrigger.groovy">

<lang:propertyname="publishTaskDao"ref="com.sihuatech.ability.dao.publishTaskDao">

</lang:property>

<lang:propertyname="externalInterfaceManager"ref="externalInterfaceManager">

</lang:property>

<lang:propertyname="abilityExternalSystemManager"ref="abilityExternalSystemManager">

</lang:property>

<lang:propertyname="day"value="${ability.deliver.task.before.day}"/>

<lang:propertyname="maxTime"value="${ability.deliver.task.max.time}"/>

<lang:propertyname="parser"ref="deliverParser"/>

</lang:groovy>

<beanid="deliverTaskJobDetail"class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">

<propertyname="targetObject"ref="deliverTaskTrigger">

</property>

<propertyname="targetMethod">

<value>execute</value>

</property>

</bean>

<beanid="deliverTaskCronTrigger"class="org.springframework.scheduling.quartz.CronTriggerBean">

<propertyname="jobDetail">

<refbean="deliverTaskJobDetail"/>

</property>

<!--时间-->

<propertyname="cronExpression"value="${ability.deliver.task.trigger}">

</property>

</bean>

<beanclass="org.springframework.scheduling.quartz.SchedulerFactoryBean">

<propertyname="triggers">

<list>

<reflocal="deliverTaskCronTrigger"/>

</list>

</property>

</bean>

</beans>

相关推荐