|
|
Re: Http services and contexts [message #91142 is a reply to message #90887] |
Fri, 22 June 2007 19:37 |
Markus Barchfeld Messages: 27 Registered: July 2009 |
Junior Member |
|
|
>> Is there a way to use the extension point mechanism and prevent the
help definitions from mixing in?
>
> Definitely. The servlets and resources extension have a
"serviceSelector" element that is for exactly this purpose.
> I'll log a bug against help as we certainly don't want them to leak
their web resources into other instances of the http service.
> It's a little late for 3.3 however I think this seems reasonable for
3.3.1 - we'll see.
Thanks Simon, just if anybody wants to track it, the BUG id is 193530.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=193530.
For 3.3. there will be no serviceSelector before the first maintenance
release. So, what does it mean if I want to start an OSGi HTTP service
without Eclipse Help participating (and blocking JSPs entirely)?
AFAIU I can *not* use the o.e.equinox.http.registry, i.e. extension
points, to register resources and servlets (including and the Jasper
servlet for JSPs). Instead I have to switch Code base registration,
which means to create a service tracker and register resources.
Below you find some example code how this could be done. I just would be
glad to know if I am heading in the right direction.
Thanks
Markus
void registerUsingServiceTracker(final BundleContext bundleContext) {
ServiceTracker serviceTracker = new ServiceTracker(
bundleContext,
HttpService.class.getName(),
new ServiceTrackerCustomizerImplementation(bundleContext))
serviceTracker.open();
}
class ServiceTrackerCustomizerImplementation implements
ServiceTrackerCustomizer {
private final BundleContext bundleContext;
private ServiceTrackerCustomizerImplementation(
BundleContext bundleContext) {
this.bundleContext = bundleContext;
}
....
public Object addingService(ServiceReference reference) {
registerResourcesAndServlets(reference);
return null;
}
private void registerResourcesAndServlets(ServiceReference reference) {
HttpContext context = httpService.createDefaultHttpContext() ;
HttpService httpService = (HttpService)
bundleContext.getService(reference) ;
try {
httpService.registerResources("/resource", "/WebContent", context);
httpService.registerServlet(
"/servlet",
new MyServlet(),
new Hashtable(),
context) ;
} catch (Exception e) {
}
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.04371 seconds