Hi,

in this tutorial, Christian explains how to use CXF to exposed WebService in Karaf, not OSGI services.

Basically, an OSGi service is simply an interface.

You register the impl in the service registry using this interface.

For instance, in one bundle (the provider bundle), you have an interface:

public interface HelloService {
  public String hello(String message);
}

And you have the impl:
public class HelloServiceImpl implements HelloService {
  public String hello(String message) {
    return "hello " + message;
  }
}

You register the service in the OSGi service registry:

bundleContext.registerService(HelloService.class, new HelloServiceImpl(), null);

Another bundle (consumer bundle), can lookup the OSGi service registry to get the service and call operation on the service:

ServiceReference ref = bundleContext.getServiceReference(HelloService.class);
if (ref != null) {
  HelloService service = (HelloService) bundleContext.getService(ref);
  System.out.println(service.hello("budy"));
  bundleContext.ungetService(ref);
}

Regards
JB

On 06/25/2014 07:07 PM, parker wrote:
Hi

Today I have :
I have a bundle for logging and  the bundle for person (tuto part 4 :
http://www.liquid-reality.de/display/liquid/2011/12/22/Karaf+Tutorial+Part+4+-+CXF+Services+in+OSGi
<http://www.liquid-reality.de/display/liquid/2011/12/22/Karaf+Tutorial+Part+4+-+CXF+Services+in+OSGi>

I would like to create a OSGi service. The goal of this OSGi service is than
the bundle for person become a message provider and the bundle logging
become a message consumer.

How to do it ?

Thank you for your advice






--
View this message in context: 
http://karaf.922171.n3.nabble.com/Karaf-Tutorial-Part-4-CXF-Services-in-OSGi-tp4033785.html
Sent from the Karaf - User mailing list archive at Nabble.com.


--
Jean-Baptiste Onofré
[email protected]
http://blog.nanthrax.net
Talend - http://www.talend.com

Reply via email to