/** * Register a service with the OSGi environment in a standardized way. The service properties * {@link org.osgi.framework.Constants#SERVICE_PID} and {@link org.osgi.framework.Constants#SERVICE_DESCRIPTION} are * created properly. */ public static ServiceRegistration registerService(ComponentContext cc, Object o, Class serviceClass, String serviceDescription) { if (!serviceClass.isAssignableFrom(o.getClass())) throw new Error("Service " + o + " is not of type " + serviceClass); final Dictionary props = dict(tuple(SERVICE_PID, o.getClass().getName()), tuple(SERVICE_DESCRIPTION, serviceDescription)); return cc.getBundleContext().registerService(serviceClass.getName(), o, props); }
/** OSGi callback. */ public synchronized void activate(ComponentContext cc) throws ConfigurationException { logger.info("[{}] Start", this.getClass().getName()); this.cc = cc; if (!needConfig()) { updated(dict()); } }