Commit Graph

99 Commits

Author SHA1 Message Date
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
Oliver Gierke
5a6cefc4a9 DATACMNS-389 - RepositoryFactorySupport now caches RepositoryInformation.
Instead of creating a new DefaultRepositoryInformation for each call to getRepositoryInformation(…) we now actively cache the created instances per repository type and custom implementation class.
2013-11-12 15:03:24 +01:00
Oliver Gierke
d7b0a3e4d4 DATACMNS-392, DATACMNS-386 - Polished code after upgrade to Spring 3.2.5.
Spring 3.2.5 made AnnotationConfigUtils.processCommonDefinitionAnnotations(…) public so that we can call it directly instead of invoking it via reflection.
2013-11-12 13:15:52 +01:00
Oliver Gierke
a438d1ef17 DATACMNS-389 - Polishing of @Enable…Auditing support.
JavaDoc and assertion fixes.

Original pull requests: #26, #53.
2013-11-11 20:04:52 +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
Ben Hale
3a7acf29d7 DATACMNS-388 - Improve declaration of PagedResourceAssembler in JavaConfig.
Based on the discussion in SPR-11004 [0], the declaration of the PagedResourcesAssembler in HateoasAwareSpringDataWebConfiguration will not result in it being autowired using Spring 4.0 in certain circumstances.  This change loosens the declaration so that it can be autowired into declarations that have specific generics declarations.

Original pull request: #51.

[1]: https://jira.springsource.org/browse/SPR-11004
2013-10-27 16:49:50 +01: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
Thomas Darimont
55be70d911 DATACMNS-90 - Support old EnableXXXRepository annotations that do not yet allow to configure the handling of nested repositories.
Previously a call to attributes.getBoolean(…) resulted in a NPE if a EnableXXXRepository annotation of a store (Neo4J in that case ) did not have the required property yet. With the added check we are safe again.
2013-10-23 01:35:14 +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
Thomas Darimont
e76f820469 DATACMNS-382 - Remove copy of AnnotationTypeFilter in RepositoryComponentProvider.
Removed the copied class to use the one from Spring Core now that the necessary tweak is available in Spring 3.1.x.

Original pull request: #49.
2013-10-17 18:12:34 +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
Thomas Darimont
2d699b6b36 DATACMNS-374 - Improved error handling in case of a missing repository.
In Repositories.getCrudInvoker(…) we now throw an IllegalArgumentException if we cannot find an appropriate repository for the given domain class. Previously it just blew up with a NullPointerException without a clear error message.

Original pull request: #46.
2013-10-07 13:21:27 +02:00
Thomas Darimont
43b7a54294 DATACMNS-363 - Improved support for unicode characters for repository query methods.
In order to find a keyword like "And" followed by a property name we now probe also for non Basic Latin characters in addition to just an uppercase letter. This is needed to support property-names with characters that don't have an upper or lowercase representation. This allows us to support finder methods like: findBy이름And생일OrderBy생일Asc(…).

Original pull request: #47.
2013-10-07 12:44:37 +02:00
Oliver Gierke
93b2d39cf1 DATACMNS-377 - Prevent page sizes less than one.
PageRequest now actively prevents page sizes less than one. PageableHandlerMethodArgumentResolver falls back to default page size if it detects a page size less than one. It also rejects invalid default configuration using @PageableDefault.
2013-10-07 10:47:25 +02:00
Oliver Gierke
59e9af4950 DATACMNS-376 - Repositories now inspects user class for factory lookups.
When looking up the RepositoryFactoryInformation for a domain type we now make sure we look up the user type to not accidentally try to do so for a persistence provider generated proxy class for the original type. This prevents us from not finding PersistentEntity instances, Repository- or EntityInformation accidentally.
2013-10-01 17:24:42 +02:00
Thomas Darimont
e7475e5e0f DATACMNS-364 - Infrastructure to allow redeclaring CRUD methods with queries.
Introduced new meta-annotation QueryAnnotation to mark and identify store specific Query annotations. This enables us to handle finder methods annotated with such store specific annotations in a generic way. Adjusted DefaultRepositoryInformation.getQueryMethods(…) to consider custom store specific query annotations.

Original pull request: #43.
2013-09-24 13:01:15 +02:00
Oliver Gierke
78b27d1bcd DATACMNS-363 - Revert support for unicode characters in in query method names.
This reverts commit f7679d41b8 as it introduced every Or in query method names to be considered a keyword.
2013-09-09 22:28:37 -07:00
Thomas Darimont
f7679d41b8 DATACMNS-363 - Support unicode characters in in query method names.
Modified the regex for prefix_template and keyword_template in PartTree in order to support arbitrary unicode characters. Before that change we didn't support unicode correctly since we assumed that a character would have a lower and upper case representation which is often not the case, e.g. in chinese.

Original pull request: #41.
2013-09-08 17:21:22 -07:00
Oliver Gierke
1976878bd5 DATACMNS-362 - Resolved concurrency problem in Repositories.
We now create a copy of the keys before iterating over them in Repositories.getRepoInforFor(…) to make sure other threads can safely trigger lookupRepositoryFactoryInformationFor(…) which potentially alters the repositories instance variable. So far we haven't guarded against this scenario which caused a ConcurrentModificationException.
2013-08-26 18:29:04 +02:00
Oliver Gierke
5ccb0bc9c2 DATACMNS-360 - Scanning for repository interfaces now considers active profiles.
The configuration entry points (RepositoryBeanDefinitionParser and RepositoryBeanDefinitionRegistrar) now hand the Environment they're running in forward into the infrastructure scanning for repositories. Thus it will correctly find or not find repository interfaces based on which profiles are activated or not.
2013-08-25 18:29:52 +02:00
Nick Williams
eb4b801dc9 DATACMNS-353 - Make Spring HATEOAS purely optional.
Extracted the implementation of UriComponentsContributor from PageableHandlerMethoArgumentResolver and SortHandlerMethodArgumentResolver into dedicated subclasses so that we can really make Spring HATEOAS an optional dependency.

The integration tests are now guarded with an assumption to run on Spring 3.2 as Spring 3.1 has issues with JavaConfig and configuration method overrides. We've upgraded to Spring Data Build 1.2 snapshots so that the tests can be run with -Pspring32. This effectively means that the Spring Data Web support can only be used with a current Spring 3.2. Added a note on that in the reference docs and JavaDoc of @EnableSpringDataWebSupport.

Original pull request: #39.
2013-08-22 08:14:58 +02:00
Oliver Gierke
9843447a58 DATACMNS-357 - Cleanups in primitive id detection.
Changed implementation in AbstractEntityInformation quite a bit to not need the non-final fields and a protected callback method. Cleaned up test cases to really test the new behavior, not the artificially introduced test helper class.

Original pull request: #37.
2013-08-14 09:38:43 +02:00
Nick Williams
98b8129a74 DATACMNS-357 - Added support for primitive ids in EntityInformation.
AbstractEntityInformation now detects primitive id types and adapts the isNew state according to the Java Language Specification §4.12.5. Supported are primitive Numbers and the entity is considered new if the value of the primitive field is zero.

Original pull request: #37.
2013-08-14 09:38:17 +02:00
Oliver Gierke
b059da8f4f DATACMNS-341 - RepositoryFactory(Bean)Support is now class loader aware.
Let both RepositoryFactorySupport and RepositoryFactoryBeanSupport implement BeanClassLoaderAware to pick up the ClassLoader used by the container. The latter class forwards the configured instance into the factory it creates.
2013-08-12 10:49:36 +02:00
Thomas Darimont
7b5bdd45e6 DATACMNS-304 - JavaDoc fix for PageableArgumentResolver.
The deprecation hint in PageableArgumentResolver now points to PageableHandlerMethodArgumentResolver.

Original pull request: #38.
2013-08-12 09:30:32 +02:00
Oliver Gierke
59a8cd5566 DATACMNS-352 - Aligned setter names for argument resolvers for Pageable and Sort.
PageableHandlerMethodArgumentResolver and SortHandlerMethodArgumentResolver now consistently use set*ParameterName(…) and setQualifierDelimiter(…) for configuration.

Added some more unit tests to verify invalid configuration get rejected.
2013-08-08 12:52:11 +02:00
Oliver Gierke
541ef648f1 DATACMNS-356 - Parameters now uses DefaultParameterNameDiscoverer if present.
We now leniently try to lookup DefaultParameterNameDiscoverer and create an instance of it to make use of Spring 4's improved parameter name capabilities on Java 8. We fall back on a LocalVariableTableParameterNameDiscoverer if on Spring versions prior to 4.
2013-08-07 14:39:37 +02:00
Oliver Gierke
04d6859354 DATACMNS-355 - ReflectionAuditingBeanWrapper now uses a ConversionService.
We're not manually converting the DateTime instance into the user field type but delegate to a ConversionService instance. This will allow us to automatically adhere to enhancements in conversion capabilities to the DefaultConversionService.
2013-08-07 13:48:19 +02:00
Thomas Darimont
a63a2bbd75 DATACMNS-351 - Add setFallbackSort(…) to SortHandlerMethodArgumentResolver.
SortHandlerMethodArgumentResolver now has a setFallbackSort(…) to be able to configure the Sort instance to be used if nothing can be resolved from the request and sort default is configured on the controller method.

Renamed name of getDefaults(…) method in SortHandlerMethodArgumentResolver to getDefaultFromAnnotationOrFallback(…) and refactored implementation to be more understandable.

Original pull request: #36
2013-08-07 12:29:05 +02:00
Oliver Gierke
b8e457db9b DATACMNS-350 - Improved extensibility of Parameters.
Parameters is now a class explicitly designed for extension using generics. We provide a new DefaultParameters which is essentially a drop in replacement for former Parameters as it exposes individual Parameter instances.

Modules that previously extended Parameters will now have to implement the abstract factory methods exposed to create concrete - and potentially customized - Parameter instances.
2013-07-30 15:02:51 +02:00
Thomas Darimont
cc576a7398 DATACMNS-349 - Opened up SPI in DefaultTypeMapper to allow subclasses to resolve TypeAliases.
Added getAliasFor(TypeInformation) method in DefaultTypeMapper to allow subclasses to resolve TypeAliases.
2013-07-23 13:21:59 +02:00
Thomas Darimont
2afb570729 DATACMNS-345 - Use the actual type of the persistent property.
Changed getPersistentEntity(PersistentProperty<?>) to return the actual type of the persistent property in order to deal with collection and map types transparently.

Original pull request: #31.
2013-07-16 12:42:31 +02:00
Oliver Gierke
634789c3b7 DATACMNS-344 - Allow Repositories to work with non-CrudRepositories.
Introduced CrudMethods abstraction obtainable via a RepositoryInformation to inspect a repository for the presence of individual CRUD methods. The default implementation favors more special methods (e.g. the findAll(Pageable) over a simple findAll()). Introduced a CrudInvoker to be able to easily invoke findOne(…) and save(…) independently of whether the target methods are declared explicitly or inherited from CrudRepository.

Fixed some test case names to make sure they're executed during the Maven build.
2013-07-15 15:02:32 +02:00
Oliver Gierke
8a02b4ad6e DATACMNS-343 - PageableHandlerMethodArgumentResolver replaces pagination parameters now.
PageableHandlerMethodArgumentResolver now uses replaceQueryParam(…) to make sure the query parameters necessary for pagination don't accidentally get added multiple times.
2013-07-12 12:53:14 +02:00
Thomas Darimont
fc5ce662af DATACMNS-342 - Open up id property selection API in BasicPersistentEntity.
To support more advanced id property selection mechanisms we introduced a callback method returnPropertyIfBetterIdPropertyCandidate(…).

Pull request: #30.
2013-07-08 12:07:21 +02:00
Oliver Gierke
3a496b1f44 DATACMNS-337 - PersistentProperty now exposes getActualType().
The call transparently resolves map value types and collection component types if the property is either one of them.
2013-06-10 15:01:39 +02:00
Oliver Gierke
3f41810b86 DATACMNS-336 - Config classes backing @EnableSpringDataWebSupport are now public. 2013-06-10 14:12:42 +02:00
Oliver Gierke
15c4e34716 DATACMNS-335 - PageableHandlerMethodArgumentResolver now has configurable max page size.
The default is set to 2000.
2013-06-10 14:11:26 +02:00
Oliver Gierke
e0dda2a4f0 DATACMNS-333 - Added Jackson 2 support to repository populators.
Added necessary infrastructure to use Jackson 2 with repository populators. Expose a jackson2-populator XML element in the namespace to setup a Jackson2 based repository populator.
2013-05-29 17:51:39 +02:00
Oliver Gierke
cd2ea03928 DATACMNS-332 - Further performance improvements.
Reverted from ConcurrentHashMap to plain HashMap where concurrency wasn't an issue and profiling showed performance hotspots. Introduced caches for ParameterizedTypeInformation.getComponentType() and the resolved raw type in TypeDiscoverer.
2013-05-23 18:57:48 +02:00
Oliver Gierke
905565cbcc DATACMNS-332 - Cache AnnotationBasedPersistentProperty.isTransient(). 2013-05-23 10:03:05 +02:00
Oliver Gierke
24bc432d48 DATACMNS-332 - AbstractMappingContext now prefers most concrete property.
BasicPersistentEntity now only caches the most concrete property for a by-name lookup to mimic the behavior that was implemented in getPersistentProperty(String name). This is to prevent shadowed properties of superclasses leaking into the by-name lookups.

Improved AbstractPersistentProperty.toString() to rather render the concrete field it is backed by.
2013-05-22 18:37:51 +02:00