Package org.ocpsoft.rewrite.config

Examples of org.ocpsoft.rewrite.config.Configuration


         {
            ConfigurationProvider provider = enriched.iterator().next();
            Object configurationContext = context.get(type);
            if (provider.handles(configurationContext))
            {
               Configuration config = provider.getConfiguration(configurationContext);
               if (config != null)
               {
                  for (Rule rule : config.getRules())
                  {
                     ConfigurationRuleBuilder ruleBuilder = context.getConfigurationBuilder().addRule(rule);
                     if (rule instanceof RelocatableRule && ((RelocatableRule) rule).isRelocated())
                        ruleBuilder.withPriority(((RelocatableRule) rule).priority());
                     else
View Full Code Here


   }

   @Override
   public Configuration getConfiguration(final ServletContext context)
   {
      Configuration config = ConfigurationBuilder.begin()
               .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"))
View Full Code Here

public class ConfigurationBuilderMetadataTest
{
   @Test
   public void testBuildConfigurationMetadata()
   {
      Configuration config = ConfigurationBuilder.begin().addRule()
               .perform(new Operation() {
                  @Override
                  public void perform(Rewrite event, EvaluationContext context)
                  {}
               });

      Assert.assertEquals(1, config.getRules().size());
      Rule rule = config.getRules().get(0);
      Assert.assertTrue(rule instanceof Context);

      String location = (String) ((Context) rule).get(RuleMetadata.PROVIDER_LOCATION);
      Assert.assertEquals(
               "org.ocpsoft.rewrite.metadata.ConfigurationBuilderMetadataTest"
View Full Code Here

   }

   @Test
   public void testBuildConfigurationMetadataWrappedRule()
   {
      Configuration config = ConfigurationBuilder.begin().addRule(RuleBuilder.define());

      Assert.assertEquals(1, config.getRules().size());
      Rule rule = config.getRules().get(0);
      Assert.assertTrue(rule instanceof Context);

      String location = (String) ((Context) rule).get(RuleMetadata.PROVIDER_LOCATION);
      Assert.assertEquals(
               "org.ocpsoft.rewrite.metadata.ConfigurationBuilderMetadataTest"
View Full Code Here

   }

   @Test
   public void testBuildConfigurationMetadataOtherwise()
   {
      Configuration config = ConfigurationBuilder.begin().addRule()
               .perform(new Operation() {
                  @Override
                  public void perform(Rewrite event, EvaluationContext context)
                  {}
               })
               .otherwise(new Operation() {

                  @Override
                  public void perform(Rewrite event, EvaluationContext context)
                  {}
               });

      Assert.assertEquals(2, config.getRules().size());

      for (Rule rule : config.getRules()) {

         Assert.assertTrue(rule instanceof Context);

         String location = (String) ((Context) rule).get(RuleMetadata.PROVIDER_LOCATION);
         Assert.assertEquals(
View Full Code Here

   }

   @Override
   public Configuration getConfiguration(final ServletContext context)
   {
      Configuration config = ConfigurationBuilder
               .begin()

               /*
                * Test buffered
                */
 
View Full Code Here

   }

   @Override
   public Configuration getConfiguration(final ServletContext context)
   {
      Configuration config = ConfigurationBuilder
               .begin()

               /*
                * Test buffered
                */
 
View Full Code Here

   }

   @Override
   public Configuration getConfiguration(final ServletContext context)
   {
      Configuration config = ConfigurationBuilder.begin()

               // Chaining explicitly enabled
               .addRule(Join.path("/chain").to("/1").withChaining())
               .addRule(Join.path("/chain-nochain").to("/nochain").withChaining())
View Full Code Here

   }

   @Override
   public Configuration getConfiguration(final ServletContext context)
   {
      Configuration config = ConfigurationBuilder.begin()

               .addRule(Join.path("/p/{project}").to("/success"))
               .otherwise(SendStatus.code(420))

               .addRule().when(Path.matches("/success"))
View Full Code Here

   }

   @Override
   public Configuration getConfiguration(final ServletContext context)
   {
      Configuration config = ConfigurationBuilder.begin()
               .addRule().when(Path.matches("{*}.txt"))
               .perform(SendStatus.code(200))
               .where("*").matches("foo");

      return config;
View Full Code Here

TOP

Related Classes of org.ocpsoft.rewrite.config.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.