-
Notifications
You must be signed in to change notification settings - Fork 3
/
RewriteServletConfig.java
35 lines (30 loc) · 1.32 KB
/
RewriteServletConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package fdmcjsf.config;
import org.ocpsoft.logging.Logger;
import org.ocpsoft.rewrite.annotation.RewriteConfiguration;
import org.ocpsoft.rewrite.config.Configuration;
import org.ocpsoft.rewrite.config.ConfigurationBuilder;
import org.ocpsoft.rewrite.config.Direction;
import org.ocpsoft.rewrite.config.Log;
import org.ocpsoft.rewrite.servlet.config.HttpConfigurationProvider;
import org.ocpsoft.rewrite.servlet.config.Path;
import org.ocpsoft.rewrite.servlet.config.rule.Join;
import javax.servlet.ServletContext;
@RewriteConfiguration
public class RewriteServletConfig extends HttpConfigurationProvider {
@Override
public int priority() {
return 10;
}
@Override
public Configuration getConfiguration(final ServletContext context) {
return ConfigurationBuilder.begin()
.addRule()
.when(Direction.isInbound().and(Path.matches("/{path}")))
.perform(Log.message(Logger.Level.INFO, "Client requested path: {path}"))
.where("path").matches(".*")
.addRule(Join.path("/").to("/faces/view/index.xhtml"))
.addRule(Join.path("/index").to("/faces/view/index.xhtml"))
.addRule(Join.path("/create").to("/faces/view/create.xhtml"))
.addRule(Join.path("/all").to("/faces/view/all.xhtml"));
}
}