Edit the project POM build plugins section; the maven-bundle-plugin
will be configured to include additional imports that may not be used in the class-set:
<plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <version>2.1.0</version> <extensions>true</extensions> <configuration> <instructions> <Bundle-Category>sample</Bundle-Category> <Webapp-Context>bookshelf</Webapp-Context> <!-- <Web-ContextPath>/bookshelf</Web-ContextPath> --> <Bundle-SymbolicName>${project.artifactId} </Bundle-SymbolicName> <Import-Package> com.packtpub.felix.bookshelf.inventory.api,* </Import-Package> </instructions>
Notice the last imported package (*); it will be replaced by the other packages detected by the bundle plugin during the manifest file generation.
You get the gist of it, right? How about you implement the remaining pages? Here are the ones remaining from the initial scope:
A searchAuthors.action.jsp
page takes an optional author parameter as search criterion. If none is passed, then it displays the search form:
When the form is submitted, the page performs the search against the bookshelf service and displays the results:
Also design an addBook.jsp
form for submitting a request to add a new book to the bookshelf along with the addBook.action.jsp
page to perform the add action and display a page confirming its success.
The confirmation results page re-uses the book details embedded JSP bit:
This obviously doesn't cover all the features the bookshelf service provides, especially if you had extended its interface earlier!
There are quite a few more additions that can be made to this:
This concludes this case study. If you've followed it carefully, then you've mostly not encountered any problems and have learned a lot on the way. You'd have learned more if you did encounter some issues!
The next chapter looks at some of the common issues and proposes some means to investigate their root cause and resolve them.
How about a quick quiz to jog your memory?
a. Web Container
b. Web Context
c. Service Reference
a. Use the BundleContext
provided at construction
b. Use the servlet context, retrieving the osgi-bundlecontext
attribute
c. Use injection