Where The Streets Have No Name

google guava를 이용한 Service 작성 본문

Developement/Java

google guava를 이용한 Service 작성

highheat 2013. 3. 2. 22:51
package kr.co.ntcsoft.guava.service.demo;

public class Daemon2 {

	/**
	 * @param args
	 * @throws Exception
	 */
	public static void main(String[] args) throws Exception {
		MyGuavaService2 service = new MyGuavaService2();
		service.startAndWait();
	}

}
package kr.co.ntcsoft.guava.service.demo;

import com.google.common.util.concurrent.AbstractExecutionThreadService;

public class MyGuavaService2 extends AbstractExecutionThreadService {

	@Override
	protected void run() throws Exception {
		while (isRunning() && !Thread.currentThread().isInterrupted()) {

			String[] cmd = {"C:\\Windows\\System32\\cscript.exe", "C:\\wamp\\www\\doc_convert\\xls2image.vbs", "C:\\wamp\\www\\doc_convert\\aa.xlsx" };
			Process p = Runtime.getRuntime().exec(cmd);
			p.waitFor();

			System.out.println("run...");
			Thread.sleep(5 * 1000);
		}
	}

	@Override
	protected void startUp() throws Exception {
		super.startUp();
		System.out.println("startUp...");
	}

}