users@jersey.java.net

[Jersey] Jersey Server Linking

From: Bob Krier <rkrier_at_axway.com>
Date: Thu, 17 Oct 2013 22:29:15 +0000

Hi All,

I have a question about a feature that was in 1.7 and is no longer in 2.3. I was using the jersey-server-linking jar to build my URI links in my bean class. Now that is gone, it is messy for me to build them via URIBuilder. Here is why:

I have a bean called ExchangePoint which is abstract. You can think of an exchange point as the configuration of a HTTP client, FTP client, SFTP client, FilesystemClient, etc. Any given ExchangePoint can be owned by a different resource. In my case, the owner will be one of the following: A community, a trading partner or application delivery (produce or consume from some backend system).

Now my exchange point bean used to have a reference link configured as follows:

public abstract class ExchangePointBean
{
@JsonProperty("@id")
 private String id;
. // other fields.
.
.

@Ref(value = "${resource.basePath}/{id}/schedules", style = Ref.Style.RELATIVE_PATH)
private URI schedule;

.
. //Getters and setters
.
}

Now I could have my getSchedule() method use URIBuilder, but my bean doesn't know the resource that created it. Also, I can't use UriInfo in the context to create the link because the pathing can be inconsistent.

I should note that all my resources (community, tradingPartner and application) all have a method like this:

public String getBasePath()
{
return "/v1/communities/exchange";
}

Of course the path would vary based on the resource.


Any advice you can give would help. Let me know if you have questions.

Bob