|
From: <sja...@st...> - 2006-08-02 14:41:10
|
Hello ! I am new with cron and get into troubles to develop some crons or rather simple triggers: My program lets a user filling a form to create a person. This person needs to be stored in a database (its properties: name, email, username, password...etc). But I would like this person to be created later for example the 10th of September 2006 at 8am or in 2 weeks exactly. Then I will need a cron to create automatically this person in the database at the chosen date. Trying to understand how to do that with Spring I read http://www.springframework.org/docs/reference/scheduling.html and I was obtaining some xml file and code like this: <bean name="createPersonJob" class="org.springframework.scheduling.quartz.JobDe tailBean"> <property name="jobClass" value="org.alfresco.web.bean.EthicFlow_Jobs.Create PersonJob"/> <property name="jobDataAsMap"> <map> <entry key="record" value=""/> <!--the name of the record where I have the new person properties: stay empty and when we launch a cron we will set a value to record--> </map> </property> </bean> <bean id="simpleTrigger" class="org.springframework.scheduling.quartz.Simpl eTriggerBean"> <!-- see the example of method invoking job above --> <property name="jobDetail" ref="jobDetail"/> <!-- 10 seconds --> <property name="startDelay" value="10000"/> <!-- repeat every 50 seconds --> <property name="repeatInterval" value="50000"/> </bean> <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronT riggerBean"> <property name="jobDetail" ref="exampleJob"/> <!-- run every morning at 6 AM --> <property name="cronExpression" value="0 0 6 * * ?"/> </bean> <bean class="org.springframework.scheduling.quartz.Sched ulerFactoryBean"> <property name="triggers"> <list> <ref bean="cronTrigger"/> <ref bean="simpleTrigger"/> </list> </property> </bean> public class EthicFlow_CreatePersonJob extends QuartzJobBean { private String record; /** * Setter called after the CreateJob is instantiated * with the value from the JobDetailBean (5) */ public void setRecord(String record) { this.record = record; } protected void executeInternal(JobExecutionContext ctx) throws JobExecutionException { // do the actual work } } Is it correct? But then how is this cron launched? EthicFlow_CreatePersonJob.executeInternal()?? Did I miss something? I have no choice than using cronTrigger rather than simpleTrigger if I want to define a date to launch a cron? Thanks in advance for your help Best, Sophie Jarlier |