if (null != oclass && !super.isProxy(oclass)) {
final BeanData bd;
try {
bd = BeanSerializer.getBeanData(oclass);
} catch (IntrospectionException e) {
throw new MarshallException(oclass.getName()
+ " is not a bean", e);
}
if (_ser.getMarshallClassHints()) {
try {
val.put(IJSONRPCConstants.TAG_JAVACLASS,
oclass.getName());
} catch (Exception e) {
throw new MarshallException(
"JSONException: " + e.getMessage(), e);
}
}
final Iterator i = bd.readableProps.entrySet().iterator();
final Object args[] = new Object[0];
Object result;
while (i.hasNext()) {
final Map.Entry ent = (Map.Entry) i.next();
final String prop = (String) ent.getKey();
final Method getMethod = (Method) ent.getValue();
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "invoking {0}()", getMethod.getName());
}
try {
result = getMethod.invoke(o, args);
} catch (Throwable e) {
if (e instanceof InvocationTargetException) {
e = ((InvocationTargetException) e).getTargetException();
}
throw new MarshallException("bean " + oclass.getName()
+ " can't invoke " + getMethod.getName() + ": " + e.getMessage(), e);
}
try {
if (result != null || _ser.getMarshallNullAttributes()) {
try {
Object json = _ser.marshall(state, o, result, prop);
// omit the object entirely if it's a circular reference or duplicate
// it will be regenerated in the fixups phase
if (JSONSerializerController.CIRC_REF_OR_DUPLICATE != json) {
val.put(prop, json);
}
} catch (JSONException e) {
throw new MarshallException(
"JSONException: " + e.getMessage(), e);
}
}
} catch (MarshallException e) {
throw new MarshallException("bean " + oclass.getName() + " " + e.getMessage(), e);
}
}
}
return val;