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.admin;
17:
18: import java.io.*;
19: import java.net.*;
20: import java.util.*;
21:
22: import org.apache.openejb.server.ServerService;
23: import org.apache.openejb.server.ServiceManager;
24: import org.apache.openejb.server.ServiceException;
25: import org.apache.openejb.client.RequestMethodConstants;
26:
27: public class AdminDaemon implements ServerService {
28:
29: public void init(Properties props) throws Exception {
30: }
31:
32: public void service(Socket socket) throws ServiceException,
33: IOException {
34: InputStream in = null;
35: InetAddress clientIP = null;
36:
37: try {
38: in = socket.getInputStream();
39: clientIP = socket.getInetAddress();
40:
41: byte requestType = (byte) in.read();
42:
43: if (requestType == -1) {
44: return;
45: }
46:
47: switch (requestType) {
48: case RequestMethodConstants.STOP_REQUEST_Quit:
49: case RequestMethodConstants.STOP_REQUEST_quit:
50: case RequestMethodConstants.STOP_REQUEST_Stop:
51: case RequestMethodConstants.STOP_REQUEST_stop:
52: ServiceManager.getManager().stop();
53:
54: }
55:
56: } catch (SecurityException e) {
57:
58: } catch (Throwable e) {
59:
60: } finally {
61: try {
62: if (in != null)
63: in.close();
64: if (socket != null)
65: socket.close();
66: } catch (Throwable t) {
67:
68: }
69: }
70: }
71:
72: public void service(InputStream in, OutputStream out)
73: throws ServiceException, IOException {
74: throw new UnsupportedOperationException(
75: "Method not implemented: service(InputStream in, OutputStream out)");
76: }
77:
78: public void start() throws ServiceException {
79: }
80:
81: public void stop() throws ServiceException {
82: }
83:
84: public int getPort() {
85: return 0;
86: }
87:
88: public String getIP() {
89: return "";
90: }
91:
92: public String getName() {
93: return "admin thread";
94: }
95:
96: }
|