public final ResourceAddress resolve(String newPath) { if ( newPath == null ) { throw new NullPointerException(newPath); } URI addressURI = getResource(); return resolve(addressURI.getPath(), newPath); }
protected void resolve(String oldPath, String newPath, ResourceOptions newOptions) { ResourceAddress transport = getOption(TRANSPORT); if (transport != null) { newOptions.setOption(TRANSPORT, transport.resolve(oldPath, newPath)); } ResourceAddress alternate = getOption(ALTERNATE); if (alternate != null) { newOptions.setOption(ALTERNATE, alternate.resolve(oldPath, newPath)); } }
private ResourceAddress createWsrCreateAddress(ResourceAddress address) { ResourceAddress wsrTransportAddress = address.getTransport(); URI wsrTransportBindURI = wsrTransportAddress.getResource(); return wsrTransportAddress.resolve(createResolvePath(wsrTransportBindURI, CREATE_SUFFIX)); }
protected final ResourceAddress resolve(String oldPath, String newPath) { URI addressURI = getResource(); String externalURI = getExternalURI(); boolean newPathDiffersFromOld = !oldPath.equals(newPath); if ( !newPathDiffersFromOld ) { return this; } boolean shouldResolveNewPath = oldPath.equals(addressURI.getPath()); if (!shouldResolveNewPath) { return this; } URI newResourceURI = addressURI.resolve(newPath); String newExternalURI = URIUtils.resolve(externalURI, newPath); ResourceOptions newOptions = FACTORY.newResourceOptions(this); resolve(oldPath, newPath, newOptions); String externalUriToString = newExternalURI; String newResourceUriToString = URIUtils.uriToString(newResourceURI); return factory.newResourceAddress0(externalUriToString, newResourceUriToString, newOptions); }
options.setOption(TRANSPORT, session.getLocalAddress().resolve(resource.getPath())); options.setOption(NEXT_PROTOCOL, nextProtocol);
private ResourceAddress createReadAddress(URI readUri, HttpSession transport, WsebSession wsebSession) { ResourceAddress httpxeAddress = REMOTE_ADDRESS.get(transport); ResourceAddress readAddress = httpxeAddress.resolve(readUri.getPath()); String readSessionIdentity = format("%s#%sd", getTransportMetadata().getName(), wsebSession.getId()); IdentityResolver resolver = new FixedIdentityResolver(readSessionIdentity); ResourceOptions options = ResourceOptions.FACTORY.newResourceOptions(readAddress); options.setOption(ResourceAddress.IDENTITY_RESOLVER, resolver); return resourceAddressFactory.newResourceAddress(URIUtils.uriToString(readAddress.getResource()), options); }
private ResourceAddress createWriteAddress(URI writeUri, HttpSession transport, WsebSession wsebSession) { ResourceAddress httpxeAddress = REMOTE_ADDRESS.get(transport); ResourceAddress writeAddress = httpxeAddress.resolve(writeUri.getPath()); String writeSessionIdentity = format("%s#%su", getTransportMetadata().getName(), wsebSession.getId()); IdentityResolver resolver = new FixedIdentityResolver(writeSessionIdentity); ResourceOptions options = ResourceOptions.FACTORY.newResourceOptions(writeAddress); options.setOption(ResourceAddress.IDENTITY_RESOLVER, resolver); return resourceAddressFactory.newResourceAddress(URIUtils.uriToString(writeAddress.getResource()), options); }
options.setOption(TRANSPORT, session.getLocalAddress().resolve(resource.getPath())); options.setOption(NEXT_PROTOCOL, nextProtocol);
@Override protected <T extends ConnectFuture> ConnectFuture connectInternal( ResourceAddress connectAddress, IoHandler handler, final IoSessionInitializer<T> initializer) { final DefaultConnectFuture bridgeConnectFuture = new DefaultConnectFuture(); // propagate connection failure, if necessary IoFutureListener<ConnectFuture> parentConnectListener = new IoFutureListener<ConnectFuture>() { @Override public void operationComplete(ConnectFuture future) { // fail bridge connect future if parent connect fails if (!future.isConnected()) { bridgeConnectFuture.setException(future.getException()); } } }; IoSessionInitializer<ConnectFuture> parentInitializer = createParentInitializer( connectAddress, handler, initializer, bridgeConnectFuture); URI connectURI = connectAddress.getResource(); ResourceAddress createAddress = connectAddress.resolve(connectURI.getPath()+CREATE_SUFFIX); final ResourceAddress transportAddress = createAddress.getTransport(); BridgeConnector connector = bridgeServiceFactory.newBridgeConnector(transportAddress); connector.connect(transportAddress, selectConnectHandler(transportAddress), parentInitializer) .addListener(parentConnectListener); return bridgeConnectFuture; }
private ResourceAddress createApiHttpxeAddress(ResourceAddress httpxeTransport) { String path = URIUtils.getPath(appendURI(ensureTrailingSlash(httpxeTransport.getExternalURI()), HttpProtocolCompatibilityFilter.API_PATH)); httpxeTransport = httpxeTransport.resolve(path); String httpxeLocation = modifyURIPath(httpxeTransport.getExternalURI(), path); ResourceOptions httpxeOptions = ResourceOptions.FACTORY.newResourceOptions(httpxeTransport); httpxeOptions.setOption(NEXT_PROTOCOL, null); // terminal endpoint, so next protocol null return resourceAddressFactory.newResourceAddress(httpxeLocation, httpxeOptions); }
ResourceAddress localDownstream = httpBaseAddress.resolve(createResolvePath(httpBaseAddress.getResource(), downstreamSuffix + sessionIdSuffix)); logger.trace("Binding "+localDownstream.getTransport()+" to downstreamHandler"); httpBaseAddress = httpAddressNoSecurity(httpAddress, httpxeBaseAddress, upstreamResolver); ResourceAddress localUpstream = httpBaseAddress.resolve(createResolvePath(httpBaseAddress.getResource(), upstreamSuffix + sessionIdSuffix)); logger.trace("Binding "+localUpstream.getTransport()+" to upstreamHandler");
pathAndQuery += "?" + URIUtils.getQuery(uri); ResourceAddress createAddress = httpxeAddress.resolve(pathAndQuery); BridgeConnector connector = bridgeServiceFactory.newBridgeConnector(createAddress);
ResourceAddress newHttpBindAddress = httpBindAddress.resolve(format("%s;s/%s", httpBindAddress.getResource().getPath(), sessionId)); ResourceOptions sseRemoteOptions = ResourceOptions.FACTORY.newResourceOptions(); sseRemoteOptions.setOption(TRANSPORT, newHttpBindAddress);