Explicit HttpService resource registration - bad idea?

As part of one of the Felix/OSGi/HttpService applications I'm working on, I 
need to do a lot of explicit resource registration, i.e.
httpService.registerResource("/test.html", "/resources/test.html", 
myCustomContext);

where myCustomContext is an implementation of HttpContext and simply resolves 
/resources/test.html as a bundle resource.

(to be clear, I'm not actually coding dozens of calls to registerResources - 
that's all automated)

I've always had some weirdness with Felix's HttpService implementation where 
the name actually received by myCustomContext.getResource() has a slash 
appended to it, but that was easy enough to handle that I didn't think much 
about it. But now I'm run into a more serious problem when using the 
Bridge/Proxy modules in HttpService 2.0.2 - when the webapp receives a request 
for /test.html;someextrastuff the name passed to getResource() is 
/test.html/;someextrastuff (actually, in 2.0.2 it's 
/test.html/;someextrastuff/;someextrastuff due to FELIX-1713, but that's fixed 
in trunk).

I can workaround this, but I wanted to ask a larger question of this community 
- is this type of resource registration a bad idea? Nothing that I read in the 
HttpService spec suggests that it is prohibited, just that it's not typical.

And is the fact that getResource() is being called with 
/test.html/;someextrastuff a bug? What about when it was called with 
/test.html/?

To give a bit of context - what I'm trying to do overall is a modular web 
framework along the lines of Spring Slices, although unlike Slices, this 
framework uses HttpService, not Jetty or Tomcat directly (also it doesn't 
support fragments, at least not yet). The implementation uses a custom Spring 
DM web extender which makes some assumptions about the construction of a web 
application (i.e. it completely ignores web.xml). Resource registration comes 
into play in that the extender looks for all files within a war file that 
aren't in the WEB-INF directory and registers them.

I'm on the verge of rambling, so if any of this doesn't make sense, I can 
clarify.

 

Thanks,

Justin

 

Reply via email to