[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] HttpService

The HttpService is simply a service that has been registered with the OSGi service registry.  You simply acquire the service from the OSGi service registry (using BundleContext/ServiceReference APIs, a ServiceTracker, or Declarative Services) and then use the service per the HttpService interface.  One you're done with the service (or if the service is unregistered, which ever happens first) you must release the service.  Please take a look at the OSGi spec for details of acquiring and releasing services from the OSGi service registry.

To use the HttpService you need only a few bundles installed, for example:

id        State       Bundle
0        ACTIVE      system.bundle_3.2.0.v20060601
3        ACTIVE      org.eclipse.equinox.servlet.api_1.0.0.v20060601
4        ACTIVE      org.eclipse.osgi.services_3.1.100.v20060601
5        ACTIVE      org.eclipse.equinox.http_1.0.0.v20060601a

This results in the HttpService being registered and running on port 80.

{org.osgi.service.http.HttpService}={http.port=80, service.pid=org.eclipse.equinox.http.HttpService-http, http.address=ALL, service.vendor=IBM, service.description=OSGi Http Service - IBM Implementation, http.scheme=http, http.timeout=30, service.id=20}
  Registered by bundle: initial@reference:file:plugins/org.eclipse.equinox.http_1.0.0.v20060601a.jar/ [5]
  No bundles using service.

The HttpService API is well documented here:

Good luck,


"Khawaja Shams" <ksshams@xxxxxxxxx>
Sent by: equinox-dev-bounces@xxxxxxxxxxx

07/05/2006 07:47 PM

Please respond to
Equinox development mailing list <equinox-dev@xxxxxxxxxxx>

"Equinox development mailing list" <equinox-dev@xxxxxxxxxxx>
[equinox-dev] HttpService

   I am trying to develop a servlet that would utilize plugins, and I would like to use Equinox to accomplish the task.  I have a servlet ready, but I am not sure how I could register the servlet with the HttpService.  The code samples tend to mention the getHttpService() method, but I cannot seem to find that method.  The HttpListener class has a method with signature Object getService(), which returns an HttpService. Is there a canonical way to get an instance of the HttpService? I understand that the Http class has an HttpListener attribute, which has an HttpService object.  However, I am not sure if this is the right service that I would register with or how to register my servlet.  

Is there any place I can check out some sample code? I have checked out the R4 compendium, but I am wondering if anyone has a working sample.

Also, do these servlets run within the Http plugin? OR can I deploy the servlets on a tomcat instnace?

I would sincerely appreciate any help.

Khawaja Shams
equinox-dev mailing list