wicket on OSGI + customized webapp url

I posted earlier about getting wicket to run on OSGI using the ServletFilter features of the Apache Felix ExtHttpService. Well, that one was done using the default “/*” filter pattern, that is capturing all requests. While Wicket will nicely pass through anything it does not want to handle, I wanted to put my web based UI under something like “/ui/”, meaning I wanted to capture a pattern like “/ui/*”. So, in order to do this, I set it up as

service.registerFilter(new WebUIWicketFilter(), "/ui/*", props, 0, null);

But this did not really work so nicely. While my filter was invoked (as evidenced by some printouts I put in), Wicket never did anything. After googling around and trying to read the WicketFilter source code, I figure that wicket does some form of url matching to figure out if the request is something that Wicket should process. And “/ui/” did not qualify for some reason. So I got it to work with the following addition

Hashtable<String, String> props = new Hashtable<String, String>();
props.put("applicationClassName", WebUIWicketApplication.class.getName());
props.put("filterMappingUrlPattern", "/ui/*");
try {
service.registerFilter(new WebUIWicketFilter(), "/ui/*", props, 0, null);
} catch (ServletException e) {

 

And here it is the line

props.put("filterMappingUrlPattern", "/ui/*");

that makes the difference. It seems that this is what causes Wicket to realize that the filter pattern given for Felix is intended to be a match for Wicket. Why is this? Don’t really know but I guess this is some form of standard parameter of the Java Servlet spec that is usually taken from the web.xml or something like that. Since I have no web.xml I need to populate it all myself. Well, that’s what I tell myself so I can move on to the next thing.. As long as it works (today), right?

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s