users@jersey.java.net

Re: Re: [Jersey] understanding content types and resource methods

From: John Calcote <john.calcote_at_gmail.com>
Date: Sat, 19 Dec 2009 12:21:20 -0700

Robert,

Thanks for the quick response...

On 12:59 PM, Robert Koberg wrote:
>
> You probably want a @Path, e.g.
>
>
> @Path("/message")
>
>> @POST
>> @Consumes("application/vnd.com.example-v1+xml")
>> public Response postMessageA(JAXBElement<MessageA> msg) {
>> MessageA msgA = msg.getValue();
>> ...
>> }
>>
>>
> @Path("/message/updated-event")
> // or if you want to identify the message being updated, perhaps
> //_at_Path("/message/{messageId}/updated-event")
>
>> @POST
>> @Consumes("application/vnd.com.example-v1+xml")
>> public Response postMessageB(JAXBElement<MessageB> msg) {
>> MessageB msgB = msg.getValue();
>> ...
>> }
>>
>>

In reality, this service is a simple event server, where each message is
an event to be POSTed to the servers event manager resource. The server
acts on the event but doesn't return anything other than ACCEPTED. Each
event type is a different Java object. There are only a few types of
event - perhaps 4 or 5 at the most.

As these are events being logged to an event service, I was hoping not
to have to send each different type of event object to a different URL.
My first thought was that each event is a different content type, but
one of my co-workers tells me it's improper to have a different mime
type per message. Rather, each web service should support a single
mime-type for all of it's messages.

John