this.api = api;
this.parentContext = parentContext;
log.info("api=" + api + " device=" + device);
if ((device != null) && (api instanceof Driver)) {
Driver driver = (Driver) api;
try {
boolean registered = false;
try {
StubDeviceManager.INSTANCE.getDevice(device.getId());
registered = true;
} catch (DeviceNotFoundException e) {
registered = false;
}
device.setDriver(driver);
if (!registered) {
StubDeviceManager.INSTANCE.register(device);
}
} catch (DriverException e) {
log.error("Error while starting device " + driver.getDevice(),
e);
} catch (DeviceAlreadyRegisteredException e) {
log.error("Error while starting device " + driver.getDevice(),
e);
}
}
log.info(api.getClass().getName() + " initialized");