亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? nativejob.java

?? Java中非常實(shí)用流控制工具
?? JAVA
字號(hào):
/* 
 * Copyright 2004-2005 OpenSymphony 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 
 * use this file except in compliance with the License. You may obtain a copy 
 * of the License at 
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0 
 *   
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
 * License for the specific language governing permissions and limitations 
 * under the License.
 * 
 */

/*
 * Previously Copyright (c) 2001-2004 James House
 */

package org.quartz.jobs;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

/*
 * <p> Built in job for executing native executables in a separate process.</p> 
 * 
 * If PROP_WAIT_FOR_PROCESS is true, then the Integer exit value of the process
 * will be saved as the job execution result in the JobExecutionContext.
 * 
 * @see #PROP_COMMAND
 * @see #PROP_PARAMETERS
 * @see #PROP_WAIT_FOR_PROCESS
 * @see #PROP_CONSUME_STREAMS
 * 
 * @author Matthew Payne
 * @author James House
 * @author Steinar Overbeck Cook
 * @date Sep 17, 2003 @Time: 11:27:13 AM
 */
public class NativeJob implements Job {

    private final Log log = LogFactory.getLog(getClass());

    /*
     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     *
     * Constants.
     *  
     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     */
        
    /**
     * Required parameter that specifies the name of the command (executable) 
     * to be ran.
     */
    public static final String PROP_COMMAND = "command";
    
    /**
     * Optional parameter that specifies the parameters to be passed to the
     * executed command.
     */
    public static final String PROP_PARAMETERS = "parameters";
    
    
    /**
     * Optional parameter (value should be 'true' or 'false') that specifies 
     * whether the job should wait for the execution of the native process to 
     * complete before it completes.
     * 
     * <p>Defaults to <code>true</code>.</p>  
     */
    public static final String PROP_WAIT_FOR_PROCESS = "waitForProcess";
    
    /**
     * Optional parameter (value should be 'true' or 'false') that specifies 
     * whether the spawned process's stdout and stderr streams should be 
     * consumed.  If the process creates output, it is possible that it might
     * 'hang' if the streams are not consumed.
     * 
     * <p>Defaults to <code>false</code>.</p>  
     */
    public static final String PROP_CONSUME_STREAMS = "consumeStreams";
    
    
    /*
     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     * 
     * Interface.
     * 
     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     */

    public void execute(JobExecutionContext context)
        throws JobExecutionException {

        JobDataMap data = context.getMergedJobDataMap();
        
        String command = data.getString(PROP_COMMAND);

        String parameters = data.getString(PROP_PARAMETERS);

        if (parameters == null) {
            parameters = "";
        }

        boolean wait = true;
        if(data.containsKey(PROP_WAIT_FOR_PROCESS)) {
            wait = data.getBooleanValue(PROP_WAIT_FOR_PROCESS);
        }
        boolean consumeStreams = false;
        if(data.containsKey(PROP_CONSUME_STREAMS)) {
            consumeStreams = data.getBooleanValue(PROP_CONSUME_STREAMS);
        }
            
        Integer exitCode = this.runNativeCommand(command, parameters, wait, consumeStreams);
        context.setResult(exitCode);
        
    }

    protected Log getLog() {
        return log;
    }
    
    private Integer runNativeCommand(String command, String parameters, boolean wait, boolean consumeStreams) throws JobExecutionException {

        String[] cmd = null;
        String[] args = new String[2];
        Integer  result = null;
        args[0] = command;
        args[1] = parameters;

        
        try {
            //with this variable will be done the swithcing
            String osName = System.getProperty("os.name");

            //only will work with Windows NT
            if (osName.equals("Windows NT")) {
                if (cmd == null) {
                    cmd = new String[args.length + 2];
                }
                cmd[0] = "cmd.exe";
                cmd[1] = "/C";
                for (int i = 0; i < args.length; i++) {
                    cmd[i + 2] = args[i];
                }
            } else if (osName.equals("Windows 95")) { //only will work with Windows 95
                if (cmd == null) {
                    cmd = new String[args.length + 2];
                }
                cmd[0] = "command.com";
                cmd[1] = "/C";
                for (int i = 0; i < args.length; i++) {
                    cmd[i + 2] = args[i];
                }
            } else if (osName.equals("Windows 2003")) { //only will work with Windows 2003
                if (cmd == null) {
                    cmd = new String[args.length + 2];
                }
                cmd[0] = "cmd.exe";
                cmd[1] = "/C";

                for (int i = 0; i < args.length; i++) {
                    cmd[i + 2] = args[i];
                }
            } else if (osName.equals("Windows 2000")) { //only will work with Windows 2000
                if (cmd == null) {
                    cmd = new String[args.length + 2];
                }
                cmd[0] = "cmd.exe";
                cmd[1] = "/C";

                for (int i = 0; i < args.length; i++) {
                    cmd[i + 2] = args[i];
                }
            } else if (osName.equals("Windows XP")) { //only will work with Windows XP
                if (cmd == null) {
                    cmd = new String[args.length + 2];
                }
                cmd[0] = "cmd.exe";
                cmd[1] = "/C";

                for (int i = 0; i < args.length; i++) {
                    cmd[i + 2] = args[i];
                }
            } else if (osName.equals("Linux")) {
           		if (cmd == null) {
            		 cmd = new String[3];
            	 }
            	 cmd[0] = "/bin/sh";
            	 cmd[1] = "-c";
            	 cmd[2] = args[0] + " " + args[1];
            } else { // try this... 
                cmd = args;
            }

            Runtime rt = Runtime.getRuntime();
            // Executes the command
            getLog().info("About to run" + cmd[0] + " " + cmd[1] + " " + (cmd.length>2 ? cmd[2] : "") + " ..."); 
            Process proc = rt.exec(cmd);
            // Consumes the stdout from the process
            StreamConsumer stdoutConsumer = new StreamConsumer(proc.getInputStream(), "stdout");

            // Consumes the stderr from the process
            if(consumeStreams) {
                StreamConsumer stderrConsumer = new StreamConsumer(proc.getErrorStream(), "stderr");
                stdoutConsumer.start();
                stderrConsumer.start();
            }
            
            if(wait) {
                result = new Integer(proc.waitFor());
            }
            // any error message?
            
        } catch (Exception x) {
            throw new JobExecutionException("Error launching native command: ", x, false);
        }
        
        return result;
    }

    /**
     * Consumes data from the given input stream until EOF and prints the data to stdout
     *
     * @author cooste
     * @author jhouse
     */
    class StreamConsumer extends Thread {
        InputStream is;
        String type;

        /**
         *
         */
        public StreamConsumer(InputStream inputStream, String type) {
            this.is = inputStream;
            this.type = type;
        }

        /**
         * Runs this object as a separate thread, printing the contents of the InputStream
         * supplied during instantiation, to either stdout or stderr
         */
        public void run() {
            BufferedReader br = null;
            try {
                br = new BufferedReader(new InputStreamReader(is));
                String line = null;

                while ((line = br.readLine()) != null) {
                    if(type.equalsIgnoreCase("stderr")) {
                        getLog().warn(type + ">" + line);
                    } else {
                        getLog().info(type + ">" + line);
                    }
                }
            } catch (IOException ioe) {
                getLog().error("Error consuming " + type + " stream of spawned process.", ioe);
            } finally {
                if(br != null) {
                    try { br.close(); } catch(Exception ignore) {}
                }
            }
        }
    }
    
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产亚洲综合性久久久影院| 亚洲三级在线免费观看| 91久久精品网| 国产一区二区三区高清播放| 依依成人精品视频| 国产亚洲一区二区在线观看| 欧美日高清视频| 色偷偷一区二区三区| 国产麻豆9l精品三级站| 日产国产欧美视频一区精品| 亚洲日本在线天堂| 国产精品视频免费| 精品国产乱码久久久久久免费| 色老汉一区二区三区| 国产a区久久久| 国内精品伊人久久久久av影院| 亚洲国产精品尤物yw在线观看| 中文字幕不卡的av| 欧美xxx久久| 欧美一区2区视频在线观看| 色拍拍在线精品视频8848| 国产成人精品免费一区二区| 裸体在线国模精品偷拍| 午夜日韩在线电影| 亚洲成人av一区二区三区| 一区二区三区成人在线视频| 国产精品久99| 国产精品伦理一区二区| 中文字幕第一区第二区| 国产欧美精品一区| 国产农村妇女毛片精品久久麻豆| 久久久久国产精品麻豆| 精品国产电影一区二区| 日韩欧美中文字幕公布| 日韩欧美成人激情| 在线观看av一区二区| 欧洲亚洲国产日韩| 欧美亚洲动漫另类| 欧美日韩亚洲综合在线| 欧洲国产伦久久久久久久| 91精彩视频在线| 在线精品亚洲一区二区不卡| 欧美性videosxxxxx| 欧美三级视频在线观看| 欧美肥妇毛茸茸| 日韩精品一区二区三区视频在线观看| 欧美精品一二三区| 日韩欧美自拍偷拍| 久久色在线视频| 欧美经典三级视频一区二区三区| 国产午夜亚洲精品羞羞网站| 国产精品视频一二三区| 亚洲免费大片在线观看| 亚洲精品日韩专区silk| 亚洲一级二级在线| 日韩av一区二| 国产激情精品久久久第一区二区 | 中文字幕的久久| 国产精品乱码人人做人人爱| 亚洲人成电影网站色mp4| 亚洲国产欧美在线| 久久精品国产亚洲aⅴ| 国产成人在线影院 | 欧美亚洲动漫另类| 678五月天丁香亚洲综合网| 日韩无一区二区| 国产亚洲欧美激情| 亚洲免费av观看| 免费成人在线播放| 国产成人免费在线| 日本久久电影网| 欧美大片一区二区| 国产精品久久久久婷婷| 天天免费综合色| 国产乱子伦视频一区二区三区 | 国产精品一区二区在线看| 成人ar影院免费观看视频| 欧美视频在线播放| 久久精品亚洲精品国产欧美kt∨ | 亚洲自拍偷拍麻豆| 久久精品国产第一区二区三区| 成人av电影在线| 欧美电影免费观看高清完整版在| 欧美韩国日本不卡| 亚洲黄色小说网站| 久久99精品一区二区三区三区| 91色porny在线视频| 欧美电视剧在线观看完整版| 亚洲免费观看高清完整版在线| 麻豆中文一区二区| 91影院在线观看| 精品国内二区三区| 亚洲一区在线视频| 国产酒店精品激情| 91精品在线一区二区| 一区精品在线播放| 国产在线播放一区| 欧美肥妇bbw| 久久99国产精品成人| 99久久久国产精品| 久久亚洲免费视频| 五月天久久比比资源色| 99久久婷婷国产| 久久综合中文字幕| 亚洲成人一区在线| 91色porny蝌蚪| 中文字幕二三区不卡| 美女被吸乳得到大胸91| 欧美最新大片在线看 | 视频一区中文字幕国产| 99久久国产免费看| 久久亚洲欧美国产精品乐播| 日韩1区2区日韩1区2区| 欧美日韩一级视频| 一区二区三区在线播| 北条麻妃国产九九精品视频| 久久久久久影视| 久久福利视频一区二区| 欧美久久婷婷综合色| 亚洲国产成人av| 在线观看日韩精品| 亚洲精品免费在线观看| 91在线一区二区| 中文字幕一区视频| 成人黄页毛片网站| 亚洲国产高清在线观看视频| 国产在线视频一区二区三区| 精品奇米国产一区二区三区| 免费一级片91| 欧美一区二区日韩| 日产欧产美韩系列久久99| 91精品欧美福利在线观看| 三级久久三级久久久| 7777精品伊人久久久大香线蕉最新版| 亚洲国产日韩综合久久精品| 欧美日韩免费观看一区二区三区| 一区二区三区在线免费| 欧美系列日韩一区| 午夜欧美视频在线观看 | 精品成人一区二区三区四区| 美脚の诱脚舐め脚责91| 精品国产乱码久久久久久图片 | 欧美日韩精品专区| 亚洲高清不卡在线| 欧美日本国产视频| 九九国产精品视频| 久久久久高清精品| 97久久人人超碰| 亚洲综合在线电影| 欧美日本一道本| 久久精品国产一区二区| 国产日韩v精品一区二区| av网站免费线看精品| 亚洲啪啪综合av一区二区三区| 欧美性猛交xxxxxxxx| 天天射综合影视| 亚洲人成在线观看一区二区| 在线视频国内自拍亚洲视频| 午夜欧美2019年伦理 | 一区二区成人在线观看| 欧美专区在线观看一区| 青青国产91久久久久久| 亚洲精品一区二区在线观看| 成人天堂资源www在线| 亚洲人成电影网站色mp4| 欧美区视频在线观看| 精品中文字幕一区二区| 国产精品入口麻豆原神| 欧美写真视频网站| 国产一区二区免费看| 亚洲天堂2014| 日韩精品一区国产麻豆| 成人福利视频在线看| 午夜国产精品影院在线观看| 久久亚洲一区二区三区明星换脸| 91色婷婷久久久久合中文| 裸体健美xxxx欧美裸体表演| 国产精品蜜臀在线观看| 欧美精品久久久久久久久老牛影院| 国产一区二区美女| 亚洲国产中文字幕在线视频综合| 欧美一区二区高清| 91婷婷韩国欧美一区二区| 久久9热精品视频| 亚洲在线免费播放| 久久久777精品电影网影网 | 欧美三级电影在线观看| 国产美女久久久久| 丝袜美腿亚洲一区| 亚洲色图19p| 久久久亚洲高清| 欧美日韩一区在线| 不卡欧美aaaaa| 精品无人码麻豆乱码1区2区 | 国产欧美日产一区| 欧美一级二级三级乱码| 色悠悠亚洲一区二区| 国产老妇另类xxxxx| 免费高清在线视频一区·| 中文字幕日本乱码精品影院|