朱杰兵blog

          jonhney'blog
          posts - 140, comments - 1, trackbacks - 0, articles - 0

          spring定時(shí)器的配置

          Posted on 2013-02-27 20:57 朱杰兵 閱讀(844) 評論(0)  編輯  收藏
          1>需要的jar包 quartz-all-1.5.2.jar
          2>添加application-job.xml
          <!--    注入service-->
              <bean id="quarzJob" class="com.wonders.sjyy.job.QuarzJob">
                  <property name="appointmentService" ref="appointmentService" />
              </bean>
              
              <!-- 定時(shí)任務(wù)的配置 -->
              <bean id="jobDetailBean1"
                  class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
                  <property name="targetObject" ref="quarzJob" />
                  <property name="targetMethod" value="sctingzhen" />
              </bean>
              <bean id="jobDetailBean2"
                  class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
                  <property name="targetObject" ref="quarzJob" />
                  <property name="targetMethod" value="scYishengScheduling" />
              </bean>
              
              <!---->
              <bean id="triggerBean1"
                  class="org.springframework.scheduling.quartz.CronTriggerBean">
                  <property name="jobDetail" ref="jobDetailBean1" />
                  <property name="cronExpression" value="0 0/5 * * * ?" />
              </bean>
              <bean id="triggerBean2"
                  class="org.springframework.scheduling.quartz.CronTriggerBean">
                  <property name="jobDetail" ref="jobDetailBean2" />
                  <property name="cronExpression" value="0 0/5 * * * ?" />
              </bean>
              
              <bean id="schedulerFactoryBean"
                  class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
                  <property name="triggers">
                      <list>
                          <ref bean="triggerBean1" />
                          <ref bean="triggerBean2"/>
                      </list>
                  </property>
              </bean>

          3>定時(shí)任務(wù)方法編寫
          package com.wonders.sjyy.job;

          import java.net.MalformedURLException;
          import java.net.URL;

          import org.codehaus.xfire.client.Client;

          import com.wonders.sjyy.service.DoctorAppointmentService;

          public class QuarzJob {
              
              
              private DoctorAppointmentService appointmentService;

              /**
               * 抽取ee信息
               * @return
               */
              public String sctingzhen(){
                  /*String reString="";
                  try {
                      Client client = new Client(new URL("http://172.16.254.202:8089/xhws_znts_lhyy/services/ISjyyService?wsdl"));
                      client.setTimeout(0);
                      Object[] results = client.invoke("LHS204",
                              new Object[] { "","" });
                      reString=(String)results[0];
                      System.out.println(reString.length());
                      } catch (MalformedURLException e) {
                          e.printStackTrace();
                      } catch (Exception e) {
                          e.printStackTrace();
                      }
                      return reString;*/
                  
                  System.out.println("抽取ee信息");
                  return null;
              }
              
              /**
               * 抽取xx信息
               * @return
               */
              public String scYishengScheduling(){
                  /*String reString="";
                  try {
                      Client client = new Client(new URL("http://172.16.254.202:8089/xhws_znts_lhyy/services/ISjyyService?wsdl"));
                      client.setTimeout(0);
                      Object[] results = client.invoke("LHS203",
                              new Object[] { "","" });
                      reString=(String)results[0];
                      System.out.println("接受--->"+reString);
                      System.out.println(reString.length());
                      } catch (MalformedURLException e) {
                          e.printStackTrace();
                      } catch (Exception e) {
                          e.printStackTrace();
                      }
                      return reString;*/
                  
                  System.out.println("上傳xx信息");
                  return null;
              }
              public DoctorAppointmentService getAppointmentService() {
                  return appointmentService;
              }

              public void setAppointmentService(DoctorAppointmentService appointmentService) {
                  this.appointmentService = appointmentService;
              }

          }

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 资源县| 宜兰县| 南充市| 泰安市| 阜城县| 吉安县| 普兰县| 大丰市| 彭州市| 古丈县| 昌宁县| 阿瓦提县| 夏津县| 三台县| 沅江市| 湘阴县| 祁东县| 佛冈县| 会理县| 城口县| 五大连池市| 兴化市| 错那县| 东安县| 延吉市| 乌恰县| 衡阳市| 仁布县| 盖州市| 江安县| 竹北市| 金门县| 防城港市| 岱山县| 犍为县| 宾川县| 友谊县| 集贤县| 余姚市| 乐平市| 进贤县|