proxystub.java
来自「主要是对串口驱动的的一些控制源码!!! 在下载javacomm20-win32」· Java 代码 · 共 145 行
JAVA
145 行
/**
* $Log: ProxyStub.java,v $
* Revision 1.2 2003/02/03 14:16:03 mwulff
* changed ExceptionHandling; differentiation between local and remote errors
*
* Revision 1.1 2003/01/16 13:12:40 mwulff
* initial version
*
* Revision 1.6 2002/12/20 18:52:25 mwulff
* no message
*
* Revision 1.5 2002/12/15 16:55:07 mwulff
* adjusted to reorganisation of the client logging system
*
* Revision 1.4 2002/12/13 20:08:34 mwulff
* no message
*
* Revision 1.3 2002/12/05 21:33:50 mwulff
* reengineering of the complete communication component
*
* Revision 1.2 2002/12/01 13:02:14 mwulff
* accomodated to ClientResourceManager and ClientLoggingManager,
* that are now implemented as singleton
*
* Revision 1.1 2002/11/22 16:43:00 mwulff
* moved and renamed
*
* Revision 1.7 2002/11/17 17:59:07 mwulff
* no message
*
* Revision 1.6 2002/11/16 12:29:23 mwulff
* organized imports
*
* Revision 1.5 2002/11/15 18:25:05 mwulff
* - addes support for remote gc
* - changed exception handling
*
* Revision 1.4 2002/11/08 19:23:27 mwulff
* is now responsible for compression check
* of the DeflaterByteArrayOutputStream
*
* Revision 1.3 2002/11/05 19:49:03 mwulff
* class is now inherited from CommunicationHandler and therefore supports
* transfering local LoggingEvents to the server
*
* Revision 1.2 2002/11/03 21:06:42 mwulff
* added support for handling compressed and uncompressed stream by using
* a ClientCompressionManager
*
* Revision 1.1.1.1 2002/10/23 14:13:23 mwulff
* initial checkin
*
*/
package de.fhm.jkf.comm.cl;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import de.fhm.jkf.comm.clsv.DataResponse;
import de.fhm.jkf.comm.clsv.QueryRequest;
import de.fhm.jkf.comm.clsv.RemoteObjectID;
import de.fhm.jkf.comm.clsv.RemoteObjectQueryException;
import de.fhm.jkf.resource.cl.JKFClientLogger;
/**
* @author marten wulff
*
* <br><br><center><table border="1" width="80%"><hr>
* <strong><a href="http://jkf.sourceforge.net">The JKF Project</a></strong>
* <p>
* Copyright (C) 2002 by Marten Wulff
* <p>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* <p>
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* <p>
* You should have received a copy of the <a href="http://www.gnu.org/copyleft/lesser.html">
* GNU Lesser General Public License</a> along with this library; if not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
* <hr></table></center>
*/
class ProxyStub
extends CommunicationHandler
implements InvocationHandler {
private RemoteObjectID remoteObjectId = null;
ProxyStub(RemoteObjectID remoteObjectId) {
this.remoteObjectId = remoteObjectId;
}
/*
* @see InvocationHandler#invoke(Object, Method, Object[])
*/
public Object invoke(Object proxy, Method method, Object[] params)
throws Throwable {
DataResponse response = null;
try {
if(JKFClientLogger.isDebugEnabled()) {
JKFClientLogger.debug("Querying remote Object...");
}
QueryRequest request = new QueryRequest();
request.setRemoteObjectId(remoteObjectId);
request.setMethodName(method.getName());
request.setParams(params);
prepareConnection(request);
this.compressionHandler.sendObject(request);
response = (DataResponse) this.compressionHandler.receiveObject();
followUpConnection(response);
} catch (Exception ex) {
throw new RemoteObjectQueryException(
"[LocalError] querying object",
ex);
}
// check if any exceptions on server side occured
if (response.errorOccured()) {
Exception ex = response.getRemoteException();
throw new RemoteObjectQueryException(
"[RemoteError] querying object",
ex);
}
return response.getData();
}
protected void finalize() {
gcBuffer.addGCMessage(remoteObjectId);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?