Search in sources :

Example 1 with Server

use of org.apache.openejb.server.Server in project tomee by apache.

the class NTService method stopImpl.

private void stopImpl() {
    if (running.getAndSet(false)) {
        final Server server = SystemInstance.get().getComponent(Server.class);
        if (null != server) {
            try {
                System.out.println("Stopping NTService");
                server.stop();
            } catch (Exception e) {
                //Failed to stop
                running.set(true);
                e.printStackTrace(System.err);
            }
        }
    }
}
Also used : Server(org.apache.openejb.server.Server) ServerRuntimeException(org.apache.openejb.server.ServerRuntimeException)

Example 2 with Server

use of org.apache.openejb.server.Server in project tomee by apache.

the class AdminDaemon method service.

@Override
public void service(Socket socket) throws ServiceException, IOException {
    InputStream in = null;
    try {
        in = socket.getInputStream();
        byte requestTypeByte = (byte) in.read();
        try {
            RequestType requestType = RequestType.valueOf(requestTypeByte);
            switch(requestType) {
                case NOP_REQUEST:
                    return;
                case STOP_REQUEST_Quit:
                case STOP_REQUEST_quit:
                case STOP_REQUEST_Stop:
                case STOP_REQUEST_stop:
                    Server server = SystemInstance.get().getComponent(Server.class);
                    if (null != server) {
                        server.stop();
                    }
                    break;
                default:
                    //If this turns up in the logs then it is time to take action
                    Logger.getInstance(LogCategory.OPENEJB_SERVER, AdminDaemon.class).warning("Invalid Server Socket request: " + requestType);
                    break;
            }
        } catch (IllegalArgumentException iae) {
            Logger.getInstance(LogCategory.OPENEJB_SERVER, AdminDaemon.class).warning("Invalid Server Socket request: " + requestTypeByte);
        }
    } catch (Throwable e) {
        Logger.getInstance(LogCategory.OPENEJB_SERVER, AdminDaemon.class).warning("Server Socket request failed", e);
    } finally {
        if (null != in) {
            try {
                in.close();
            } catch (Throwable t) {
            //Ignore
            }
        }
        if (null != socket) {
            try {
                socket.close();
            } catch (Throwable t) {
            //Ignore
            }
        }
    }
}
Also used : Server(org.apache.openejb.server.Server) RequestType(org.apache.openejb.client.RequestType)

Aggregations

Server (org.apache.openejb.server.Server)2 RequestType (org.apache.openejb.client.RequestType)1 ServerRuntimeException (org.apache.openejb.server.ServerRuntimeException)1