|
| 1 | +Rewrite: Get Started |
| 2 | +================================================= |
| 3 | + |
| 4 | +A highly configurable URL-rewriting tool for Java EE 6+ and Servlet 3.0 applications, supporting integration with: |
| 5 | + |
| 6 | + * CDI |
| 7 | + * Spring DI |
| 8 | + * JodaTime configuration |
| 9 | + * Tuckey.org URLRewriteFilter configuration |
| 10 | + * JavaServer Faces (JSF) |
| 11 | + * JavaServer Pages (JSP) |
| 12 | + * Struts |
| 13 | + * Wicket |
| 14 | + * Groovy on Grails |
| 15 | + * Spring Roo |
| 16 | + * Spring Web Flow |
| 17 | + * Any servlet & web framework! |
| 18 | + |
| 19 | +Get Started |
| 20 | +========== |
| 21 | + |
| 22 | +1. It is recommended but not required to remove other URL-rewriting tools from your application before using Rewrite. If you choose to leave them in place, weird things may happen, be warned. |
| 23 | + |
| 24 | +2. Include OCPSoft Rewrite in your application's POM file: |
| 25 | + |
| 26 | + <dependency> |
| 27 | + <groupId>com.ocpsoft.rewrite</groupId> |
| 28 | + <artifactId>rewrite-impl-servlet</artifactId> |
| 29 | + <version>${rewrite.version}</version> |
| 30 | + </dependency> |
| 31 | + |
| 32 | +3. Add a configuration provider implementing the 'com.ocpsoft.rewrite.config.ConfigurationProvider' interface, or extending from the abstract HttpConfigurationProvider class for convenience: |
| 33 | + |
| 34 | + package com.example; |
| 35 | + |
| 36 | + public class ExampleConfigurationProvider extends HttpConfigurationProvider |
| 37 | + { |
| 38 | + @Override |
| 39 | + public int priority() |
| 40 | + { |
| 41 | + return 10; |
| 42 | + } |
| 43 | + |
| 44 | + @Override |
| 45 | + public Configuration getConfiguration(final ServletContext context) |
| 46 | + { |
| 47 | + return ConfigurationBuilder.begin() |
| 48 | + .addRule() |
| 49 | + .setCondition( |
| 50 | + |
| 51 | + Direction.isInbound() |
| 52 | + .and(Path.matches("/some/page/.*/")) |
| 53 | + ) |
| 54 | + |
| 55 | + .setOperation(new Operation() { |
| 56 | + @Override |
| 57 | + public void perform(final Rewrite event) |
| 58 | + { |
| 59 | + ((HttpInboundServletRewrite) event).forward("/new-page/"); |
| 60 | + } |
| 61 | + }); |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | +4. Create a file named: '/META-INF/services/com.ocpsoft.rewrite.config.ConfigurationProvider' which contains the fully qualified name of your ConfigurationProvider implementation: |
| 66 | + |
| 67 | + /META-INF/services/com.ocpsoft.rewrite.config.ConfigurationProvider | |
| 68 | + --------------------------------------------------------------------| |
| 69 | + com.example.ExampleConfigurationProvider |
| 70 | + |
| 71 | +5. Add rules to your configuration. Condition objects such as 'Direction.isInbound()' and 'Path.matches(É)' can be found in the 'com.ocpsoft.rewrite.config.*' and 'com.ocpsoft.rewrite.servlet.config.*' packages. |
| 72 | + |
| 73 | +6. Consider using Rewrite extensions for extra power: |
| 74 | + * [JodaTime Integration](https://github.com/ocpsoft/rewrite/tree/master/config-jodatime) |
| 75 | + * [Tuckey URLRewriteFilter Integration](https://github.com/ocpsoft/rewrite/tree/master/config-tuckey) |
| 76 | + * [CDI Integration](https://github.com/ocpsoft/rewrite/tree/master/integration-cdi) |
| 77 | + * And more... |
| 78 | + |
| 79 | +7. Run your application! |
| 80 | + |
| 81 | +FEEDBACK |
| 82 | +======== |
| 83 | + |
| 84 | +This project is looking for your feedback! What would make your task easier? How can we simplify this experience? |
| 85 | + |
| 86 | +TODO's |
| 87 | +====== |
| 88 | + |
| 89 | + * Continue simplification of Configuration objects and convenience APIs. |
| 90 | + |
| 91 | + * Implement additional file-based configuration support. |
| 92 | + |
| 93 | + * Implement http://localhost:8080/rewrite-status monitoring tool |
| 94 | + |
| 95 | + * Implement parameter mapping and value injection (like in the PrettyFaces extension) |
0 commit comments