@Override public void bind(ResourceAddress address, IoHandler handler, BridgeSessionInitializer<?> initializer) { if (acceptor != null) { try { acceptor.bind(address, handler, initializer); } catch (RuntimeException re) { // Catch this RuntimeException and add a bit more information // to its message (cf KG-1462) throw new RuntimeException(String.format("Error binding to %s: %s", address.getResource(), re.getMessage()), re); } } }
private void bindCookiesHandler(ResourceAddress address) { final ResourceAddress cookiesAddress = createCookiesAddress(address); BridgeAcceptor cookiesAcceptor = bridgeServiceFactory.newBridgeAcceptor(cookiesAddress); cookiesAcceptor.bind(cookiesAddress, cookiesHandler, null); }
private void bindApiPath(ResourceAddress address) { ResourceAddress apiAddress = createApiAddress(address); bridgeServiceFactory.newBridgeAcceptor(apiAddress).bind(apiAddress, WsAcceptor.API_PATH_HANDLER, null); }
private void bindInternal(final ResourceAddress address, final IoHandler handler, final Transport transport, final IoSessionInitializer<ConnectFuture> sessionInitializer, final BridgeSessionInitializer<ConnectFuture> bridgeSessionInitializer) { BridgeAcceptor acceptor = transport.getAcceptor(address); try { acceptor.bind(address, handler, new BridgeSessionInitializer<ConnectFuture>() { @Override public BridgeSessionInitializer<ConnectFuture> getParentInitializer(Protocol protocol) { return (bridgeSessionInitializer != null) ? bridgeSessionInitializer.getParentInitializer(protocol) : null; } @Override public void initializeSession(IoSession session, ConnectFuture future) { sessionInitializer.initializeSession(session, future); if (bridgeSessionInitializer != null) { bridgeSessionInitializer.initializeSession(session, future); } } }); } catch (RuntimeException re) { // Catch this RuntimeException and add a bit more information // to its message (cf KG-1462) throw new RuntimeException(String.format("Error binding to %s: %s", address.getResource(), re.getMessage()), re); } }
private void bindApiPath(ResourceAddress address) { ResourceAddress apiHttpAddress = createApiHttpAddress(address.getTransport()); bridgeServiceFactory.newBridgeAcceptor(apiHttpAddress).bind(apiHttpAddress, WsAcceptor.API_PATH_HANDLER, null); ResourceAddress apiHttpxeAddress = address.getTransport().getOption(ALTERNATE); if (apiHttpxeAddress != null) { apiHttpxeAddress = createApiHttpxeAddress(apiHttpxeAddress); bridgeServiceFactory.newBridgeAcceptor(apiHttpxeAddress).bind(apiHttpxeAddress, WsAcceptor.API_PATH_HANDLER, null); } }
@Override public void bind(ResourceAddress address, IoHandler handler, BridgeSessionInitializer<? extends IoFuture> initializer) { // bind only address with matching scheme URI location = address.getResource(); String schemeName = location.getScheme(); if (!canBind(schemeName)) { throw new IllegalArgumentException(format("Unexpected scheme \"%s\" for URI: %s", schemeName, location)); } // note: ignore BIND_ALTERNATE (used by delegate acceptors) do { BridgeAcceptor bridgeAcceptor = selectWsAcceptor(address); if ( bridgeAcceptor != null ) { bridgeAcceptor.bind(address, handler, initializer); } else { if (logger.isDebugEnabled()) { String format = "No bridge acceptor found for address '%s'. Is the %s transport enabled?"; logger.warn(format(format, address.getExternalURI(), URIUtils.getScheme(address.getExternalURI()))); } } address = address.getOption(ALTERNATE); } while (address != null); }
@Override protected <T extends IoFuture> void bindInternal(final ResourceAddress address, IoHandler handler, final BridgeSessionInitializer<T> initializer) { if (logger.isTraceEnabled()) { logger.trace(format("binding: '%s' %s", address.getExternalURI(), address.getOption(NEXT_PROTOCOL))); } // // Bind the transport of the address. // final ResourceAddress transportAddress = address.getTransport(); final URI transportURI = transportAddress.getResource(); final Protocol transportProtocol = bridgeServiceFactory.getTransportFactory().getProtocol(transportURI.getScheme()); final BridgeSessionInitializer<T> sessionInitializer = (initializer != null) ? initializer.getParentInitializer(transportProtocol) : null; BridgeAcceptor acceptor = bridgeServiceFactory.newBridgeAcceptor(transportAddress); acceptor.bind(transportAddress, bridgeHandler, sessionInitializer); }
if (transport != null) { BridgeAcceptor acceptor = bridgeServiceFactory.newBridgeAcceptor(transport); acceptor.bind(transport, handler, initializer);
private <T extends IoFuture> void bindCreateAddress(final ResourceAddress address, BridgeSessionInitializer<T> initializer) { // bind the create URL accessed using HTTP transport ResourceAddress wsrCreateAddress = createWsrCreateAddress(address); BridgeAcceptor createAcceptor = bridgeServiceFactory.newBridgeAcceptor(wsrCreateAddress); final BridgeSessionInitializer<T> theCreateInitializer = (initializer != null) ? initializer.getParentInitializer(HttpProtocol.HTTP) : null; BridgeSessionInitializer<T> wrapperInitializer = new BridgeSessionInitializerAdapter<T>() { @Override public void initializeSession(IoSession session, T future) { if ( theCreateInitializer != null ) { theCreateInitializer.initializeSession(session, future); } // Store the next over-the-top of-websocket protocols the server supports for this address on session. SUPPORTED_PROTOCOLS.set(session, address.getOption(WsResourceAddress.SUPPORTED_PROTOCOLS)); } }; createAcceptor.bind(wsrCreateAddress, selectCreateHandler(wsrCreateAddress), wrapperInitializer); }
@Override protected <T extends IoFuture> void bindInternal(final ResourceAddress address, IoHandler handler, final BridgeSessionInitializer<T> initializer) { final ResourceAddress transportAddress = address.getTransport(); if (transportAddress != null) { try { URI transportURI = transportAddress.getResource(); Protocol transportProtocol = bridgeServiceFactory.getTransportFactory().getProtocol(transportURI.getScheme()); final BridgeSessionInitializer<T> httpInitializer = (initializer != null) ? initializer.getParentInitializer(transportProtocol) : null; BridgeSessionInitializer<T> wrapper = new BridgeSessionInitializerAdapter<T>() { @Override public void initializeSession(IoSession session, T future) { session.setAttribute(NEXT_PROTOCOL_RESOURCE_ADDRESS, address); if ( httpInitializer != null ) { httpInitializer.initializeSession(session, future); } } }; BridgeAcceptor transportAcceptor = bridgeServiceFactory.newBridgeAcceptor(transportAddress); final IoHandler transportHandler = selectTransportHandler(transportAddress); transportAcceptor.bind(transportAddress, transportHandler, wrapper); } catch (NioBindException e) { throw new RuntimeException("Unable to bind address " + address + ": " + e.getMessage(), e); } } }
transportAcceptor.bind(transportAddress, createHandler, wrapperHttpInitializer);
bridgeAcceptor.bind(transportAddress, tcpBridgeHandler, null); } else {
private <T extends IoFuture> void bindRtmpAddress(ResourceAddress address, IoHandler handler, BridgeSessionInitializer<T> initializer) { // TODO: avoid the global bind for all RTMP streams // instead, dynamically bind RTMP streams, like WSE upstream & downstream // note: may require an RTMP transport ResourceAddress wsrRtmpAddress = createWsrRtmpAddress(address); // add bind mapping for the wsr rtmp address addWsrRtmpBinding(wsrRtmpAddress, handler, initializer); // bind the wsr rtmp address transport BridgeAcceptor acceptor = bridgeServiceFactory.newBridgeAcceptor(wsrRtmpAddress.getTransport()); BridgeSessionInitializer<T> theInitializer = (initializer != null) ? initializer.getParentInitializer(HttpProtocol.HTTP) : null; acceptor.bind(wsrRtmpAddress.getTransport(), ioBridgeHandler, theInitializer); }
acceptor.bind(transportAddress, bridgeHandler, wrapperInitializer);
ResourceAddress transport = address.getTransport(); IoHandler transportHandler = selectHandler(address); acceptor.bind(transport, transportHandler, wrapperInitializer); } catch (NioBindException e) { throw new RuntimeException("Unable to bind address " + address.getTransport() + ": " + e.getMessage(), e);
httpAcceptor.bind(newHttpBindAddress, reconnectHandler, null);