When not providing an accept.

0 views
Skip to first unread message

jdbj...@gmail.com

unread,
Feb 1, 2011, 7:38:41 AM2/1/11
to restfu...@googlegroups.com
Hi,

The restfulie-java version should return an specific resource even
when no MediaType have been registered?

Response response = Restfulie.at("http://mydomain.com/item/1").get();
// How it is supposed to know that he should marshall for this Item class?
Item item = response.getResource();

Or we will always have to provide the types been marshall/unmarshall?

Restfulie client = Restfulie.custom();
// annotating the Item class with @XStreamAlias
client.register(new XmlMediaType().withTypes(Item.class));

Regards.

Guilherme Silveira

unread,
Feb 1, 2011, 8:09:18 AM2/1/11
to restfulie-dev
Hi Doni,

By default, there are already a few media type drivers registered, so
if they know how to deserialize an Item by default, great! (1st
example)
If they don't, so you need to teach them (2nd example).

Unlike Rails and Ruby where devs write their app code without any
namespace, in Java we use packages all the time. That means the
deserializer wont know where the <item> ==> "Item" class is to be
found. So the minimal config would be to set up a default package and
load classes from that package.

Using the xstream based xml driver, that means just changing how
xstream behaves by default with unknown elements
What do you think?
Regards

Guilherme Silveira
Caelum | Ensino e Inovação
http://www.caelum.com.br/

Jose Donizetti

unread,
Feb 1, 2011, 8:22:33 AM2/1/11
to restfu...@googlegroups.com
Hi Gui,

The first example won't be used frequently, right? Cos' as you said we
are always using packages.
I was considering implement some package-scan, so that we can find any
class annotated with @XStreamAlias and register it automatically on
the defaults MediaTypes. Dunno if it is the same think you said about
changing XStream default behaviour.
What would that be like?

Regards.

Guilherme Silveira

unread,
Feb 2, 2011, 10:00:59 AM2/2/11
to restfulie-dev
Yep... package scanning would work just fine. Might work in a
unexpected way if there are two sets of serializable types. But then
just give an option to turn-on the scanning, what do you think?

Regards

Guilherme Silveira
Caelum | Ensino e Inovação
http://www.caelum.com.br/

Reply all
Reply to author
Forward
0 new messages