Open a Web browser and navigate to http://localhost/greenpages/home.htm
.
Click the Submit button. Unfortunately the search will not return any results
as the
Web module 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 OSGi console.
Open a command prompt and enter
telnet localhost 2401
At the resulting prompt, enter ss (for short status) and press return. This will return a list of all of the bundles currently running in dm Server. Something like this:
69 ACTIVE com.springsource.server.web.dm_1.0.2.RELEASE 70 ACTIVE org.springframework.web.servlet_2.5.6.A 71 ACTIVE com.springsource.freemarker_2.3.12 72 ACTIVE com.springsource.org.apache.commons.fileupload_1.2.0 73 ACTIVE com.springsource.org.apache.commons.io_1.4.0 74 ACTIVE org.springframework.context.support_2.5.6.A 75 ACTIVE greenpages-1-greenpages-synthetic.context_1.0.0 76 ACTIVE greenpages-1-greenpages_1.0.0 77 ACTIVE greenpages-1-greenpages.db_1.0.0 78 ACTIVE greenpages-1-greenpages.jpa_1.0.0 79 ACTIVE greenpages-1-greenpages.web_1.0.0 80 ACTIVE com.springsource.org.h2_1.0.71 81 ACTIVE com.springsource.org.apache.commons.dbcp_1.2.2.osgi 82 ACTIVE org.springframework.aspects_2.5.6.A
The bundle that is of primary interest is the Web module (greenpages-1-greenpages.web_1.0.0
).
In the example
above this is bundle 79. Enter a command of bundle <web-module-bundle-id>
, that
is bundle 79
for the case above. There will be several lines of output.
Towards the top of the generated output will be details of the services which are being used by the Web module:
Services in use: {greenpages.Directory}={org.springframework.osgi.bean.name=directory, Bundle-SymbolicName=greenpages-1-greenpages, Bundle-Version=1.0, com.springsource.server.app.name=greenpages-1, service.id=129} {org.osgi.service.packageadmin.PackageAdmin}={service.ranking=2147483647, service.pid=0.com.springsource.server.osgi.framework.equinox.EquinoxOsgiFramework$LockEnforcingPackageAdmin, service.vendor=Eclipse.org, service.id=1} {org.xml.sax.EntityResolver}={service.id=32} {org.springframework.beans.factory.xml.NamespaceHandlerResolver}={service.id=31}
As can be seen in this output the greenpages.Directory
service is being provided by a bundle
with a symbolic name of greenpages-1-greenpages
: the service is coming from the
greenpages.app
bundle, rather than the greenpages.jpa
bundle.
The service which is being used by the Web module can be changed at runtime without having to restart the
application or dm Server. This can be achieved 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 module 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.