Martin

I don't think what you were doing is in error - would have to double check the OSGi spec on aliases.

But it does seem to have shown up either a bug in Felix Http service - or an inconsistency with other implementations.

I've raised Jira issue 503 for this - can't promise when I or anyone else will get a chance to investigate and fix it, but at least it's logged.

   http://issues.apache.org/jira/browse/FELIX-503

For now, I know that registering via dirs / paths does work if that's a feasible workaround for you

Regards

-- Rob


Martin Thelian wrote:
Hi,

thank you for your answer and your help.

I think now I understand what you mean. You seem to assume that a resource is always a directory. But what I was trying to do is to register a single file as resource. The javadoc of the HttpService does not forbid to do so, and I was doing the same thing in knopflerfish and equinox and it worked.

Of course I could change my application and always register a whole directory,
even if I just have one file to register, but it would be nice if felix
could support this either.


Best regards,
Martin

Rob wrote:
What this is saying to me is " alias requests to '/ as '/image.png' " - which may not be what you want.

The more common approach from examples we've worked with, where it's typical to register aliases to paths where several resources are located, as opposed to alias every specific resource e.g.

m_httpServ.registerResources("/resource", "/org/ungoverned/osgi/bundle/httptest/resource", null);

(this is from the httptest bundle that is still available on OBR at http://oscar-osgi.sourceforge.net/ which has some source if you want examples)

One thing to be careful of, which is why the alias mechanism exists, is that the HTTP namespace is global, but multiple bundles may have their own package/dir namespace - so each bundle needs to be careful that the aliases it registers map to files in their resource space, and don't collide with other aliases from other bundles

If image.png is a resource in the root of your bundle, then you may be able to use following:

http.registerResources("/", "/", null);

(this assumes a getResource("/image.png") for your bundle's context would locate the required resource)

The trouble here, is that by registering the "root" as an alias, you may limit/collide with anything other bundles want to register - you'll effectively be saying go to this bundle for all / resources.


--


Ascert - Taking systems to the Edge
[EMAIL PROTECTED]
+44 (0)20 7488 3470
www.ascert.com

Reply via email to