public void register(StarterNode node) throws InvocationTargetException {
try {
Class<?>[] constArgsType = new Class[args.size()];
Object[] constArgsVal = new Object[args.size()];
int index = 0;
for(Object arg: args) {
constArgsType[index] = arg.getClass();
constArgsVal[index] = arg;
index++;
}
Connection<?> cnx = type.getConstructor(constArgsType).newInstance(constArgsVal);
for(Map.Entry<String, String> e: beansValue.entrySet()) {
String textValue = Util.parseTemplate(e.getValue(), cnx);
ArgFactory.beanSetter(cnx, e.getKey(), textValue);
cnx.log(Level.TRACE, "Setting bean '%s' to value '%s' for %s", e.getKey(), textValue, node);
}
if(name != null && !name.trim().isEmpty())
cnx.setName(name.trim());
node.registerStarter(cnx);
logger.debug(Util.delayedFormatString("Connexion registred: %s for %s", cnx, node));
} catch (InvocationTargetException ex) {
String message = ex.getCause() != null ? ex.getCause().getMessage(): ex.getMessage();
throw new InvocationTargetException(ex.getCause(), "Error during connection creation of type " + type.getName() + " for " + node + ": " + message);
} catch (Exception ex) {
throw new InvocationTargetException(ex, "Error during connection creation of type " + type.getName() + " for " + node);
}
}