/**
   * Silent checkstyle.
   *
   * @param args not used
   */
  public static void main(final String[] args) {
    // Initialize Play Application to use the play environment functions...
    Application play =
        new DefaultApplication(
            new File("."), WaypointDemo.class.getClassLoader(), null, Mode.Dev());
    Play.start(play);

    try {
      // Set up Google Guice Dependency Injector
      Injector injector = Guice.createInjector();

      /* Build up the application, resolving dependencies
       * automatically by Guice */
      WaypointTUI tui = injector.getInstance(WaypointTUI.class);

      tui.printTUI();
      /* continue to read user input on the tui until the user
       * decides to quit*/
      boolean continu = true;
      Scanner scanner = new Scanner(System.in);
      while (continu) {
        continu = tui.processInputLine(scanner.nextLine());
      }
      scanner.close();
    } finally {
      Play.stop();
    }
  }
Exemple #2
0
 /**
  * Instantiates a new form that wraps the specified class.
  *
  * @deprecated inject a {@link FormFactory} instead, since 2.5.0
  */
 @Deprecated
 public static <T> Form<T> form(Class<T> clazz) {
   return new Form<>(
       clazz,
       play.api.Play.current().injector().instanceOf(MessagesApi.class),
       play.api.Play.current().injector().instanceOf(Formatters.class));
 }
Exemple #3
0
  @Override
  public play.mvc.Result onError(final RequestHeader rh, final Throwable t) {
    Logger.error("onError " + rh + " " + t);

    JPA.withTransaction(
        new play.libs.F.Callback0() {

          @Override
          public void invoke() throws Throwable {
            Group group =
                Group.findByTitle(
                    play.Play.application().configuration().getString("htwplus.admin.group"));
            if (group != null) {
              Post p = new Post();
              p.content = "Request: " + rh + "\nError: " + t;
              p.owner =
                  Account.findByEmail(
                      play.Play.application().configuration().getString("htwplus.admin.mail"));
              p.group = group;
              p.create();
            }
          }
        });

    // prod mode? return 404 page
    if (Play.mode(play.api.Play.current()).toString().equals("Prod")) {
      return play.mvc.Results.redirect(routes.Application.error());
    }

    return super.onError(rh, t);
  }
Exemple #4
0
 /**
  * Instantiates a new form that wraps the specified class.
  *
  * @deprecated inject a {@link FormFactory} instead, since 2.5.0
  */
 @Deprecated
 public static <T> Form<T> form(String name, Class<T> clazz, Class<?> group) {
   return new Form<>(
       name,
       clazz,
       group,
       play.api.Play.current().injector().instanceOf(MessagesApi.class),
       play.api.Play.current().injector().instanceOf(Formatters.class));
 }
 @Test
 public void testSession() {
   Application app = new GuiceApplicationBuilder().build();
   Play.start(app);
   Context ctx =
       new Context(new RequestBuilder().session("a", "1").session("b", "1").session("b", "2"));
   assertEquals("1", ctx.session().get("a"));
   assertEquals("2", ctx.session().get("b"));
   Play.stop(app);
 }
 /** Stops an application. */
 public static void stop(FakeApplication fakeApplication) {
   play.api.Play.stop();
 }
  /** Starts a new application. */
  public static void start(FakeApplication fakeApplication) {

    play.api.Play.start(fakeApplication.getWrappedApplication());
  }
Exemple #8
0
 /**
  * Instantiates a dynamic form.
  *
  * @deprecated inject a {@link FormFactory} instead, since 2.5.0
  */
 @Deprecated
 public static DynamicForm form() {
   return new DynamicForm(
       play.api.Play.current().injector().instanceOf(MessagesApi.class),
       play.api.Play.current().injector().instanceOf(Formatters.class));
 }
 /** Returns `true` if the current application is `DEV` mode. */
 private static boolean isDev() {
   return play.api.Play.isDev(play.api.Play.current());
 }
Exemple #10
0
 /** Stops an application. */
 public static void stop(Application application) {
   play.api.Play.stop(application.getWrappedApplication());
 }
Exemple #11
0
 private static OpenIdClient client() {
   return play.api.Play.current().injector().instanceOf(OpenIdClient.class);
 }