type = typeSet.findTypeByMatch(key, value);
}
}
}
Variable variable = null;
if (type!=null) {
Class<?> variableClass = type.getVariableClass();
try {
log.trace("creating new "+type+" variable "+key);
variable = (Variable) variableClass.newInstance();
} catch (Exception e) {
throw new JbpmException("couldn't instantiate variable instance class '"+variableClass.getName()+"'");
}
Converter converter = type.getConverter();
variable.setConverter(converter);
} else {
if (value==null) {
log.trace("creating null variable for "+key);
variable = new NullVariable();
} else {
log.trace("creating new unpersistable variable for "+key);
variable = new UnpersistableVariable();
}
}
variable.setKey(key);
variable.setExecution(getExecution());
variable.setTask(getTask());
variable.setHistoryEnabled(isHistoryEnabled);
if (isHistoryEnabled) {
HistoryEvent.fire(new VariableCreate(variable));
}
variable.setValue(value);
return variable;
}