users@jersey.java.net

[Jersey] Re: Decoding URI into path parameters

From: Markus Karg <markus.karg_at_gmx.net>
Date: Thu, 17 Mar 2011 20:12:26 +0100

Yes, for those references marked with @XmlJavaTypeAdapter this is what
happens at unmarshalling of a received JAXB document.

 

I will post a complete source code tomorrow showcasing the scenario.

 

From: Gili [mailto:cowwoc_at_bbs.darktech.org]
Sent: Donnerstag, 17. März 2011 16:06
To: users_at_jersey.java.net
Subject: [Jersey] Re: Decoding URI into path parameters

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    Just curious: what do you mean "it replaced them by an instance using a
subsequent HTTP GET"? Are you saying it fires an HTTP GET for any URI you
send and converts it into an entity depending on the body?

Thanks,
Gili

On 17/03/2011 10:03 AM, Martin Matula-3 [via Jersey] wrote:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> Hi Markus -
good point! I guess we should add a paragraph on this to our user guide as
well as a sample. Please do share the snipped or even better feel free to
contribute the sample.
Thanks!
Martin

On 17.3.2011 10:52, Markus Karg wrote:

Side Note: Using XmlAdapter you can performan translation of URI<--->Entity
on the fly (when sending entity trees it replaces entity references by URIs,
and when receiving entity URIs it replaces them by an instance using a
subsequent HTTP GET). We're using this heavily in our application and it
works pretty well. Maybe this makes your code easier for you. If you like I
can post a snippet.

 

From: Gili [[hidden email]]
Sent: Mittwoch, 16. März 2011 23:02
To: [hidden email]
Subject: [Jersey] Re: Decoding URI into path parameters

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    That's exactly what I was looking for. Thank you!

PS: Is it possible to use regex in the template? For example, I'd want to
match any host name to support clustering.

Thanks,
Gili

On 16/03/2011 5:52 PM, Martin Matula-3 [via Jersey] wrote:

Hi Gili,

On Mar 16, 2011, at 4:47 PM, Gili wrote:

> If a user invokes HTTP PUT with a body that contains URIs, how should I
> translate those URIs back to resource identifiers? Am I expected to hit
the
> URI, examine the body in order to figure out the resource identity or
should
> I parse the URI to an ID somehow? What's the best practice?

You can use UriTemplate (see
http://jersey.java.net/nonav/apidocs/1.5/jersey/com/sun/jersey/api/uri/UriTe
mplate.html).

For example, like this:

        // create URI template object for a given template
        UriTemplate ut = new
UriTemplate("http://localhost:8080/context/jersey/books/{id}/page/{pageNum}"
);
        // this hashmap will be populated with param name->value mapping
after the URI is matched
        HashMap<String, String> m = new HashMap<String, String>();
        // match the URI passed in the first parameter, populate the map in
the second parameter with params and values
        ut.match("http://localhost:8080/context/jersey/books/20/page/10
<http://localhost:8080/context/jersey/books/20/page/10%22> ", m);
        // extract book ID from the URI
        int bookId = m.get("id");

Is that good enough for what you need?
Martin

  _____

If you reply to this email, your message will be added to the discussion
below:

http://jersey.576304.n2.nabble.com/Decoding-URI-into-path-parameters-tp61677
50p6179023.html
<http://jersey.576304.n2.nabble.com/Decoding-URI-into-path-parameters-tp6167
750p6179023.html?by-user=t&by-user=t&by-user=t>

To unsubscribe from Decoding URI into path parameters, click here
<http://jersey.576304.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscri
be_by_code&node=6167750&code=Y293d29jQGJicy5kYXJrdGVjaC5vcmd8NjE2Nzc1MHwxNTc
0MzIxMjQ3&by-user=t&by-user=t&by-user=t> .

 

  _____

View this message in context: Re: Decoding URI into path parameters
<http://jersey.576304.n2.nabble.com/Decoding-URI-into-path-parameters-tp6167
750p6179046.html?by-user=t&by-user=t>
Sent from the Jersey mailing list archive
<http://jersey.576304.n2.nabble.com/?by-user=t&by-user=t> at Nabble.com.

 

  _____

If you reply to this email, your message will be added to the discussion
below:

http://jersey.576304.n2.nabble.com/Decoding-URI-into-path-parameters-tp61677
50p6180997.html
<http://jersey.576304.n2.nabble.com/Decoding-URI-into-path-parameters-tp6167
750p6180997.html?by-user=t>

To unsubscribe from Decoding URI into path parameters, click here
<http://jersey.576304.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscri
be_by_code&node=6167750&code=Y293d29jQGJicy5kYXJrdGVjaC5vcmd8NjE2Nzc1MHwxNTc
0MzIxMjQ3&by-user=t> .

 

  _____

View this message in context: Re: Decoding URI into path parameters
<http://jersey.576304.n2.nabble.com/Decoding-URI-into-path-parameters-tp6167
750p6181284.html>
Sent from the Jersey mailing list archive
<http://jersey.576304.n2.nabble.com/> at Nabble.com.