@Override
 public Configuration getConfiguration(final ServletContext context) {
   Configuration config =
       ConfigurationBuilder.begin()
           .addRule(Join.path("/{lang}/{path}.xhtml").to("/{path}.xhtml"))
           .where("path")
           .transposedBy(LocaleTransposition.bundle("bundle", "lang"))
           .addRule(Join.path("/{lang}/{path}").to("/{path}"))
           .where("path")
           .configuredBy(LocaleTransposition.bundle("bundle", "lang"))
           .addRule(Join.path("/{lang}/{path}/transposition_only").to("/{path}"))
           .where("path")
           .transposedBy(LocaleTransposition.bundle("bundle", "lang"))
           .addRule(Join.path("/{lang}/{path}/transposition_failed_1").to("/{path}"))
           .where("path")
           .transposedBy(
               LocaleTransposition.bundle("bundle", "lang")
                   .onTranspositionFailed(
                       new HttpOperation() {
                         @Override
                         public void performHttp(
                             HttpServletRewrite event, EvaluationContext context) {
                           SendStatus.code(201).performHttp(event, context);
                         }
                       }))
           .addRule(Join.path("/{lang}/{path}/transposition_failed_2").to("/{path}"))
           .where("path")
           .transposedBy(
               LocaleTransposition.bundle("bundle", "lang")
                   .onTranspositionFailed(
                       new HttpOperation() {
                         @Override
                         public void performHttp(
                             HttpServletRewrite event, EvaluationContext context) {
                           SendStatus.code(202).performHttp(event, context);
                         }
                       }));
   return config;
 }
Exemplo n.º 2
0
  @Override
  public Configuration getConfiguration(final ServletContext context) {
    Configuration config =
        ConfigurationBuilder.begin()
            .addRule(Join.path("/metadata").to("/internalMetadata"))
            .addRule()
            .perform(Log.message(Level.INFO, "Just loggin somethin'."))
            .addRule()
            .when(Path.matches("/internalMetadata"))
            .perform(
                new Operation() {
                  @Override
                  public void perform(Rewrite event, EvaluationContext context) {
                    throw new IllegalStateException("expected");
                  }
                });

    return config;
  }