Commit Graph

901 Commits

Author SHA1 Message Date
Oliver Gierke
8026e9ff72 DATACMNS-1106 - Removed deprecations in ProjectionFactory.
Removed the deprecated implementation of ResourceLoaderAware in favor of BeanClassLoaderAware. Removed deprecated ProjectionFactory.getInputProperties() in favor of ….getProjectionInformation(). Removed the Java conditional to add a MethodInterceptor for default methods. Adapted test cases.
2017-07-11 11:18:18 +02:00
Oliver Gierke
24704fc4de DATACMNS-1097 - Polishing.
Updated Sonargraph architecture description. Polished imports in domain package to avoid unnecessary imports (mostly due to Javadoc references).

Removed manually declared constructor in ExampleMatcherAccessor in favor of Lombok's @RequiredArgsConstructor. Removed deprecations in type information subsystem. Moved to different way of class loading to avoid null pointer warnings in ReflectionUtils.
2017-07-06 11:38:12 +02:00
Jens Schauder
1fc25727cf DATACMNS-1097 - Move classes to better matching packages.
Introduced new ExampleMatcherAccessor in data.support in favor of the now deprecated one in data.repository.core to avoid a dependency into the repositories subsystem to work with examples in general.

Added Degraph based test in order to avoid future cyclic package dependency violations.

Original pull request: #230.
Related ticket: DATAMONGO-1721.
2017-07-06 11:38:12 +02:00
Oliver Gierke
f44255b9a8 DATACMNS-1102 - Reuse ConversionService in ProjectingMethodInterceptors created by ProxyProjectionFactory.
Applied the same to internals of MapDataBinder.
2017-07-05 09:41:21 +02:00
Mark Paluch
3dbbb15672 DATACMNS-1101 - Use dedicated type to cache custom conversion targets without requested target type.
We now use a marker interface to store cache hits for conversion targets without requesting a conversion target in the conversion query. The dedicated marker type has an individual cache view and does not interfere with other types.

Previously we used Object as cache key which caused false positives due to assignability checks. If an earlier conversion query with a requested target type yielded a hit (e.g. negative hit), subsequent queries without a target type received the same answer. This might happen although the non-cached answer would return a different result.
2017-07-04 14:30:45 +02:00
Christoph Strobl
f6a6565638 DATACMNS-1101 - Remove getPersistentProperties/Associations from PersistentEntity.
Remove lately introduced getPersistentProperties / getAssociations and rather extend Iterable<? extends PersistentProperty<P>>
2017-07-04 14:30:45 +02:00
Christoph Strobl
88ac1fc165 DATACMNS-1101 - Polishing.
Move MappingException from o.s.d.mapping.model to o.s.d.mapping package and use it for getRequired* methods in MappingContext instead of throwing IllegalArgumentException. Further on we’ve consolidated usage of IllegalArgumentException and IllegalStateException. Along that IllegalMappingException was removed in favor or MappingException.

BasicPersistentEntity now looks up all properties by annotation instead of just returning the first one found. We’ve kept the original methods behavior and updated the comment as well as introduced getPersistentProperties returning all matching properties.
2017-07-04 14:30:45 +02:00
Oliver Gierke
09dd13c41a DATACMNS-1101 - Adapt API changes in PropertyAccessor from MappingAuditableBeanWrapperFactory.
We now avoid wrapping the value into an Optional as PropertyAccessor now takes Object as parameter right away.
2017-07-04 14:30:45 +02:00
Oliver Gierke
f78793ceeb DATACMNS-1101 - User method invocation over reference to avoid compiler error in Eclipse. 2017-07-04 14:30:45 +02:00
Mark Paluch
4a04251a81 DATACMNS-1101 - Reinstantiate assertions using Supplier. 2017-07-04 14:30:44 +02:00
Mark Paluch
5015b34a58 DATACMNS-1101 - Add caching for annotation-based property lookup. 2017-07-04 14:30:44 +02:00
Mark Paluch
0493d131e0 DATACMNS-1101 - Remove Optional from TypeDiscoverer API. 2017-07-04 14:30:44 +02:00
Mark Paluch
2064c72a85 DATACMNS-1101 - Remove Optional from PersistentProperty.getComponentType(…)/getMapValueType(…). 2017-07-04 14:30:44 +02:00
Mark Paluch
eb9854f18f DATACMNS-1101 - Cache positive and negative simple type hits. 2017-07-04 14:30:44 +02:00
Oliver Gierke
0e86470e36 DATACMNS-1101 - Remove Alias.ofOptional(…).
Refactored type alias detection invocation in BasicPersistentEntity into separate method and avoid the factory method Alias.ofOptional(…) so that it can be removed.
2017-07-04 14:30:44 +02:00
Mark Paluch
8c499122c7 DATACMNS-1101 - Alias is no longer based on Optional.
Remove internal Optional usage from Alias so it's a pure value object that does not create Optional instances during its usage.
2017-07-04 14:30:43 +02:00
Mark Paluch
78e8327d2d DATACMNS-1101 - Replace Stream usage in SimpleTypeHolder with loops.
Use loops to prevent Stream allocation in isSimpleType(…). Use WeakHashMap for type caching for improved contains(…) performance and GC behavior.
2017-07-04 14:30:43 +02:00
Mark Paluch
773fb80263 DATACMNS-1101 - Apply caching to frequently used flags in AnnotationBasedPersistentProperty. 2017-07-04 14:30:43 +02:00
Mark Paluch
17b82cfe37 DATACMNS-1101 - Use construction object array pooling.
Use a thread-local object pool for constructor arguments to reduce object allocations.
2017-07-04 14:30:43 +02:00
Mark Paluch
e6e3290e59 DATACMNS-1101 - Refactor CustomConversion to use two-level caching.
We now use a two-level cache instead of using a composite cache key to reduce object allocations.
2017-07-04 14:30:43 +02:00
Mark Paluch
6495a50df7 DATACMNS-1101 - Replace ArrayList indirections in ReflectionEntityInstantiator/PreferredConstructor.
Iterate over simple ArrayList and construct array of params instead of copying elements between multiple Lists.
2017-07-04 14:30:43 +02:00
Mark Paluch
b2ce4b8f1b DATACMNS-1101 - Use array to store map types in TypeDiscoverer.
Prevent iterator creation.
2017-07-04 14:30:43 +02:00
Mark Paluch
ce9aae49c8 DATACMNS-1101 - Use non-capturing lambdas in CustomConversions for conversion lookup. 2017-07-04 14:30:43 +02:00
Oliver Gierke
38d9b08132 DATACMNS-1101 - Ternary value assignment in AnnotationBasedPersistentProperty. 2017-07-04 14:30:43 +02:00
Mark Paluch
a15b25c9ef DATACMNS-1101 - Cache Value annotation value eagerly. 2017-07-04 14:30:42 +02:00
Mark Paluch
6c65c02e78 DATACMNS-1101 - Remove Optional from mapping/convert use except for caching of absence and computations that are used to populate caches. 2017-07-04 14:30:42 +02:00
Mark Paluch
74fbe13f54 DATACMNS-1101 - Reduce Optional usage in convert/mapping packages.
Reducing Optional usage that lies on hot code paths for object mapping.
2017-07-04 14:30:42 +02:00
Mark Paluch
4aa083377b DATACMNS-1101 - Iterate with BasicPersistentEntity.doWithProperties(…) over precomputed properties. 2017-07-04 14:30:42 +02:00
Oliver Gierke
c3c5e7e331 DATACMNS-1102 - Avoid superfluous recreation of ConversionService for projections.
For repository query methods with a dynamic projection parameter, the ResultProcessor is recreated with the type handed to the method. This results in recreation of the ProjectingConverter, which previously recreated a DefaultConversionService instance (for fallback conversions), which is rather expensive due to the reflection lookups checking for the presence of libraries on the classpath.

This is now avoided by using copying methods that reuse the initially created DefaultConversionService.
2017-07-02 21:37:02 +02:00
Oliver Gierke
8a0dffea67 DATACMNS-1098 - Polishing.
Removed obsolete Spring version check. Formatting.
2017-06-26 16:26:41 +02:00
Oliver Gierke
fce40e981c DATACMNS-1098 - RepositoryComponentScanner now exposes BeanDefinitionRegistry.
We now override ClassPathScanningCandidateComponentProvider's getRegistry() to make sure custom conditions on repository candidates can use the currently available BeanDefinitionRegistry in their implementations. To achieve that we forward the BeanDefinitionRegistry at hand through the configuration infrastructure (both XML and annotation side of things).
2017-06-26 16:26:41 +02:00
Oliver Gierke
6cd5f7c052 DATACMNS-1096 - Replaced references to Spring's Converter to JDK 8's Function in domain package.
Switched to use Optional<Object> to make nullability explicit. Keep the original ….convert(…) method around as deprecated default method so that clients can be migrated gradually.
2017-06-26 16:26:41 +02:00
Oliver Gierke
97bd85e628 DATACMNS-1095 - Made ObjectInstantiator public to avoid IllegalAccessErrors.
ObjectInstantiator needs to be declared public as otherwise loading the implementation class fails as it doesn't have access to the (package) private interface in a different classloader.
2017-06-21 18:23:04 +02:00
Oliver Gierke
663ae9b4bf DATACMNS-102 - Polishing.
Changed RepositoryConfiguration to return Streamable over Iterable. A couple of code reorganizations, suppression of raw type. Turned abstract helper classes into interfaces where possible. A couple of typos in JavaDoc.

Original pull request: #222.
2017-06-13 23:47:54 +02:00
Mark Paluch
92e8907030 DATACMNS-102 - Allow Repositories to be composed of an arbitrary number of implementation classes.
We now use RepositoryComposition as backing implementation for repository method calls to implementations. We now scan for repository fragments during the repository configuration phase. Fragment implementation candidates derive from the repository interface declaration, specifically the declared interfaces and their order. We scan the class path during fragment scan for each interface and add discovered fragments to the repository composition. The name of the implementation is derived from the simple name of the interface and the implementation suffix. Qualified fragments are top-level interface declarations that are not annotated with NoRepositoryBean. Inherited interfaces are not considered as fragment candidates.

We create a RepositoryComposition from the discovered fragments in the order of interface declaration in the repository interface and supply the composition to the actual repository creation.

Original pull request: #222.
2017-06-13 23:47:54 +02:00
Mark Paluch
5e123ad7df DATACMNS-102 - Remove trailing whitespaces.
Original pull request: #222.
2017-06-13 23:47:54 +02:00
Christoph Strobl
f913aa7439 DATACMNS-1063 - Polishing.
Add deleteById accepting Publisher and alter JavaDoc to be more explicit about illegal arguments.

Original Pull Request: #226
2017-06-13 19:42:23 +02:00
Mark Paluch
9f1af1fb09 DATACMNS-1063 - Accept Publisher in ReactiveCrudRepository findById(…) and existsById(…).
We now accept Publisher<T> instead of Mono<T> in findById(…) and existsById(…). Users of a ReactiveStreams-based framework are no longer required to perform Publisher to Mono-adoption themselves but can pass a Publisher directly. Both methods use the first emitted value to issue their queries. Additional values are not consumed from the stream.

Original Pull Request: #226
2017-06-13 19:34:51 +02:00
Christian Wiejack
13907152fb DATACMNS-1073 - Remove unnecessary generics from PagingAndSortingRepository.findAll(Pageable).
Original pull request: #220.
2017-06-13 13:05:46 +02:00
Oliver Gierke
dc30810936 DATACMNS-764 - Fix ClassLoader lookup in XmlRepositoryConfigurationSource.
As per @jhoeller's recommendation, we now use the ResourceLoader's ClassLoader instead of the bean ClassLoader exposed by the XmlReaderContext. The latter can apparently be null outside certain lifecycle phases.

Related pull request: #201.
2017-06-09 15:31:51 +02:00
Oliver Gierke
9462a5ba47 DATACMNS-764 - Java 8 polishing.
Use Streamable in configuration APIs for more efficient, lazy traversal of source lists. Introduced SelectionSet.of(…) to move away from constructors. Avoid the use of null in SelectionSet.

Original pull request: #201.
2017-06-09 13:53:09 +02:00
Jens Schauder
eec63cb11d DATACMNS-764 - Disambiguate custom repository implementation if necessary
When multiple repository implementations are found based on the class name, the one with a bean name matching the interfaces bean name + implementation postfix is picked. Includes support for CDI.

RepositoryBeanNameGenerator now no longer implements BeanNameGenerator since while it produces names it does not behave like the interface suggests, i.e. it can work without a BeanFactory in the first place. It now uses constructor injection and is package private.

Original pull request: #201.
2017-06-09 13:53:09 +02:00
Oliver Gierke
976aeaf34c DATACMNS-1074 - Polishing.
Java-8-ification.

Original pull request: #221.
2017-06-07 10:45:04 +02:00
Oliver Gierke
83d9c56eb4 DATACMNS-1074 - Polishing.
Enum names in all caps.

Original pull request: #221.
2017-06-07 10:45:04 +02:00
Mark Paluch
9038e6894c DATACMNS-1074 - Cache MethodHandles of default methods after lookup.
We now cache method handles after lookup on a best-effort basis to reuse them and prevent subsequent lookups as a MethodHandle lookup is expensive, in particular the lookup uses exceptions as control flow [0] during speculative lookup [1].

[0] http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/5b86f66575b7/src/share/classes/java/lang/invoke/MemberName.java#l978
[1] http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-August/042770.html

Original pull request: #221.
2017-06-07 10:45:04 +02:00
Roman Rodov
cabfa287cb DATACMNS-1082 - Skip synthetic constructors.
Constructor discovery no longer considers synthetic constructors for preferred constructor.

Original pull request: #225
2017-06-07 08:45:28 +02:00
Mark Paluch
11c1ad8025 DATACMNS-1079 - Polishing.
Remove javadoc params without documentation. Reorder methods in the order they are called. Rename arePropertyHashCodesUnique to hasUniquePropertyHashCodes. Add author tag. Formatting.

Original pull request: #224.
2017-06-02 16:55:00 +02:00
Jens Schauder
497dc08a7c DATACMNS-1079 - Polishing.
Refactored all the checks done to check if ClassGeneratingPropertyAccessorFactory works into separate methods, so the body of isSupported becomes nice and readable.

Original pull request: #224.
2017-06-02 16:53:10 +02:00
Jens Schauder
59f52a9e35 DATACMNS-1079 - Disable generated property accessors if ClassLoader is encapsulated.
ClassGeneratingPropertyAccessorFactory does not work with Java 9 (encapsulated modules, without --permit-illegal-access), because making ClassLoader.defineClass accessible fails.

Therefore this change moves call to setAccessible to the check that ensures availability of the method so isSupported(…) returns false.

Original pull request: #224.
2017-06-02 16:52:59 +02:00
Mark Paluch
07da629356 DATACMNS-1076 - Deprecate RxJava1CrudRepository and RxJava1SortingRepository interfaces.
Spring Data 2.0 is going GA after the feature freeze of RxJava 1. In prospect of its EOL it makes no sense to ship new APIs based on a library that goes towards EOL.

RxJava1CrudRepository and RxJava1SortingRepository are subject to removal in a future milestone.
2017-05-31 16:01:59 +02:00