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


Java StreamConnection类代码示例

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


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

示例1: connect

import org.xnio.StreamConnection; //导入依赖的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: HttpClientConnection

import org.xnio.StreamConnection; //导入依赖的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

示例3: handleConnected

import org.xnio.StreamConnection; //导入依赖的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

示例4: AbstractServerConnection

import org.xnio.StreamConnection; //导入依赖的package包/类
public AbstractServerConnection(StreamConnection channel, final Pool<ByteBuffer> bufferPool, final HttpHandler rootHandler, final OptionMap undertowOptions, final int bufferSize) {
    this.channel = channel;
    this.bufferPool = bufferPool;
    this.rootHandler = rootHandler;
    this.undertowOptions = undertowOptions;
    this.bufferSize = bufferSize;
    closeSetter = new CloseSetter();
    if (channel != null) {
        this.originalSinkConduit = channel.getSinkChannel().getConduit();
        this.originalSourceConduit = channel.getSourceChannel().getConduit();
        channel.setCloseListener(closeSetter);
    } else {
        this.originalSinkConduit = null;
        this.originalSourceConduit = null;
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:AbstractServerConnection.java

示例5: handleEvent

import org.xnio.StreamConnection; //导入依赖的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

示例6: HttpServerConnection

import org.xnio.StreamConnection; //导入依赖的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: sendBadRequestAndClose

import org.xnio.StreamConnection; //导入依赖的package包/类
private void sendBadRequestAndClose(final StreamConnection connection, final Exception exception) {
    UndertowLogger.REQUEST_IO_LOGGER.failedToParseRequest(exception);
    connection.getSourceChannel().suspendReads();
    new StringWriteChannelListener(BAD_REQUEST) {
        @Override
        protected void writeDone(final StreamSinkChannel c) {
            super.writeDone(c);
            c.suspendWrites();
            IoUtils.safeClose(connection);
        }

        @Override
        protected void handleError(StreamSinkChannel channel, IOException e) {
            IoUtils.safeClose(connection);
        }
    }.setup(connection.getSinkChannel());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:HttpReadListener.java

示例8: removeProtocol

import org.xnio.StreamConnection; //导入依赖的package包/类
/**
 * Remove a protocol from this handler.
 *
 * @param productString the product string to match
 * @param openListener  The open listener
 */
public synchronized void removeProtocol(String productString, ChannelListener<? super StreamConnection> openListener) {
    List<Holder> holders = handlers.get(productString);
    if (holders == null) {
        return;
    }
    Iterator<Holder> it = holders.iterator();
    while (it.hasNext()) {
        Holder holder = it.next();
        if (holder.listener == openListener) {
            it.remove();
            break;
        }
    }
    if (holders.isEmpty()) {
        handlers.remove(productString);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:ChannelUpgradeHandler.java

示例9: ReadTimeoutStreamSourceConduit

import org.xnio.StreamConnection; //导入依赖的package包/类
public ReadTimeoutStreamSourceConduit(final StreamSourceConduit delegate, StreamConnection connection, OpenListener openListener) {
    super(delegate);
    this.connection = connection;
    this.openListener = openListener;
    final ReadReadyHandler handler = new ReadReadyHandler.ChannelListenerHandler<>(connection.getSourceChannel());
    delegate.setReadReadyHandler(new ReadReadyHandler() {
        @Override
        public void readReady() {
            handler.readReady();
        }

        @Override
        public void forceTermination() {
            cleanup();
            handler.forceTermination();
        }

        @Override
        public void terminated() {
            cleanup();
            handler.terminated();
        }
    });
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:ReadTimeoutStreamSourceConduit.java

示例10: WebSocketChannel

import org.xnio.StreamConnection; //导入依赖的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

示例11: installConnectorServicesForNetworkInterfaceBinding

import org.xnio.StreamConnection; //导入依赖的package包/类
@Deprecated
public static void installConnectorServicesForNetworkInterfaceBinding(ServiceTarget serviceTarget,
                                                                      final ServiceName endpointName,
                                                                      final String connectorName,
                                                                      final ServiceName networkInterfaceBindingName,
                                                                      final int port,
                                                                      final OptionMap connectorPropertiesOptionMap,
                                                                      final ServiceName securityRealm,
                                                                      final ServiceName saslAuthenticationFactory,
                                                                      final ServiceName sslContext,
                                                                      final ServiceName socketBindingManager) {
    final InjectedNetworkBindingStreamServerService streamServerService = new InjectedNetworkBindingStreamServerService(connectorPropertiesOptionMap, port);

    final ServiceBuilder<AcceptingChannel<StreamConnection>> serviceBuilder = serviceTarget.addService(serverServiceName(connectorName), streamServerService)
                .addDependency(networkInterfaceBindingName, NetworkInterfaceBinding.class, streamServerService.getInterfaceBindingInjector());
    if (socketBindingManager != null) {
        serviceBuilder.addDependency(socketBindingManager, SocketBindingManager.class, streamServerService.getSocketBindingManagerInjector());
    }
    installConnectorServices(serviceBuilder, streamServerService, endpointName, securityRealm, saslAuthenticationFactory, sslContext);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:21,代码来源:RemotingServices.java

示例12: installConnectorServicesForSocketBinding

import org.xnio.StreamConnection; //导入依赖的package包/类
public static void installConnectorServicesForSocketBinding(ServiceTarget serviceTarget,
                                                            final ServiceName endpointName,
                                                            final String connectorName,
                                                            final ServiceName socketBindingName,
                                                            final OptionMap connectorPropertiesOptionMap,
                                                            final ServiceName securityRealm,
                                                            final ServiceName saslAuthenticationFactory,
                                                            final ServiceName sslContext,
                                                            final ServiceName socketBindingManager) {
    final InjectedSocketBindingStreamServerService streamServerService = new InjectedSocketBindingStreamServerService(connectorPropertiesOptionMap);
    final ServiceBuilder<AcceptingChannel<StreamConnection>> serviceBuilder = serviceTarget.addService(serverServiceName(connectorName), streamServerService)
            .addDependency(socketBindingName, SocketBinding.class, streamServerService.getSocketBindingInjector())
            .addDependency(socketBindingManager, SocketBindingManager.class, streamServerService.getSocketBindingManagerInjector());

    installConnectorServices(serviceBuilder, streamServerService, endpointName, securityRealm, saslAuthenticationFactory, sslContext);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:17,代码来源:RemotingServices.java

示例13: installConnectorServices

import org.xnio.StreamConnection; //导入依赖的package包/类
private static void installConnectorServices(final ServiceBuilder<AcceptingChannel<StreamConnection>> serviceBuilder,
                                             final AbstractStreamServerService service,
                                             final ServiceName endpointName,
                                             final ServiceName securityRealm,
                                             final ServiceName saslAuthenticationFactory,
                                             final ServiceName sslContext) {

    serviceBuilder.addDependency(endpointName, Endpoint.class, service.getEndpointInjector());
    if (securityRealm != null) {
        serviceBuilder.addDependency(securityRealm, SecurityRealm.class, service.getSecurityRealmInjector());
    }
    if (saslAuthenticationFactory != null) {
        serviceBuilder.addDependency(saslAuthenticationFactory, SaslAuthenticationFactory.class, service.getSaslAuthenticationFactoryInjector());
    }
    if (sslContext != null) {
        serviceBuilder.addDependency(sslContext, SSLContext.class, service.getSSLContextInjector());
    }
    serviceBuilder.install();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:20,代码来源:RemotingServices.java

示例14: createServer

import org.xnio.StreamConnection; //导入依赖的package包/类
private AcceptingChannel<? extends StreamConnection> createServer(int sourcePort, int targetPort)
    throws IllegalArgumentException, IOException {
    OptionMap socketOptions = OptionMap.builder()
        .set(Options.WORKER_IO_THREADS, 16)
        .set(Options.TCP_NODELAY, true)
        .set(Options.REUSE_ADDRESSES, true)
        .getMap();

    ChannelListener<AcceptingChannel<StreamConnection>> acceptListener = ChannelListeners.openListenerAdapter(
        new PortForwardOpenListener(connection, portForwardURI.getPath(), targetPort, requestId, bufferPoolSlice,
            OptionMap.EMPTY));
    AcceptingChannel<? extends StreamConnection> server =
        xnioWorker.createStreamConnectionServer(new InetSocketAddress(portForwardBindAddress, sourcePort),
            acceptListener, socketOptions);
    server.resumeAccepts();
    return server;
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:18,代码来源:PortForwarder.java

示例15: doGet

import org.xnio.StreamConnection; //导入依赖的package包/类
@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {

    final ServletWebSocketHttpExchange facade = new ServletWebSocketHttpExchange(req, resp, peerConnections);
    Handshake handshaker = null;
    for (Handshake method : handshakes) {
        if (method.matches(facade)) {
            handshaker = method;
            break;
        }
    }

    if (handshaker == null) {
        UndertowLogger.REQUEST_LOGGER.debug("Could not find hand shaker for web socket request");
        resp.sendError(StatusCodes.BAD_REQUEST);
        return;
    }
    final Handshake selected = handshaker;
    facade.upgradeChannel(new HttpUpgradeListener() {
        @Override
        public void handleUpgrade(StreamConnection streamConnection, HttpServerExchange exchange) {
            WebSocketChannel channel = selected.createChannel(facade, streamConnection, facade.getBufferPool());
            peerConnections.add(channel);
            callback.onConnect(facade, channel);
        }
    });
    handshaker.handshake(facade);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:WebSocketServlet.java


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