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


Java Pool类代码示例

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


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


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