Thanks for the reply, this is helpful. I was thinking through this today and came to some of the same conclusions-- the issue of potentially more than one deployment and using a static variable for a custom predicate to "find" the servlet information.
Here's a few brainstorms--
Is there a programmatic way to access all of the servlet deployments that have been created? What if, in the event that there is no servlet context in the exchange, the file and directory predicates could check and see if only one servlet context existed, and if so, just grab that one? That doesn't solve the scenario where two or more deployments exist, but it would at least allow it to make a decent guess for single deployments.
Being able to specify a given deployment when creating a predicate handler chain is an interesting idea as well, but I'm not entirely sure how many things in the API would need to change to get it all the way down to the predicatebuilder's build() call. In my particular case, I'm using the PredicatedHandlersParser.
And on the topic of using the dispatcher-- what if instead of writing a new handler, the existing handler detected if it was inside the servlet, and if so, it used the dispatcher, and if there was no servlet, it just fell back to its current behavior of using the SetAttribtueHandler to override the relative path? From an architectural standpoint, I don't know if it would be against "the rules" to have a handler in the core package touching stuff in the servlet package.
Thanks!
~Brad
Developer Advocate
Ortus Solutions, Corp