Does the GreeterImpl
correctly provide the Greeter
service? Who knows? Let's connect
the Greeter service to a web server to create an endpoint that allows HTTP requests
to invoke the service.
- Read the REAMDE. It is chock-full of goodness.
Add the JAX-RS annotations to hello
method to make it a web service. (You will also need
to add new dependencies to the POM file so that the annotations are recognized)
@GET
@Path("/hello/{name}")
@Produces(MediaType.TEXT_PLAIN)
- Turn to a neighbor and explain what each of the three JAX-RX annotations is supposed to do.
Add Blueprint instructions to blueprint.xml
that create the web server
- Update the
<blueprint>
element's attributes to include some new XML namespaces. The new namespaces arecxf
(the application server) andjaxrs
the annotations. Theblueprint
tag should look like:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cxf="http://cxf.apache.org/blueprint/core"
xmlns:jaxrs="http://cxf.apache.org/schemas/jaxrs.xsd">
- Add an element to create the something called the bus". I think this is the transport layer that all of your CXF applications (servers) will use to communicate using HTTP.
<cxf:bus id="greetingServiceBus">
<cxf:features>
<cxf:logging/>
</cxf:features>
</cxf:bus>
- Register the bean that provides the service with the application:
<jaxrs:server address="/greeting" id="greetingRest">
<jaxrs:serviceBeans>
<ref component-id="greetingImpl"/>
</jaxrs:serviceBeans>
</jaxrs:server>
NOTE TO SELF: I don't think we need the directive at this point. We aren't really using an OSGi service lookup anywhere. We needed it in the original Karaf tutorial because we created a class called `GreetingRest` that needed the service. We injected the service provider into `GreetingRest` with Blueprint, in the directive ``. Mabye change up the tutorial to first create and use multiple providers **then** expose all that as a webservice?
- What do you think would happen if you built the bundle and installed in Karaf?
- Try it and find out.