iPOJO and the Whiteboard Extender

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.

iPOJO and the Whiteboard Extender

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:

  • Write an HttpServlet implementation
  • Declare its component and instance using iPOJO
  • Deploy and start on the framework

The 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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.154.64