use of org.eclipse.smarthome.core.thing.type.ChannelTypeRegistry in project smarthome by eclipse.
the class SystemProfileFactoryTest method setup.
@Before
public void setup() {
channelTypeRegistry = new ChannelTypeRegistry();
factory = new SystemProfileFactory();
factory.setChannelTypeRegistry(channelTypeRegistry);
}
use of org.eclipse.smarthome.core.thing.type.ChannelTypeRegistry in project smarthome by eclipse.
the class ThingFactoryHelper method withChannelTypeRegistry.
@SuppressWarnings({ "rawtypes", "unchecked" })
private static <T> T withChannelTypeRegistry(Function<ChannelTypeRegistry, T> consumer) {
BundleContext bundleContext = FrameworkUtil.getBundle(ThingFactoryHelper.class).getBundleContext();
ServiceReference ref = bundleContext.getServiceReference(ChannelTypeRegistry.class.getName());
try {
ChannelTypeRegistry channelTypeRegistry = null;
if (ref != null) {
channelTypeRegistry = (ChannelTypeRegistry) bundleContext.getService(ref);
}
return consumer.apply(channelTypeRegistry);
} finally {
if (ref != null) {
bundleContext.ungetService(ref);
}
}
}
Aggregations