public ResourceAddress newResourceAddress(String location, String nextProtocol) { if (nextProtocol != null) { ResourceOptions options = ResourceOptions.FACTORY.newResourceOptions(); options.setOption(NEXT_PROTOCOL, nextProtocol); return newResourceAddress(location, options); } else { return newResourceAddress(location); } }
private ResourceAddress createApiHttpAddress(ResourceAddress httpTransport) { String path = URIUtils.getPath(appendURI(ensureTrailingSlash(httpTransport.getExternalURI()), HttpProtocolCompatibilityFilter.API_PATH)); String httpLocation = modifyURIPath(httpTransport.getExternalURI(), path); ResourceOptions httpOptions = ResourceOptions.FACTORY.newResourceOptions(httpTransport); httpOptions.setOption(NEXT_PROTOCOL, null); // terminal endpoint, so next protocol null httpOptions.setOption(ALTERNATE, null); return resourceAddressFactory.newResourceAddress(httpLocation, httpOptions); }
private ResourceAddress createCookiesAddress(ResourceAddress httpAddress) { // /;e/cookies is a terminal endpoint so next protocol should == null ResourceOptions cookieOptions = ResourceOptions.FACTORY.newResourceOptions(httpAddress); cookieOptions.setOption(NEXT_PROTOCOL, null); cookieOptions.setOption(TRANSPORT, httpAddress.getTransport()); cookieOptions.setOption(BIND_ALTERNATE, Boolean.FALSE); URI cookiesLocation = appendURI(httpAddress.getResource(), COOKIES_SUFFIX); return resourceAddressFactory.newResourceAddress(URIUtils.uriToString(cookiesLocation), cookieOptions); }
private ResourceAddress createApiAddress(ResourceAddress address) { ResourceAddress transport = address.getTransport(); ResourceOptions apiAddressOptions = ResourceOptions.FACTORY.newResourceOptions(transport); // /;api/operation is a terminal endpoint so next protocol should be null apiAddressOptions.setOption(NEXT_PROTOCOL, null); // even if the address has an alternate, do not bind the alternate apiAddressOptions.setOption(BIND_ALTERNATE, Boolean.FALSE); String path = URIUtils.getPath(appendURI(ensureTrailingSlash(address.getExternalURI()), HttpProtocolCompatibilityFilter.API_PATH)); String apiLocation = URIUtils.modifyURIPath(URIUtils.uriToString(transport.getResource()), path); return resourceAddressFactory.newResourceAddress(apiLocation, apiAddressOptions); }
public ResourceAddress newResourceAddress(ResourceAddress uriAddress, ResourceAddress transportAddress) { ResourceOptions options = ResourceOptions.FACTORY.newResourceOptions(); options.setOption(TRANSPORT, transportAddress); options.setOption(NEXT_PROTOCOL, uriAddress.getOption(NEXT_PROTOCOL)); return newResourceAddress(uriToString(uriAddress.getResource()), options); }
private ResourceAddress createWsrRtmpAddress(ResourceAddress address) { // wsr[wsr/1.0] | tcp or wsr[wsr/1.0] | ssl // so find http[http/1.1] layer's transport either way and you'll get ssl or tcp. ResourceAddress wsrRtmpTransportAddress; wsrRtmpTransportAddress = address.findTransport("http[http/1.1]").getTransport(); ResourceOptions wsrRtmpTransportAddressOptions = ResourceOptions.FACTORY.newResourceOptions(wsrRtmpTransportAddress); wsrRtmpTransportAddressOptions.setOption(NEXT_PROTOCOL, "rtmp/1.0"); wsrRtmpTransportAddressOptions.setOption(ResourceAddress.ALTERNATE, null); wsrRtmpTransportAddress = resourceAddressFactory.newResourceAddress(wsrRtmpTransportAddress.getExternalURI(), wsrRtmpTransportAddressOptions); ResourceOptions wsrRtmpAddressOptions = ResourceOptions.FACTORY.newResourceOptions(address); wsrRtmpAddressOptions.setOption(TRANSPORT, wsrRtmpTransportAddress); return resourceAddressFactory.newResourceAddress(address.getExternalURI(), wsrRtmpAddressOptions); }
private ResourceAddress httpAddressNoSecurity(ResourceAddress httpAddress, ResourceAddress httpxeAddressNoSecurity, IdentityResolver resolver) { ResourceOptions noSecurityOptions = new NoSecurityResourceOptions(httpAddress); noSecurityOptions.setOption(ALTERNATE, httpxeAddressNoSecurity); noSecurityOptions.setOption(ResourceAddress.IDENTITY_RESOLVER, resolver); noSecurityOptions.setOption(HttpResourceAddress.REALMS, new HttpRealmInfo[0]); return resourceAddressFactory.newResourceAddress(httpAddress.getExternalURI(), noSecurityOptions, httpAddress.getOption(ResourceAddress.QUALIFIER)); }
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)); } }
@Override public ResourceOptions newResourceOptions(ResourceOptions defaults) { ResourceOptions newOptions = ResourceOptions.FACTORY.newResourceOptions(defaults); newOptions.setOption(NEXT_PROTOCOL, nextProtocol); return newOptions; }
@Override public <T> T setOption(ResourceOption<T> key, T value) { if (key == HttpResourceAddress.REALMS) return null; return options.setOption(key,value); }
@SuppressWarnings("unchecked") protected T newResourceAddressWithAlternate(String location, Map<String, Object> optionsByName, ResourceAddress alternateAddress) { optionsByName.put(ALTERNATE.name(), alternateAddress); return (T) getResourceAddressFactory().newResourceAddress(location, optionsByName); }
@Override public <T> T getOption(ResourceOption<T> key) { if (key == HttpResourceAddress.REALMS) return null; return options.getOption(key); }
@Override public final <V> V getOption(ResourceOption<V> option) { V value = getOption0(option); return (value != null) ? value : option.defaultValue(); }
/** * Default access method allowing to set an identity resolver (should allow usage from within the same package) * @param identityResolverOption * @param identityResolver */ void setIdentityResolver(DefaultResourceOption<IdentityResolver> identityResolverOption, IdentityResolver identityResolver) { super.setOption0(identityResolverOption, identityResolver); }
public static Comparator<ResourceAddress> compareAlternates(Comparator<ResourceAddress> comparator) { return compareNonNull(new AlternateResourceAddressComparator(comparator)); }
public static <T extends Comparable<T>> Comparator<T> compareComparable(Class<T> clazz) { return compareNonNull(new ComparableComparator<T>()); }
protected final boolean equals(Binding that) { return this == that || (this.bindAddress.equals(that.bindAddress) && this.handler == that.handler && this.initializer == that.initializer); } }
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); }
private ResourceAddress getCandidateResourceAddress(IoSessionEx session) { // Build candidate address from session final ResourceAddress candidateTransportAddress = REMOTE_ADDRESS.get(session); URI candidateURI = candidateTransportAddress.getOption(TRANSPORTED_URI); ResourceOptions candidateOptions = ResourceOptions.FACTORY.newResourceOptions(); candidateOptions.setOption(NEXT_PROTOCOL, NEXT_PROTOCOL_KEY.get(session)); candidateOptions.setOption(TRANSPORT, candidateTransportAddress); return resourceAddressFactory.newResourceAddress(URIUtils.uriToString(candidateURI), candidateOptions); }
@Override public ResourceOptions newResourceOptions() { ResourceOptions newOptions = ResourceOptions.FACTORY.newResourceOptions(); newOptions.setOption(NEXT_PROTOCOL, nextProtocol); return newOptions; } });