本文整理汇总了Java中org.glassfish.grizzly.Connection.isOpen方法的典型用法代码示例。如果您正苦于以下问题:Java Connection.isOpen方法的具体用法?Java Connection.isOpen怎么用?Java Connection.isOpen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.glassfish.grizzly.Connection
的用法示例。
在下文中一共展示了Connection.isOpen方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOrAddChannel
import org.glassfish.grizzly.Connection; //导入方法依赖的package包/类
static GrizzlyChannel getOrAddChannel(Connection<?> connection, URL url, ChannelHandler handler) {
if (connection == null) {
return null;
}
GrizzlyChannel ret = ATTRIBUTE.get(connection);
if (ret == null) {
ret = new GrizzlyChannel(connection, url, handler);
if (connection.isOpen()) {
ATTRIBUTE.set(connection, ret);
}
}
return ret;
}
示例2: getChannel
import org.glassfish.grizzly.Connection; //导入方法依赖的package包/类
@Override
protected Channel getChannel() {
Connection<?> c = connection;
if (c == null || ! c.isOpen())
return null;
return GrizzlyChannel.getOrAddChannel(c, getUrl(), this);
}
示例3: handleClose
import org.glassfish.grizzly.Connection; //导入方法依赖的package包/类
/**
* This method will be called, to notify about {@link Connection} closing.
*/
@Override
public NextAction handleClose(FilterChainContext ctx) throws IOException {
final Connection connection = ctx.getConnection();
final Connection peerConnection = peerConnectionAttribute
.get(connection);
// Close peer connection as well, if it wasn't closed before
if (peerConnection != null && peerConnection.isOpen()) {
peerConnection.closeSilently();
}
return ctx.getInvokeAction();
}
示例4: getChannel
import org.glassfish.grizzly.Connection; //导入方法依赖的package包/类
@Override
protected Channel getChannel() {
Connection<?> c = connection;
if (c == null || !c.isOpen())
return null;
return GrizzlyChannel.getOrAddChannel(c, getUrl(), this);
}
示例5: removeChannelIfDisconnectd
import org.glassfish.grizzly.Connection; //导入方法依赖的package包/类
static void removeChannelIfDisconnectd(Connection<?> connection) {
if (connection != null && ! connection.isOpen()) {
ATTRIBUTE.remove(connection);
}
}
示例6: handleRead
import org.glassfish.grizzly.Connection; //导入方法依赖的package包/类
/**
* This method will be called, once {@link Connection} has some available
* data
*/
@Override
public NextAction handleRead(final FilterChainContext ctx)
throws IOException {
logger.log(Level.FINEST, "Connection: {0} handleRead: {1}",
new Object[] { ctx.getConnection(), ctx.getMessage() });
final Connection connection = ctx.getConnection();
final Connection peerConnection = peerConnectionAttribute
.get(connection);
// if connection is closed - stop the execution
if (!connection.isOpen()) {
return ctx.getStopAction();
}
final NextAction suspendNextAction = ctx.getSuspendAction();
// if peerConnection wasn't created - create it (usually happens on
// first connection request)
if (peerConnection == null) {
// "Peer connect" phase could take some time - so execute it in
// non-blocking mode
// Connect peer connection and register completion handler
transport.connect(redirectAddress,
new ConnectCompletionHandler(ctx));
// return suspend status
return suspendNextAction;
}
final Object message = ctx.getMessage();
// if peer connection is already created - just forward data to peer
redirectToPeer(ctx, peerConnection, message);
// if peer connection is already created - just forward data to peer
final AsyncQueueWriter writer = (AsyncQueueWriter) connection
.getTransport().getWriter(false);
if (writer.canWrite(peerConnection)) {
return ctx.getStopAction();
}
// Make sure we don't overload peer's output buffer and do not cause
// OutOfMemoryError
ctx.suspend();
writer.notifyWritePossible(peerConnection, new WriteHandler() {
@Override
public void onWritePossible() throws Exception {
finish();
}
@Override
public void onError(Throwable t) {
finish();
}
private void finish() {
ctx.resumeNext();
}
});
// return ctx.getStopAction();
return suspendNextAction;
}
示例7: removeChannelIfDisconnectd
import org.glassfish.grizzly.Connection; //导入方法依赖的package包/类
static void removeChannelIfDisconnectd(Connection<?> connection) {
if (connection != null && !connection.isOpen()) {
ATTRIBUTE.remove(connection);
}
}