細心!用心!耐心!

          吾非文人,乃市井一俗人也,讀百卷書,跨江河千里,故申城一游; 一兩滴辛酸,三四年學業,五六點粗墨,七八筆買賣,九十道人情。

          BlogJava 聯系 聚合 管理
            1 Posts :: 196 Stories :: 10 Comments :: 0 Trackbacks

          ----------->Spring配置文件的參考:
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "

          <beans>
          ??? <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
          ??<property name="driverClassName">
          ???<value>${jdbc.driverClassName}</value>
          ??</property>
          ??<property name="url">
          ???<value>${jdbc.url}</value>
          ??</property>
          ??<property name="username">
          ???<value>${jdbc.username}</value>
          ??</property>
          ??<property name="password">
          ???<value>${jdbc.password}</value>
          ??</property>
          ?</bean>
          ??? <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
          ??<property name="locations">
          ???<list>
          ????<value>classpath:/config/jdbc.properties</value>
          ????<value>classpath:/config/customer.properties</value>
          ???</list>
          ??</property>
          ?</bean>
          ?
          ?<bean id="ftpHandle" class="com.stt.dosp.datacollect.remote.FtpHandle"
          ??abstract="false" singleton="true" lazy-init="default"
          ??autowire="default" dependency-check="default">
          ??<property name="server">
          ???<value type="java.lang.String">${ftp.ip}</value>
          ??</property>
          ??<property name="user">
          ???<value type="java.lang.String">${ftp.user}</value>
          ??</property>
          ??<property name="password">
          ???<value type="java.lang.String">${ftp.password}</value>
          ??</property>
          ??<property name="remotePath">
          ???<value type="java.lang.String">${ftp.remotePath}</value>
          ??</property>
          ??<property name="localPath">
          ???<value type="java.lang.String">${ftp.localPath}</value>
          ??</property>
          ??<property name="temp">
          ???<value type="java.lang.String">${ftp.temp}</value>
          ??</property>
          ?</bean>
          ?
          ?<bean id="fileHandle"
          ??class="com.stt.dosp.datacollect.local.FileHandle" abstract="false"
          ??singleton="true" lazy-init="default" autowire="default"
          ??dependency-check="default">
          ??<property name="ftpHandle">
          ???<ref bean="ftpHandle" />
          ??</property>
          ??<property name="batchSize">
          ???<value type="java.lang.Long">${local.batch}</value>
          ??</property>
          ??<property name="backupDir">
          ???<value type="java.lang.String">${local.backup}</value>
          ??</property>
          ??<property name="doubleNameFix">
          ???<value type="java.lang.String">
          ????${local.double.name.fix}
          ???</value>
          ??</property>
          ??<property name="insertSQL">
          ???<value type="java.lang.String">${db.insert}</value>
          ??</property>
          ?</bean>
          ?
          ?<bean id="connectFtpServerTask"
          ??class="com.stt.dosp.datacollect.schedule.ConnectFtpServerTask"
          ??abstract="false" singleton="true" lazy-init="default"
          ??autowire="default" dependency-check="default">
          ??<property name="ftpHandle">
          ???<ref bean="ftpHandle" />
          ??</property>
          ?</bean>
          ???
          ??? <bean id="collectLocalTask"
          ??class="com.stt.dosp.datacollect.schedule.CollectLocalTask"
          ??abstract="false" singleton="true" lazy-init="default"
          ??autowire="default" dependency-check="default">
          ??<property name="fileHandle">
          ???<ref bean="fileHandle" />
          ??</property>
          ?</bean>
          ?
          ?<bean id="ftpConnectCheck" class="org.springframework.scheduling.timer.ScheduledTimerTask">
          ??<property name="timerTask">
          ???<ref bean="connectFtpServerTask" />
          ??</property>
          ??<property name="period">
          ???<value>${ftp.task.period}</value>
          ??</property>
          ??<property name="delay">
          ???<value>${ftp.task.delay}</value>
          ??</property>
          ?</bean>
          ?
          ?<bean id="localFileCheck" class="org.springframework.scheduling.timer.ScheduledTimerTask">
          ??<property name="timerTask">
          ???<ref bean="collectLocalTask" />
          ??</property>
          ??<property name="period">
          ???<value>${local.task.period}</value>
          ??</property>
          ??<property name="delay">
          ???<value>${local.task.delay}</value>
          ??</property>
          ?</bean>
          ?
          ?<bean id="timerBean" class="org.springframework.scheduling.timer.TimerFactoryBean">
          ??<property name="scheduledTimerTasks">
          ???<list>????
          ????<ref bean="ftpConnectCheck" />
          ????<ref bean="localFileCheck" />
          ???</list>
          ??</property>
          ?</bean>
          ?
          ?</beans>




          --------->啟動類參考:
          /**
          ?* 啟動類
          ?* @author zhangjp
          ?* @version 1.0
          ?*/
          public class StartMain {

          ?/**
          ? * @param args
          ? */
          ??public static void main(String[] args) {
          ?? /*
          ? 只需要初始化一個taskBean就可以加載ScheduledTimerTask任務隊列
          ?? "<list>????
          ????? ?<ref bean="ftpConnectCheck" />
          ??????? <ref bean="localFileCheck" />
          ??? ??</list>"
          ??? 里的所有任務
          ? */
          ???SpringBeanFactory.getBean("connectFtpServerTask");??
          ???do{
          ?????? ??try {
          ????????????? ??Thread.sleep(1000);?
          ? ?//因為main類是一個進程,所以要使main不退出,加一個阻塞
          ?? //(使用Thread.sleep(1000);?或者Timer timer = new?Timer();都可以)
          ???????????} catch (InterruptedException e) {
          ?????????????? ?// TODO Auto-generated catch block
          ?????????????????? e.printStackTrace();
          ????????? ?}
          ???}while(true);
          ?
          ?}

          }


          ---------->運行啟動類(可以編寫各個平臺的shell腳本,如 ".bat" ".sh"文件)
          .bat腳本參考(windows):----->
          @Echo Off
          title dosp_collect

          If %1.==CPGEN. GoTo :CPGEN

          Rem ============= CLASSPATH ===================
          Echo Generating classpath ...
          Set CLASSPATH=
          For %%X in (dospcollect-lib/*.jar) Do Call %0 CPGEN dospcollect-lib\%%X
          For %%X in (common-lib/*.jar) Do Call %0 CPGEN common-lib\%%X

          Rem ============= START DOSP COLLECT SERVER ===================
          Echo Starting Dosp Collect Server ...
          java? -Xms128m -Xmx256m? -classpath %CLASSPATH% com.stt.dosp.datacollect.startup.StartMain
          GoTo :END

          Rem ============= CLASSPATH HELP ===================
          Rem This target is used to concatenate the classpath parts
          :CPGEN
          Set CLASSPATH=%CLASSPATH%;%2

          Rem ============= END ===================
          Rem Target needed to jump to the end of the file
          :END


          .sh腳本參考(linux/unix)----->
          #!/bin/bash

          # don't run? DOSP COLLECT Server as root
          if [ $UID -eq 0 ] ; then
          ?echo
          ?echo "For security reasons you should not run this script as root!"
          ?echo
          ?exit 1
          fi?

          # go to current directory
          cd `dirname $0`/..

          # defining some variables
          COMMON_LIB="common-lib"
          DOSP_LIB="dospcollect-lib"

          # generating the proper classpath
          echo "Generating classpath ..."
          CLASSPATH=""
          for N in $COMMON_LIB/*.jar; do CLASSPATH="$CLASSPATH$N:"; done?
          for N in $DOSP_LIB/*.jar; do CLASSPATH="$CLASSPATH$N:"; done?

          # startup? DOSP COLLECT Server
          echo "Starting? Dosp-Collect Server ..."
          java? -Xms128m -Xmx256m -classpath $CLASSPATH com.stt.dosp.datacollect.startup.StartMain


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


          網站導航:
           
          主站蜘蛛池模板: 海原县| 乌苏市| 华坪县| 扶绥县| 白河县| 兴城市| 大关县| 鄂托克旗| 根河市| 任丘市| 蓝田县| 枞阳县| 汉中市| 会同县| 虹口区| 松潘县| 巴林左旗| 枣阳市| 库车县| 龙江县| 顺昌县| 泗水县| 大化| 襄垣县| 大丰市| 沅江市| 临武县| 潢川县| 吉安县| 资中县| 周口市| 东兰县| 茌平县| 高安市| 枣强县| 南华县| 胶州市| 家居| 江北区| 雷州市| 长垣县|