@Override
public Object readObject(AbstractHessianInput in, Object[] fields) throws IOException {
try {
Transcribable o = cls.newInstance();
in.addRef(o);
Map<String,Class> paramClassMap = new HashMap<String, Class>();
Parameter[] parameters = o.getParameters();
for (Parameter param : parameters) {
paramClassMap.put(param.getName(), param.getParameterType().getImplementationClass());
}
final Map<String, Object> fieldValues = new HashMap<String, Object>();
for (int i = 0; i < fields.length; i++) {
Class paramClass = paramClassMap.get(fields[i]);
fieldValues.put((String)fields[i], in.readObject(paramClass));//important to use the class so that hessian creates arrays of correct type
}
TranscriptionInput ti = new TranscriptionInput() {
@Override
public <T> T readObject(Parameter param, boolean client) throws Exception {
return (T) fieldValues.get(param.getName());
}
};
o.transcribe(ti, transcriptionParams, client);
return o;
} catch (Exception e) {
throw new IOException(e);