To package the demo into an OSGI bundle enter the following command:
>
ant osgi
When Ant finishes building and packaging the demo you will find the bundle in the
build
folder.
Once you have packaged your application into a bundle, you must install it to a running OSGi container. How you install bundles into your OSGi container will depend on your OSGi container.
Use the install command from the FUSE ESB's OSGi command shell to install it into the container as shown in Example 4.6.
Example 4.6. Installing HelloWorld to the FUSE ESB Container
servicemix osgi>
install file:
SampleDir
/build/wsdl_first.jarBundle ID: 134
![]() | Tip |
---|---|
FUSE ESB has a hot deployment feature that automates the installation and starting of OSGi bundles. Any bundle copied into
FUSE ESB's |
Before an application can be used the bundle containing the service implementation must be moved into the active life-cycle state and all of the bundles containing dependencies must be in the resolved, or active, life-cycle state.
In the demo, the bundle contains a Spring configuration file that defines the endpoint to be created by the application. FUSE ESB comes pre-loaded
with the Spring-DM extender bundle. The Spring-DM extender bundle creates a Spring ApplicationContext
for
the jaxws:endpoint
element included in the endpoint bundle's
META-INF/spring
directory. For more information about writing Spring configuration for
a service provider see Configuring Service Providers.
When starting the bundle, the container begins trying to resolve all of the bundle's dependencies. Once the endpoint's bundle's dependencies are resolved, the container activates it.
To start the demo from FUSE ESB's osgi command shell use the start command as shown in Example 4.7.
Example 4.7. Starting the HelloWorld OSGi Sample
servicemix osgi>
install 134
Jan 18, 2009 6:09:35 PM org.apache.cxf.endpoint.ServerImpl initDestination INFO: Setting the server's publish address to be http://localhost:9000/SoapContext/SoapPort
Once the endpoint bundle is fully started, the HelloWorld service provider is ready to accept requests from consumers. To test the application you can run the client against the service provider by executing the ant client command. Example 4.8 shows the expected results.
Example 4.8. Output from HelloWorld
Buildfile: build.xml
maybe.generate.code:
compile:
build:
client:
[java] file:/home/emjohnson/iona/fsf213/samples/wsdl_first_osgi/wsdl/hello_world.wsdl
[java] Invoking sayHi...
[java] Server responded with: Bonjour
[java]
[java] Invoking greetMe...
[java] Server responded with: Hello emjohnson
[java]
[java] Invoking greetMe with invalid length string, expecting exception...
[java] Caught expected WebServiceException:
[java] Marshalling Error: cvc-maxLength-valid: Value 'Invoking greetMe with invalid length string, expecting exception...' with length = '67' is not facet-valid with respect to maxLength '30' for type 'MyStringType'.
[java]
[java] Invoking greetMeOneWay...
[java] No response from server as method is OneWay
[java]
[java] Invoking pingMe, expecting exception...
[java] Expected exception: PingMeFault has occurred: PingMeFault raised by server
[java] FaultDetail major:2
[java] FaultDetail minor:1
BUILD SUCCESSFUL
Total time: 6 seconds
When you are ready to take the service provider off line you can simply move it from the active state to the resolved state. This will shut down the service provider and free the resources it is using. However, the contents of the application's bundle remain available to other bundles.
To stop a bundle in FUSE ESB you use the stop command from the osgi command shell.
![]() | Tip |
---|---|
Stopped bundles can be easily reactivated using the start command. |
When you want to completely remove any resources exposed by your application's bundles you need to uninstall the bundles. Once a bundle is uninstalled none of its exported resources are available to bundles in the container. It also cannot be re-started. It must be reinstalled before it can be used again.
To uninstall bundles from the FUSE ESB container you use the uninstall command from the osgi command shell.