• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Pool类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: connect

import org.xnio.Pool; //导入依赖的package包/类
@Override
public void connect(final ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress, final URI uri, final XnioWorker worker, final XnioSsl ssl, final Pool<ByteBuffer> bufferPool, final OptionMap options) {
    ChannelListener<StreamConnection> openListener = new ChannelListener<StreamConnection>() {
        @Override
        public void handleEvent(StreamConnection connection) {
            handleConnected(connection, listener, uri, ssl, bufferPool, options);
        }
    };
    IoFuture.Notifier<StreamConnection, Object> notifier = new IoFuture.Notifier<StreamConnection, Object>() {
        @Override
        public void notify(IoFuture<? extends StreamConnection> ioFuture, Object o) {
            if (ioFuture.getStatus() == IoFuture.Status.FAILED) {
                listener.failed(ioFuture.getException());
            }
        }
    };
    if(bindAddress == null) {
        worker.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 8009 : uri.getPort()), openListener, options).addNotifier(notifier, null);
    } else {
        worker.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 8009 : uri.getPort()), openListener, null, options).addNotifier(notifier, null);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:AjpClientProvider.java


示例2: connect

import org.xnio.Pool; //导入依赖的package包/类
public IoFuture<ClientConnection> connect(InetSocketAddress bindAddress, final URI uri, final XnioWorker worker, XnioSsl ssl, Pool<ByteBuffer> bufferPool, OptionMap options) {
    ClientProvider provider = getClientProvider(uri);
    final FutureResult<ClientConnection> result = new FutureResult<>();
    provider.connect(new ClientCallback<ClientConnection>() {
        @Override
        public void completed(ClientConnection r) {
            result.setResult(r);
        }

        @Override
        public void failed(IOException e) {
            result.setException(e);
        }
    }, bindAddress, uri, worker, ssl, bufferPool, options);
    return result.getIoFuture();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:UndertowClient.java


示例3: HttpClientConnection

import org.xnio.Pool; //导入依赖的package包/类
HttpClientConnection(final StreamConnection connection, final OptionMap options, final Pool<ByteBuffer> bufferPool) {
    this.options = options;
    this.connection = connection;
    this.pushBackStreamSourceConduit = new PushBackStreamSourceConduit(connection.getSourceChannel().getConduit());
    this.connection.getSourceChannel().setConduit(pushBackStreamSourceConduit);
    this.bufferPool = bufferPool;
    this.originalSinkConduit = connection.getSinkChannel().getConduit();

    connection.getCloseSetter().set(new ChannelListener<StreamConnection>() {

        public void handleEvent(StreamConnection channel) {
            HttpClientConnection.this.state |= CLOSED;
            ChannelListeners.invokeChannelListener(HttpClientConnection.this, closeSetter.get());
        }
    });
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:HttpClientConnection.java


示例4: connect

import org.xnio.Pool; //导入依赖的package包/类
@Override
public void connect(ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress, URI uri, XnioWorker worker, XnioSsl ssl, Pool<ByteBuffer> bufferPool, OptionMap options) {
    if (uri.getScheme().equals("https")) {
        if (ssl == null) {
            listener.failed(UndertowMessages.MESSAGES.sslWasNull());
            return;
        }
        if (bindAddress == null) {
            ssl.openSslConnection(worker, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, options), options).addNotifier(createNotifier(listener), null);
        } else {
            ssl.openSslConnection(worker, bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, options), options).addNotifier(createNotifier(listener), null);
        }
    } else {
        if (bindAddress == null) {
            worker.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options), options).addNotifier(createNotifier(listener), null);
        } else {
            worker.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options), null, options).addNotifier(createNotifier(listener), null);
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:HttpClientProvider.java


示例5: handleConnected

import org.xnio.Pool; //导入依赖的package包/类
private void handleConnected(final StreamConnection connection, final ClientCallback<ClientConnection> listener, final Pool<ByteBuffer> bufferPool, final OptionMap options) {
    if (options.get(UndertowOptions.ENABLE_SPDY, false) && connection instanceof SslConnection && SpdyClientProvider.isEnabled()) {
        try {
            SpdyClientProvider.handlePotentialSpdyConnection(connection, listener, bufferPool, options, new ChannelListener<SslConnection>() {
                @Override
                public void handleEvent(SslConnection channel) {
                    listener.completed(new HttpClientConnection(connection, options, bufferPool));
                }
            });
        } catch (Exception e) {
            listener.failed(new IOException(e));
        }
    } else {
        listener.completed(new HttpClientConnection(connection, options, bufferPool));
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:HttpClientProvider.java


示例6: HttpServerConnection

import org.xnio.Pool; //导入依赖的package包/类
public HttpServerConnection(StreamConnection channel, final Pool<ByteBuffer> bufferPool, final HttpHandler rootHandler, final OptionMap undertowOptions, final int bufferSize) {
    super(channel, bufferPool, rootHandler, undertowOptions, bufferSize);
    if (channel instanceof SslChannel) {
        sslSessionInfo = new ConnectionSSLSessionInfo(((SslChannel) channel), this);
    }
    this.responseConduit = new HttpResponseConduit(channel.getSinkChannel().getConduit(), bufferPool);

    fixedLengthStreamSinkConduit = new ServerFixedLengthStreamSinkConduit(responseConduit, false, false);
    readDataStreamSourceConduit = new ReadDataStreamSourceConduit(channel.getSourceChannel().getConduit(), this);
    //todo: do this without an allocation
    addCloseListener(new CloseListener() {
        @Override
        public void closed(ServerConnection connection) {
            responseConduit.freeBuffers();
        }
    });
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:HttpServerConnection.java


示例7: SpdyOpenListener

import org.xnio.Pool; //导入依赖的package包/类
public SpdyOpenListener(final Pool<ByteBuffer> pool, final Pool<ByteBuffer> heapBufferPool, final OptionMap undertowOptions) {
    this.undertowOptions = undertowOptions;
    this.bufferPool = pool;
    Pooled<ByteBuffer> buf = pool.allocate();
    this.bufferSize = buf.getResource().remaining();
    buf.free();
    this.heapBufferPool = heapBufferPool;
    Pooled<ByteBuffer> buff = heapBufferPool.allocate();
    try {
        if (!buff.getResource().hasArray()) {
            throw UndertowMessages.MESSAGES.mustProvideHeapBuffer();
        }
    } finally {
        buff.free();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:SpdyOpenListener.java


示例8: WebSocketChannel

import org.xnio.Pool; //导入依赖的package包/类
/**
 * Create a new {@link WebSocketChannel}
 * 8
 *
 * @param connectedStreamChannel The {@link org.xnio.channels.ConnectedStreamChannel} over which the WebSocket Frames should get send and received.
 *                               Be aware that it already must be "upgraded".
 * @param bufferPool             The {@link org.xnio.Pool} which will be used to acquire {@link java.nio.ByteBuffer}'s from.
 * @param version                The {@link WebSocketVersion} of the {@link WebSocketChannel}
 * @param wsUrl                  The url for which the channel was created.
 * @param client
 * @param peerConnections        The concurrent set that is used to track open connections associtated with an endpoint
 */
protected WebSocketChannel(final StreamConnection connectedStreamChannel, Pool<ByteBuffer> bufferPool, WebSocketVersion version, String wsUrl, String subProtocol, final boolean client, boolean extensionsSupported, Set<WebSocketChannel> peerConnections) {
    super(connectedStreamChannel, bufferPool, new WebSocketFramePriority(), null);
    this.client = client;
    this.version = version;
    this.wsUrl = wsUrl;
    this.extensionsSupported = extensionsSupported;
    this.subProtocol = subProtocol;
    this.peerConnections = peerConnections;
    addCloseTask(new ChannelListener<WebSocketChannel>() {
        @Override
        public void handleEvent(WebSocketChannel channel) {
            WebSocketChannel.this.peerConnections.remove(WebSocketChannel.this);
        }
    });
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:WebSocketChannel.java


示例9: AjpClientConnection

import org.xnio.Pool; //导入依赖的package包/类
AjpClientConnection(final AjpClientChannel connection, final OptionMap options, final Pool<ByteBuffer> bufferPool) {
    this.options = options;
    this.connection = connection;
    this.bufferPool = bufferPool;

    connection.addCloseTask(new ChannelListener<AjpClientChannel>() {
        @Override
        public void handleEvent(AjpClientChannel channel) {
            ChannelListeners.invokeChannelListener(AjpClientConnection.this, closeSetter.get());
        }
    });
    connection.getReceiveSetter().set(new ClientReceiveListener());
    connection.resumeReceives();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:AjpClientConnection.java


示例10: createOpenListener

import org.xnio.Pool; //导入依赖的package包/类
private ChannelListener<StreamConnection> createOpenListener(final ClientCallback<ClientConnection> listener, final Pool<ByteBuffer> bufferPool, final OptionMap options) {
    return new ChannelListener<StreamConnection>() {
        @Override
        public void handleEvent(StreamConnection connection) {
            handleConnected(connection, listener, bufferPool, options);
        }
    };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:HttpClientProvider.java


示例11: connect

import org.xnio.Pool; //导入依赖的package包/类
@Override
public void connect(final ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress, final URI uri, final XnioWorker worker, final XnioSsl ssl, final Pool<ByteBuffer> bufferPool, final OptionMap options) {
    if(uri.getScheme().equals("spdy-plain")) {

        if(bindAddress == null) {
            worker.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, uri, ssl, bufferPool, options), options).addNotifier(createNotifier(listener), null);
        } else {
            worker.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, uri, ssl, bufferPool, options), null, options).addNotifier(createNotifier(listener), null);
        }
        return;
    }


    if(ALPN_PUT_METHOD == null) {
        listener.failed(UndertowMessages.MESSAGES.jettyNPNNotAvailable());
        return;
    }
    if (ssl == null) {
        listener.failed(UndertowMessages.MESSAGES.sslWasNull());
        return;
    }
    if(bindAddress == null) {
        ssl.openSslConnection(worker, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, uri, ssl, bufferPool, options), options).addNotifier(createNotifier(listener), null);
    } else {
        ssl.openSslConnection(worker, bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, uri, ssl, bufferPool, options), options).addNotifier(createNotifier(listener), null);
    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:SpdyClientProvider.java


示例12: createOpenListener

import org.xnio.Pool; //导入依赖的package包/类
private ChannelListener<StreamConnection> createOpenListener(final ClientCallback<ClientConnection> listener, final URI uri, final XnioSsl ssl, final Pool<ByteBuffer> bufferPool, final OptionMap options) {
    return new ChannelListener<StreamConnection>() {
        @Override
        public void handleEvent(StreamConnection connection) {
            handleConnected(connection, listener, uri, ssl, bufferPool, options);
        }
    };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:SpdyClientProvider.java


示例13: handleConnected

import org.xnio.Pool; //导入依赖的package包/类
private void handleConnected(StreamConnection connection, final ClientCallback<ClientConnection> listener, URI uri, XnioSsl ssl, Pool<ByteBuffer> bufferPool, OptionMap options) {
    if(connection instanceof SslConnection) {
        handlePotentialSpdyConnection(connection, listener, bufferPool, options, new ChannelListener<SslConnection>() {
            @Override
            public void handleEvent(SslConnection channel) {
                listener.failed(UndertowMessages.MESSAGES.spdyNotSupported());
            }
        });
    } else {
        listener.completed(createSpdyChannel(connection, bufferPool));
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:SpdyClientProvider.java


示例14: HttpOpenListener

import org.xnio.Pool; //导入依赖的package包/类
public HttpOpenListener(final Pool<ByteBuffer> pool, final OptionMap undertowOptions) {
    this.undertowOptions = undertowOptions;
    this.bufferPool = pool;
    Pooled<ByteBuffer> buf = pool.allocate();
    this.bufferSize = buf.getResource().remaining();
    buf.free();
    parser = HttpRequestParser.instance(undertowOptions);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:HttpOpenListener.java


示例15: AlpnOpenListener

import org.xnio.Pool; //导入依赖的package包/类
public AlpnOpenListener(Pool<ByteBuffer> bufferPool, String fallbackProtocol, DelegateOpenListener fallbackListener) {
    this.bufferPool = bufferPool;
    this.fallbackProtocol = fallbackProtocol;
    if(fallbackProtocol != null && fallbackListener != null) {
        addProtocol(fallbackProtocol, fallbackListener, 0);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:AlpnOpenListener.java


示例16: AbstractFramedChannel

import org.xnio.Pool; //导入依赖的package包/类
/**
 * Create a new {@link io.undertow.server.protocol.framed.AbstractFramedChannel}
 * 8
 *
 * @param connectedStreamChannel The {@link org.xnio.channels.ConnectedStreamChannel} over which the WebSocket Frames should get send and received.
 *                               Be aware that it already must be "upgraded".
 * @param bufferPool             The {@link org.xnio.Pool} which will be used to acquire {@link java.nio.ByteBuffer}'s from.
 * @param framePriority
 */
protected AbstractFramedChannel(final StreamConnection connectedStreamChannel, Pool<ByteBuffer> bufferPool, FramePriority<C, R, S> framePriority, final Pooled<ByteBuffer> readData) {
    this.framePriority = framePriority;
    if (readData != null) {
        if(readData.getResource().hasRemaining()) {
            this.readData = new ReferenceCountedPooled<>(readData, 1);
        } else {
            readData.free();
        }
    }
    if(bufferPool == null) {
        throw UndertowMessages.MESSAGES.argumentCannotBeNull("bufferPool");
    }
    if(connectedStreamChannel == null) {
        throw UndertowMessages.MESSAGES.argumentCannotBeNull("connectedStreamChannel");
    }
    IdleTimeoutConduit idle = createIdleTimeoutChannel(connectedStreamChannel);
    connectedStreamChannel.getSourceChannel().setConduit(idle);
    connectedStreamChannel.getSinkChannel().setConduit(idle);
    this.idleTimeoutConduit = idle;
    this.channel = connectedStreamChannel;
    this.bufferPool = bufferPool;

    closeSetter = new ChannelListener.SimpleSetter<>();
    receiveSetter = new ChannelListener.SimpleSetter<>();
    channel.getSourceChannel().getReadSetter().set(null);
    channel.getSourceChannel().suspendReads();

    channel.getSourceChannel().getReadSetter().set(new FrameReadListener());
    connectedStreamChannel.getSinkChannel().getWriteSetter().set(new FrameWriteListener());
    FrameCloseListener closeListener = new FrameCloseListener();
    connectedStreamChannel.getSinkChannel().getCloseSetter().set(closeListener);
    connectedStreamChannel.getSourceChannel().getCloseSetter().set(closeListener);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:43,代码来源:AbstractFramedChannel.java


示例17: beginParse

import org.xnio.Pool; //导入依赖的package包/类
public static ParseState beginParse(final Pool<ByteBuffer> bufferPool, final PartHandler handler, final byte[] boundary, final String requestCharset) {

        // We prepend CR/LF to the boundary to chop trailing CR/LF from
        // body-data tokens.
        byte[] boundaryToken = new byte[boundary.length + BOUNDARY_PREFIX.length];
        System.arraycopy(BOUNDARY_PREFIX, 0, boundaryToken, 0, BOUNDARY_PREFIX.length);
        System.arraycopy(boundary, 0, boundaryToken, BOUNDARY_PREFIX.length, boundary.length);
        return new ParseState(bufferPool, handler, requestCharset, boundaryToken);
    }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:MultipartParser.java


示例18: ChunkedStreamSourceConduit

import org.xnio.Pool; //导入依赖的package包/类
public ChunkedStreamSourceConduit(final StreamSourceConduit next, final PushBackStreamSourceConduit channel, final Pool<ByteBuffer> pool, final ConduitListener<? super ChunkedStreamSourceConduit> finishListener, Attachable attachable) {
    this(next, new BufferWrapper() {
        @Override
        public Pooled<ByteBuffer> allocate() {
            return pool.allocate();
        }

        @Override
        public void pushBack(Pooled<ByteBuffer> pooled) {
            channel.pushBack(pooled);
        }
    }, finishListener, attachable, null);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:ChunkedStreamSourceConduit.java


示例19: UpgradeServletInputStream

import org.xnio.Pool; //导入依赖的package包/类
public UpgradeServletInputStream(final StreamSourceChannel channel, final Pool<ByteBuffer> bufferPool, Executor ioExecutor) {
    this.channel = channel;
    this.bufferPool = bufferPool;
    this.ioExecutor = ioExecutor;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:UpgradeServletInputStream.java


示例20: MockServerConnection

import org.xnio.Pool; //导入依赖的package包/类
private MockServerConnection(Pool<ByteBuffer> bufferPool) {
    this.bufferPool = bufferPool;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:ServletInitialHandler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Method类代码示例发布时间:2022-05-22
下一篇:
Java CompressedThrottledReader类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap