Hi,

I am not sure, whether I get your points right, but lets try ...

Am Sonntag, den 31.10.2010, 20:21 -0700 schrieb misha680: 
> Dear All:
> 
> My apologies I do not currently have a simple test case (I tried to get one
> ready but it does not seem to be provisioning properly at the moment).
> Please bear with me if possible.
> 
> I am tackling http://tickets.openmrs.org/browse/TRUNK-1596 (OSGi conversion
> of a Spring/Hibernate/etc/etc project).
> 
> I have made some progress using Spring DM extender, but am not trying to
> generalize to the OSGI http service.
> 
> Specifically, Felix HTTP service seems like a great match as:
> * it allows easy embedding as shown in
> org.apache.felix.http-2.0.4/samples/bridge/
> * per http://felix.apache.org/site/apache-felix-http-service.html,
> "org.apache.felix.http.proxy - Proxy that is needed inside WAR when deployed
> inside an application server."
> it seems that (please correct me if I am wrong) we can then use Felix HTTP
> Service (and unmodified code) in a traditional WAR - an important
> intermediate step in deploying OpenMRS inside a traditional container, and
> something that would be a plus and the main devs seem to want as well at the
> moment.
> 
> In any case, I have run into a slight problem, and was wondering if you
> might be able to help.
> 
> It seems, even for a Servlet registered under the path "/openmrs", both
> 
> ServletContext.getContextPath()

This gives the servlet context path. I would assume that for the OSGi
Http Service specification this would always be the empty String
denoting the root context.

The path "/openmrs" is returned by the
HttpServletRequest.getServletPath() method.

> 
> and
> 
> ServletContext.getResource("/").getPath()

The ServletContext.getResource() method has no relationship to any
registered servlets and hence you would of course not expected the
URL.getPath() method of the resource returned (which may of course be
null !) to be the same as the servlet name.

So what you are experiencing as the results -- empty string for the
first call and "/" for the second -- is quite expected and IMHO correct.

Hope this helps.

Regards
Felix

> 
> return simply an empty string, rather than "openmrs"
> 
> I have also tested with Equinox HTTP Service and Pax Web, which makes me
> suspect I am doing something wrong.
> 
> Unfortunately, I am not actually able to deduce some wronghood from my code
> and would appreciate any quick hints/suggestions.
> 
> I have posted the relevant code snippets here:
> http://gist.github.com/657551
> 
> My apologies, they are somewhat over-wrought with extensions etc at the
> moment (I want to use a listener and also a filter, but I have commented the
> non-relevant parts out).
> 
> In any case, the code uses registerServlet, and then the servlet, in its
> init method, calls both:
> ServletContext.getContextPath()
> ServletContext.getResource("/").getPath()
> both seems to give empty strings (the part inside the [] parentheses):
> !!! []
> !!! [/]
> 
> If there is something simple I am missing, please let me know.
> 
> Thank you so much. Sorry to bother with what is probably a trivial
> question/mistake.
> 
> Thank you again
> 
> Yours
> Misha



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to