📄 abstractservercmdmngfactory.java
字号:
/* * JRemCntl - Copyright (C) 2007 Filippo Di Vattimo <fildiv@gmail.com> * See COPYING */package fildiv.jremcntl.server.core;import java.util.HashMap;import java.util.Map;import fildiv.jremcntl.common.core.Command;import fildiv.jremcntl.common.core.Extension;import fildiv.jremcntl.common.core.JRemRuntimeException;public abstract class AbstractServerCmdMngFactory implements ServerCmdMgnFactory { private final JRemServerListeners delegate; private JRemServerProtocol proto; private Map extMap; private JRemEnv env; protected AbstractServerCmdMngFactory(JRemServerListeners delegate) { this.env = JRemEnv.getInstance(); this.delegate = delegate; extMap = new HashMap(); } public ServerCmdProcessor createCmdProcessor(Command command) { DeviceProxy dp = getDeviceProxy(command); return createCmdProcessor(command, dp); } private DeviceProxy getDeviceProxy(Command command) { JRemExtension ext = getExtension(command); if (ext == null) return null; DeviceProxy dp = ext.getDeviceProxy(); if (dp == null) return null; DeviceProxy dpc = null; try { dpc = (DeviceProxy) dp.clone(); } catch(CloneNotSupportedException e) { throw new JRemRuntimeException( "DeviceProxy must be cloneable", e); } dpc.init(env.getLogger()); return dpc; } private JRemExtension getExtension(Command command) { JRemExtension ext = (JRemExtension) extMap.get(command); if (ext != null) return ext; Extension e = command.getExtension(true); if (e == null) return null; ext = (JRemExtension) e.getImplObj(); extMap.put(command, ext); return ext; } public JRemServerListeners getDelegate() { return delegate; } public void setProtocol(JRemServerProtocol proto) { this.proto = proto; } public JRemServerProtocol getProtocol() { return this.proto; } protected abstract ServerCmdProcessor createCmdProcessor(Command command, DeviceProxy dp);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -