Commit Graph

197 Commits

Author SHA1 Message Date
Oliver Gierke
9db6ccaa4b DATACMNS-412 - Fixed potential classloader leak.
Turned the static cache of RepositoryInformations in RepositoryFactorySupport into a non-static one to avoid the instance from potentially surviving redeployments in web app scenarios.
2014-01-14 17:44:23 +01:00
Oliver Gierke
5906ae04da DATACMNS-415 - Further performance improvements for repository config.
We now also set a resource pattern on the ClassPathScanningCandidateComponentProvider to limit the scanning for custom implementations even more and thus avoid reading a lot of unnecessary class files.
2014-01-13 18:31:31 +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
bf3437f39c DATACMNS-415 - Performance improvements in configuration subsystem.
Changed the design of RepositoryBeanDefinitionBuilder to receive stable dependencies in the constructor and the moving parts as method arguments. This enables us to reuse the builder instance for the creation of all repository bean definitions. Most importantly that means we can use a single CachingMetadataReaderFactory instance which will avoid reading files again when looking for custom implementation classes.

Adapted clients for XML configuration and JavaConfig accordingly.
2014-01-12 23:13:32 +01:00
Oliver Gierke
51b128fac1 DATACMNS-411 - Add support for Java 8 date/time types in auditing.
The auditing subsystem now supports the usage of JDK 8 date time types when running on Spring 4.0.1 or better. To achieve that switched to use the DefaultFormattingConversionService which registers the relevant converters needed. We also modified the SPI CurrentDateTimeProvider to return a Calendar instance as it carries time-zone information to be able to convert the instance into time-zone based JDK 8 date/time types.

This also allows us to make the use of JodaTime optional and only rely on it in case of the usage of Auditable or any of the JodaTime types used in the annotation based scenario. Added support to set LocalDateTime as well.
2014-01-12 19:23:35 +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
341912acec DATACMNS-403 - Prepare release 1.7 M1.
Updated release metadata and bumped versions.
2013-11-19 12:48:42 +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
c0fc0f905a DATACMNS-401 - Some cleanups regarding generics and deprecations.
Suppress deprecation warnings for GenericTypeResolver for now. Added Simple(Property|Association)Handler to ease working with untyped PersistentProperty instances without having to fall back to raw types. Polished Sonargraph architecture description.
2013-11-14 09:28:11 +00: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
Oliver Gierke
22223f4386 DATACMNS-393 - Improved CRUD method detection in DefaultCrudMethods.
Slightly refined the detection algorithm to favor early returns and thus avoid unnecessary reflection lookups.

Original pull request: #55.
2013-11-12 15:07:55 +01: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
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
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
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
Thomas Darimont
4849f32447 DATACMNS-366 - Test for SortHandlerMethodArgumentResolver and property lists.
Added test case to show SortHandlerMethodArgumentResolver can deal with property lists.

Original pull request: #45.
2013-09-23 15:16:51 +02:00
Thomas Darimont
2556bf7a4a DATACMNS-368 - Add test for PartTree properties that contain keyword sequences.
Added appropriate test to PartTreeUnitTests to check whether the regular expression in PartTree doesn't accidentally finds keywords in property expressions.
2013-09-23 15:08:49 +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
Oliver Gierke
2136fa8cdf DATACMNS-315 - Prepare 1.6.0.RELEASE. 2013-09-09 12:27:13 -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