Commit Graph

1329 Commits

Author SHA1 Message Date
Oliver Gierke
57180568c5 DATACMNS-655 - Invoking default methods on projection proxies now works.
Extracted DefaultMethodInvokingMethodInterceptor from RepositoryFactorySupport and register it within ProxyProjectionFactory if the code is running on Java 8.

Original pull request: #117.
2015-03-10 11:47:12 +01:00
Oliver Gierke
e2a7057af9 DATACMNS-652 - Removed JDK 8 reference from TypeDiscoverer.
Removed accidentally introduced reference to JDK 8's Executable as common super type of Constructor and Method.
2015-03-05 17:14:27 +01:00
Oliver Gierke
2d75cf2c43 DATACMNS-651 - Introduced a Range value type.
Primarily intended to be used with Distance instances, we introduce a Range value type. Distance now has factory methods to create Range instances between two distances. To support this, Distance now implements comparable based on the normalized value of it.

Tiny refactoring in TypeDiscoverer to avoid code duplication between the lookup of parameter type information for constructors and methods.
2015-03-04 17:34:32 +01:00
Oliver Gierke
186cb25605 DATACMNS-650 - Polishing.
Added stream to the list of supported query method prefixes. Allow Stream to be used as return type for paginating queries, too.

Renamed Java8StreamUtils to StreamUtils. Some additional JavaDoc.

Original pull request: #116.
2015-03-03 18:10:40 +01:00
Thomas Darimont
e92c235fdf DATACMNS-650 - Introduced CloseableIterator abstraction as a foundation for streaming of results.
A CloseableIterator abstracts the underlying result with support for releasing the associated resources via close() which can be transparently be used with try-with-resources in Java 7 since Closeable implements AutoCloseable from Java 7 on upwards. Added detector methods to QueryMethod to check whether the current method returns a Stream. 

Introduced ReflectionUtils.isJava8StreamType to safely detect whether the given type is assignable to a Java 8 Stream. Introduced CloseableIteratorDisposingRunnable that can be registered as a cleanup action on a Stream.

Original pull request: #116.
2015-03-03 16:08:00 +01:00
Thomas Darimont
ec643d21cb DATACMNS-554 - Added QueryDslPredicateExecutor.findAll(Predicate, Sort).
We now support findAll on QueryDslPredicateExecutor that accepts a Querydsl Predicate and a Sort.

Original pull request: #115.
2015-02-24 09:40:16 +01:00
Oliver Gierke
0c65c7bb67 DATACMNS-638, DATACMNS-643 - Support for JSR-310 and ThreeTen datetime types.
Extend AuditableBeanWrapper to allow access to the last modification date of a target object. Made AuditableBeanWrapperFactory an interface and renamed what’s been previously known under this name as DefaultAuditableBeanWrapperFactory.

The components previously relying on a MappingContext to lookup a PersistentEntity now use PersistentEntities to be able to back a collection of MappingContexts behind that and also avoid unmanaged types to be added to the MappingContext.

We now also register the JSR-310 and ThreeTen back-port converters with the ConversionService to be able to get and set auditing dates as these types.
2015-02-04 19:30:02 +01:00
Oliver Gierke
fe49e4cf14 DATACMNS-642 - Avoid setter lookup in BeanWrapper for if field access is used.
We now delay the lookup of the setter method until we discover we really  need to use property access.
2015-02-04 17:11:48 +01:00
Oliver Gierke
bff8caba75 DATACMNS-641 - Order clauses in derived repository clauses now default to ascending order.
OrderBySource now considers the Asc and Desc keywords in an OrderBy-clause optional defaulting to ascending order as Sort defaults to anyway.
2015-02-04 12:06:58 +01:00
Oliver Gierke
2b4d173320 DATACMNS-640 - Fixed potential NullPointerException in PageableHandlerMethodArgumentResolver.
We now double check the fallback Pageable for being null before trying to lookup the Sort to fall back.
2015-02-04 10:32:17 +01:00
Oliver Gierke
57a42ababd DATACMNS-630 - Added HandlerMethodArgumentResolver to create proxies for interfaces.
We now ship a ProxyingHandlerMethodArgumentResolver that gets registered when @EnableSpringDataWebSupport is activated. It creates Map-based proxy instances for interfaces used as Spring MVC controller method parameters.
2015-01-30 15:15:55 +01:00
Thomas Darimont
0fb572b550 DATACMNS-636 - Add QueryDslPredicateExecutor.exists(…) which accepts a Querydsl predicate.
Original pull request: #112.
2015-01-26 11:03:13 +01:00
Oliver Gierke
df9f8c417e DATACMNS-637 - Performance improvements.
Made ObjectInstantiator interface public as otherwise the generated class to implement it cannot access it and thus the usage of the ByteCodeGeneratingEntityInstantiator fails completely.

PreferredConstructor.isEnclosingClassParameter(…) now eagerly returns if the parameter itself is not an enclosing one and thus avoids a collection lookup and equals check. Moved equals check for the type to the very end of the equals check to increase the chances that other inequality guards kick in earlier.

AbstractMappingContext now leaves the non-null-check for getPersistentEntity(…) to the factory method of ClassTypeInformation.

We now pre-calculate the hash codes for TypeInformation implementations as far as possible as the instances are used as cache keys quite a lot. The same applies to AbstractPersistentProperty.

BasicPersistentEntity now uses an ArrayList we sort during the verify() phase to mimic the previous behavior wich was implemented using a TreeSet as ArrayLists are way more performant when iterating over all elements which doWithProperties(…) is doing which is used quite a lot.

BeanWrapper now avoids the getter lookup if field access is used.

SimpleTypeHolder now uses a CopyOnWriteArrySet to leniently add types detected to be simple to the set of simple types to avoid ongoing checks against the inheritance hierarchy.
2015-01-25 17:43:59 +01:00
Oliver Gierke
5cc4811c52 DATACMNS-635 - Slice and Page can now be mapped using a Converter.
Introduced a map(Converter converter) method on Slice and Page to be able to easily transform the elements and create a new Slice or Page of the transformation result.

On Java 8 this allows code like this:

Page<String> strings = …;
Page<Integer> ints = strings.map(String::length);
2015-01-22 19:01:16 +01:00
Oliver Gierke
2c772d60de DATACMNS-634 - Polishing.
Simplified type traversal in Repositories.getRepositoryFactoryInfoFor(…) and unit tests.

Original pull request: #110.
2015-01-20 17:53:33 +01:00
Thomas Eizinger
9f21cc2f28 DATACMNS-634 - Repositories now als returns repositories for super types of a domain class.
In case the repository lookup for a given domain type fails we traverse the given types super-types and try to detect a repository for those.

Original pull request: #110.
2015-01-20 17:53:20 +01:00
Oliver Gierke
b2251aa5b9 DATACMNS-621 - Polishing.
Simplified implementation of Path conversion. Inlined helper domain types to not to pollute the packages with types that are only used within that very one test class.

Original pull request: #111.
2015-01-20 16:31:30 +01:00
Christoph Strobl
95bda862e7 DATACMNS-621 - QSort now treats nested paths correctly.
We now inspect intermediate path elements to build sort order accordingly.

Original pull request: #111.
2015-01-20 16:25:52 +01:00
Oliver Gierke
2e62a16f69 DATACMNS-631 - Made RepositoryFactorySupport.getRepositoryMetadata(…) protected.
Some JavaDoc polishes.
2015-01-15 15:46:26 +01:00
Oliver Gierke
a98d5c7ec6 DATACMNS-630 - Integrate projection infrastructure from Spring Data REST.
Ported the projection infrastructure previously residing in Spring Data REST and extended it by defaulting to a Map-backed source to store and retrieve data.

Separated out the SpEL based functionality mostly for SOC-reasons and easier testability.

Related tickets: DATAREST-437, DATACMNS-618, DATACMNS-89.
2015-01-11 19:35:31 +01:00
Oliver Gierke
9d3fab5e41 DATACMNS-628 - Polishing.
Renamed converter to ThreeTenBackPortConverter to better reflect the project we're integrating with.
2015-01-05 18:14:46 +01:00
Oliver Gierke
047d883371 DATACMNS-627 - DomainClassConverter is able to translate into identifier types, too.
Extended the implementation of DomainClassConverter to also support converting domain types into their identifier types and transitively convertible types.
2015-01-05 18:08:37 +01:00
Oliver Gierke
adbd363e2d DATACMNS-628 - Added converters for JSR-310 backport library.
We now include Spring Converters for the ThreeTen backport project [0].

[0] http://www.threeten.org/threetenbp
2015-01-04 21:43:26 +01:00
Oliver Gierke
23cad97b9a DATACMNS-626 - Added formatters for Point and Distance.
Ported Spring Data REST's converters for Distance and Point and turned them into Formatter instances. Extended Metric interface to return an abbreviation. Added getUnit() to Distance and tweaked Jackson setup to ignore the additional property.

We now automatically register the news introduced Formatters when using @EnableSpringDataWebSupport so that Point and Distance values can be parsed and printed from and to Strings out of the box.
2015-01-04 16:42:05 +01:00
Oliver Gierke
c5d920fa69 DATACMNS-623 - Added converter for JSR-310 Instant instances.
Made the converter types public to be able to reuse them from other projects.

Related tickets: DATAJPA-650.
2014-12-30 19:09:27 +01:00
Oliver Gierke
d7ecaa8db0 DATACMNS-619 - DefaultCrudMethods now exposes accessible methods.
We now make sure that all methods detected are made accessible so that clients using them can reflectively invoke them without additional checks.
2014-12-18 19:02:38 +01:00
Oliver Gierke
013f97899e DATACMNS-616 - Fixed field value lookup for private fields in AnnotationDetectionFieldCallback.
We now make the field detected by the callback accessible so that the value lookup doesn't fail for private fields. Added a few more unit tests to verify behavior.
2014-12-17 17:38:04 +01:00
Oliver Gierke
55d988e7b7 DATACMNS-615 - PageImpl now rejects a total less than the amount of items given.
PageImpl now makes sure that the total given to the constructor is never less than then number of items given to make sure we do not mask broken count calculation by creating an actually invalid instance.

Related ticket: DATAMONGO-1120.
2014-12-16 12:40:48 +01:00
Oliver Gierke
c343a65632 DATACMNS-611 - Improved cache lookups in RepositoryInterfaceAwareBeanPostProcessor.
Refactored predictBeanType(…) to only look up the predicted cached type once.

Related pull request: #108.
2014-12-08 17:51:17 +01:00
Oliver Gierke
d8781888d8 DATACMNS-610 - Extracted QueryExecutionResultHandler from RepositoryFactorySupport.
To be able to verify the conversion of List based query execution results into Sets I extracted a QueryExecutionResultHandler that applies the already implemented handling for Optional types and eventually general prost processing in case the return type declared at the repository query method doesn't match the returned value.

Added additional unit tests for Optional handling.
2014-12-04 20:35:39 +01:00
Oliver Gierke
5b1b73b297 DATACMNS-609 - Polishing in RepositoryConfigurationExtensionSupport.
RepositoryConfigurationExtensionSupport.registerBeansForRoot(…) now hands the extracted source of the configuration to the bean registration for the RepositoryInterfacePostProcessor.
2014-12-02 23:36:19 +01:00
Oliver Gierke
6677612f8e DATACMNS-609 - Improved bean definition registration for repository configuration.
The bean definitions that were registered for a repository configuration setup we registered once for every usage of the repository configuration element (annotation or XML). This caused multiple registrations of the very same bean definition which - as in case of the RepositoryInterfaceAwareBeanPostProcessor - apparently leads to performance problems in the container startup. Feedback for the latter claim is already asked for but we improved the registration setup nonetheless.

Introduced a registerIfNotAlreadyRegistered(…) method on RepositoryConfigurationExtensionSupport to allow easy registration of to-b-registered-once-and-only-once beans. We now hint towards the newly introduced method in registerWithSourceAndGeneratedBeanName(…).
2014-12-01 10:17:11 +01:00
Oliver Gierke
90a9462221 DATACMNS-587 - Added findAll(OrderSpecifier… orders) to QueryDslPredicateExecutor.
QueryDslPredicateExecutor now has a findAll(…) method to take multiple OrderSpecifiers to order the results. Polished JavaDoc along the way.
2014-11-28 10:02:19 +01:00
Oliver Gierke
fea5b1c439 DATACMNS-607 - Introduced AnnotationAttributes and MethodParameters from Spring HATEOAS to avoid dependency. 2014-11-27 18:34:18 +01:00
Oliver Gierke
a5df8d92a7 DATACMNS-606 - Added converters for JSR-310 types.
Added Jsr310Converters to contain converters to map between Date and JDK 8 date/time types.
2014-11-27 14:54:41 +01:00
Oliver Gierke
bb6ec38541 DATACMNS-605 - Moved key-value infrastructure to dedicated project. 2014-11-27 14:17:27 +01:00
Thomas Darimont
5448b3e63b DATACMNS-604 - Move QueryDsl helper methods from QueryDslUtils to KV package.
Moved to new class KeyValueQueryDslUtils in order to avoid class loading issues.

Original pull request: #107.
2014-11-27 12:29:34 +01:00
Oliver Gierke
cb884eb0cd DATACMNS-525 - Removed EhCache implementation.
Original pull request: #25.
2014-11-26 17:09:10 +01:00
Oliver Gierke
499182f4c9 DATACMNS-525 - Removed Hazelcast implementation.
Original pull request: #95.
2014-11-26 17:09:10 +01:00
Christoph Strobl
52108ed006 DATACMNS-525 - Add KeyValuePersistenceExceptionTranslator, fixing Todos.
Added key/value specific PersistenceExceptionTranslator and use it within KeyValueTemplate. Fixed some todos in JavaDoc and added missing tests. Renamed test class for SimpleKeyValueRepository according to the changed name.

Original pull request: #95.
2014-11-26 17:09:07 +01:00
Oliver Gierke
1f71a28408 DATACMNS-525 - Polishing.
Extracted KeySpaceUtils from KeyValueTemplate and pulled in the copy of MetaAnnotationUtils to hide it from the outside. Separated related test cases into dedicated test class.

Renamed BasicMappingContext to KeyValueMappingContext and BasicPersistentProperty to KeyValuePersistentProperty. Fixed spelling in SpelQueryCreatorUnitTests.

Moved MappingContext into separate package to satisfy architectural guidelines. Created dedicated KeyValueRepositoryNamespaceHandler to avoid a circular reference between commons and the key-value subsystem.

Made the query creator type an annotation on @EnableKeyValueRepositories so that it's not exposed to the user to be configured. Added the necessary ImportBeanDefinitionRegistrars to the Hazelcast and EhCache implementation. Removed @since tags from those modules at they're not going to make it into Spring Data Commons. Renamed EnableEhCacheRepsotoriesUnitTests to EnableEhCacheRepositoriesIntegrationTests as well as the same for the Hazelcast specific test.

The KeyValueRepositoryConfigurationExtension now explicitly registers a KeyValueMappingContext unless one is already registered. AnnotationRepositoryConfigurationSource now explicitly exposes an AnnotationMetadata instance for the annotation that triggered the configuration.

Turned SpelCriteriaAccessor and SpelPropertyComparator into classes to be able to pass them a SpelExpressionParser to be able to get rid of SpelExpressionFactory eventually. Made both classes as well as SpelQueryEngine package protected for now.

Moved repository implementations into support package. Updated architcture description JavaDoc polish, spacing, blank lines. Added TODOs.

Original pull request: #95.
2014-11-26 16:47:01 +01:00
Christoph Strobl
e2358f3bf8 DATACMNS-525 - Introduce infrastructure for KeyValue repositories.
Added basic infrastructure for repositories on top of key-value data stores. For more details see the original pull request.

Original pull request: #95.
2014-11-26 16:43:15 +01:00
Oliver Gierke
e1b38faee9 DATACMNS-601 - Fixes for most of the SonarQube warnings. 2014-11-26 09:25:14 +01:00
Oliver Gierke
9a1879617e DATACMNS-600 - Moved RepositoryInvoker subsystem into support package. 2014-11-25 11:34:16 +01:00
Oliver Gierke
5d9b89c339 DATACMNS-591 - RepositoryConfigurationDelegate now uses Environment and ResourceLoader everywhere.
We now also use the Environment and ResourceLoader for the component scan to detect whether multiple Spring Data modules are on the classpath.
2014-11-24 22:38:48 +01:00
Oliver Gierke
4c1a187dd4 DATACMNS-599 - Introduced IdentifierAccessor API.
PersistentEntity now exposes an getIdentifierAccessor(…)-method that allows obtaining the identifier of an entity without using a PersistentProperty instance. This allows advanced scenarios (like multi-property identifiers). Also we can use store specific means to optimize id lookups to e.g. avoid proxy initialization for lazy loading proxies.
2014-11-24 13:01:23 +01:00
Oliver Gierke
2388b6fa90 DATACMNS-597 - Fixed to strict consistency check in PersistentPropertyAccessor lookup.
BasicpersistentEntity now allows subtypes to be handed into the PersistentPropertyAccessor lookup to support inheritance hierarchies as well as interface based PersistentEntity scenarios.
2014-11-19 17:05:50 +01:00
Oliver Gierke
3446c457d5 DATACMNS-596 - Polishing.
PersistentEntityInformation now falls back to null values for PersistentEntity instances that don't expose an identifier property.
2014-11-18 16:46:18 +01:00
Oliver Gierke
6a849bc8ef DATACMNS-596 - Introduced PersistentPropertyAccessor.
To be able to customize the lookup of bean properties by persistent store we now expose a getPropertyAccessor(Object entity) method on PersistentEntity. It returns a PersistentPropertyAccessor which is basically an interface with a simplified API of BeanWrapper.

Reduced the plain BeanWrapper to not perform any type conversion to be able to drop the ConversionService dependency. To compensate for that we introduced a ConvertingPropertyAccessor that takes a ConversionService and delegates to a standard PersistentPropertyAccessor and applies conversions if necessary.

Refactored client APIs to use the PersistentPropertyAccessor instead of referring to BeanWrapper directly. Deprecated BeanWrapper.create(…) for removal in RC1.
2014-11-18 12:29:30 +01:00
Oliver Gierke
93dbc26969 DATACMNS-589 - Polishing.
Made DefaultCrudMethods public to support better testing. Components that are based on CrudMethods can be tested easier if DefaultCrudMethods is public, so that an instance can easily be set up by using a DefaultRepositoryMetadata instance.

Polished JavaDoc and copyright headers.
2014-11-14 16:53:17 +01:00