Hi Florian,
Your attachment looks really good.
It should also be possible to implement the readFrom method as a SAX
filter that push fake start/end document events wrapped around each
child of the root element and pass this to JAXB unmarshalling.
Also not that the current JAXB entity provider supports JSON as well as
XML, it should be easy to support marshaling, but unmarshaling may be
tricker (depending on the low-level JSON parsing support).
My only main concern Collection<?> is very general and this is specific
to JAXB, and Collection<?> may make sense in other contexts for other
Java types.
Perhaps we can include this but not add it by default to the
javax.ws.rs.ext.EntityProvider file? Thus developers wishing to avail of
this functionality need to explicitly create the services file.
Paul.
Florian Rosenberg wrote:
> On Tue, October 23, 2007 10:16, Paul Sandoz wrote:
>> Florian Rosenberg wrote:
>>>> Some possible solutions:
>>>>
>>>> 1) We could provide a Collection type entity provider that checks if
>>>> all
>>>> of the objects are JAXB element objects, if so a root element is
>>>> written out and then each JAXB element is marshalled.
>>>>
>>>> 2) A generic collection type class with an entity provider:
>>>>
>>>> class CollectionType<T> {
>>>> Collection<T> c;
>>>>
>>>> CollectionType(Collection<T> c) { ... }
>>>> }
>>>>
>>>> The entity provider can then create a JAXBElement instance:
>>>>
>>>> QName q = // work out root element name from c
>>>> new JAXBElement(q, CollectionType.class, c)
>>> I would go with (1) just for simplicity and it allows the user to stick
>>> to
>>> his preferred API without used the typed collection.
>> Right. Since similar classes for 2) i have mentioned will be required
>> for an implementation of 1) i think i can expose various things out
>> depending on if developers need simplicity, performance or configuration
>> of the root element and for each case don't require to create a
>> collection class for each entry class.
>>
>> https://jersey.dev.java.net/issues/show_bug.cgi?id=18
>
> hopefully, I have some time to help on that issues this week...
>
>>> when going for (1)
>>> you need to find a name for the root element, eg., customers if the
>>> objects in the collection are of type Customer.
>>>
>> Yes, same applies for 2). I need some pluralizer code that given a
>> singular word returns the plural. I suppose i could append an 's', know
>> of anything better i could use?
>
> I send a link as a response to Mark's posting but I don't now how mature
> it is.
>
> appending an "s" as a first draft seems to be fine, but there are a lot of
> exceptions, e.g., people has both, a plural and singular sense. some other
> exception are:
>
> man -> men
> thief -> thieves
> person -> people
>
> -Florian
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109