use of org.eclipse.smarthome.config.core.validation.ConfigDescriptionValidator in project smarthome by eclipse.
the class BaseThingHandler method setBundleContext.
@SuppressWarnings({ "unchecked", "rawtypes" })
public void setBundleContext(final BundleContext bundleContext) {
this.bundleContext = bundleContext;
thingRegistryServiceTracker = new ServiceTracker(this.bundleContext, ThingRegistry.class.getName(), null) {
@Override
public Object addingService(@Nullable final ServiceReference reference) {
thingRegistry = (ThingRegistry) bundleContext.getService(reference);
return thingRegistry;
}
@Override
public void removedService(@Nullable final ServiceReference reference, @Nullable final Object service) {
synchronized (BaseThingHandler.this) {
thingRegistry = null;
}
}
};
thingRegistryServiceTracker.open();
thingTypeRegistryServiceTracker = new ServiceTracker(this.bundleContext, ThingTypeRegistry.class.getName(), null) {
@Override
public Object addingService(@Nullable final ServiceReference reference) {
thingTypeRegistry = (ThingTypeRegistry) bundleContext.getService(reference);
return thingTypeRegistry;
}
@Override
public void removedService(@Nullable final ServiceReference reference, @Nullable final Object service) {
synchronized (BaseThingHandler.this) {
thingTypeRegistry = null;
}
}
};
thingTypeRegistryServiceTracker.open();
configDescriptionValidatorServiceTracker = new ServiceTracker(this.bundleContext, ConfigDescriptionValidator.class.getName(), null) {
@Override
public Object addingService(@Nullable final ServiceReference reference) {
configDescriptionValidator = (ConfigDescriptionValidator) bundleContext.getService(reference);
return configDescriptionValidator;
}
@Override
public void removedService(@Nullable final ServiceReference reference, @Nullable final Object service) {
synchronized (BaseThingHandler.this) {
configDescriptionValidator = null;
}
}
};
configDescriptionValidatorServiceTracker.open();
}
Aggregations