Register a command provider as an OSGi service in order to make it available to the Home Automation Manager.
Key |
Value |
|---|---|
"command_type" (com.prosyst.mbs.services.ham.Command.TYPE) |
<your_command_type> |
"configurable_type" (com.prosyst.mbs.services.configtree.Configurable.CONFIGURABLE_TYPE) |
<your_command_type> |
Alternatively, use the createRegistrationProperties() method from BaseCommandProvider to build the dictionary automatically.
The following example shows a service provider Activator class that registers the command provider from the previous example
package demo.command.impl;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import com.prosyst.mbs.services.configtree.Configurable;
import com.prosyst.mbs.services.ham.spi.CommandProvider;
public class Activator implements BundleActivator {
private static BundleContext context;
static BundleContext getContext() {
return context;
}
DemoCommandProvider provider;
ServiceRegistration servRerg;
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
provider = new DemoCommandProvider();
servRerg = context.registerService(
// The provider class is registered both as
// a CommandProvider and as a Configurable
new String[] { CommandProvider.class.getName(), Configurable.class.getName() }, provider, provider.createRegistrationProperties());
}
public void stop(BundleContext bundleContext) throws Exception {
if (provider != null) {
provider.release();
provider = null;
}
if (servRerg != null) {
servRerg.unregister();
servRerg = null;
}
}
}