public interface GreetingService {
String sayHello(String name);
}
public class GreetingServiceImpl implements GreetingService {
public String sayHello(String name) {
return "Hello, " + name + "!";
}
}
public class MyModuleActivator implements BundleActivator {
public void start(BundleContext context) throws Exception {
GreetingService greetingService = new GreetingServiceImpl();
Dictionary<String, Object> props = new Hashtable<>();
props.put("service.exported.interfaces", GreetingService.class.getName());
context.registerService(GreetingService.class.getName(), greetingService, props);
}
public void stop(BundleContext context) throws Exception {
}
}