Time for action - updating the bookshelf service logging calls

Next, we'll edit the BookshelfServiceImpl class. Add the logger field (an instance of BookshelfLogHelper). This will be set up for injection in a bit:

public class BookshelfServiceImpl implements BookshelfService
{
private String sessionId;
BookInventory inventory;
BookshelfLogHelper logger;

For flexibility, we'll also add a getter for this field. This will allow us to change the means for looking up the service easily, if it is needed in the future:

private BookshelfLogHelper getLogger()
{
return this.logger;
}

If you don't want to use iPOJO, then this is the place where you'd perform the service look-up using a BundleContext instance, initialized during service construction.

In our case, we'll configure this property for injection in the iPOJO XML configuration file (src/main/ipojo/meta.xml):

<component
classname=
"com.packtpub.felix.bookshelf.service.impl.BookshelfServiceImpl"
name="BookshelfServiceImpl">
<provides />
<requires field="inventory" />
<requires field="logger" />
</component>

The integration setup is now complete. We can carry on with the update of the bookshelf service methods.

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

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