⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstractservercmdprocessor.java

📁 JRemoteControl is a simple Java&#8482 driven bluetooth remote control.It allows you to initiate virt
💻 JAVA
字号:
/* * JRemCntl - Copyright (C) 2007 Filippo Di Vattimo <fildiv@gmail.com> * See COPYING */package fildiv.jremcntl.server.core;import fildiv.jremcntl.common.core.Command;import fildiv.jremcntl.common.core.CommandResult;import fildiv.jremcntl.common.core.JRemRuntimeException;import fildiv.jremcntl.common.proto.JRemAbstractProtocol;import fildiv.jremcntl.common.proto.JRemDataTransferException;import fildiv.jremcntl.server.utils.JRemServerUtils;import fildiv.jremcntl.server.utils.SystemRuntimeProcessor;public abstract class AbstractServerCmdProcessor implements ServerCmdProcessor {	private JRemEnv env;	private Command command;	private JRemServerListeners delegate;	private DeviceProxy dp;	private CommandResult dpResult;	private JRemServerProtocol proto;	private SystemRuntimeProcessorImpl slImpl;		protected AbstractServerCmdProcessor(JRemServerProtocol proto, 			JRemServerListeners delegate, Command command,			DeviceProxy dp) {				this.env = JRemEnv.getInstance();		this.proto = proto;		this.delegate = delegate;		this.command = command;		this.dp = dp;				this.slImpl = new SystemRuntimeProcessorImpl();	}	public void process() {		String execPath = JRemServerUtils.getCmdFullExePath(env, command);				String []envs = getEnvironmentVars();				SystemRuntime.run(execPath,				envs, 				slImpl);	}			protected class SystemRuntimeProcessorImpl implements SystemRuntimeProcessor {				private boolean skipForError = false;				public void processErrorOccurred(Exception e) {			skipForError = true;			delegate.onCommandRunException(command, e);		}			public void processStdError(String data) {			delegate.onCommandProcessStderr(data);		}			public void processStdOutput(String data) {					delegate.onCommandProcessStdout(data);						try {				if (dp != null) {					dp.processOutputLine(data);					if (dp.getProcessType() == DeviceProxy.DP_PROCESS_TYPE_CMD_LINE)						sendResult();				}							} catch(Exception e) {				delegate.onCommandDeviceProxyException(command, e);			}		}						public void processTerminated(String cmdLine, int exitCode) {						delegate.onCommandTerminated(command, exitCode);			if (skipForError)				return;						if (dp != null) {				try {					dp.processTerminated(cmdLine, exitCode);				} catch(Exception e) {					delegate.onCommandDeviceProxyException(command, e);				}				if (dp.getProcessType() == DeviceProxy.DP_PROCESS_TYPE_CMD_ENDS) {					try {						sendResult();										} catch(Exception e) {						delegate.onSendClientResultException(command, e);					}				}			}		}	}	private void sendResult() throws JRemDataTransferException {				dpResult = dp.getResult();		if (dpResult != null)			sendResponse(dpResult);	}				public Command getCommand() {		return command;	}		public JRemAbstractProtocol getProtocol() {		return proto;	}			protected String[] getEnvironmentVars() {		return null;	}		protected void sendResponse(CommandResult commandResult) throws JRemDataTransferException {		if (proto.isClosed())			throw new JRemRuntimeException(					"Unable to send result, connection closed!");				proto.sendCmdResponse(commandResult);			}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -