Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

36 lines (27 sloc) 1.176 kb

Type-safe method invocation for Rewrite

A simple configuration that enables type-safe method invocation in Rewrite

How to use

  • Include OCPSoft Rewrite in your application's POM file:

    <dependency>
       <groupId>org.ocpsoft.rewrite</groupId>
       <artifactId>rewrite-servlet</artifactId>
       <version>${rewrite.version}</version>
    </dependency>
    
  • Also include the type-safe config extension:

    <dependency>
       <groupId>org.ocpsoft.rewrite</groupId>
       <artifactId>rewrite-config-typesafe</artifactId>
       <version>${rewrite.version}</version>
    </dependency>
    
  • Create rules using type-safe method invocation!

    Typesafe typesafeInvocation = Typesafe.method();
    typesafe.invoke(MyObject.class).myMethod(typesafe.param(int.class, "id"));
    
    ConfigurationBuilder.begin()
       .defineRule()
       .when(Path.matches("/id/{id}")
           .where("id")
           .convertedBy(IntegerConverter.class))
           .validatedBy(IntegerValidator.class))
       .perform(typesafeInvocation);
    
Jump to Line
Something went wrong with that request. Please try again.