Commit Graph

407 Commits

Author SHA1 Message Date
Oliver Gierke
2a8f4ddf93 DATACMNS-456 - Introduced getAttribute(String) on RepositoryConfigurationSupport.
RepositoryConfigurationSupport now has a getAttribute(String) method to lookup String attributes on XML elements and annotations. The XML implementation converts the given attribute name in a lower-case, dashed representation for the lookup.

RepositoryConfigurationExtensionSupport now ha a generic postProcess(…) method to allow implementations that only need to work with String attributes unify their customizations into that single method.
2014-03-01 12:18:44 +01:00
Oliver Gierke
6408e16faf DATACMNS-452 - Added some helper types to simplify the implementations in store modules.
Added AnnotatedTypeScanner to easily scan for annotated types within a set of base packages. Picks up interfaces by default which had to be customized when using ClassPathScanningCanidateComponentProvider.

Added DirectFieldAccessFallbackBeanWrapper that will use direct field access for beans in case no accessor method can be found. This allows to easily implement bean property values through accessors first but using the field directly if the accessors aren't available.

Introduced AnnotationDetectionMethodCallback to easily find methods equipped with a given annotation.
2014-02-27 08:36:00 +01:00
Fabian Buch
43d731f5ed DATACMNS-453 - Fix NPE in isPageableRepository() for Repositories without a findAll() method.
Added additional null check to isPagingRepository() to handle repository definitions that do not have a findAll method.

Original pull request: #69.
2014-02-26 15:13:34 +01:00
Oliver Gierke
3131ffbc5f DATACMNS-451 - Added custom CollectionFactory.
Added a Spring Data specific CollectionFactory that augments Spring's CollectionFactory with support for special collection types like EnumSet and EnumMap. For all other types we delegate to the wrapped class.
2014-02-26 05:12:23 +01:00
Oliver Gierke
ab37869a1a DATACMNS-446 - Added toString() methods to TypeInformation types. 2014-02-23 13:51:41 +01:00
Oliver Gierke
4cee676608 DATACMNS-444 - DefaultPersistentPropertyPath now skips null converted names.
If a Converter handed into DefaultPersistentPropertyPath.toDotPath(…) returns null or an empty string for a mapped property name, that value is skipped during path construction.
2014-02-19 18:10:02 +01:00
Oliver Gierke
611c6194f4 DATACMNS-442 - Added test case to show that id resolution succeeds for intermediate repositories.
Adapted test case failing on Spring 4 due to eager RepositoryMetadata resolution.
2014-02-19 14:01:30 +01:00
Thomas Darimont
f047cce7c3 DATACMNS-441 - Fixed potential NullPointerException in query method detection on Java 8 compiled code.
We now skip bridge methods for query method processing in order to circumvent the changed behavior of Class#getMethods() in Java 8 (when the code was compiled with target byte code level 1.8). On Java 8 this results in bridge methods being found and inspected for query method annotations. Since we currently cannot analyze generic return types of bridge methods this results in NullPointerExceptions being thrown at a later stage in AbstractRepositoryMetadata#getReturnedDomainClass(…).

Original pull request: #64.
Related issue: DATAJPA-465.
2014-02-19 09:30:58 +01:00
Oliver Gierke
931a697ec5 DATACMNS-440 - Fixed map value type resolving for Map value types.
Previously the map value type resolving algorithm checked the value type to be of type Map again to shortcut the resolution. We now weakened this to an assignment check and eagerly resolve the generic type if its bound on exactly that level already. If no concrete type argument can be found, we fall back to the general generics resolution mechanism.
2014-02-13 12:06:26 +01:00
Oliver Gierke
20846809e1 DATACMNS-439 - AnnotationRepositoryConfigSource now evaluates REGEX and ASPECTJ filters.
We now leniently detect AspectJ and regular expression filters in an @Filter annotation in @Enable…Repositories annotations.
2014-02-12 12:18:24 +01:00
Oliver Gierke
1e3640e0ee DATACMNS-436 - Order.equals(…) / hashCode() / toString() now consider ignore case flag.
Extended equals(…), hashCode() and toString() methods t consider the ignore case flag held in an Order instance.
2014-02-06 18:13:54 +01:00
Thomas Darimont
899cf25330 DATACMNS-432 - Make Repositories effectively immutable.
We now eagerly populate the repository factory information in Repositories to provide a read only view on the discovered repository information. Previously lookup operations could also change some maps that held information about the until then discovered repository meta data which could lead to ConcurrentModifcationExceptions in multi-threaded environments. Since we don't allow any modification after construction this won't happen anymore.

We also cache the computed RepositoryMetadata in RepositoryFactoryBeanSupport.

Original pull request: #63.
2014-02-06 18:06:31 +01:00
Martin Baumgartner
d381b694fe DATACMNS-433 - Added Is prefix to Like keywords.
Like expressions are now also recognized if they're prefixed with Is. So both "IsLike" and "Like" are recognized as well as "NotLike" and "IsNotLike".
2014-02-06 16:37:39 +01:00
Oliver Gierke
30a63f5546 DATACMNS-418 - Added test case to show how to use custom element assembler. 2014-01-27 08:42:50 +01:00
Oliver Gierke
a16375bb17 DATACMNS-418 - PagedResourcesAssembler now exposes method to append template parameters.
PagedResourcesAssembler.appendPaginationParameterTemplates adds the currently missing pagination template variables to the given link.
2014-01-23 15:50:10 +01:00
Oliver Gierke
6822f39e3b DATACMNS-422 - Remove workaround in test cases after recent fix for generic component types.
Build should be fine on Spring 4 now.
2014-01-22 17:46:37 +01:00
Oliver Gierke
0ce214cd56 DATACMNS-418 - Use TemplateVariables value type for pagination templates.
Changed Hateoas(Pageable|Sort)HandlerMethodArgumentResolver to use newly introduced TypeVariables abstraction to avoid having to deal with string representations manually.

The registered TemplateVariables carry a "pagination.….description" key to be resolved against a MessageSource.
2014-01-21 14:31:46 +01:00
Oliver Gierke
0f38612dab DATACMNS-426 - RepositoryMetadata now has an isPagingRepository().
Moved getCrudMethods() to RepositoryMetadata to be able to add a isPagingRepository() to the interface as well. Changed DefaultCrudMethods to work with a RepositoryMetadata instead of RepositoryInformation.

DefaultRepositoryInformation now completely delegates to the ResourceMetadata given and not extend it to avoid initialization order issues.
2014-01-21 14:31:37 +01:00
Oliver Gierke
1f172725f0 DATACMNS-422 - Mitigate semantic changes in Spring 4.0's GenericTypeResolver.
In case of an unresolvable generic parameter in TypeDiscoverer's getTypeArgument(…) we check for a generic super type for the given bound and fall back to Object in case we find a parameterized type.
2014-01-19 15:37:44 +01:00
Oliver Gierke
a5eedad48f DATACMNS-420 - Introduced RepositoryConfigurationDelegate.
RepositoryConfigurationDelegate allows to easily trigger repository BeanDefinitions to be registered independently of the client API (XML or annotation configuration support). Refactored the existing configuration base classes to use the newly introduced class. Removed defaulting of infrastructure components needed for Spring 3.1 compatibility.
2014-01-18 12:35:21 +01:00
Oliver Gierke
e646fc9f16 DATACMNS-418 - Improvements to template variables in HandlerMethodArgumentResolvers.
The Hateoas(Pageable|Sort)HandlerMethodArgumentResolver now receive a UriComponents instance to inspect for existing query parameters. They then refrain from adding template variables for already present parameters. Slightly modified the way the sort parameters is appended to the pagination properties (although semantically equivalent).
2014-01-17 12:45:10 +01:00
Oliver Gierke
72a8d072a3 DATACMNS-419 - PagedResourceAssemblerArgumentResolver now works with templated URIs.
We now handle an IllegalArgumentException being thrown in case we deal with a templated request mapping. We simply skip the attempt to eagerly resolve the base URI for the request and rely on the assembler being capable of resolving it itself or the user effectively providing a Link instances to one of the toResource(…) overloads.
2014-01-16 14:34:14 +01:00
Oliver Gierke
92a22182f1 DATACMNS-418 - PagedResourcesAssembler now adds self links to PagedResources.
PagedResourcesAssembler now adds a LinkTemplate to every PagedResources instance created and pulls the template variable information from the registered resolvers for Pageable and Sort.

Extended PageableResourceAssemblerArgumentResolver to create a special MethodParameterAwarePagedResourcesAssembler so that the assembler will take qualifier information into account when being injected into controller methods.

Upgraded to Spring HATEOAS 0.9.0.BUILD-SNAPSHOT to be able to benefit from new methods added to MethodParameters as well as the LinkTemplate class. Updated Sonargraph architecture definition to allow the web layer to access logging.
2014-01-16 14:31:55 +01:00
Oliver Gierke
df1373aa81 DATACMNS-416 - Added means to enforce eager instantiation of CDI repositories.
The CDI extension now eagerly instantiates repository beans that are annotated with the newly introduced @Eager annotation. This is necessary to prevent the initialization procedure from interfering with potentially already executed business logic.

To achieve this CdiRepositoryExtensionSupport provides a new method registerBean(…) that has to be called by store implementations. The extension will then keep track of beans that require eager initialization and trigger it when the container has finished validation.
2014-01-13 11:53:32 +01:00
Oliver Gierke
05f303c2be DATACMNS-414 - Removed unnecessary generic types for AuditingHandler.
Removed the unnecessary type arguments for AuditingHandler so that the setter taking an AuditorAware<T> can be successfully wired against implementations other than AuditorAware<Object> with Spring 4. The type argument was superfluous anyway as internally the type wasn't referred to and the handler is not used on a by-type basis.
2014-01-12 19:23:22 +01:00
Oliver Gierke
e21a7850f6 DATACMNS-407 - Fixed sort parameter building in HateoasAwareSortHandlerMethodArgumentResolver.
We're now replacing the sort parameter for the URI to be created instead of simply appending them to the source URI to prevent previously applied sort parameters to be taken forward.
2013-12-16 12:59:50 +01:00
Thomas Darimont
f148d19c81 DATACMNS-410 - Fixed bug in ReflectionRepositoryInvoker#invokeFindOne.
We now delegate calls to invokeFindOne to the correct target repository.

Original pull request: #80.
2013-12-13 13:39:58 +01:00
Oliver Gierke
78443eb83e DATACMNS-379 - Fixed AIOOBE in SortHandlerMethodArgumentResolver. 2013-12-05 14:45:28 +01:00
Oliver Gierke
cc4a4de892 DATACMNS-408 - Handle invalid pagination and sorting parameters gracefully.
The PageableHandlerMethodArgumentResolver and SortHandlerMethodArgumentResolver now transparently ignore invalid values provided for page number, size and sort. We fall back to ignore the invalid values (for sort) and fall back to the defaults where appropriate (page number and size).

Used and adapted test cases from pull request #48.
2013-12-05 10:37:42 +01:00
Oliver Gierke
62e14d2b12 DATACMNS-402 - Slight refinements in QSort implementation.
Re-enable concatenation with plain Sort via ….and(…) method. Some general polishing and JavaDoc cleanups.

Original pull request: #59.
2013-12-04 13:30:19 +01:00
Thomas Darimont
f2ff84fb63 DATACMNS-402 - Add support for sorting by a QueryDSL OrderSpecifier.
Previously we did only support ordering by a string or property path through Sort. In order to be able to express more type safe ordering expressions we introduce QSort as a subclass of Sort that is able to wrap QueryDSL OrderSpecifiers. To be able to separate the concerns of sorting via QueryDSL expressions better we introduce the AbstractPageRequest base class and QPageRequest as a special implementation that accepts a QSort or OrderSpecifiers for ordering.

Original pull request: #59.
2013-12-04 13:09:25 +01:00
Oliver Gierke
9f65b57867 DATACMNS-406 - Polishing.
Refactored code in RepositoryMetadata implementations to avoid compiler warnings. Some JavaDoc polishing.

Original pull request: #58.
2013-11-21 12:39:32 +01:00
Thomas Darimont
b96f613b98 DATACMNS-406 - Tighten contract for RepositoryMetadata implementations.
We now resolve the domain and id-types eagerly within the constructor of AbstractRepositoryMetadata implementations to prevent a RepositoryMetadata instance to be created in an invalid state. Pulled-up repositoryInterface property to AbstractRepositoryMetadata.

Original pull request: #58.
2013-11-21 12:39:17 +01:00
Thomas Darimont
eddb3323de DATACMNS-399 - Support query prefix to designate repository query methods.
Extended PREFIX regex in PartTree to support the "query" prefix.

Original author: @jiming
Original pull request: #56.
2013-11-19 12:26:11 +01:00
Oliver Gierke
fed61720b0 DATACMNS-400 - PersistentProperty now exposes findAnnotation(…).
Pulled up the method declaration from AnnotationBasedProperty as it's useful to be able to inspect a property for annotations being configured on it independently from whether the persistent mapping of it has been defined via annotations or not.

Expose isAnnotationPresent(…) as well to ease quick checks for an annotation.
2013-11-13 18:09:28 +00:00
Thomas Darimont
907ea74d8a DATACMNS-393 - Improved CRUD method detection in DefaultCrudMethods.
The detection of CRUD methods in DefaultCrudMethods is now carried out in a more robust and predictable fashion. The exact algorithm is described in the JavaDoc.

Original pull request: #55.
2013-11-12 15:07:55 +01:00
Thomas Darimont
a7d909846c DATACMNS-389 - Support for JavaConfig in auditing.
Basic infrastructure for supporting annotation based auditing configuration.

Introduces AuditingBeanDefinitionRegistrarSupport for store specific auditing configuration enhancements. An AuditorAware instance is wired into the Auditing handler automatically if it's present in the ApplicationContext. The auditorAwareRef attribute of the enabling annotation can be used to disambiguate in case multiple AuditorAware instances are present in the configuration.

Original pull requests: #26, #53.
2013-11-11 20:04:40 +01:00
Oliver Gierke
e616ec5d05 DATACMNS-392 - Support for eager repository instantiation.
Changed the initialization of repositories to default to eager with the ability to explicitly defer instantiation using @Lazy on the repository interface definition. In practice, the change in default shouldn't make any difference to most client projects as repositories are usually depended on by other application components so that the repositories never stay uninitialized.
2013-11-05 16:22:16 +01:00
Oliver Gierke
d26f90b281 DATACMNS-390 - Create defensive copy for persistent entities in AbstractMappingContext.
To prevent ConcurrentModificationExceptions when iterating over PersistentEntities while further entity types are potentially added to the MappingContext we now return a immutable defensive copy of the current entity set.
2013-11-04 11:03:49 +01:00
Oliver Gierke
057c2e9bf8 DATACMNS-384 - Polished toString() representation of Version.
Trailing zeros now get removed up until the minor version number.
2013-11-04 11:02:50 +01:00
Oliver Gierke
9b077890b4 DATACMNS-391 - Mitigate changes between Spring 3 and 4' GenericTypeResolver.
As of Spring 4, the GenericTypeResolver is more consistent in detecting raw types. It now returns null for both resolveTypeArguments(Set.class, Set.class) as well as resolveTypeArguments(Set.class, Iterable.class). The latter returns an array of Object.class in 3.x.

As this shouldn't make a pratical difference to actual clients (as they need to check for null anyway, we loosen the test case to be able to build Spring Data Commons against both Spring 3 and Spring 4.

Some polishing in the version detection in integration tests. Moved the Servlet 3.0 dependency into the Spring 4 profile.
2013-11-01 09:34:32 +00:00
Thomas Darimont
c34983b22b DATACMNS-391 - Ensure compatibility with Spring Framework 4.0.
Some tests required an explicit dependency to servlet-api-3.x.
The GenericApplicationContext doesn't refresh automatically in Spring 4.x we thus we have to call refresh manually. Added a specific version of populators.xml for Spring 4.x since the jaxb2-marshaller element definition no longer renamed the contextPath attribute to context-path in 4.x.

Original pull request: #52.
2013-11-01 09:30:34 +00:00
Oliver Gierke
ae9ee5b428 DATACMNS-387 - Improvements in null handling in PartTree area.
We're now rejecting invalid constructor arguments handed to ClassTypeInformation, Part, PartTree and PropertyPath. Beyond that we skip the creation of a Part for an empty path segment, so that you don't end up with an invalid Part instance for a findAllByOrderByFooAsc.
2013-10-27 16:34:26 +01:00
Oliver Gierke
8e9b4f78a0 DATACMNS-385 - Fixed repository method matching for iterable entities.
When matching the save(Iterable<T>) method of CrudRepository for an entity implementing Iterable we accidentally determined CrudRepository.save(T) as target method if the entity type under consideration implements Iterable.

We now explicitly check for the parameter type not being Iterable when matching the domain type generics in matchesGenericType(…).
2013-10-23 18:35:34 +02:00
Oliver Gierke
1dfe235a87 DATACMNS-90 - Polishing.
Added missing author tags where needed. Removed the template method to pick up the configuration from the RepositoryConfigurationSource interface as it's not needed from the outside.

Original pull request: #50.
2013-10-22 14:11:28 +02:00
Thomas Darimont
60534974bf DATACMNS-90 - Allow Repository namespace handler to be configured to scan for inner class repositories.
We now optionally consider nested repository interfaces defined as inner-classes. This can be configured by setting the considerNestedRepositories property on EnableXXXRepository annotations or the consider-nested-repositories attribute to true - it defaults to false.

Original pull request: #50.
2013-10-22 14:11:19 +02:00
Oliver Gierke
06df973c54 DATACMNS-384 - Introduced value object for Version. 2013-10-17 10:29:33 +02:00
Oliver Gierke
1b3d9ed2c4 DATACMNS-380 - MappingContext.getPersistentPropertyPath(…) now throws MappingException. 2013-10-10 13:42:33 +02:00
Oliver Gierke
048394690f DATACMNS-381 - Improved exception message in PropertyReferenceException.
PropertyReferenceException now not only exposes the property not found but also the already resolved Property path to make it easier to understand what is causing the exception in the first place.
2013-10-10 13:01:09 +02:00
Oliver Gierke
06c2f41584 DATACMNS-380 - MappingContext exposes PersistentPropertyPath by dot path.
Introduced MappingContext.getPersistentPropertyPath(String, Class<?>) to allow looking up a PersistentPropertyPath from a plain dot-notated path expression (e.g. foo.bar.foobar). This removes the need to use a PropertyPath in case you really only want to look up plain path expressions and the additional functionality in PropertyPath (camel case traversal and interpreting _ as hard delimiter) is not needed or wanted.
2013-10-10 12:54:24 +02:00