|
Page Created :
CXF :
Developing a Distributed OSGi Application in Eclipse
Developing a Distributed OSGi Application in Eclipse has been created by David Bosschaert (Dec 23, 2008). Content:This is really easy and assumes that you've already set up your Eclipse workspace as described here. 1. Create a new Plugin Project for a 'standard' OSGi Framework. 2. Create an OSGi service and and register it with the OSGi Service Registry. I'm creating a service that implements my test.distributed.service.TemperatureService. package test.distributed.service; import java.util.Date; public interface TemperatureService { int getTemperature(Date date, String city, boolean celcius); } The service is registered with the OSGi Service Registry in the Activator. package test.distributed.service; import java.util.*; import org.osgi.framework.*; public class Activator implements BundleActivator { private ServiceRegistration registration; public void start(BundleContext bc) throws Exception { Dictionary props = new Hashtable(); props.put("osgi.remote.interfaces", "*"); registration = bc.registerService(TemperatureService.class.getName(), new TemperatureServiceImpl(), props); } public void stop(BundleContext context) throws Exception { registration.unregister(); } } The only thing you need to do to expose a service remotely is setting the osgi.remote.interfaces property to the (comma separated) list of interfaces of the service that need to be exposed. Specifying * simply takes all the interfaces that were passed in to the registerService() call. props.put("osgi.remote.configuration.type", "pojo"); props.put("osgi.remote.configuration.pojo.address", "http://localhost:8888/temp"); |
Unsubscribe or edit your notifications preferences
