⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 schedulerclient.java

📁 一个java工作流引擎
💻 JAVA
字号:
package org.jbpm.scheduler;

import java.io.*;
import java.net.*;

/**
 * is the external client that will provide a request-thread to the 
 * {@link SchedulerServer}.
 * 
 * The scheduler client will do this by sending a http request to the 
 * scheduler servlet.  The default url is http://localhost:8080/jbpm.scheduler/schedulerservlet
 * To start the SchedulerClient type the following in a command line prompt : 
 * <pre>
 *   java -cp jbpm.core.jar org.jbpm.scheduler.SchedulerClient
 * </pre>
 * If you have configured the SchedulerServlet on a different address, 
 * just provide an altenative url as the single parameter to the application.
 * E.g.
 * <pre>
 *   java -cp jbpm.core.jar org.jbpm.scheduler.SchedulerClient http://localhost:8080/myschedulerservleturl
 * </pre>
 */
public class SchedulerClient {

	public static void main(String[] args) {
    String urlText = "http://localhost:8080/jbpm.scheduler/schedulerservlet";
    
    if ( ( args != null )
         && ( args.length > 0 ) ) {
      urlText = args[0];
    }
    
    
    while(true) {
      long millisToWait = 5000;
      try {
        System.out.println( "triggering the server to execute jobs" );
				URL url = new URL( urlText );
				InputStream inputStream = url.openStream();
				byte[] buffer = new byte[16];
				int bytesRead = inputStream.read( buffer );
				String result = new String( buffer, 0, bytesRead );
				System.out.println( "waiting for " + result + " milliseconds" );
				millisToWait = Long.parseLong( result );
			} catch (Exception e) {
				e.printStackTrace();
			}
      // we use 2 separate try-catch blocks because we want to 
      // sleep for a period, even if something goes wrong with 
      // the client-server communication.
      try {
				Thread.sleep( millisToWait );
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
    }
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -