朱杰兵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)航:
           
          主站蜘蛛池模板: 临湘市| 蓬安县| 左权县| 手游| 四会市| 阿拉善左旗| 会昌县| 武清区| 正镶白旗| 宜川县| 伊宁县| 荣成市| 武平县| 石首市| 秭归县| 禹城市| 德州市| 边坝县| 贡嘎县| 防城港市| 远安县| 克东县| 台中市| 衡南县| 九台市| 易门县| 衡阳市| 体育| 龙里县| 海城市| 会泽县| 鄂伦春自治旗| 疏附县| 广昌县| 东方市| 晋中市| 蒙城县| 监利县| 曲靖市| 永靖县| 博野县|