log.error("JSON invocation error", error);
}
private void initBridge(ServletConfig config, ApplicationContext applicationContext) throws ServletException {
// Create the JSON RPC Bridge (context-wide object)
JSONRPCBridge jsonBridge = new JSONRPCBridge(false);
try {
// Order is important !!!!
jsonBridge.registerSerializer(applicationContext.getBean("dojo.server.json.AnnotatedBeanSerializer",
AnnotatedBeanSerializer.class));
jsonBridge.registerSerializer(new GeometrySerializer());
jsonBridge.registerSerializer(new DtoGeometrySerializer());
jsonBridge.registerSerializer(new BigNumberSerializer());
jsonBridge.registerSerializer(new ArraySerializer());
jsonBridge.registerSerializer(new DictionarySerializer());
jsonBridge.registerSerializer(new MapSerializer());
jsonBridge.registerSerializer(new SetSerializer());
jsonBridge.registerSerializer(new ListSerializer());
jsonBridge.registerSerializer(new DateSerializer());
jsonBridge.registerSerializer(new StringSerializer());
jsonBridge.registerSerializer(new NumberSerializer());
jsonBridge.registerSerializer(new BooleanSerializer());
jsonBridge.registerSerializer(new PrimitiveSerializer());
jsonBridge.registerSerializer(new RectangleSerializer());
jsonBridge.registerSerializer(new ColorSerializer());
jsonBridge.registerSerializer(new FontSerializer());
jsonBridge.registerSerializer(new EnumSerializer());
} catch (Exception e) {
throw new ServletException("json : could not register all serializers", e);
}
// register the controller object
CommandDispatcher commandDispatcher = applicationContext.getBean("command.CommandDispatcher",
CommandDispatcher.class);
if (null == commandDispatcher) {
throw new ServletException(
"Cannot find CommandDispatcher, the org.geomajas.internal.global.GeomajasContextListener "
+ "was probably not registered.");
}
jsonBridge.registerObject("CommandDispatcher", commandDispatcher);
jsonBridge.registerCallback(this, HttpServletRequest.class);
// put in application context
config.getServletContext().setAttribute(JSON_RPC_BRIDGE_ATTRIBUTE, jsonBridge);
}