abstractjremserverlistener.java
来自「JRemoteControl is a simple Java™ dr」· Java 代码 · 共 128 行
JAVA
128 行
/* * Copyright (C) 2007 Filippo Di Vattimo - See LICENSE * */package fildiv.jremcntl.server.core;import fildiv.jremcntl.common.core.Command;import fildiv.jremcntl.common.core.Logger;import fildiv.jremcntl.server.utils.JRemServerUtils;public abstract class AbstractJRemServerListener implements JRemServerEventsListener, JRemServerCommandEventsListener { private Logger logger; private JRemEnv env; public AbstractJRemServerListener(Logger logger) { if (logger == null) throw new IllegalArgumentException("Logger cannot be null"); this.env = JRemEnv.getInstance(); this.logger = logger; } public void onCommandDeviceProxyException(Command c, Exception e) { String msg = "Error processing output for command " + JRemServerUtils.getCommandDescForLog(env, c); logger.error(msg); logger.error(e); printServerError(msg); printServerError(e); } public void onCommandRunException(Command c, Exception e) { String msg = "Error executing command " + JRemServerUtils.getCommandDescForLog(env, c); logger.error(msg); logger.error(e); printServerError(msg); printServerError(e); } public void onSendClientResultException(Command c, Exception e) { String msg = "Error while sending result to client running command " + JRemServerUtils.getCommandDescForLog(env, c); logger.error(msg); logger.error(e); printServerError(msg); printServerError(e); } public void onServerExceptionOccurred(Exception e) { String msg = "A server exception has occurred"; logger.error(msg); logger.error(e); printServerError(msg); printServerError(e); } public void onConnectionListening() { printServerInfo("Listening for client connection ..."); } public void onClientCommandListening() { printServerInfo("Listening for client commands ..."); } public void onCommandProcessStderr(String data) { printCmdStderr(data); } public void onCommandProcessStdout(String data) { printCmdStdout(data); } public void onCommandRun(Command c) { printServerInfo("Run command " + JRemServerUtils.getCommandDescForLog(env, c)); } public void onCommandTerminated(Command c, int exitCode) { printServerInfo("The command " + JRemServerUtils.getCommandDescForLog(env, c) + " exits with code (" + exitCode + ")"); } public void onDeviceConnected(String deviceName) { printServerInfo(deviceName + " connected ..."); } public void onDeviceDisconnected() { printServerInfo("Device disconnected"); } public void onServerStarted() { printServerInfo("Server running ..."); } public void onServerStopped() { printServerInfo("Server not running"); } /* * Override */ public abstract void printCmdStderr(String data); public abstract void printCmdStdout(String data); public abstract void printServerInfo(String msg); public abstract void printServerError(Exception e); public abstract void printServerError(String msg);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?