As mentioned in Chapter 9, Improving the Bookshelf Service with iPOJO, we will use the whiteboard pattern to register our servlets, instead of registering them directly with the Http Service.
In this context, the HTTP whiteboard implementation will listen to registered HttpServlets
and will add them to the installed Http Service.
In Chapter 9, we also saw how to simplify service registration using iPOJO. Combining iPOJO service declaration along with an http whiteboard extender reduces the publishing of an Http Servlet to the following steps:
HttpServlet
implementationThe iPOJO service detects the bundle and registers its service with the framework. Next, the whiteboard extension recognizes it as a servlet and publishes it with the Http Service.
One of the main gains from using this approach is to avoid having a direct dependency on the HttpService
interface, which, in this case, is only used to publish the servlet. All the bundle knows is that it implements the HttpServlet
interface, iPOJO publishes the service, and the Http Whiteboard extender recognizes it as a servlet and publishes it with the Http Service.