dev@jsr311.java.net

Re: "Dual dispatch"

From: Dhanji R. Prasanna <dhanji_at_gmail.com>
Date: Sat, 21 Apr 2007 14:24:49 +1000

I am curious, how is a TypeStreamingProvider intended to be registered to a
type? Is there a registry of such serializers? Or does each @HttpMethod need
to return a TypeStreamingProvider impl (as necessary)?

I would favor the registry of externalizers discussed in another thread
(registration with annotations), something like:

@URITemplate(...)
@Externalizer(Class<T>, Class<? extends TypeStreamingProvider<T>>)
//example psuedo-signature
public class InvoicesService {
//..
}

On 4/21/07, Stefan Tilkov <stefan.tilkov_at_innoq.com> wrote:

>
> OK; so what about
>
> @ProduceMime("application/invoice+xml,application/json,text/plain")
> @HttpMethod
> Invoices getInvoices() {...}


Yea, this should be the more appropriate case. I dont see the purpose for
several getAs...() methods all returning the same entity but with different
metadata annotations. Unless I've misunderstood how those should work, Paul?

I would propose:

@Produces(@MediaType("application/invoice+xml"),
@MediaType("application/json"), @MediaType(MediaTypes.TEXT_PLAIN)) //etc.
@HttpMethod
Invoices getInvoices() { ... }


> So does this mean I can do the following?
>
> @ProduceMime("text/plain")
> @HttpMethod
> String getLastComment() {...}
>
> @ProduceMime("application/xml")
> @HttpMethod



> javax.xml.transform.Source getDocument() {...}



Hmm, so something like an "inline" serializer + http service-method?
How would you distinguish between an raw entity (String xml) with an
external serializer and a representation (Document xml)? Perhaps Jerome's
suggestion of an @Output annotation has relevance here?

> Its sort of both, it enables a developer to write a plug-in for a
> > particular type that is portable across JSR 311 implementations.
> > The plug-in can be packaged with an application or separately. We
> > called it an SPI since its an API for extending the capabilities of
> > the runtime.
> >
>
> Does it really extend the runtime's capabilities? I'd argue that this
> is part of the user API, albeit possibly part of the 20% segment.


I agree, it doesn't seem like part of the spi. I also feel the
custom/portable serializers should be commonplace and not necessarily of the
20% segment. I can see users wanting to do some subtle modifications via
custom type serializers quite often.

Dhanji.