Relation names can be fully qualified URIs. HalLinkDiscoverer now quotes the relation name handed into the constructor so that the expression parsing works as expected.
We now reflectively invoke the JSONPath.compile(…) method as the method signature has changed but we need to stay compatible with 0.9 to allow the Spring Data Evans release train to upgrade to 0.17 without a major third-party dependency upgrade.
Copied the reflective method lookup from Spring's JsonPathExpectationsHelper.
Related ticket: #297, #305.
Renamed the Resource, Resources and PagedResources types in TypeReferences to *Type so that new TypeReferences.Resources<User>() {} now becomes new ResourcesType<User>() {}.
Prior to this change a static import of TypeReferences would've cause the actual Resource types to be fully qualified.
673f82d introduced a glitch in a delegation within ControllerLinkBuilder.linkTo(Class<?> controller, Method method, Object... parameters) which is fixed by this commit.
Original pull request: #300.
Fixed imports in production code and test cases. Extended copyright range. Extracted request parameter handling into dedicated method. Added missing ticket reference.
Original pull request: #210.
Introduced Traverson.getDefaultMessageConverters(…) to be able to obtain the list of default HttpMessageConverters depending on the given media types. Added overloads for varargs as well as a List for consistency.
TypeReferences contains a set of predefined types that allows to shortcut the creation of ParameterizedTypeReference instances a bit, which is very useful for the usage on the client side (e.g., via RestTemplate).
new ParameterizedTypeReference<Resources<Resource<User>>>() {};
becomes
new TypeReferences.Resources<Resource<User>>() {};
The latter can even be abbreviated by using a static import for TypeReferences.
EmbeddedWrappers.wrap(Object, String) now allows empty collections. Also a new emptyCollectionOfType(Class<?>) was introduced to allow the RelProvider kick in and dynamically resolve the lazily.
Added more details to the JavaDoc of EmbeddedWrapper to make clear that we either expect a static rel returned or a type to resolve the rel from. Make HalEmbeddedBuilder detect invalid implementations and reject them although that should never occur if users use EmbeddedWrappers factory.
ControllerLinkBuilder now favors the value of the Forwarded and X-Forwarded-Proto header to build the scheme for the link created.
For more information on the Forwarded header, see http://tools.ietf.org/html/rfc7239.
Related issue: #107.
Previously we registered a special HttpMessageConverter with a custom ObjectMapper to deploy the HAL customizations. That converter was added to Spring MVC registered HandlerAdapters and registered as the first converter.
In case Spring MVC handled a request with Accept header */* or no Accept header at all, this meant that this converter kicked in and served HAL even for objects that don't need the customizations.
We now restrict the applicability of that special HttpMessageConverter to subtypes of ResourceSupport so that it will only be chosen if the object to render is of such type.
TempalteVariables now concatenates all request parameter styles correctly. UriTemplate uses continued style of request parameters if the base URI already contains request parameters.
Traverson now has an additional constructor taking a RestOperations instance which will be used instead of the default one. This allows more fine grained control over the HTTP request infrastructure used when performing link traversals.
Some internal polishing (moved from RestTemplate to RestOperations).
Original pull request: #203.
The Enhancer used to create the proxy instances wasn't explicitly
setting the class loader to use, which meant by default the proxied
class's class loader was chosen. This is fine for controller classes, but
in some containers the return types for the controller may have a
class loader that doesn't have access to Spring, resulting in
ClassNotFoundExceptions. For example, returning a JAX-RS class JBoss.
Using the controller's class loader when proxying the return type solves
this.
Related issues: #136.
We now only lookup the beans, Jackson2ModuleRegisteringBeanPostProcessor needs to post-process other beans if the post-processing is really needed. This avoids premature initialization of those dependent beans.
We now provide a dedicated EmbeddedWrappers API that HalEmbeddedBuilder uses to transparently handle the collection enforcement etc. It also allow manually hand in EmbeddedWrapper instances to enforce a certain behavior independent of the global settings in HalEmbeddedBuilder.
Simplified HalResourcesSerializer in Jackson2Hal module as we now don't have to deploy custom serializers for the embedded elements anymore.
Supersedes some of the API introduced for #195.
This change introduces a RelAware interface for objects to implement which want to enforce a particular rel to be used in the _embedded clause. This is useful if the objects being added are not categorized by type but rather by their role in the context of the main object.
The newly introduced method is needed to make sure the correct mappings are looked up if the method given is actually not declared on the class the method shall eventually be invoked on.
This is basically allowing to try to build links, similar to the dummy invocation mechanism but effectively avoiding the overhead of creating such invocation manually (as it would usually require reflection to be used).
Traverson correctly applies headers when using JsonPath to evaluate GET result: accepts the media types it is configured for and preserves additional headers.
LinkBuilderSupport now prefers the URI string over the URI to avoid double encoding issues.
VndErrorsMarshallingTest.jackson2marshalling(…) shouldn't take line breaks into account due to platform differences (Win, OSX, Linux)
Original pull request: #179.
We're now consistently using Spring HATEOAS' UriTemplate instead of the Spring MVC one to be able to expand extended template parameters correctly.
Also the ObjectMapper used by Traverson to unmarshal JSON responses does not fail for unknown properties anymore.
When building links for method invocations we previously only inspected the type that declared the method for type level mappings. We now use the type the method was invoked on explicitly.
ControllerLinkBuilder now inspects the X-Forwarded-Port and uses that if present. If an X-Forwarded-Host header doesn't contain a :, we now also reset the port to prevent the local one from leaking into links generated.
Introduce Traverson as means to traverse hypermedia based APIs by providing a set of relation names to discover and follow to access the final representation. Traverson allows to specify a parameter map that will be used to potentially expand the URIs discovered.
We currently support LinkDiscoverer based relation discovery, which means that relations in HAL representations can be found by simply stating their names. Alternatively JSON path expressions can be used (starting with a $).
The Jackson(2)ModuleRegisteringBeanPostProcessor now uses postProcess*Before*Initialization to make sure, afterPropertiesSet() has not been called on the target components which might have propagated the original HttpMessageConverters into other internal components.
With this fix, adding the HttpMessageConverter for HAL is added before the call and thus will be propagated to downstream components.
UriTemplate.expand(Map) not takes a Map<String, ? extends Object> to make sure Link.expand(Map) binds to the correct method. Previously it was bound to the method overload taking an Object vararg which caused an invalid expansion.
To correctly resolve the rel for a proxied class we need to build up relation types for, HalEmbeddedBuilder now uses Spring's AopUtils.getTargetClass(), which will use the object's getTargetClass() method in case it implements TargetClassAware.
To get consistent representations rendered for single-item collections and multi-item collections, we now use an enforceEmbeddedCollections flag in the Jackson 2 HAL module. Adapted HalEmbeddedBuilder to respect that setting and exposed it via the HandlerInstantiator for user level customization.
Changed RelProvider.getSingleResourceRel(…) to getItemResourceRel(…).