2009/2/6 Thomas Diesler <[email protected]> > Dear Folks, > > While implementing HttpService for the JBoss OSGi integration I came across > an inconsistent API issue. > > The specification sais: > > Alternatively, the resource registration could have used a > default HttpContext object, as demonstrated in the following > call to registerResources: > > getHttpService().registerResources( > "/files", > "/com/acme/www", > null > ); > > In this case, the Http Service implementation would call the > createDefaultHttpContext() method and use its return value > as the HttpContext argument for the registerResources method. > The default implementation must map the resource request to > the bundle's resource, using Bundle.getResource(String). > > An implementation of the default HttpContext has however no knowledge of > the callers bundle. The fundamental question is which bundle should > HttpContext.getResource(String) use for the default HttpContext? > > This issue also applies when a servlet is registered with the default > HttpContext. A call to ServletContext.getResource(String) cannot access the > bundle that registered the servlet. > > AFAICS, the only bundle available to the default HttpContext is that of the > HttpService itself, but not that of the caller. >
if you implement the HttpService as a ServiceFactory then you can return a specific instance of it that is configured for the requesting bundle, see: http://www.osgi.org/javadoc/r4v41/org/osgi/framework/ServiceFactory.html as well as section 5.6 of the core spec many of the compendium services are implemented as service factories, because it means you don't have to repeatedly pass the client bundle around when you call the service. HTH cheers > -thomas > _______________________________________________ > OSGi Developer Mail List > [email protected] > https://mail.osgi.org/mailman/listinfo/osgi-dev > -- Cheers, Stuart
_______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
