Commit Graph

901 Commits

Author SHA1 Message Date
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
Oliver Gierke
6894fcb36a DATACMNS-1056 - Prevent QueryExecutionResultHander from rewrapping JDK 8 Optionals.
In case a repository method execution returns a JDK 8 Optional in the first place, the Optional instance had been wrapped into a third-party null-wrapper as is. We're now unwrapping the value held inside that optional and forward it to the value conversion.
2017-05-04 13:37:59 +02:00
Oliver Gierke
727ab8384c DATACMNS-944 - Moved to more consistent naming scheme for CrudRepository methods.
We now follow a more consistent naming scheme for the methods in repository that are driven by the following guidelines:

* Methods referring to an identifier now all end on …ById(…).
* Methods taking or returning a collection are named …All(…)

That results in the following renames:

* findOne(…) -> findById(…)
* save(Iterable) -> saveAll(Iterable)
* findAll(Iterable<ID>) -> findAllById(…)
* delete(ID) -> deleteById(ID)
* delete(Iterable<T>) -> deleteAll(Iterable<T>)
* exists() -> existsById(…)

As a side-effect of that, we can now drop the Serializable requirement for identifiers.

Updated CRUD method detection to use the new naming scheme and moved the code to Java 8 streams and Optional. Adapted RepositoryInvoker API to reflect method name changes as well.
2017-05-03 17:49:50 +02:00
Oliver Gierke
382c912111 DATACMNS-1052 - Sort is now Streamable. 2017-05-03 17:26:36 +02:00
Oliver Gierke
357efe4551 DATACMNS-1053 - EntityInformation now exposes getRequiredId(…).
Added EntityInformation.getRequiredId(…) that throws an exception if getId(…) returns an empty Optional.
2017-05-03 17:26:36 +02:00
Mark Paluch
b0177b2ab7 DATACMNS-1014 - Polishing.
Remove superfluous static modifier for inner enum types.

Original pull request: #213.
2017-05-03 08:26:00 +02:00
Jens Schauder
6be036af3a DATACMNS-1014 - Removed DateMidnight related converters.
org.joda.time.DateMidnight is deprecated, therefore we drop support for DateMidnight and remove all references to it.

Original pull request: #213.
2017-05-03 08:25:26 +02:00
Mark Paluch
14647f9192 DATACMNS-1021 - Add Order.asc(…) and Order.desc(…) factory methods.
We now support Order creation with Order.asc(String) and Order.desc(String) factory methods as shortcut to constructor creation via new Order(Direction, String).

Sort.by(Order.asc("age"), Order.desc("name"));

Deprecated Order(String) constructor in favor of the Order.by(String) factory method. Replace references to new Order(String) with Order.by(String).

Original pull request: #211.
2017-04-26 16:48:40 +02:00
Oliver Gierke
78374f3cb7 DATACMNS-1050 - Polishing.
Used @RequiredArgsConstructor in a couple of places in favour of manually declared constructors. Removed obsolete factory methods on Range. Adapted test cases accordingly.

Original pull request: #212.
2017-04-26 16:30:32 +02:00
Mark Paluch
22dc91b68f DATACMNS-1050 - Encapsulate boundaries in value objects for Range.
We now encapsulate a boundary in Range within a Bound value object. Bound consists of a value and whether the value is inclusive or exclusive. Boundaries without a value are unbounded. We introduced factory methods for Range and Boundary creation using primitives and a builder to build a Range.

Range<Long> range = Range.unbounded();
Range<Integer> range = Range.from(Bound.inclusive(10)).to(Bound.inclusive(20));
Range<Integer> range = Range.of(Bound.inclusive(10), Bound.inclusive(20));

Original pull request: #121.
2017-04-26 16:30:28 +02:00
Oliver Gierke
233fde36b5 DATACMNS-1035 - Moved CustomConversions to Spring Data Commons.
Extracted CustomConversions — whose code has largely been duplicated between the MongoDB, Couchbase and Cassandra modules — into Spring Data Commons. Store-specific extensions can now be contributed via a StoreConversions value type that carries both, store-specific default converters as well as a store-specific SimpleTypeHolder to augment the default list of simple types.

Removed SimpleTypeHolders public default constructor in favour of a protected one and a static DEFAULT instance for plain references.

Original pull request: #210.
2017-04-21 16:49:00 +02:00
Oliver Gierke
46d7e47239 DATACMNS-1042 - PagedResourceAssembler now keeps pagination information for self link.
We now hand the Pageable contained in the Page to the code that constructs the self link.

Added toEmptyResource(Page, Class) to force clients to resolve an optional base link before calling the method. Removed deprecated method to append pagination template parameters.
2017-04-21 16:48:59 +02:00
Oliver Gierke
4918eca7cf DATACMNS-1043 - Slice now exposes Pageable.
We now expose the Pageable that was used to create a Slice via its API. Slice itself constructs a default PageRequest so that current implementations of it still work as before.
2017-04-21 16:48:59 +02:00
Oliver Gierke
9d315af70a DATACMNS-993 - Polishing.
Removed custom JUnit integration as we can just create HidingClassLoader instances in the test and the integration actually causes more code being needed (additional JUnit rule, method level annotations etc.).

Tweaked ShadowingClassLoader to make obvious what has been changed over the Spring Framework variant. Created upstream ticket [0] to ask for the tweaks that would allow us to remove the class again.

Changed SpringDataWebConfigurationImportSelector to be lenient against the ResourceLoader not being available.

Original pull request: #202.
Related ticket: SPR-15439
[0] https://jira.spring.io/browse/SPR-15439
2017-04-12 08:03:38 +02:00
Jens Schauder
65734739bd DATACMNS-993 - Clean up class loader hacking in tests.
ClassLoaderRule with @ClassLoaderConfiguration allows easy creation FilteringClassLoader. Changed usage pattern of ClassUtils.isPresent(…) in order to ease testing. Copied the ShadowingClassloader from SpringFramework to get a constructor that doesn't shadow anything by default.

Original pull request: #202.
2017-04-12 08:03:32 +02:00
Oliver Gierke
37f78a3707 DATACMNS-1024 - Reinstated root object method lookup behavior in EvaluationContextExtensionInformation.
The switch to Java 8 and thus to Collectors.toMap(…) to assemble the root object's methods as functions broke due to the fact that overloaded methods have the same name which causes a collision in keys when preparing the map of functions.

We now use the same approach as before, of letting later methods trump earlier ones as this fixes the original bug. Filed DATACMNS-1026 to keep track of that problem.

Related tickets: DATACMNS-1026.
2017-04-04 07:07:42 +02:00
Mark Paluch
d72e9486be DATACMNS-988 - Fix Publisher to RxJava 2 conversion.
And fix some issues in JavaDoc.

Original Pull Request: #194
2017-04-03 10:47:53 +02:00
Mark Paluch
3099125aa3 DATACMNS-988 - Polishing.
Improve JavaDoc. Remove findAll declarations in reactive sorting repositories as they are inherited with the same signature.

Original Pull Request: #194
2017-04-03 10:47:02 +02:00
Mark Paluch
39ab1b3555 DATACMNS-988 - Provide RxJava 2 Repository interfaces.
Provide RxJava 2 Repository interfaces using back-pressure enabled Flowable as default return type for multi-element queries and Maybe for queries that can complete without emitting a value.

Original Pull Request: #194
2017-04-03 10:46:32 +02:00
Mark Paluch
e73710374d DATACMNS-1023 - We prefer direct matches on reactive repository query method overloads.
We now attempt to look up a target class method based on exact name and parameter types before falling back on the more expensive type matches. This also eliminates the possibility of invalid method matches as described in the ticket.

Related ticket: DATACMNS-943.
Original Pull Request: #194
2017-04-03 10:45:19 +02:00
Oliver Gierke
b5af2e9d96 DATACMNS-1020 - Improvements to revision API.
RevisionRepository now returns Optional for methods that could previously return null. Revision exposes additional methods to lookup required revision numbers and dates. Revisions now implements Streamable and exposes a ….none() factory method to create an empty instance.

AnnotationBasedRevisionMetadata now uses Lazy to lookup the fields with revision annotations. AnnotationDetectionFieldCallback now also uses Optional in places it previously returned null. StreamUtils now exposes factory methods for Collector instances producing unmodifiable List and Set instances.

Related ticket: DATACMNS-867.
2017-03-25 12:34:24 +01:00
Oliver Gierke
11dc67da2c DATACMNS-1018 - Reinstantiated ability to customize repository factory bean through annotation and XML namespace.
The refactoring for DATACMNS-867 has dropped support to customize the repository factory bean class on both the @Enable-annotations and the XML namespace. Reintroduced this feature, added a test case and moved the fallback into the value that's defined by the configuration extension inside DefaultRepositoryConfiguration.
2017-03-24 14:18:40 +01:00
Oliver Gierke
6b5b65804e DATACMNS-1015 - Introduced IdentifierAccessor.getRequiredIdentifier().
The new method allows to look up identifiers and immediately fail in the case of absence. Introduced the method as default method but also a new base type TargetAwareIdentifierAccessor to throw an exception with more context, i.e. the actual target bean we try to look up the identifier on.
2017-03-24 11:57:57 +01:00
Oliver Gierke
5f117a00a3 DATACMNS-867 - Polishing of Property value type in mapping package. 2017-03-24 08:00:48 +01:00
Oliver Gierke
baccb412f0 DATACMNS-867 - Cleanups.
SliceImpl now already checks Sort instance for not null. Removed unnecessary warnings supression.
2017-03-24 08:00:47 +01:00
Oliver Gierke
bc28a6b094 DATACMNS-867 - Improvements in Chunk and PageImpl.
Chunk now rejects null Pageables. Improved total calculation in PageImpl by using ….toOptional().
2017-03-24 08:00:47 +01:00
Oliver Gierke
93bb3d2e21 DATACMNS-867 - Additional assertions in AuditingHandler. 2017-03-24 08:00:47 +01:00
Oliver Gierke
7ac12c3c3d DATACMNS-867 - BasicPersistentEntity now rejects null Association.
Related ticket: DATACMNS-934.
2017-03-24 08:00:47 +01:00
Oliver Gierke
429dcbf659 DATACMNS-867 - ReflectionRepositoryInvoker now avoids ConversionService for Optional creation.
We now manually create Optional instances as the ConversionService converts single-argument collections into an optional with only that element.
2017-03-24 08:00:47 +01:00