Home » openejb-3.1.2-src » org.apache » openejb » server » admin » [javadoc | source]

    1   /**
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *     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    */
   17   package org.apache.openejb.server.admin;
   18   
   19   import java.io;
   20   import java.net;
   21   import java.util;
   22   
   23   import org.apache.openejb.server.ServerService;
   24   import org.apache.openejb.server.ServiceManager;
   25   import org.apache.openejb.server.ServiceException;
   26   import org.apache.openejb.client.RequestMethodConstants;
   27   
   28   public class AdminDaemon implements ServerService {
   29   
   30       public void init(Properties props) throws Exception {
   31       }
   32   
   33       public void service(Socket socket) throws ServiceException, 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) in.close();
   63                   if (socket != null) socket.close();
   64               } catch (Throwable t) {
   65   
   66               }
   67           }
   68       }
   69   
   70       public void service(InputStream in, OutputStream out) throws ServiceException, IOException {
   71           throw new UnsupportedOperationException("Method not implemented: service(InputStream in, OutputStream out)");
   72       }
   73       
   74       public void start() throws ServiceException {
   75       }
   76   
   77       public void stop() throws ServiceException {
   78       }
   79   
   80       public int getPort() {
   81           return 0;
   82       }
   83   
   84       public String getIP() {
   85           return "";
   86       }
   87   
   88       public String getName() {
   89           return "admin thread";
   90       }
   91   
   92   }

Home » openejb-3.1.2-src » org.apache » openejb » server » admin » [javadoc | source]