JBoss.orgCommunity Documentation
In addition to the various updated frameworks discussed in previous sections, a few individual classes have been updated or discarded.
org.jboss.resteasy.spi.Link has been replaced by
the abstract class javax.ws.rs.core.Link and its implementation
org.jboss.resteasy.specimpl.LinkImpl. They both represent links as
described in RFC 5988, with slight
variations. For example, there is now javax.ws.rs.core.Link.getRel()
instead of org.jboss.resteasy.spi.Link.getRelationship(). Also, they
are constructed differently. For example,
@GET
@Path("/link-header")
public Response getWithHeader(@Context UriInfo uri)
{
URI subUri = uri.getAbsolutePathBuilder().path("next-link").build();
Link link = new Link();
link.setHref(subUri.toASCIIString());
link.setRelationship("nextLink");
return Response.noContent().header("Link", link.toString()).build();
}
would now be written
@GET
@Path("/link-header")
public Response getWithHeader(@Context UriInfo uri)
{
URI subUri = uri.getAbsolutePathBuilder().path("next-link").build();
Link link = new LinkBuilderImpl().uri(subUri).rel("nextLink").build();
return Response.noContent().header("Link", link.toString()).build();
}
org.jboss.resteasy.util.GenericType, which allows the creation of
parameterized type objects at runtime, is now replaced by
javax.ws.rs.core.GenericType. They are essentially the same class, with
minor method name changes. In particular, getGenericType() becomes
getType() and getType() becomes
getRawType().
Implementations of the org.jboss.resteasy.spi.StringConverter interface in
Resteasy 2 are providers that can marshal and unmarshal string-based parameters labelled with @HeaderParam,
@MatrixParam, @QueryParam, or @PathParam. JAX-RS 2.0 introduces a similar interface,
javax.ws.rs.ext.ParamConverter, but implementations of
ParamConverter are not recognized as providers. Rather, a provider
that implements javax.ws.rs.ext.ParamConverterProvider, which produces a
ParamConverter, may be registered. For example,
public static class POJO { ... }
public static class POJOConverter implements ParamConverter<POJO>
{
public POJO fromString(String str)
{
POJO pojo = new POJO();
return pojo;
}
public String toString(POJO value)
{
return value.getName();
}
}
public static class POJOConverterProvider implements ParamConverterProvider
{
@Override
public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations)
{
if (!POJO.class.equals(rawType)) return null;
return (ParamConverter<T>)new POJOConverter();
}
}
...
ResteasyProviderFactory.getInstance().registerProvider(POJOConverterProvider.class);
...
Resteasy 2 comes with a logging abstraction called org.jboss.resteasy.logging.Logger,
extensions of which delegate to logging frameworks such as log4j and slf4j. Resteasy 3 no longer uses its
own logging abstraction but rather adopts the JBoss Logging framework, a brief description of which can
be found at
http://docs.jboss.org/hibernate/orm/4.3/topical/html/logging/Logging.html.
JBoss Logging was chosen for its internationalization and localization support.