Open a Web browser and navigate to http://localhost:8080/greenpages.
Click the Submit button. Unfortunately the search will not return any results
as the Web bundle is still using the stub Directory
implementation provided by the
greenpages.app
module, rather than the JPA-based implementation that is provided
by greenpages.jpa
.
This can be confirmed by using the dm Server shell, or the web-based admin console to examine the services being used
by greenpages.web
.
The service which is being used by the Web bundle can be changed at runtime without having to restart the
application or the dm Server. This can be achieved by changing greenpages.app
so that it no longer
publishes its Directory
implementation. As a result of this Directory
service no longer being available, the Web bundle will automatically switch to using the JPA-based
implementation.
Open the osgi-context.xml
file in the META-INF/spring
folder of the
greenpages.app
project and comment out the publication of the directory service:
<!-- <osgi:service interface="greenpages.Directory" ref="directory"/> -->
Now save the updated file which will cause the application to be updated and refreshed on the server. Switch back to the Web browser and click Submit again.
This time eight results should be returned. Clicking on any of the View links will display the listing’s details. The application is now working. All that remains is to apply some best practices to the middle tier.