blob: e3791ea314c5a56c4175cb4d825b1adc0d5371c2 [file] [log] [blame]
Richard S. Hallfbd735b2009-06-11 16:07:20 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package aQute.shell.telnet;
20
21import java.io.*;
22import java.net.*;
23
24import org.osgi.service.command.*;
25
26import aQute.shell.console.*;
27
28public class Handler extends Thread {
29 TelnetShell master;
30 Socket socket;
31 CommandSession session;
32 Console console;
33
34 public Handler(TelnetShell master, CommandSession session, Socket socket)
35 throws IOException {
36 this.master = master;
37 this.socket = socket;
38 this.session = session;
39 }
40
41 public void run() {
42 try {
43 console = new Console();
44 console.setSession(session);
45 console.run();
46 } finally {
47 close();
48 master.handlers.remove(this);
49 }
50 }
51
52 public void close() {
53 session.close();
54 try {
55 socket.close();
56 } catch (IOException e) {
57 // Ignore, this is close
58 }
59 }
60
61}