Class<? extends Controller> clazz = this.factories.get(device.getType().toString());
if (clazz == null) {
throw new DagoException(I18N.format(I18NMessages.noControllerFound, device.getType()));
}
Controller controller;
try {
// Creates the controller
controller = clazz.newInstance();
// Initialize the controller
controller.initialize(device);
return controller;
}
catch (Exception err) {
throw new DagoException(I18N.format(I18NMessages.failToCreateController, device.getType(), err), err);
}