abstractserverproxy.java
来自「这是一个以JAVA编写的程序,本人还没有试过,是一个简单的温度控制系统」· Java 代码 · 共 83 行
JAVA
83 行
package net.sf.dz.view.tcp.server;import java.io.PrintWriter;import java.util.HashSet;import java.util.Iterator;import java.util.Set;import org.freehold.jukebox.logger.LogAware;import org.freehold.jukebox.logger.Logger;/** * The abstract server side proxy. * * @author Copyright © <a href="mailto:vt@freehold.crocodile.org">Vadim Tkachenko</a> 2001-2002 * @version $Id: AbstractServerProxy.java,v 1.4 2002/08/06 04:33:25 vtt Exp $ */abstract public class AbstractServerProxy extends LogAware { private Set clientSet = new HashSet(); public AbstractServerProxy(Logger logger) { super(logger); } protected void configure() throws Throwable { // It's unlikely that the subclasses will have to be configured } /** * Render the object's reflection. * * The preferred way of doing this is rendering the XML element that can * be easily parsed by the client. * * @param pw The print writer to render the reflection onto. * * @exception IOException if ther was an I/O error. */ abstract public void renderReflection(PrintWriter pw); /** * Dump the current state of the object. * * The preferred way of doing this is dumping the data exactly the same * way that it would have been done during the normal activity * notification. * * @param pw The print writer to dump the state onto. * * @exception IOException if ther was an I/O error. */ abstract public void dumpState(PrintWriter pw); /** * Start listening to the reflected component's state changes. */ public void listen(PrintWriter pw) { clientSet.add(pw); } /** * Stop passing notifications to this stream. */ public void ignore(PrintWriter pw) { clientSet.remove(pw); } protected synchronized void send(String message) { for ( Iterator i = clientSet.iterator(); i.hasNext(); ) { PrintWriter pw = (PrintWriter)i.next(); pw.println(message); pw.flush(); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?