Commit Graph

489 Commits

Author SHA1 Message Date
Mark Paluch
f453130569 DATACMNS-987 - Polishing.
Remove unused Querydsl tests. Add author. Reformat code. Extend Javadoc.
2017-02-13 13:32:42 +01:00
Jens Schauder
0ad1a8dad3 DATACMNS-987 - Jackson converter gets only loaded if Jackson and Jayway dependencies are present.
Added a test for loading of QuerydslPredicateArgumentResolver, but it fails presumably because EnableSpringDataWebSupport is not in effect.

Renamed SpringDataWebConfigurationUnitTests to SpringDataWebConfigurationIntegrationTests since it is actually an integration test.

Related ticket: DATACMNS-993.
2017-02-13 13:32:39 +01:00
Christoph Strobl
3e048a6dca DATACMNS-985 - Remove references to single-argument assertion methods. 2017-01-31 18:10:40 +01:00
Oliver Gierke
88e70a2730 DATACMNS-776 - Made ProxyingHandlerMethodArgumentResolver to only support user types or annotated ones.
ProxyingHandlerMethodArgumentResolver is now more lenient when it comes to which types to support for proxying. As indicated in the ticket, we've been to aggressive opting in for all interfaces which - depending on the order of converter registrations - caused us interfering with other interface based resolutions (e.g. in Spring Mobile, Security etc.).

We now only aggressively kick in if either the type or parameter is annotated with @ProjectedPayload or the type itself is not a Spring Framework or native Java one. This should leave user defined types still be accepted whereas the types we previously erroneously interfered with should now be ignored.
2017-01-23 11:42:25 +01:00
Oliver Gierke
50b84e701f DATACMNS-972 - Fixed ProjectingJackson2HttpMessageConverter.canRead(…) for generic type variables.
ProjectingJackson2HttpMessageConverter.canRead(…) now resolves the given type correctly, even in context of their owning class.
2017-01-19 12:30:08 +01:00
Oliver Gierke
e3b7bb8b01 DATACMNS-957 - AuditingHandler now works with entities without an identifier.
Entities without an identifier previously an exception because the IsNewStrategyFactory wasn't able to determine a strategy even if there was no auditing to be applied in the first place.

We now eagerly check for auditability and skip the lookup for an IsNewStrategy completely in case that check returns false.

Related pull request: #189.
2017-01-19 09:50:11 +01:00
Oliver Gierke
74426c01e1 DATACMNS-977 - Added @Indexed to core annotations and types to be indexed for component scanning.
Equipped @Persistent, @RepositoryDefinition and our Repository marker interface with @Indexed so that Spring 5's annotation processor will detect types annotated with or extending the aforementioned type for inclusion in the component index.

Related ticket: SPR-11890.
2017-01-18 19:14:02 +01:00
Oliver Gierke
db17a28238 DATACMNS-975 - Make sure repository method is invoked before event publication.
To make sure that event handlers can read the state of the aggregate persisted, we now invoke the call to the repository before publishing the events. That shouldn't make too much of a difference to most listeners as the event usually contains a reference to the aggregate. However, the new model generally aligns with the approach of reporting what *already has happened* better that our previous approach of first publishing the events and then invoking the repository method.

Related tickets: DATACMNS-928.
2017-01-13 12:28:29 +01:00
Mark Paluch
8bafe7964b DATACMNS-973 - Polishing.
Convert @see http://… links to valid format using @see <a href=…>…</a>.
2017-01-13 08:50:54 +01:00
Oliver Gierke
a946d651ff DATACMNS-967 - Getters that are default methods are not considered projection input properties anymore.
We now exclude getter methods that are default methods from the consideration which properties of a projection interface are considered input properties in the first place.

Some additional Java 8 polish in DefaultProjectionInformation.
2016-12-23 13:06:34 +01:00
Oliver Gierke
3b635e665a DATACMNS-963 - Returned type returns distinct input properties now.
We now manually filter already gathered property names in ReturnedInterface.getInputProperties() as we have to deal with duplications for properties with the same name at different levels of the inheritance hierarchy.
2016-12-21 14:14:48 +01:00
Oliver Gierke
a2218ba81e DATACMNS-891 - Moved to constructor injection for RepositoryFactoryBeanSupport.
RepositoryFactoryBeanSupport now takes the repository interface as a constructor argument instead of as a setter. This makes sure that the container induced type prediction for factory beans actually wires the interface *before* it calls getObjectType() on the instance. This allows us to remove the extra infrastructure we had in place to predict the bean types and autowiring will just work out of the box.

Adapted infrastructure code accordingly, removed obsolete infrastructure code and adapted test cases accordingly.
2016-12-15 16:32:03 +01:00
Oliver Gierke
313e0ae196 DATACMNS-960 - RevisionRepository now extends Repository. 2016-12-15 16:17:15 +01:00
Oliver Gierke
47b8e0290f DATACMNS-959 - RepositoryFactorySupport now registers interceptor to detect transactions.
The interceptor discovers whether a transaction was running before the call entered the repository proxy and exposes that fact via ….isSurroundingTransactionActive() for donwstream usage.

Related ticket: DATAJPA-1023.
2016-12-14 15:34:08 +01:00
Oliver Gierke
21a6f19312 DATACMNS-958 - Use ExposeInvocationInterceptor.ADVISOR in RepositoryFactorySupport.
Its usage is recommended over using the instance as advice.
2016-12-14 13:59:50 +01:00
Oliver Gierke
a9c3b9f66f DATACMNS-940 - Support for Javaslang collections as repository return types.
Javaslang's collection and map types can now be used on repository query methods and get adapted similarly to nullable wrapper types (like JDK's Optional). Also made TypeInformation infrastructure aware of the map type so that a value type lookup gets handle correctly.
2016-12-12 20:08:19 +01:00
Oliver Gierke
c52aba358d DATACMNS-956 - Ensure consistent use of ClassTypeInformation.from(…). 2016-12-12 17:09:35 +01:00
Oliver Gierke
f93d2df4f1 DATACMNS-941 - Support for downcasts in Querydsl web bindings.
We now support downcasts (e.g. user.as(QSpecialUser.class).…) expressions in Querydsl web binding. We do so by skipping the introduced intermediate step in the path when calculating the dot path.

Refactored the internals of the binding to now work based on a PathInformation implementation for which either a Querydsl Path or a Spring Data PropertyPath can be used. This allows us to reuse the paths of predefined bindings.

A bit of Lombok cleanup in internal implementations.
2016-12-12 16:34:18 +01:00
Oliver Gierke
a696484f8d DATACMNS-953 - Fixed application of GenericPropertyMatchers.exact().
We now really use exact matching for a match setup requesting exact matching. Previously, we erroneously set up the matching with a startsWith().
2016-12-06 10:58:52 +01:00
Oliver Gierke
d3f235872c DATACMNS-934 - BasicPersistentEntity.addAssociation(…) drops null values now.
Previously a null value was added to the list of associations if it was handed to BasicaPersistentEntity.addAssociation(…). We now drop those null values and log a warning as it usually indicates a MappingContext implementation identifying a property as association but subsequently failing to look it up.
2016-12-05 16:39:58 +01:00
Oliver Gierke
9354800225 DATACMNS-952 - Switched from component scanning to SpringFactoriesLoader for internal extension points.
Both the configuration code looking up Spring Data specific Jackson modules as well as the code detecting whether we have multiple Spring Data modules on the classpath used component scanning. That can have quite significant impact on startup times.

This commit replaces the classpath scanning with the use of SpringFactoriesLoader that now requires modules that want to extend the behavior of Spring Data's web configuration or indicate a repository implementation being present by shipping a file called META-INF/spring.factories. Spring Data relies on the following keys:

- org.springframework.data.web.config.SpringDataJacksonModules - list the Spring configuration classes that will expose additional Jackson modules that are supposed to be registered for Spring Data's Jackson web support
- org.springframework.data.repository.core.support.RepositoryFactorySupport - list the Spring Data repository factory implementation class that implements repository support for your module. The general detection and configuration mechanism for user repositories is not affected by this. Currently Spring Data only uses the pure number of different entries for that key to switch into strict configuration mode in case we find more than one entry.
2016-12-05 13:55:05 +01:00
Oliver Gierke
092972824e DATACMNS-951 - Polishing.
Switched to parameterized tests for newly introduced Converters.

Fixed imports and JavaDoc.

Original pull request: #186.
2016-12-05 09:59:25 +01:00
Barak Schuster
5020c7b8bb DATACMNS-951 - Added Converter implementations for JSR-310 Duration and Period.
Original pull request: #186.
2016-12-05 09:59:25 +01:00
Mark Paluch
e768e8eb5e DATACMNS-947 - Adopt ReactiveTypeDescriptor and ReactiveAdapterRegistry changes.
Remove our own ReactiveWrappers.Descriptor type in favor of ReactiveTypeDescriptor. Adopt changes in ReactiveAdapterRegistry.
2016-12-04 13:12:43 +01:00
Oliver Gierke
f6db714206 DATACMNS-928 - Refinements for aggregate root domain event publication.
We now publish events for all methods named "save" on the repository. Fundamentally, that's in place to capture calls to CrudRepository.save(Iterable entities), too.

Some minor refactorings to the internal setup of EventPublishingMethodInterceptor. More JavaDoc.
2016-12-01 09:43:28 +01:00
Oliver Gierke
c52c45741a DATACMNS-928 - Polishing.
Additional JavaDoc and @since tags. Minor additions to AbstractAggregateRoot.
2016-11-30 18:30:51 +01:00
Oliver Gierke
802eb7deef DATACMNS-928 - Support for publishing events from aggregate roots.
Introduced @DomainEvents usable on a method of an aggregate root. The method will be invoked when the aggregate is passed to a repository to save and its returned value or values will be exposed via an ApplicationEventListener.

Also, the aggregate can expose a method annotated with @AfterDomainEventPublication which will be invoked once all events have been published.
2016-11-30 18:30:51 +01:00
Oliver Gierke
a8b2eb1589 DATACMNS-918 - Polishing.
Minor JavaDoc stuff.
2016-11-29 14:15:19 +01:00
Mark Paluch
08d9a61ea3 DATACMNS-918 - Provide interfaces for Pageable and Sort method argument resolvers.
We now provide HandlerMethodArgumentResolver interfaces to resolve Sort and Pageable method arguments with typed return values.
2016-11-29 14:15:19 +01:00
Oliver Gierke
fbd560ee4f DATACMNS-943 - We prefer direct matches on repository query method overloads.
We now try to look up a target class method based on concrete name and parameter type before falling back on the more expensive type matches. This also eliminates the possibility of invalid method matches as described in the ticket.
2016-11-24 17:23:57 +01:00
Oliver Gierke
bc2af4ceb1 DATACMNS-937 - Fixed spelling of Javaslang related code.
Using a lower case "s" now.
2016-11-21 12:35:07 +01:00
Mark Paluch
ed11c9dbd7 DATACMNS-939 - Do not create queries for static interface methods.
We now no longer attempt query creation for static methods declared on a repository interface. This allows static method usage inside of repository interfaces.

interface PersonRepository extends CrudRepository<Person, String> {

    static String createId() {
        // …
    }

    default Person findPerson() {
        return findOne(createId());
    }
}
2016-11-21 10:32:52 +01:00
Oliver Gierke
e009471aaa DATACMNS-937 - Polishing.
Removed Spring 4.2 guard from QueryExecutionConverter and its unit tests.
2016-11-19 12:59:08 +01:00
Oliver Gierke
71fc87ad42 DATACMNS-937 - Support for JavaSlang's Option type as nullable wrapper.
Repository methods can now return JavaSlang's Option as alternative to JDK 8's Optional or Guavas Optional.
2016-11-19 12:56:19 +01:00
Oliver Gierke
f3433a4fd4 DATACMNS-935 - Removed dependency to Spring's Descriptor.
The Descriptor class is nested in the ReactiveAdapter interface which in turn has a strong dependency to Project Reactor as it exposes some if its types as method return types. That means we can't refer to Spring's Descriptor without Project Reactor on the classpath.

Introduced a custom Descriptor that exposes the setup needs we have using a fluent API.

We now also only conditionally actually the ReactiveAdapterRegistry as eagerly instantiating it in RectiveWrapperConverter causes a strong dependency on Reactor.

Related tickets: DATACMNS-836, SPR-14902.
2016-11-14 20:18:49 +01:00
Mark Paluch
8a2ce30e70 DATACMNS-836 - Encapsulate reactive type conversion in ReactiveWrapperConverters.
Reactive type conversion now happens fully inside of ReactiveWrapperConverters and does not require an external ConversionService. This change allows changes to reactive type conversion without changing the API since all details are encapsulated by ReactiveWrapperConverters.
2016-11-14 15:41:59 +01:00
Oliver Gierke
325f7bb1d2 DATACMNS-836 - Introduced base class for reactive repository factories.
Introduced ReactiveRepositoryFactorySupport so that validation for the presence of all required converters (e.g. RxJava 1) does not have to be repeated in individual stores.
2016-11-14 15:41:54 +01:00
Oliver Gierke
9bca55a8c4 DATACMNS-836 - Improve reactive repository configuration.
RepositoryConfigurationExtensionSupport now exposes a ….useRepositoryConfiguration(RepositoryMetadata) so that extensions can opt in or out of an interface taking part in configuration more easily. Turned loadRepositoryInterface(…) private again as extensions should be able to just inspect the RepositoryMetadata now.

Some parameter rename in ReactiveWrapperConverters to avoid confusion.
2016-11-14 15:41:54 +01:00
Oliver Gierke
5d591db848 DATACMNS-836 - Polishing.
RepositoryMetadata now exposes an ….isReactiveRepository() that's implemented by inspecting the backing repository interface for any reactive wrapper type appearing in method signatures. That allows us to move down the use of a ConversionService down to ReactiveRepositoryInformation.WrapperConversionMatch.

Made a couple of methods static that could be. Simplified some logic using streams. A bit better wording in assertions. Some formatting when using streams.
2016-11-14 15:41:54 +01:00
Christoph Strobl
5bf19d1c2a DATACMNS-836 - Favor usage of Function over Converter. 2016-11-14 15:41:53 +01:00
Mark Paluch
c049fd8368 DATACMNS-836 - Enhance JavaDoc. 2016-11-14 15:41:53 +01:00
Mark Paluch
d0836773ba DATACMNS-836 - Apply deferred reactive type conversion as RxJava's PublisherAdapter keep state between multiple subscribers. 2016-11-14 15:41:53 +01:00
Mark Paluch
a6bc800138 DATACMNS-836 - Move reactive wrapper converters to ReactiveWrapperConverters.
Move reactive wrapper conversion to ReactiveWrapperConverters to minimize touching points with reactive APIs. ReactiveWrapperConverters is used only from reactive repository components and does not initialize with blocking API use. This removes the need of having Project Reactor on the class path for non-reactive use.
2016-11-14 15:41:53 +01:00
Mark Paluch
dd2fe0a34d DATACMNS-836 - Cleanups.
- Rename RxJava...Repository to RxJava1...Repository
- Use Completable and Observable instead of Single for results without values/optional values
- Remove reactive paging for now as it does not really fit reactive data streaming
- Expose ReactiveWrappers.isAvailable(ReactiveLibrary) method to query library availability
2016-11-14 15:41:53 +01:00
Mark Paluch
474c9981da DATACMNS-836 - Provide wrapper conversion, ReactiveWrappers and RxJava 2 type conversion. 2016-11-14 15:41:53 +01:00
Mark Paluch
2e4d63fddd DATACMNS-836 - Add reactive repository support.
We now expose reactive interfaces to facilitate reactive repository support in store-specific modules. Spring Data modules are free to implement their reactive support using either RxJava 1 or Project Reactor (Reactive Streams). We expose a set of base interfaces:

* `ReactiveCrudRepository`
* `ReactiveSortingRepository`
* `RxJava1CrudRepository`
* `RxJava1SortingRepository`

Reactive repositories provide a similar feature coverage to blocking repositories. Reactive paging support is limited to a `Mono<Page>`/`Single<Page>`. Data is fetched in a deferred way to provide a paging experience similar to blocking paging.

A store module can choose either Project Reactor or RxJava 1 to implement reactive repository support. Project Reactor and RxJava types are converted in both directions allowing repositories to be composed of Project Reactor and RxJava 1 query methods. Reactive wrapper type conversion handles wrapper type conversion at repository level. Query/implementation method selection uses multi-pass candidate selection to invoke the most appropriate method (exact arguments, convertible wrappers, assignable arguments).

We also provide ReactiveWrappers to expose metadata about reactive types and their value multiplicity.
2016-11-14 15:41:52 +01:00
Oliver Gierke
3f3ab494a8 DATACMNS-919 - Removed deprecated DomainClassPropertyEditor and -Registrar. 2016-11-14 15:39:48 +01:00
Oliver Gierke
5d1ce6daa5 DATACMNS-864 - Fix Java 8 compiler ambiguities.
Added explicit generics invocations in places that caused an ambiguous invocation on Java 8.
2016-11-14 15:39:48 +01:00
Oliver Gierke
b4518f0583 DATACMNS-920 - Added accessors for Range.lowerInclusive / ….upperInclusive.
Generally improved Range to be a value type by using Lombok's @Value.
2016-11-04 18:37:22 +01:00
Oliver Gierke
2e4e6ee61f DATACMNS-929 - Fixed NullPointerException in PageableHandlerMethodArgumentResolver.
PageableHandlerMethodArgumentResolver.isFallbackPageable() now correctly guards against the fallback Pageable being null, a situation that's explicitly deemed valid in setFallbackPageable(…).
2016-11-01 18:04:54 +01:00