当前位置: 首页>>代码示例>>Java>>正文


Java ChannelListeners.invokeChannelListener方法代码示例

本文整理汇总了Java中org.xnio.ChannelListeners.invokeChannelListener方法的典型用法代码示例。如果您正苦于以下问题:Java ChannelListeners.invokeChannelListener方法的具体用法?Java ChannelListeners.invokeChannelListener怎么用?Java ChannelListeners.invokeChannelListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.xnio.ChannelListeners的用法示例。


在下文中一共展示了ChannelListeners.invokeChannelListener方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleEvent

import org.xnio.ChannelListeners; //导入方法依赖的package包/类
@Override
public void handleEvent(StreamConnection channel) {
    try {
        for (CloseListener l : closeListeners) {
            try {
                l.closed(AbstractServerConnection.this);
            } catch (Throwable e) {
                UndertowLogger.REQUEST_LOGGER.exceptionInvokingCloseListener(l, e);
            }
        }
        if (current != null) {
            current.endExchange();
        }
        ChannelListeners.invokeChannelListener(AbstractServerConnection.this, listener);
    } finally {
        if(extraBytes != null) {
            extraBytes.free();
            extraBytes = null;
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:AbstractServerConnection.java

示例2: handleEvent

import org.xnio.ChannelListeners; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public void handleEvent(final StreamSourceChannel channel) {
    final R receiver = AbstractFramedChannel.this.receiver;
    if ((isLastFrameReceived() || receivesSuspended) && receiver == null) {
        channel.suspendReads();
        return;
    } else {
        final ChannelListener listener = receiveSetter.get();
        if (listener != null) {
            WebSocketLogger.REQUEST_LOGGER.debugf("Invoking receive listener", receiver);
            ChannelListeners.invokeChannelListener(AbstractFramedChannel.this, listener);
        } else {
            channel.suspendReads();
        }
    }
    if (readData != null && channel.isOpen()) {
        ChannelListeners.invokeChannelListener(channel.getIoThread(), channel, this);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:AbstractFramedChannel.java

示例3: close

import org.xnio.ChannelListeners; //导入方法依赖的package包/类
@Override
public void close() throws IOException {
    if(anyAreSet(state, STATE_CLOSED)) {
        return;
    }
    state |= STATE_CLOSED;
    if (allAreClear(state, STATE_DONE | STATE_LAST_FRAME)) {
        state |= STATE_STREAM_BROKEN;
        getFramedChannel().notifyClosed(this);
        channelForciblyClosed();
    }
    if (data != null) {
        data.free();
        data = null;
    }
    while (!pendingFrameData.isEmpty()) {
        pendingFrameData.poll().frameData.free();
    }
    ChannelListeners.invokeChannelListener(this, (ChannelListener<? super AbstractFramedStreamSourceChannel<C, R, S>>) closeSetter.get());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:AbstractFramedStreamSourceChannel.java

示例4: run

import org.xnio.ChannelListeners; //导入方法依赖的package包/类
@Override
public void run() {
    handle = null;
    if (expireTime == -1) {
        return;
    }
    long current = System.currentTimeMillis();
    if (current  < expireTime) {
        //timeout has been bumped, re-schedule
        handle = connection.getIoThread().executeAfter(timeoutCommand, (expireTime - current) + FUZZ_FACTOR, TimeUnit.MILLISECONDS);
        return;
    }
    UndertowLogger.REQUEST_LOGGER.tracef("Timing out channel %s due to inactivity");
    IoUtils.safeClose(connection);
    if (connection.getSourceChannel().isReadResumed()) {
        ChannelListeners.invokeChannelListener(connection.getSourceChannel(), connection.getSourceChannel().getReadListener());
    }
    if (connection.getSinkChannel().isWriteResumed()) {
        ChannelListeners.invokeChannelListener(connection.getSinkChannel(), connection.getSinkChannel().getWriteListener());
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:WriteTimeoutStreamSinkConduit.java

示例5: complete

import org.xnio.ChannelListeners; //导入方法依赖的package包/类
@Override
protected void complete() throws IOException {
    super.complete();
    if(completionListener != null) {
        ChannelListeners.invokeChannelListener(this, completionListener);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:SpdyStreamStreamSourceChannel.java

示例6: handleFlushComplete

import org.xnio.ChannelListeners; //导入方法依赖的package包/类
@Override
protected void handleFlushComplete(boolean finalFrame) {
    super.handleFlushComplete(finalFrame);
    if (finalFrame) {
        if (completionListener != null) {
            ChannelListeners.invokeChannelListener(this, completionListener);
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:SpdySynReplyStreamSinkChannel.java

示例7: close

import org.xnio.ChannelListeners; //导入方法依赖的package包/类
@Override
public void close() throws IOException {
    if(fullyFlushed || anyAreSet(state, STATE_CLOSED)) {
        return;
    }
    try {
        state |= STATE_CLOSED;
        buffer.free();
        buffer = null;
        if (header != null && header.getByteBuffer() != null) {
            header.getByteBuffer().free();
        }
        if (trailer != null) {
            trailer.free();
        }
        if (anyAreSet(state, STATE_FIRST_DATA_WRITTEN)) {
            channelForciblyClosed();
        }
        //we need to wake up/invoke the write listener
        if (isWriteResumed()) {
            ChannelListeners.invokeChannelListener(getIoThread(), this, (ChannelListener) getWriteListener());
        }
        wakeupWrites();
    } finally {
        wakeupWaiters();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:AbstractFramedStreamSinkChannel.java

示例8: markBroken

import org.xnio.ChannelListeners; //导入方法依赖的package包/类
public void markBroken() {
    this.broken = true;
    try {
        wakeupWrites();
        wakeupWaiters();
        if (isWriteResumed()) {
            ChannelListener<? super S> writeListener = this.writeSetter.get();
            if (writeListener != null) {
                ChannelListeners.invokeChannelListener(getIoThread(), (S) this, writeListener);
            }
        }
        ChannelListener<? super S> closeListener = this.closeSetter.get();
        if (closeListener != null) {
            ChannelListeners.invokeChannelListener(getIoThread(), (S) this, closeListener);
        }
    } finally {
        if(header != null && header.getByteBuffer() != null) {
            header.getByteBuffer().free();
        }
        if(trailer != null) {
            trailer.free();
        }
        if(buffer != null) {
            buffer.free();
            buffer = null;
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:AbstractFramedStreamSinkChannel.java

示例9: done

import org.xnio.ChannelListeners; //导入方法依赖的package包/类
private void done() {
    try {
        final ChannelListener<? super I> sourceListener = this.sourceListener;
        final ChannelListener<? super O> sinkListener = this.sinkListener;
        final I source = this.source;
        final O sink = this.sink;
        source.suspendReads();
        sink.suspendWrites();

        ChannelListeners.invokeChannelListener(source, sourceListener);
        ChannelListeners.invokeChannelListener(sink, sinkListener);
    } finally {
        pooledBuffer.free();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:WebSocketUtils.java

示例10: run

import org.xnio.ChannelListeners; //导入方法依赖的package包/类
@Override
public void run() {
    UndertowLogger.REQUEST_LOGGER.tracef("Timing out channel %s due to inactivity");
    try {
        if (delegate.isReadResumed()) {
            ChannelListeners.invokeChannelListener(ReadTimeoutStreamSourceChannel.this, readSetter.get());
        }
    } finally {
        IoUtils.safeClose(delegate);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:ReadTimeoutStreamSourceChannel.java

示例11: run

import org.xnio.ChannelListeners; //导入方法依赖的package包/类
@Override
public void run() {
    UndertowLogger.REQUEST_LOGGER.tracef("Timing out channel %s due to inactivity");
    try {
        if (delegate.isWriteResumed()) {
            ChannelListeners.invokeChannelListener(WriteTimeoutStreamSinkChannel.this, writeSetter.get());
        }
    } finally {
        IoUtils.safeClose(delegate);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:WriteTimeoutStreamSinkChannel.java

示例12: handleEvent

import org.xnio.ChannelListeners; //导入方法依赖的package包/类
public void handleEvent(final StreamSinkChannel channel) {
    ChannelListener<? super StreamSinkChannel> channelListener = setter.get();
    if(channelListener != null) {
        ChannelListeners.invokeChannelListener(this.channel, channelListener);
    } else {
        UndertowLogger.REQUEST_LOGGER.debugf("suspending writes on %s to prevent listener runaway", channel);
        channel.suspendWrites();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:DetachableStreamSinkChannel.java

示例13: handleEvent

import org.xnio.ChannelListeners; //导入方法依赖的package包/类
public void handleEvent(final StreamSourceChannel channel) {
    ChannelListener<? super StreamSourceChannel> channelListener = setter.get();
    if(channelListener != null) {
        ChannelListeners.invokeChannelListener(this.channel, channelListener);
    } else {
        UndertowLogger.REQUEST_LOGGER.debugf("suspending reads on %s to prevent listener runaway", channel);
        channel.suspendReads();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:DetachableStreamSourceChannel.java

示例14: flushComplete

import org.xnio.ChannelListeners; //导入方法依赖的package包/类
/**
 * Method that is invoked when a frame has been fully flushed. This method is only invoked by the IO thread
 */
final void flushComplete() throws IOException {
    try {
        int remaining = header.getRemainingInBuffer();
        boolean finalFrame = finalFrameQueued;
        boolean channelClosed = finalFrame && remaining == 0 && !header.isAnotherFrameRequired();
        if(remaining > 0) {
            buffer.getResource().limit(buffer.getResource().limit() + remaining);
            if(finalFrame) {
                //we clear the final frame flag, as it could not actually be written out
                //note that we don't attempt to requeue, as whatever stopped it from being written will likely still
                //be an issue
                this.finalFrameQueued = false;
            }
        } else if(header.isAnotherFrameRequired()) {
            this.finalFrameQueued = false;
        }
        if (channelClosed) {
            fullyFlushed = true;
            buffer.free();
            buffer = null;
        } else {
            buffer.getResource().compact();
        }
        if (header.getByteBuffer() != null) {
            header.getByteBuffer().free();
        }
        trailer.free();
        header = null;
        trailer = null;

        readyForFlush = false;
        if (isWriteResumed() && !channelClosed) {
            wakeupWrites();
        } else if(isWriteResumed()) {
            //we need to execute the write listener one last time
            //we need to dispatch it back to the IO thread, so we don't invoke it recursivly
            ChannelListeners.invokeChannelListener(getIoThread(), (S)this, getWriteListener());
        }

        final ChannelListener<? super S> closeListener = this.closeSetter.get();
        if (channelClosed && closeListener != null) {
            ChannelListeners.invokeChannelListener(getIoThread(), (S) AbstractFramedStreamSinkChannel.this, closeListener);
        }
        handleFlushComplete(channelClosed);
    } finally {
        wakeupWaiters();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:52,代码来源:AbstractFramedStreamSinkChannel.java


注:本文中的org.xnio.ChannelListeners.invokeChannelListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。