|
|
@ -44,22 +44,10 @@ public class DiDeviceActuatorManager { |
|
|
|
throw new RuntimeException("Invalid actuators config"); |
|
|
|
} |
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
List<Map<String,Object>> actuators = (List<Map<String, Object>>) config; |
|
|
|
for ( Map<String,Object> actuatorConfig : actuators ) { |
|
|
|
// find actuator class |
|
|
|
String type = (String)actuatorConfig.get("type"); |
|
|
|
Class<?> actClazz = null; |
|
|
|
try { |
|
|
|
actClazz = Class.forName(type); |
|
|
|
} catch (ClassNotFoundException e) { |
|
|
|
String actClassName = "com.my.graphiteDigesterBg.diframe.actuator.DiAct" + type; |
|
|
|
try { |
|
|
|
actClazz = Class.forName(actClassName); |
|
|
|
} catch (ClassNotFoundException ex) { |
|
|
|
throw new RuntimeException(ex); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Class<?> actClazz = this.getActuatorClassByOptions(actuatorConfig); |
|
|
|
// create actuator instance |
|
|
|
Constructor<?> actuatorConstructor = null; |
|
|
|
try { |
|
|
@ -80,4 +68,40 @@ public class DiDeviceActuatorManager { |
|
|
|
this.actuators.put((String)actuatorConfig.get("key"), actuator); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// get actuator class by options |
|
|
|
private Class<?> getActuatorClassByOptions(Map<String,Object> options) { |
|
|
|
// find actuator class |
|
|
|
String type = (String)options.get("type"); |
|
|
|
Class<?> actClazz = null; |
|
|
|
try { |
|
|
|
actClazz = Class.forName(type); |
|
|
|
} catch (ClassNotFoundException e) { |
|
|
|
String actClassName = "com.my.graphiteDigesterBg.diframe.actuator.DiAct" + type; |
|
|
|
try { |
|
|
|
actClazz = Class.forName(actClassName); |
|
|
|
} catch (ClassNotFoundException ex) { |
|
|
|
throw new RuntimeException(ex); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ( !actClazz.isInterface() ) { |
|
|
|
return actClazz; |
|
|
|
} |
|
|
|
|
|
|
|
// find implement class if actuator class is an interface |
|
|
|
String actImplName = (String)options.get("implement"); |
|
|
|
try { |
|
|
|
actClazz = Class.forName(actImplName); |
|
|
|
} catch (ClassNotFoundException e) { |
|
|
|
String actImplClassName = "com.my.graphiteDigesterBg.diframe.actuator.impl.DiAct" + actImplName; |
|
|
|
try { |
|
|
|
actClazz = Class.forName(actImplClassName); |
|
|
|
} catch (ClassNotFoundException ex) { |
|
|
|
throw new RuntimeException(ex); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return actClazz; |
|
|
|
} |
|
|
|
} |