private DefaultExecution createExecution(Action<? super Execution> initialExecutionSegment, ExecutionRef parentRef) { try { return new DefaultExecution( DefaultExecController.this, parentRef, eventLoop, registry, initialExecutionSegment, onError, onStart, onComplete ); } catch (Throwable e) { throw new InternalRatpackError("could not start execution", e); } } };
protected RendererSupport() { TypeToken<T> typeToken = new TypeToken<T>(getClass()) { }; Type type = typeToken.getType(); if (type instanceof Class) { @SuppressWarnings("unchecked") Class<T> rawType = (Class<T>) typeToken.getRawType(); this.type = rawType; } else if (type instanceof ParameterizedType) { Iterable<Type> typeArgs = Arrays.asList(((ParameterizedType) type).getActualTypeArguments()); if (Iterables.any(typeArgs, Predicates.not((t) -> t.getTypeName().equals("?")))) { throw new IllegalArgumentException("Invalid renderable type " + type + ": due to type erasure, type parameter T of RendererSupport must be a Class or a parameterized type with '?' for all type variables (e.g. List<?>)"); } this.type = Types.cast(typeToken.getRawType()); } else { throw new InternalRatpackError("Unhandled type for renderer support: " + type.getClass()); } }
protected RenderableDecoratorSupport() { TypeToken<T> typeToken = new TypeToken<T>(getClass()) { }; Type type = typeToken.getType(); if (type instanceof Class) { this.type = Types.cast(typeToken.getRawType()); } else if (type instanceof ParameterizedType) { Iterable<Type> typeArgs = Arrays.asList(((ParameterizedType) type).getActualTypeArguments()); if (Iterables.any(typeArgs, Predicates.not((t) -> t.getTypeName().equals("?")))) { throw new IllegalArgumentException("Invalid renderable type " + type + ": due to type erasure, type parameter T of RenderableDecorator must be a Class or a parameterized type with '?' for all type variables (e.g. List<?>)"); } this.type = Types.cast(typeToken.getRawType()); } else { throw new InternalRatpackError("Unhandled type for RenderableDecorator: " + type.getClass()); } }
@Override public URI build() { String string = toString(); try { return new URI(string); } catch (URISyntaxException e) { throw new InternalRatpackError("HttpUriBuilder produced invalid URI: " + toString(), e); } }
public DefaultHttpUrlBuilder(URI uri) { this.protocol = uri.getScheme(); if (protocol == null) { protocol = "http"; } protocol = protocol.toLowerCase(); if (!protocol.equals("http") && !protocol.equals("https")) { throw new IllegalArgumentException("uri " + uri + " must be a http or https uri"); } host(uri.getHost()); port(uri.getPort()); String rawPath = uri.getRawPath(); if (rawPath != null && !rawPath.isEmpty() && !rawPath.equals("/")) { String[] parts = rawPath.substring(1).split("/"); for (String part : parts) { try { // have to encode + to stop URLDecoder from treating it as a space (it's only synonymous with %20 in query strings) String s = part.replaceAll("\\+", "%2B"); segment(URLDecoder.decode(s, "UTF8")); } catch (UnsupportedEncodingException e) { throw new InternalRatpackError("UTF8 is not available", e); } } hasTrailingSlash = rawPath.substring(rawPath.length() - 1, rawPath.length()).equals("/"); } if (uri.getRawQuery() != null) { new QueryStringDecoder(uri).parameters().forEach(params::putAll); } fragment = uri.getFragment(); }