/** * Create an application that wraps a Scala application. */ public DefaultApplication(play.api.Application application, Injector injector) { this(application, new Configuration(application.configuration()), injector); }
/** * Get the application classloader. * * @return the application classloader */ default ClassLoader classloader() { return asScala().classloader(); }
/** * Get the application path. * * @return the application path */ default File path() { return getWrappedApplication().path(); }
@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."); } }
/** * Check whether the application is in {@link Mode#TEST} mode. * * @return true if the application is in TEST mode */ default boolean isTest() { return asScala().isTest(); }
/** * Check whether the application is in {@link Mode#PROD} mode. * * @return true if the application is in PROD mode */ default boolean isProd() { return asScala().isProd(); }
/** * Check whether the application is in {@link Mode#DEV} mode. * * @return true if the application is in DEV mode */ default boolean isDev() { return asScala().isDev(); }
/** * Create an application that wraps a Scala application. * * @param application the application to wrap * @param config the new application's configuration * @param injector the new application's injector * * @deprecated Use {@link #DefaultApplication(play.api.Application, Config, Injector, Environment)} instead. */ @Deprecated public DefaultApplication(play.api.Application application, Config config, Injector injector) { this(application, config, injector, new Environment(application.environment())); }
@Override public Application load(Context context) { return loader.load(context.asScala()).asJava(); } };
@Override public ActorSystem actorSystem() { return scalaRef.actorSystem(); }
@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."); } }
/** * Check whether the application is in {@link Mode#TEST} mode. * * @return true if the application is in TEST mode */ default boolean isTest() { return asScala().isTest(); }
/** * Check whether the application is in {@link Mode#PROD} mode. * * @return true if the application is in PROD mode */ default boolean isProd() { return asScala().isProd(); }
/** * Check whether the application is in {@link Mode#DEV} mode. * * @return true if the application is in DEV mode */ default boolean isDev() { return asScala().isDev(); }
/** * Create an application that wraps a Scala application. * * @param application the application to wrap * @param config the new application's configuration * @param injector the new application's injector * * @deprecated Use {@link #DefaultApplication(play.api.Application, Config, Injector, Environment)} instead. */ @Deprecated public DefaultApplication(play.api.Application application, Config config, Injector injector) { this(application, config, injector, new Environment(application.environment())); }
@Override public Application load(Context context) { return loader.load(context.asScala()).asJava(); } };
/** Creates a GrpcClientSettings from the given NewTestServer. */ public static GrpcClientSettings grpcClientSettings(final RunningServer runningServer) { final ServerEndpoint http2Endpoint = getHttp2Endpoint(runningServer.endpoints()); return grpcClientSettings(http2Endpoint, runningServer.app().actorSystem()); }
/** * Create an application that wraps a Scala application. * * @param application the application to wrap * @param injector the new application's injector */ public DefaultApplication(play.api.Application application, Injector injector) { this(application, application.configuration().underlying(), injector); }
/** * Get the application path. * * @return the application path */ default File path() { return asScala().path(); }
/** * Get the application classloader. * * @return the application classloader */ default ClassLoader classloader() { return asScala().classloader(); }