Monday, February 9th, 2009p>Jerome Denanot has created CP2JavaWS, an open source “bridge between Cappuccino rich desktop applications and Java services deployed on a web server. It consists of a proxy (client side) and a servlet (server side), and manages parameters namespace, encoding, ordering and JSONP.”
Jerome told us more:
Full objects graphs are supported for services method’s arguments and return (see provided example in the distribution), including nested collections (List and Map) and heterogeneous collection elements.
Its use is as easy as with GWT (and does not require any generation step thanks to the Objective-J runtime – interpreter step at runtime).
On the client-side:
- var endPoint = [CP2JavaWSEndPoint
- var remoteService = [endPoint proxyForJavaServiceInterface:@"com.cp2javaws.demo.services.IDemoService1" delegate:self sameDomain:true];
- [remoteService method1:@"arg1StringValue"
- andWithArg2:2 andWithArg3:new Date() delegateRespHandler:@selector(manageServiceMethod1Response:) delegateFailHandler:@selector(manageServiceMethod1Fail:)];
On the server-side:
Just subclass the provided CP2JavaWSJSONServlet servlet and implement the (abstract) method:
- protected Object getService(Class serviceInterface)
A mapping file (see provided example) has to be put on the server-side for custom objects (maps custom Objective-J objects classname to corresponding Java custom objects classname).
Posted by Dion Almaer at 5:40 am