本文整理汇总了Java中org.apache.mina.core.future.ReadFuture类的典型用法代码示例。如果您正苦于以下问题:Java ReadFuture类的具体用法?Java ReadFuture怎么用?Java ReadFuture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReadFuture类属于org.apache.mina.core.future包,在下文中一共展示了ReadFuture类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: read
import org.apache.mina.core.future.ReadFuture; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public final ReadFuture read() {
if (!getConfig().isUseReadOperation()) {
throw new IllegalStateException("useReadOperation is not enabled.");
}
Queue<ReadFuture> readyReadFutures = getReadyReadFutures();
ReadFuture future;
synchronized (readyReadFutures) {
future = readyReadFutures.poll();
if (future != null) {
if (future.isClosed()) {
// Let other readers get notified.
readyReadFutures.offer(future);
}
} else {
future = new DefaultReadFuture(this);
getWaitingReadFutures().offer(future);
}
}
return future;
}
开发者ID:eclipse,项目名称:neoscada,代码行数:26,代码来源:AbstractIoSession.java
示例2: recvResponse
import org.apache.mina.core.future.ReadFuture; //导入依赖的package包/类
protected byte[] recvResponse(ReadFuture readFuture, int timeout) throws Exception {
// 读取等待超时
boolean b = readFuture.awaitUninterruptibly(timeout);
if (!b)
throw new Exception("接收远程Tcp服务器数据超时");
if (!readFuture.isRead()) {
if (readFuture.getException() != null)
throw new Exception("接收远程Tcp服务器数据异常", readFuture.getException());
throw new Exception("接收远程Tcp服务器数据异常");
}
Object ret = readFuture.getMessage();
if (logger.isInfoEnabled())
logger.info("TcpConnector RECEIVED:\r\n" + new String((byte[])ret));
return (byte[]) ret;
}
开发者ID:dreajay,项目名称:jcode,代码行数:17,代码来源:TcpConnector.java
示例3: writeAndRead
import org.apache.mina.core.future.ReadFuture; //导入依赖的package包/类
@Override
protected <T extends Reply> T writeAndRead(Command command) throws IOException {
Msg cmd = command.toMsg();
WriteFuture wf = session.write(cmd);
wf.awaitUninterruptibly();
ReadFuture readFuture = session.read();
readFuture.awaitUninterruptibly();
Msg msg = (Msg) readFuture.getMessage();
Reply reply = MsgConverter.convertReply(msg);
return (T) reply;
}
开发者ID:altiplanogao,项目名称:io-comparison,代码行数:15,代码来源:MinaClient.java
示例4: offerClosedReadFuture
import org.apache.mina.core.future.ReadFuture; //导入依赖的package包/类
/**
* TODO Add method documentation
*/
public final void offerClosedReadFuture() {
Queue<ReadFuture> readyReadFutures = getReadyReadFutures();
synchronized (readyReadFutures) {
newReadFuture().setClosed();
}
}
开发者ID:eclipse,项目名称:neoscada,代码行数:10,代码来源:AbstractIoSession.java
示例5: newReadFuture
import org.apache.mina.core.future.ReadFuture; //导入依赖的package包/类
/**
* TODO Add method documentation
*/
private ReadFuture newReadFuture() {
Queue<ReadFuture> readyReadFutures = getReadyReadFutures();
Queue<ReadFuture> waitingReadFutures = getWaitingReadFutures();
ReadFuture future;
synchronized (readyReadFutures) {
future = waitingReadFutures.poll();
if (future == null) {
future = new DefaultReadFuture(this);
readyReadFutures.offer(future);
}
}
return future;
}
开发者ID:eclipse,项目名称:neoscada,代码行数:17,代码来源:AbstractIoSession.java
示例6: getReadyReadFutures
import org.apache.mina.core.future.ReadFuture; //导入依赖的package包/类
/**
* TODO Add method documentation
*/
private Queue<ReadFuture> getReadyReadFutures() {
Queue<ReadFuture> readyReadFutures = (Queue<ReadFuture>) getAttribute(READY_READ_FUTURES_KEY);
if (readyReadFutures == null) {
readyReadFutures = new ConcurrentLinkedQueue<ReadFuture>();
Queue<ReadFuture> oldReadyReadFutures = (Queue<ReadFuture>) setAttributeIfAbsent(READY_READ_FUTURES_KEY,
readyReadFutures);
if (oldReadyReadFutures != null) {
readyReadFutures = oldReadyReadFutures;
}
}
return readyReadFutures;
}
开发者ID:eclipse,项目名称:neoscada,代码行数:17,代码来源:AbstractIoSession.java
示例7: getWaitingReadFutures
import org.apache.mina.core.future.ReadFuture; //导入依赖的package包/类
/**
* TODO Add method documentation
*/
private Queue<ReadFuture> getWaitingReadFutures() {
Queue<ReadFuture> waitingReadyReadFutures = (Queue<ReadFuture>) getAttribute(WAITING_READ_FUTURES_KEY);
if (waitingReadyReadFutures == null) {
waitingReadyReadFutures = new ConcurrentLinkedQueue<ReadFuture>();
Queue<ReadFuture> oldWaitingReadyReadFutures = (Queue<ReadFuture>) setAttributeIfAbsent(
WAITING_READ_FUTURES_KEY, waitingReadyReadFutures);
if (oldWaitingReadyReadFutures != null) {
waitingReadyReadFutures = oldWaitingReadyReadFutures;
}
}
return waitingReadyReadFutures;
}
开发者ID:eclipse,项目名称:neoscada,代码行数:17,代码来源:AbstractIoSession.java
示例8: exceptionCaught
import org.apache.mina.core.future.ReadFuture; //导入依赖的package包/类
public void exceptionCaught(IoSession session, Throwable t){
logger.error("TcpConnector exceptionCaught:" + session.getId(), t);
ReadFuture future = getReadFuture(session);
if (future != null)
future.setException(new Exception(t));
session.close(true);
}
开发者ID:dreajay,项目名称:jcode,代码行数:8,代码来源:TcpConnectorHandler.java
示例9: sessionClosed
import org.apache.mina.core.future.ReadFuture; //导入依赖的package包/类
public void sessionClosed(IoSession session) {
logger.info("TcpConnector sessionClosed:" + session.getId() +" total " + session.getReadBytes() + " byte(s)");
ReadFuture future = null;
// 此处有可能远程主机已经关闭连接,但socket客户端未收到数据,故需要在此处抛出异常
future = getReadFuture(session);
if (future != null)
future.setException(new Exception("远程服务器Tcp已关闭连接"));
}
开发者ID:dreajay,项目名称:jcode,代码行数:9,代码来源:TcpConnectorHandler.java
示例10: messageReceived
import org.apache.mina.core.future.ReadFuture; //导入依赖的package包/类
public void messageReceived(IoSession session, Object message) {
// 日志放TcpConnector中,避免因为connector使用线程池而无法定位日志属于哪个接入线程
// if (logger.isInfoEnabled())
// logger.info("TcpConnector RECEIVED:\r\n" + CommHelper.messageToString(cfg, message));
logger.debug("TcpConnector RECEIVED:" + session.getId());
ReadFuture future = getReadFuture(session);
if (future != null)
future.setRead(message);
}
开发者ID:dreajay,项目名称:jcode,代码行数:10,代码来源:TcpConnectorHandler.java
示例11: sessionIdle
import org.apache.mina.core.future.ReadFuture; //导入依赖的package包/类
public void sessionIdle(IoSession session, IdleStatus status) {
super.sessionIdle(session, status);
ReadFuture future = getReadFuture(session);
if (future != null)
future.setException(new Exception("远程服务器SOCKET通讯连接空闲:" + status));
session.close(true);
}
开发者ID:dreajay,项目名称:jcode,代码行数:8,代码来源:ShortConnectorHandler.java
示例12: getReadFuture
import org.apache.mina.core.future.ReadFuture; //导入依赖的package包/类
protected ReadFuture getReadFuture(IoSession s) {
return handlers.get(s);
}
开发者ID:dreajay,项目名称:jcode,代码行数:4,代码来源:TcpConnectorHandler.java
示例13: addReadFuture
import org.apache.mina.core.future.ReadFuture; //导入依赖的package包/类
public void addReadFuture(IoSession s, ReadFuture f) {
handlers.put(s, f);
}
开发者ID:dreajay,项目名称:jcode,代码行数:4,代码来源:TcpConnectorHandler.java
示例14: read
import org.apache.mina.core.future.ReadFuture; //导入依赖的package包/类
@Override
public ReadFuture read() {
return null;
}
开发者ID:icelemon1314,项目名称:mapleLemon,代码行数:5,代码来源:MockIOSession.java
示例15: read
import org.apache.mina.core.future.ReadFuture; //导入依赖的package包/类
@Override
public ReadFuture read() {
throw new UnsupportedOperationException("Not supported yet.");
}
开发者ID:316181444,项目名称:Hxms,代码行数:5,代码来源:MockIOSession.java
示例16: read
import org.apache.mina.core.future.ReadFuture; //导入依赖的package包/类
@Override
public ReadFuture read() {
// TODO Auto-generated method stub
return null;
}
开发者ID:Red5,项目名称:red5-websocket,代码行数:6,代码来源:WebSocketServerTest.java
示例17: read
import org.apache.mina.core.future.ReadFuture; //导入依赖的package包/类
/**
* @see IoSession#read()
*/
public ReadFuture read() {
return wrappedSession.read();
}
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:7,代码来源:FtpIoSession.java
示例18: read
import org.apache.mina.core.future.ReadFuture; //导入依赖的package包/类
/**
* TODO This javadoc is wrong. The return tag should be short.
*
* @return a {@link ReadFuture} which is notified when a new message is
* received, the connection is closed or an exception is caught. This
* operation is especially useful when you implement a client application.
* TODO : Describe here how we enable this feature.
* However, please note that this operation is disabled by default and
* throw {@link IllegalStateException} because all received events must be
* queued somewhere to support this operation, possibly leading to memory
* leak. This means you have to keep calling {@link #read()} once you
* enabled this operation. To enable this operation, please call
* {@link IoSessionConfig#setUseReadOperation(boolean)} with <tt>true</tt>.
*
* @throws IllegalStateException if
* {@link IoSessionConfig#setUseReadOperation(boolean) useReadOperation}
* option has not been enabled.
*/
ReadFuture read();
开发者ID:eclipse,项目名称:neoscada,代码行数:20,代码来源:IoSession.java
注:本文中的org.apache.mina.core.future.ReadFuture类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论