Monday, February 9th, 2009

CP2JavaWS: GWT like Cappuccino to Java remote services bridge

Category: Java

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:


  1. var endPoint = [CP2JavaWSEndPoint
  2. createForURL:@"http://localhost:8080/CP2JavaWSServletTest/CP2JavaWSEndpoint1"];
  4. var remoteService = [endPoint proxyForJavaServiceInterface:@"" delegate:self sameDomain:true];
  6. [remoteService method1:@"arg1StringValue"
  7. 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:

  1. 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).

More info

Posted by Dion Almaer at 5:40 am

4.3 rating from 12 votes


Comments feed TrackBack URI

A new 0.31 version is available at sourceforge (sorry, I emailed you about that shortly before the article was published :-)), that uses a filter instead of a servlet, and provides hooks for spring container or custom ones in the form of plugins/support jars (it doesn’t require unused containers dependencies). Then the server config has changed (documentation has been updated).

I still plan changes on the server config (remove the cp2javaws SpringContextWrapperListener by injecting the spring context in a contextHolder singleton object that implements spring’s contextAware interface. But then for other frameworks/containers to work, they would need some basic static initialization – if not providing such injection -, as the context holder singleton won’t have access to the servlet context (available only from the current listeners). It should however be ok for most frameworks.

Comment by jdenanot — February 9, 2009

Is Objective J gathering some interest now that so many programmers are learning Objective C for iPhone development?

Comment by Nosredna — February 9, 2009

Dear Friends

I am new to spring and Cappuccino both technology. any one can send me the sample application for Cappuccino to spring web services.

I have downloaded sample application (CP2JavaWS_1_0_4) from official site but i’m not getting flow and those mappings.

Thanks in advance. any help can be appreciated.
My Email id’s :

Lakhaman Odedra

Comment by slkraviatechlabspvtltd — June 27, 2011

Leave a comment

You must be logged in to post a comment.