Commit Graph

1329 Commits

Author SHA1 Message Date
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
Mark Paluch
2e532b3d21 DATACMNS-991 - Polishing.
Refactor conditional lookup strategies into enum instances reflecting the open/encapsulated lookup strategy.

Original pull request: #223.
2017-05-31 15:56:50 +02:00
Jens Schauder
6a39937d51 DATACMNS-991 - Support Java 9 compatible MethodHandle lookup.
DefaultMethodInvokingMethodInterceptor now contains two alternative implementations, one compatible to Java 8, one for Java 9.

Original pull request: #223.
2017-05-31 15:55:49 +02:00
Christoph Strobl
77be0ba859 DATACMNS-995 - Polishing.
Update JavaDoc to reflect reactive types, not null arguments and potential exceptions.
Align not null JavaDoc of imperative QueryByExample interface.

Original Pull Request: #197
2017-05-22 15:00:29 +02:00
Mark Paluch
1158b5feda DATACMNS-995 - Create ReactiveQueryByExampleExecutor allowing reactive query by example.
Provide a mix-in interface to be used in store modules providing reactive Query by Example query execution.

    Mono<T> findOne(Example<T> sample);
    Flux<T> findAll(Example<T> sample);
    Mono<Long> count(Example<T> sample);
    //...

Original Pull Request: #197
2017-05-22 14:57:27 +02:00
Oliver Gierke
17af937194 DATACMNS-1059 - Polishing.
Original pull request: #215.
2017-05-19 09:22:23 +02:00
Christoph Strobl
8c028c3115 DATACMNS-1059 - Alter QuerydslPredicateExecutor.findOne(…) to return Optional<T>.
We now return Optional<T> for QuerydslPredicateExecutor.findOne(Predicate) aligning the return type to the ones used in CrudRepository.

Original pull request: #215.
2017-05-19 09:22:23 +02:00
Oliver Gierke
0e36b43752 DATACMNS-1026 - Polishing.
Minor refactorings here in there for clarity.

Original pull request: #217.
2017-05-17 16:20:50 +02:00
Jens Schauder
1bf318fb02 DATACMNS-1026 - Polishing.
Minor improvements to Javadoc.

Original pull request: #217.
2017-05-17 16:20:48 +02:00
Jens Schauder
42621086fe DATACMNS-1026 - ExtensionAwareEvaluationContextProvider now returns all overloaded methods as functions.
All overloaded methods are now available in SPeL expressions. Among methods with identical argument list from different sources in the same extension (extension, root object, aliases) the last one in the order in parens wins. If there is more than one method for an application the following rules are applied: if there is one method with exact matching types in the argument list it is used, otherwise an exception is thrown.

Original pull request: #217.
2017-05-17 16:20:38 +02:00
Oliver Gierke
5dba2f4c59 DATACMNS-1066 - Polishing.
Formatting and removal of obsolete methods.
2017-05-16 19:11:38 +02:00
Oliver Gierke
5f9d90ee3e DATACMNS-1066 - ClassGeneratingPropertyAccessorFactory now opts out on failed access to ClassLoader.
We now eagerly check the accessibility of the defineClass(…) method on the class loader to be used for a PersistentEntity. This will then cause the clients to use a different PropertyAccessorFactory (as things stand today: the one using reflection) and not fail to create the class later on.
2017-05-16 19:11:12 +02:00
Oliver Gierke
71977c9309 DATACMNS-1067 - Polishing.
Revert change to only invoke cleanup method if events have been exposed. We now again invoke the cleanup method for every aggregate. Changed the publication of events from the aggregate instances that were handed into the method to the ones the save method returns as the save call might return different object instances.

Cleanups in the unit tests. Moved newly introduced methods to the bottom of the test case class. Extracted method to set up mock method invocation.

Original pull request: #216.
2017-05-15 15:39:52 +02:00
yukiyoshida
417fad340b DATACMNS-1067 - Fix not to call @AfterDomainEventPublication method from collection of entities.
We now make sure the event cleanup method is called on the aggregate root, not on the parameter object directly (as the latter might be a collection.

Original pull request: #216.
2017-05-15 15:25:48 +02:00
Oliver Gierke
2eb830d68f DATACMNS-822 - Polishing.
Switched to implement WebMvcConfigurer over extending WebMvcConfigurerAdapter. Formatting, assertions, Javadoc.

Original pull request: #208.
2017-05-12 16:57:02 +02:00
Jens Schauder
364ed9ab2e DATACMNS-822 - Polishing.
Replaced optional dependencies with Optional and explicit null checks with calls to ifPresent. Used Lambda style instead of anonymous classes where applicable. Converted Hamcrest matchers to AssertJ. 
Minor improvements to formatting.

Original pull request: #208.
2017-05-12 16:57:02 +02:00
Vedran Pavic
c1036b2204 DATACMNS-822 - Provide customizers for default pageable and sort resolvers.
Introduced dedicated callback interfaces to customize the HandlerMethodArgumentResolver instances registered by SpringDataWebConfiguration. This allows bean definition registration of those customizer interfaces instead of having to extend a configuration class.

Original pull request: #208.
2017-05-12 16:57:02 +02:00
Oliver Gierke
34ce83c657 DATACMNS-1065 - Added support for Vavr (successor of Javaslang).
Basically duplicated the Javaslang support to now work on Vavr types as well.
2017-05-11 12:36:23 +02:00
Mark Paluch
7d496978f5 DATACMNS-1058 - Polishing.
Improve Javadoc. Extend year range in license header.

Original pull request: #214.
2017-05-11 09:56:21 +02:00
Christoph Strobl
0ff53bd5db DATACMNS-1058 - Alter QueryByExampleExecutor.findOne to return Optional<S>.
We now return Optional<S> for findOne() just as we do in CrudRepository.

Original pull request: #214.
2017-05-11 09:56:06 +02:00
Oliver Gierke
5d08bd6273 DATACMNS-1113 - Domain event publication now happens for all methods starting with save….
Previously we explicitly intercepted repository methods named save(…) and saveAll(…) which unfortunately results in custom variants of that (e.g. JpaRepository's saveAndFlush(…)) not causing event publication.

We now publish events for methods whose names start with save….
2017-05-11 09:50:09 +02:00
Oliver Gierke
a190c082f7 DATACMNS-1034 - Introduced API to easily register converters using Java 8 lambdas.
Introduced ConverterBuilder which exposes API to register Spring GenericConverters for the use with a store module's CustomConversions. This allows simple registration of such converters using Java 8 lambdas.

ConverterAware converters = ConverterBuilder.reading(String.class, Long.class,
  it -> Long.valueOf(it)).andWriting(it -> Object::toString);

The setup can also be done from the reading side which would just need the method invocations inverted. The resulting ConverterAware will expose the registered converters so that they can be easily handed to a CustomConversions instance. Partial creation of either reading or writing converters is possible, too with the returned instance then only exposing one of the two converters.

CustomConversions now considers ConverterAware and treats them appropriately for ConvertiblePair registration as well as during the registration in the ConversionService. Tweaked parameter types in CustomConversions to rather accept a Collection<?> for the converters (previously List<?>). Also, registerConverterIn(…) now takes a ConverterRegistry over a GenericConversionService. Polished Javadoc and non-null assertions.

Original pull request: #209.
2017-05-05 12:32:19 +02:00
Oliver Gierke
3fb7c870fb DATACMNS-1057 - SingleValueBinding now returns a non-Optional again.
The binding is populated with a value so we can also expect a predicate to be returned.
2017-05-04 23:14:43 +02:00