users@jersey.java.net

Re: [Jersey] MessageBodyWriter<T>.writeTo change?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 18 Aug 2008 09:06:12 +0200

On Aug 16, 2008, at 10:45 PM, Daniel Larsson wrote:

> Right now, I'm mostly playing with Jersey and Jena for fun, but if
> something comes out of it, I'll let you know :)
>
> So far I haven't exposed a direct SPARQL interface. It's probably
> more interesting to expose the RDF, to enable federated SPARQL
> queries of the data. The queries are used internally, and I'm
> returning the results as JSON/XML/RDF (e.g. as input to jMaki
> components).
>
> I looked at the caboto project a bit, looks interesting :). Your
> Jena model provider is pretty much identical to one I wrote.
> However, I noted one big difference, your provider uses
> MessageBodyWriter<Object>. I tried using MessageBodyWriter<Model>
> (where Model is a java interface), but jersey wouldn't recognize it
> as a usable provider for my Jena models. What is the "proper" way
> of writing providers for interfaces? Is there any other way than
> using <Object>, and make a dynamic check in isWriteable? My strong
> typing "instincts" flinch at doing that ;-).
>

If all your model objects implement Model then you can do the
following in the isWriteable method:

   return Model.class.isAssignableFrom(type);

That would be my preferred way.

Paul.

> On Fri, Aug 15, 2008 at 12:50 PM, Mike Jones
> <mike.a.jones_at_gmail.com> wrote:
> I'd be very interested as well Daniel :-)
>
> I'm involved in a project that is using Jersey as a front-end to an
> RDF store although it doesn't allow direct SPARQL queries at the
> moment - although results are returned as RDF/XML, N3 or JSON. I'm
> using Jena SDB for the backend and Jena ARQ for the querying. Project
> is still in the early stages ... http://code.google.com/p/caboto/.
> Boring blog entry http://chillyinside.com/blog/?p=49
>
> Cheers
> Mike
>
> 2008/8/15 Paul Sandoz <Paul.Sandoz_at_sun.com>:
> > Hi Daniel,
> > Glad things are resolved. I thought NB would handle the
> dependencies, if you
> > you declare there is a dependence in the project properties. I
> know that if
> > using maven then unfortunately dependencies are not currently
> managed, which
> > is a real pain when there are lots of modules.
> > SPARQL queries eh? :-) if you blog about anything perhaps you can
> send a
> > link to the list.
> > Paul.
> > On Aug 15, 2008, at 2:13 AM, Daniel Larsson wrote:
> >
> > It seems to have been a syncing problem between my servlet and my
> jar
> > (containing the provider among other things) running in the
> glassfish
> > server. After rebuilding everything from scratch, and
> redeploying, it seems
> > to work again. I assumed NetBeans would handle such dependencies,
> but
> > apparently not.
> > Thanks for the help, Paul :)
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>