Oracle神谕

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  284 随笔 :: 9 文章 :: 106 评论 :: 0 Trackbacks

Using the MethodInvokingJobDetailFactoryBean
使用MethodInvokingJobDetailFactoryBean
Often you just need to invoke a method on a specific object. Using the MethodInvokingJobDetailFactoryBean you can do exactly this:
经常地,你仅仅需要调用一个对象的一个方法。使用MethodInvokingJobDetailFactoryBean,你可以正确地这样做:

<bean id="methodInvokingJobDetail"
  class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    <property name="targetObject"><ref bean="exampleBusinessObject"/></property>
    <property name="targetMethod"><value>doIt</value></property>
</bean>


The above example will result in the doIt being called on the exampleBusinessObject (see below):


public class BusinessObject {
 
  // properties and collaborators
 
  public void doIt() {
    // do the actual work
  }
}
   

<bean id="exampleBusinessObject" class="examples.ExampleBusinessObject"/>
   
Using the MethodInvokingJobDetailFactoryBean you don't need to create one-line jobs that just invoke a method, and you only need to create the actual business object and wire up the detail object.
使用MethodInvokingJobDetailFactoryBean 你不需要创建一个在线的jobs,仅仅调用它的方法,你可以仅仅只需要创建一个实际的逻辑对象并且把它绑定到细节对象。

By default, Quartz Jobs are stateless, resulting in the possibility of jobs interfering with each other. If you specify two triggers for the same JobDetail, it might be possible that before the first job has finished, the second one will start. If JobDetail objects implement the Stateful interface, this won't happen. The second job will not start before the first one has finished. To make jobs resulting from the MethodInvokingJobDetailFactoryBean non-concurrent, set the concurrent flag to false.

缺省地,Quartz jobs是无状态的,在jobs的可能性作为结果影响彼此。如果你限定两个触发器为同一个JohDetail,它在第一个job已经完成时是可能的,第二个将会开始。如果JobDetail实现了状态接口,它将不会发生。
<bean id="methodInvokingJobDetail"
  class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    <property name="targetObject"><ref bean="exampleBusinessObject"/></property>
    <property name="targetMethod"><value>doIt</value></property>
    <property name="concurrent"><value>false</value></property>
</bean>
   
Note: By default, jobs will run in a concurrent fashion.

 

posted on 2005-07-22 11:23 java世界畅谈 阅读(3114) 评论(0)  编辑  收藏 所属分类: Spring

只有注册用户登录后才能发表评论。


网站导航: