}
public void encode(Object obj, JPAServletContext ctx) {
if (obj instanceof OpenJPAStateManager) {
try {
JSON result = encodeManagedInstance((OpenJPAStateManager)obj,
ctx.getPersistenceContext().getMetamodel());
PrintWriter writer = ctx.getResponse().getWriter();
writer.println(result.toString());
} catch (Exception e) {
throw new ProcessingException(ctx, e);
}
} else {
throw new RuntimeException(this + " does not know how to encode " + obj);