View Javadoc

1   package net.sf.crispy.impl.jaxrpc;
2   
3   import java.net.ServerSocket;
4   
5   import net.sf.crispy.impl.MiniServer;
6   import net.sf.crispy.util.Util;
7   
8   import org.apache.axis.client.AdminClient;
9   import org.apache.axis.components.threadpool.ThreadPool;
10  import org.apache.axis.transport.http.SimpleAxisServer;
11  import org.apache.commons.logging.Log;
12  import org.apache.commons.logging.LogFactory;
13  
14  /**
15   * Mini web server to test JAX-RPC client requests.
16   * 
17   * @author Linke
18   *
19   */
20  public class MiniAxisServer implements MiniServer {
21  
22      protected static final Log log = LogFactory.getLog (MiniAxisServer.class);
23      private SimpleAxisServer axisServer = new SimpleAxisServer(ThreadPool.DEFAULT_MAX_THREADS);
24      private int port = 9080;
25      
26      public MiniAxisServer() { }
27  //    public MiniAxisServer(int pvPort) { port = pvPort; }
28  
29  	public void addService (String pvServiceInterface, String pvServiceObject) {
30  		if (log.isDebugEnabled()) { log.debug("The method addService in the MiniAxisServer class do nothing!"); }
31  	}
32  
33      public synchronized void start () {
34  		try {
35  			boolean isPortFree = Util.isPortFree(port);
36  			if (isPortFree == true) {
37  				axisServer.setServerSocket(new ServerSocket(port));
38  				axisServer.start();
39  				if (log.isDebugEnabled()) { log.debug("MiniAxisServer is started ..."); }
40  			}
41  			
42  			AdminClient lvAdminClient = new AdminClient();
43  			String args[] = new String[3];
44  			args[0] = "./classes/test/crispy/example/service/deployCalculator.wsdd";
45  			args[1] = "-l";
46  			args[2] = "http://localhost:" + port + "/axis/services/AdminService";
47  			String lvDeployStr1 = lvAdminClient.process(args);
48  			if (log.isDebugEnabled()) { log.debug("Deploy1: " + lvDeployStr1); }
49  			args[0] = "./classes/test/crispy/example/service/deployEcho.wsdd";
50  			args[1] = "-l";
51  			args[2] = "http://localhost:" + port + "/axis/services/AdminService";
52  			String lvDeployStr2 = lvAdminClient.process(args);
53  			if (log.isDebugEnabled()) { log.debug(" Deploy2: " + lvDeployStr2); }
54  		} catch (Exception e) {
55  			e.printStackTrace();
56  		}
57  		
58  	}
59  	
60  	public void stop() { 
61  		axisServer.stop();
62  		if (log.isDebugEnabled()) { log.debug("Stop MiniAxisServer."); } 
63  	}
64  	
65  }