1 45 package org.openejb.server.admin; 46 47 import java.io.*; 48 import java.net.*; 49 import java.util.*; 50 import org.openejb.server.ServerService; 51 import org.openejb.server.ServiceManager; 52 import org.openejb.server.ServiceException; 53 import org.openejb.client.RequestMethods; 54 55 69 public class AdminDaemon implements ServerService { 70 71 public void init(Properties props) throws Exception { 72 } 73 74 75 public void service(InputStream in, OutputStream out) throws ServiceException, IOException { 76 throw new UnsupportedOperationException ("service(in,out)"); 77 } 78 79 public void service(Socket socket) throws ServiceException,IOException { 80 InputStream in = null; 81 InetAddress clientIP = null; 82 83 try { 84 in = socket.getInputStream(); 85 clientIP = socket.getInetAddress(); 86 87 88 byte requestType = (byte)in.read(); 89 90 if (requestType == -1) {return;} 91 92 switch (requestType) { 93 case RequestMethods.STOP_REQUEST_Quit: 94 case RequestMethods.STOP_REQUEST_quit: 95 case RequestMethods.STOP_REQUEST_Stop: 96 case RequestMethods.STOP_REQUEST_stop: 97 ServiceManager.getManager().stop(); 98 100 } 101 102 } catch ( SecurityException e ) { 106 } catch ( Throwable e ) { 108 } finally { 111 try { 112 if ( in != null ) in.close(); 113 if ( socket != null ) socket.close(); 114 } catch ( Throwable t ){ 115 } 117 } 118 } 119 120 public void start() throws ServiceException { 121 } 122 123 public void stop() throws ServiceException { 124 } 125 126 130 public int getPort() { 131 return 0; 132 } 133 134 public String getIP() { 135 return ""; 136 } 137 138 public String getName() { 139 return "admin thread"; 140 } 141 142 } 143 | Popular Tags |