Re: Performance tuning

Splash Forums Rewrite Users Performance tuning Re: Performance tuning

#22986

RedShadow
Participant

Maybe all this wouldn’t be a problem if we had an option to setup a hierarchical rule structure based on path? ;)

To ensure that no other conditions are added to a hierarchical level I would introduce something like a PathSubset that can only have a path. Here is an example of what I would expect:

ConfigurationBuilder builder = ConfigurationBuilder.begin()
.addRule(
PathSubset.on("/")
.addRule(Join.simple("").to("/index.xhtml"))
.addRule(Join.simple("about").to("/about.xhtml"))
.addRule(
PathSubset.on("projects")
.addRule(Join.simple("").to("/projects.xhtml"))
.addRule(Join.path("/{projectName}").to("/projectDetail.xhtml"))
)
.addRule(
PathSubset.on("admin")
.addRule(Join.simple("").to("/login.xhtml").when(notLoggedIn))
.addRule(Join.simple("").to("/admin.xhtml").when(loggedIn))
)
);

The static rules or rules that are in a subset should be kept in something like a TrieMap<String, List<Rule>>:

staticRuleTrieMap{
"/" : [Rule("/index.xhtml")],
"/about" : [Rule("/about.xhtml")],
"/projects" : [Rule("/projects.xhtml"), Rule("/{projectName}" -> "/projectDetail.xhtml")],
"/admin" : [Rule("/login.xhtml"), Rule("/admin.xhtml")]
}

You could then make something like:

List<Rule> rules = staticRuleTrieMap.findPath(requestPath);
// Iterate over rules, just do what is done currently by DefaultHttpRewriteProvider
if(!Lifecycle.isHandled()){
// Process the other rules
}