Java Virtal Machine.net

[ News ] rss

February 01, 2011

Mark Wielaard: New GPG key. Finally created a new GPG key using gnupg. The old one was a DSA/1024 bits one and 8 years old. The new one is a RSA/2048 bits one. I will use the new one in the future to sign any release tarballs I might create. pub 2048R/57816A6A 2011-01-29 Key f...

More »

February 01, 2011

Andrew Hughes: [SECURITY] IcedTea6 1.7.8, 1.8.5, 1.9.5 Released!. We are pleased to announce a new set of security releases, IcedTea6 1.7.8, IcedTea6 1.8.5 and IcedTea6 1.9.5. This update contains the following security updates: The IcedTea project provides a harness to build the source code from OpenJDK6 u...

More »

December/2024
SunMonTueWedThuFriSat
1234567
891011121314
15161718192021
2223242526 2728
293031    

[ Archives News
for 'Java Technology' ]

home > news > java technology > declarative hyperlinking in jersey

Declarative Hyperlinking in Jersey

One of the areas I'm keen to improve in the next version of JAX-RS is link creation. JAX-RS already offers UriBuilder but I think an annotation driven approach could save a lot of repetitive coding. I've been experimenting with a couple of annotations that I think would be useful and I just checked in an experimental extension that partially implements what I have in mind. Suppose you have a resource like this: @Path{"widgets"} public class WidgetsResource { ... } and you want to include a URI to this resource in a representation. Using the new extension you can just annotate a field in your representation class like this: @Link(resource=WidgetsResource.class) URI link; and then Jersey will build the appropriate URI and inject it into the representation before the representation is serialized by a message body writer. If the URI template contains parameters, their values are obtained by looking for a bean property or field by the same name in the representation. E.g. consider the following representation class: public class WidgetRepresentation { @Link("widgets/{widgetId}") URI link; String getWidgetId() {...} } After processing by the extension, if the getWidgetId method returned "abc123", the value of the link field would be /context/widgets/abc123 where context is the deployment context. The optional style property of the @Link annotation can be used to select between absolute URIs, absolute path an...


Date: March, 10 2010
Url: http://www.java.net/blog/mhadley/archive/2010/03/10/declarative-hyperlinking-jersey


Others News

©2002-2019Java-Virtual-Machine.net easy website builder | bootstrap modal popup | free icon maker | easyhtml5video.com | bootstrap image slider