Search in sources :

Example 1 with ChannelTypeRegistry

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);
}
Also used : ChannelTypeRegistry(org.eclipse.smarthome.core.thing.type.ChannelTypeRegistry) Before(org.junit.Before)

Example 2 with 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);
        }
    }
}
Also used : ChannelTypeRegistry(org.eclipse.smarthome.core.thing.type.ChannelTypeRegistry) BundleContext(org.osgi.framework.BundleContext) ServiceReference(org.osgi.framework.ServiceReference)

Aggregations

ChannelTypeRegistry (org.eclipse.smarthome.core.thing.type.ChannelTypeRegistry)2 Before (org.junit.Before)1 BundleContext (org.osgi.framework.BundleContext)1 ServiceReference (org.osgi.framework.ServiceReference)1