/** * Starts a new application. * * @param application the application to start. */ public static void start(Application application) { play.api.Play.start(application.asScala()); }
/** * Stops an application. * * @param application the application to stop. */ public static void stop(Application application) { play.api.Play.stop(application.asScala()); }
/** * The root configuration. * <p> * @return a Configuration instance */ public static Configuration root() { return new Configuration( play.api.Play.unsafeApplication().configuration() ); }
/** * Retrieve the application Akka Actor system. */ public static ActorSystem system() { return play.api.libs.concurrent.Akka.system(Play.current()); }
/** * Check whether the application is in {@link Mode#PROD} mode. * * @return true if the application is in PROD mode */ default boolean isProd() { return play.api.Play.isProd(getWrappedApplication()); }
/** * Check whether the application is in {@link Mode#DEV} mode. * * @return true if the application is in DEV mode */ default boolean isDev() { return play.api.Play.isDev(getWrappedApplication()); }
/** * Check whether the application is in {@link Mode#TEST} mode. * * @return true if the application is in TEST mode */ default boolean isTest() { return play.api.Play.isTest(getWrappedApplication()); }
/** * Executes a block of code, providing a JDBC connection. * The connection and all created statements are automatically released. * * @param name Datasource name * @param autocommit Auto-commit setting * @param block Code block to execute */ public static void withConnection(String name, boolean autocommit, ConnectionRunnable block) { withConnection(name, autocommit, block, play.api.Play.unsafeApplication()); }
/** * Retrieve Lang availables from the application configuration. */ public static List<Lang> availables() { List<play.api.i18n.Lang> langs = Scala.asJava(play.api.i18n.Lang.availables(play.api.Play.current())); List<play.i18n.Lang> result = new ArrayList<play.i18n.Lang>(); for(play.api.i18n.Lang lang: langs) { result.add(new Lang(lang)); } return result; }
/** * Executes a block of code, providing a JDBC connection. * The connection and all created statements are automatically released. * * @param name Datasource name * @param autocommit Auto-commit setting * @param block Code block to execute */ public static <A> A withConnection(String name, boolean autocommit, ConnectionCallable<A> block) { return withConnection(name, autocommit, block, play.api.Play.unsafeApplication()); }
/** * Returns the currently running application. */ public static Application application() { return play.api.Play.current().injector().instanceOf(Application.class); }
/** * Starts a new application. * * @param application the application to start. */ public static void start(Application application) { play.api.Play.start(application.asScala()); }
/** * Stops an application. * * @param application the application to stop. */ public static void stop(Application application) { play.api.Play.stop(application.asScala()); }
/** * Get a connection from any datasource, * with the specified auto-commit setting. * * @param name Datasource name * @param autocommit Auto-commit setting */ public static Connection getConnection(String name, boolean autocommit) { return play.api.db.DB.getConnection(name, autocommit, play.api.Play.unsafeApplication()); }
/** * Guess the preferred lang in the langs set passed as argument. * The first Lang that matches an available Lang wins, otherwise returns the first Lang available in this application. */ public static Lang preferred(List<Lang> langs) { List<play.api.i18n.Lang> result = new ArrayList<play.api.i18n.Lang>(); for(play.i18n.Lang lang: langs) { result.add(lang.underlyingLang); } return new Lang(play.api.i18n.Lang.preferred(Scala.toSeq(result), play.api.Play.current())); }
/** * Starts a new application. */ public static void start(Application application) { play.api.Play.start(application.getWrappedApplication()); }