1 45 package org.openejb.server.telnet; 46 47 import java.io.DataInputStream ; 48 import java.io.IOException ; 49 import java.io.InputStream ; 50 import java.io.OutputStream ; 51 import java.io.PrintStream ; 52 import java.net.Socket ; 53 import java.util.Properties ; 54 55 import org.openejb.server.ServiceException; 56 57 60 public class TelnetServer implements org.openejb.server.ServerService { 61 62 63 public void init(Properties props) throws Exception { 64 } 65 66 public void service(InputStream in, OutputStream out) throws ServiceException, IOException { 67 throw new UnsupportedOperationException ("service(in,out)"); 68 } 69 70 public void service(Socket socket) throws ServiceException, IOException { 71 InputStream telnetIn = null; 72 PrintStream telnetOut = null; 73 74 try { 75 InputStream in = socket.getInputStream(); 76 OutputStream out = socket.getOutputStream(); 77 78 telnetIn = new TelnetInputStream(in, out); 79 telnetOut = new TelnetPrintStream(out); 80 81 telnetOut.println("OpenEJB Remote Server Console"); 82 telnetOut.println("type \'help\' for a list of commands"); 83 84 87 TextConsole shell = new TextConsole(); 88 shell.exec(telnetIn, telnetOut); 89 90 } catch (Throwable t) { 91 } finally { 95 if (telnetIn != null) 96 telnetIn.close(); 97 if (telnetOut != null) 98 telnetOut.close(); 99 if (socket != null) socket.close(); 100 101 } 102 } 103 104 public void start() throws ServiceException { 105 } 106 107 public void stop() throws ServiceException { 108 } 109 110 public String getName() { 111 return "telnet"; 112 } 113 114 public int getPort() { 115 return 0; 116 } 117 118 public String getIP() { 119 return ""; 120 } 121 122 } 123 | Popular Tags |