01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.openejb.server.telnet;
17:
18: import java.io.IOException;
19: import java.io.InputStream;
20: import java.io.OutputStream;
21: import java.io.PrintStream;
22: import java.net.Socket;
23: import java.util.Properties;
24:
25: import org.apache.openejb.server.ServiceException;
26:
27: public class TelnetServer implements
28: org.apache.openejb.server.ServerService {
29:
30: public void init(Properties props) throws Exception {
31: }
32:
33: public void service(Socket socket) throws ServiceException,
34: IOException {
35: InputStream telnetIn = null;
36: PrintStream telnetOut = null;
37:
38: try {
39: InputStream in = socket.getInputStream();
40: OutputStream out = socket.getOutputStream();
41:
42: telnetIn = new TelnetInputStream(in, out);
43: telnetOut = new TelnetPrintStream(out);
44:
45: telnetOut.println("OpenEJB Remote Server Console");
46: telnetOut.println("type \'help\' for a list of commands");
47:
48: TextConsole shell = new TextConsole();
49: shell.exec(telnetIn, telnetOut);
50:
51: } catch (Throwable t) {
52:
53: } finally {
54: if (telnetIn != null)
55: telnetIn.close();
56: if (telnetOut != null)
57: telnetOut.close();
58: if (socket != null)
59: socket.close();
60:
61: }
62: }
63:
64: public void service(InputStream in, OutputStream out)
65: throws ServiceException, IOException {
66: throw new UnsupportedOperationException(
67: "Method not implemented: service(InputStream in, OutputStream out)");
68: }
69:
70: public void start() throws ServiceException {
71: }
72:
73: public void stop() throws ServiceException {
74: }
75:
76: public String getName() {
77: return "telnet";
78: }
79:
80: public int getPort() {
81: return 0;
82: }
83:
84: public String getIP() {
85: return "";
86: }
87:
88: }
|