2

Here is what I am trying to do:

Create an interface (as an example):

@Path( "/" )
public interface Bubbles {

   @Get
   @Path( "blowBubble" )
   @Produces( "text/plain" )
   Bubble blowBubble();
}

Said interface should be deployed as a restful web service. I don't particularly care too much about the server side at this point, I mainly concerned with the client.

What I am looking for is a library where I can:

1) Implement the interface, without the interface knowing the full URL (knowing the server and port is obviously necessary (it is in the interface after all)

2) Automatically map 'Bubble' to json across the wire. No adding JAXB to it, no building type converters, etc automatically

My problem is that the 2 libraries I have used do 1 or the other, but not both :(

The Restlet library does 2 but not 1, CXF does 1 but not 2.

Are there any libraries that do both?

I have submitted bugs for both and the CXF dev's seem adamant that 2 should not be a feature - I don't understand why.

Thanks in advance.

EDIT #1:

To clarify my intent, I would like to use REST as the backing transport mechanism for SOA java. This transport should, IMO be transparent; if you have an annotated service interface to adhere to, then the client and server should not need to know anything about each other. They should operate on the contract. Furthermore, this API should be non-intrusive; example: I find that annotating business Objects\Entities with JAXB IS intrusive (what if I can't modify the source?).

javamonkey79
  • 17,443
  • 36
  • 114
  • 172
  • I am not sure if it will do it, but have you looked at spring rest or rest easy? – chrislovecnm Aug 08 '11 at 18:00
  • I was just looking at Spring today and it doesn't look like it fully supports both. I've looked at rest easy and I couldn't find good enough documentation that says either way. – javamonkey79 Aug 08 '11 at 20:50
  • Probably not going to like this answer, but you may need to extend the library that you choose. Rest Easy may do this for you, if I remember it will do interfaces out of the box, but I have never tried need #2 – chrislovecnm Aug 08 '11 at 21:25
  • I thought that might be the case and I've been trying to "get my foot in the door" so to speak with both projects. I've offered to submit patches to both and my requests seem to go unheard. I suppose I could roll my own project and not extend the existing ones... – javamonkey79 Aug 08 '11 at 23:32
  • Is this still the same problem you were having with http://stackoverflow.com/questions/6312030/cxf-no-message-body-writer-found-for-class-automatically-mapping-non-simple-r/6344047#6344047 or has your situation changed? – philwb Jan 25 '12 at 17:10
  • @philwb - My situation has not changed. Though the questions are similar, I think that question is more specific (tied to CXF), whereas this is more general. – javamonkey79 Jan 25 '12 at 19:48

3 Answers3

0

I think the best answer I can provide you is pick the best, most active stack and add your changes to make yourself the needed support. I do not believe there is a major player that meets yours needs.

chrislovecnm
  • 2,549
  • 3
  • 20
  • 36
-1

Restlet can implements the interface only if you use their own annotations (see ClientResource#create). I made my own code to handle jax-rs annotations...

For the second point, I don't know about CXF. We were using Restlet with Jackson which implements jax-rs commons interface (JacksonJsonProvider): MessageBodyWriter, MessageBodyReader. Perhaps, you can register this class to CXF. This may work since Jackson can work without annotations.

Sylvain
  • 446
  • 4
  • 6
  • Right, I am aware that Restlet is interface driven if you use the Restlet specific annotations. However, because the main library does not use JAX-RS, you have to know your URL's\full paths - which violates this constraint: "without the interface knowing the full URL" – javamonkey79 Jan 31 '12 at 20:27
  • I mention Restlet just to tell it can't reply to your first issue since I encounter the same problem. :) That's why I said I made "my own code" to handle JAX-RS annotations (and that's not really complicated). And what about the second point about CXF ? Can't you use Jackson ? – Sylvain Feb 01 '12 at 09:10
  • In order to use Jackson you still have to annotate your Objects with JAXB. – javamonkey79 Feb 01 '12 at 19:14
  • Because of CXF ? Because Jackson supports bean either: - without any annotations - with his annotations - with JAXB annotations – Sylvain Feb 02 '12 at 10:09
  • I am pretty sure you still need to annotate your Objects with JAXB, but who knows, I could be wrong. Show me a working example. – javamonkey79 Feb 02 '12 at 16:47
-1

actually CXF does both , when you use JAX-RS just annotate your method with

@Produces("application/json")

and you will get json output out of box

Igor Cunko
  • 59
  • 2
  • I think you missed part of the question: "No adding JAXB to it, no building type converters, etc automatically" With CXF, your objects have to have JAXB annotations, or you have to write message converters. – javamonkey79 Jan 31 '12 at 20:24