/** * Creates a new JavaContextComponents using play.api.Configuration.reference and play.api.Environment.simple as defaults * @return the newly created JavaContextComponents */ public static JavaContextComponents contextComponents() { return JavaHelpers$.MODULE$.createContextComponents(); }
public static byte[] contentAsBytes(Result result, long timeout) { return JavaResultExtractor.getBody(result, timeout); }
/** * @deprecated use {@link Result#cookies()} instead. */ @Deprecated public static Cookies cookies(Result result) { return play.core.j.JavaResultExtractor.getCookies(result); }
@SuppressWarnings(value = "unchecked") private static Result invokeHandler(play.api.Application app, play.api.mvc.Handler handler, Request requestBuilder, long timeout) { if (handler instanceof play.api.mvc.Action) { play.api.mvc.Action action = (play.api.mvc.Action) handler; return wrapScalaResult(action.apply(requestBuilder.asScala()), timeout); } else if (handler instanceof JavaHandler) { final play.api.inject.Injector injector = app.injector(); final JavaHandlerComponents handlerComponents = injector.instanceOf(JavaHandlerComponents.class); return invokeHandler( app, ((JavaHandler) handler).withComponents(handlerComponents), requestBuilder, timeout ); } else { throw new RuntimeException("This is not a JavaAction and can't be invoked this way."); } }
/** * @deprecated use {@link Result#headers()} instead. */ @Deprecated public static Map<String, String> headers(Result result) { return JavaResultExtractor.getHeaders(result); }
/** * An ExecutionContext that executes work on the given ExecutionContext. The * current thread's context ClassLoader and Http.Context are captured when * this method is called and preserved for all executed tasks. * * @param delegate the delegate execution context. * @return the execution context wrapped in an {@link play.libs.concurrent.HttpExecutionContext}. */ public static ExecutionContextExecutor fromThread(ExecutionContext delegate) { return HttpExecutionContext.fromThread(delegate); }
/** * @deprecated use {@link Result#flash()} instead. */ @Deprecated public static Flash flash(Result result) { return JavaResultExtractor.getFlash(result); }
/** * @deprecated use {@link Result#session()} instead. */ @Deprecated public static Session session(Result result) { return JavaResultExtractor.getSession(result); }
/** * @return a Scala HttpRequestHandler */ default play.api.http.HttpRequestHandler asScala() { return new JavaHttpRequestHandlerAdapter(this); } }
play.GlobalSettings global) { play.api.GlobalSettings scalaGlobal = (global != null) ? new play.core.j.JavaGlobalSettingsAdapter(global) : null;
/** * Create a new promise throwing an exception. * @param throwable Value to throw */ public static <A> Promise<A> throwing(Throwable throwable) { return FPromiseHelper.throwing(throwable); }
/** * Creates a new promise that will handle thrown exceptions by assigning to the value of another promise. * * @param function The function to handle the exception, and which returns another promise * @param ec The ExecutionContext to execute the function in * @return A promise that will delegate to another promise on failure */ public Promise<A> recoverWith(final Function<Throwable, Promise<A>> function, ExecutionContext ec) { return FPromiseHelper.recoverWith(this, function, ec); }
/** * Creates a new promise by applying the {@code onSuccess} function to a successful result, * or the {@code onFailure} function to a failed result. * * @param onSuccess The function to map a successful result from {@code A} to {@code B} * @param onFailure The function to map the {@code Throwable} when failed * @param ec The ExecutionContext to execute functions in * @return A new promise mapped by either the {@code onSuccess} or {@code onFailure} functions */ public <B> Promise<B> transform(final Function<? super A, B> onSuccess, final Function<Throwable, Throwable> onFailure, ExecutionContext ec) { return FPromiseHelper.transform(this, onSuccess, onFailure, ec); }
/** * Creates a new promise which holds the result of this promise if it was completed successfully, * otherwise the result of the {@code fallback} promise if it completed successfully. * If both promises failed, the resulting promise holds the throwable of this promise. * * @param fallback The promise to fallback to if this promise has failed * @return A promise that will delegate to another promise on failure */ public Promise<A> fallbackTo(final Promise<A> fallback) { return FPromiseHelper.fallbackTo(this, fallback); }
/** * Creates a new JavaContextComponents using play.api.Configuration.reference and play.api.Environment.simple as defaults * @return the newly created JavaContextComponents */ public static JavaContextComponents contextComponents() { return JavaHelpers$.MODULE$.createContextComponents(); }
@SuppressWarnings(value = "unchecked") private static Result invokeHandler(play.api.Application app, play.api.mvc.Handler handler, Request requestBuilder, long timeout) { if (handler instanceof play.api.mvc.Action) { play.api.mvc.Action action = (play.api.mvc.Action) handler; return wrapScalaResult(action.apply(requestBuilder.asScala()), timeout); } else if (handler instanceof JavaHandler) { final play.api.inject.Injector injector = app.injector(); final JavaHandlerComponents handlerComponents = injector.instanceOf(JavaHandlerComponents.class); return invokeHandler( app, ((JavaHandler) handler).withComponents(handlerComponents), requestBuilder, timeout ); } else { throw new RuntimeException("This is not a JavaAction and can't be invoked this way."); } }
/** * @deprecated use {@link Result#header(String)} instead. */ @Deprecated public static String header(String header, Result result) { return JavaResultExtractor.getHeaders(result).get(header); }
/** * @deprecated use {@link Result#cookie(String)} instead. */ @Deprecated public static Cookie cookie(String name, Result result) { return JavaResultExtractor.getCookies(result).get(name); }
@SuppressWarnings(value = "unchecked") private static Result invokeHandler(play.api.mvc.Handler handler, Request requestBuilder, long timeout) { if (handler instanceof play.api.mvc.Action) { play.api.mvc.Action action = (play.api.mvc.Action) handler; return wrapScalaResult(action.apply(requestBuilder._underlyingRequest()), timeout); } else if (handler instanceof JavaHandler) { return invokeHandler( ((JavaHandler) handler).withComponents(Play.application().injector().instanceOf(JavaHandlerComponents.class)), requestBuilder, timeout ); } else { throw new RuntimeException("This is not a JavaAction and can't be invoked this way."); } }
/** * Extracts all Headers of this Result value. */ default Map<String, String> headers() { return JavaResultExtractor.getHeaders(this); }