From ce31512c819ef09f36f7b2adb820b4485e062134 Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Wed, 25 Nov 2020 16:51:49 +0100 Subject: [PATCH] DATAGRAPH-1441 - Polishing (Remove deprecated classes on 6.1.x). --- .../Neo4jDefaultCallbacksRegistrar.java | 44 --------------- ...eo4jDefaultReactiveCallbacksRegistrar.java | 44 --------------- .../core/mapping/callback/EventSupport.java | 5 +- .../callback/ReactiveEventSupport.java | 9 ++-- .../event/AuditingBeforeBindCallback.java | 53 ------------------- .../repository/event/BeforeBindCallback.java | 45 ---------------- .../ReactiveAuditingBeforeBindCallback.java | 53 ------------------- .../event/ReactiveBeforeBindCallback.java | 48 ----------------- 8 files changed, 6 insertions(+), 295 deletions(-) delete mode 100644 src/main/java/org/springframework/data/neo4j/config/Neo4jDefaultCallbacksRegistrar.java delete mode 100644 src/main/java/org/springframework/data/neo4j/config/Neo4jDefaultReactiveCallbacksRegistrar.java delete mode 100644 src/main/java/org/springframework/data/neo4j/repository/event/AuditingBeforeBindCallback.java delete mode 100644 src/main/java/org/springframework/data/neo4j/repository/event/BeforeBindCallback.java delete mode 100644 src/main/java/org/springframework/data/neo4j/repository/event/ReactiveAuditingBeforeBindCallback.java delete mode 100644 src/main/java/org/springframework/data/neo4j/repository/event/ReactiveBeforeBindCallback.java diff --git a/src/main/java/org/springframework/data/neo4j/config/Neo4jDefaultCallbacksRegistrar.java b/src/main/java/org/springframework/data/neo4j/config/Neo4jDefaultCallbacksRegistrar.java deleted file mode 100644 index 915ad348e..000000000 --- a/src/main/java/org/springframework/data/neo4j/config/Neo4jDefaultCallbacksRegistrar.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2011-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.neo4j.config; - -import org.apiguardian.api.API; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.beans.factory.support.BeanNameGenerator; -import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; -import org.springframework.core.type.AnnotationMetadata; -import org.springframework.data.neo4j.core.Neo4jOperations; - -/** - * This brings in the default callbacks required for the default implementation of {@link Neo4jOperations} to work. The - * offered support configuration class {@link AbstractNeo4jConfig} imports this and so does the Spring Boot - * autoconfiguration. - * - * @author Michael J. Simons - * @soundtrack AC/DC - High Voltage - * @since 6.0 - * @deprecated since 6.0.2, now an empty implementation, not needed anymore and our default callbacks will be added directly via our - * infrastructure. - */ -@API(status = API.Status.DEPRECATED, since = "6.0") -@Deprecated -public final class Neo4jDefaultCallbacksRegistrar implements ImportBeanDefinitionRegistrar { - - @Override - public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry, - BeanNameGenerator beanNameGenerator) { - } -} diff --git a/src/main/java/org/springframework/data/neo4j/config/Neo4jDefaultReactiveCallbacksRegistrar.java b/src/main/java/org/springframework/data/neo4j/config/Neo4jDefaultReactiveCallbacksRegistrar.java deleted file mode 100644 index 45a919ff5..000000000 --- a/src/main/java/org/springframework/data/neo4j/config/Neo4jDefaultReactiveCallbacksRegistrar.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2011-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.neo4j.config; - -import org.apiguardian.api.API; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.beans.factory.support.BeanNameGenerator; -import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; -import org.springframework.core.type.AnnotationMetadata; -import org.springframework.data.neo4j.core.Neo4jOperations; - -/** - * This brings in the default callbacks required for the default implementation of {@link Neo4jOperations} to work. The - * offered support configuration class {@link AbstractNeo4jConfig} imports this and so does the Spring Boot - * autoconfiguration. - * - * @author Michael J. Simons - * @soundtrack AC/DC - High Voltage - * @since 6.0 - * @deprecated since 6.0.2, now an empty implementation, not needed anymore and our default callbacks will be added directly via our - * infrastructure. - */ -@API(status = API.Status.DEPRECATED, since = "6.0") -@Deprecated -public final class Neo4jDefaultReactiveCallbacksRegistrar implements ImportBeanDefinitionRegistrar { - - @Override - public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry, - BeanNameGenerator beanNameGenerator) { - } -} diff --git a/src/main/java/org/springframework/data/neo4j/core/mapping/callback/EventSupport.java b/src/main/java/org/springframework/data/neo4j/core/mapping/callback/EventSupport.java index 0e3883433..4196e6884 100644 --- a/src/main/java/org/springframework/data/neo4j/core/mapping/callback/EventSupport.java +++ b/src/main/java/org/springframework/data/neo4j/core/mapping/callback/EventSupport.java @@ -71,14 +71,11 @@ public final class EventSupport { this.entityCallbacks = entityCallbacks; } - @SuppressWarnings("deprecation") public T maybeCallBeforeBind(T object) { if (object == null) { return object; } - T o = entityCallbacks - .callback(org.springframework.data.neo4j.repository.event.BeforeBindCallback.class, object); - return entityCallbacks.callback(BeforeBindCallback.class, o); + return entityCallbacks.callback(BeforeBindCallback.class, object); } } diff --git a/src/main/java/org/springframework/data/neo4j/core/mapping/callback/ReactiveEventSupport.java b/src/main/java/org/springframework/data/neo4j/core/mapping/callback/ReactiveEventSupport.java index ed6334309..52b5cf263 100644 --- a/src/main/java/org/springframework/data/neo4j/core/mapping/callback/ReactiveEventSupport.java +++ b/src/main/java/org/springframework/data/neo4j/core/mapping/callback/ReactiveEventSupport.java @@ -75,10 +75,11 @@ public final class ReactiveEventSupport { this.entityCallbacks = entityCallbacks; } - @SuppressWarnings("deprecation") public Mono maybeCallBeforeBind(T object) { - return entityCallbacks - .callback(org.springframework.data.neo4j.repository.event.ReactiveBeforeBindCallback.class, object) - .flatMap(o -> entityCallbacks.callback(ReactiveBeforeBindCallback.class, o)); + + if (object == null) { + return Mono.empty(); + } + return entityCallbacks.callback(ReactiveBeforeBindCallback.class, object); } } diff --git a/src/main/java/org/springframework/data/neo4j/repository/event/AuditingBeforeBindCallback.java b/src/main/java/org/springframework/data/neo4j/repository/event/AuditingBeforeBindCallback.java deleted file mode 100644 index 23d3fa5c0..000000000 --- a/src/main/java/org/springframework/data/neo4j/repository/event/AuditingBeforeBindCallback.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2011-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.neo4j.repository.event; - -import org.apiguardian.api.API; -import org.springframework.beans.factory.ObjectFactory; -import org.springframework.core.Ordered; -import org.springframework.data.auditing.IsNewAwareAuditingHandler; -import org.springframework.data.mapping.callback.EntityCallback; - -/** - * {@link EntityCallback} to populate auditing related fields on an entity about to be bound to a record. - * - * @author Michael J. Simons - * @soundtrack Iron Maiden - Iron Maiden - * @since 6.0 - * @deprecated since 6.0.2, please use {@link org.springframework.data.neo4j.core.mapping.callback.AuditingBeforeBindCallback}. - */ -@API(status = API.Status.DEPRECATED, since = "6.0") -@Deprecated -public final class AuditingBeforeBindCallback implements BeforeBindCallback, Ordered { - - private final org.springframework.data.neo4j.core.mapping.callback.AuditingBeforeBindCallback delegate; - - public AuditingBeforeBindCallback(ObjectFactory auditingHandlerFactory) { - - this.delegate = new org.springframework.data.neo4j.core.mapping.callback.AuditingBeforeBindCallback( - auditingHandlerFactory); - } - - @Override - public Object onBeforeBind(Object entity) { - return delegate.onBeforeBind(entity); - } - - @Override - public int getOrder() { - return delegate.getOrder(); - } -} diff --git a/src/main/java/org/springframework/data/neo4j/repository/event/BeforeBindCallback.java b/src/main/java/org/springframework/data/neo4j/repository/event/BeforeBindCallback.java deleted file mode 100644 index c673a2597..000000000 --- a/src/main/java/org/springframework/data/neo4j/repository/event/BeforeBindCallback.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2011-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.neo4j.repository.event; - -import org.apiguardian.api.API; -import org.springframework.data.mapping.callback.EntityCallback; - -/** - * Entity callback triggered before an Entity is bound to a record (represented by a {@link java.util.Map - * java.util.Map<String, Object>}). - * - * @author Michael J. Simons - * @param The type of the entity. - * @since 6.0 - * @soundtrack Bon Jovi - Slippery When Wet - * @deprecated since 6.0.2, please use {@link org.springframework.data.neo4j.core.mapping.callback.BeforeBindCallback}. - */ -@FunctionalInterface -@API(status = API.Status.DEPRECATED, since = "6.0") -@Deprecated -public interface BeforeBindCallback extends EntityCallback { - - /** - * Entity callback method invoked before a domain object is saved. Can return either the same or a modified instance - * of the domain object. This method is called before converting the {@code entity} to a {@link java.util.Map}, so the - * outcome of this callback is used to create the record for the domain object. - * - * @param entity the domain object to save. - * @return the domain object to be persisted. - */ - T onBeforeBind(T entity); -} diff --git a/src/main/java/org/springframework/data/neo4j/repository/event/ReactiveAuditingBeforeBindCallback.java b/src/main/java/org/springframework/data/neo4j/repository/event/ReactiveAuditingBeforeBindCallback.java deleted file mode 100644 index 015b32b43..000000000 --- a/src/main/java/org/springframework/data/neo4j/repository/event/ReactiveAuditingBeforeBindCallback.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2011-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.neo4j.repository.event; - -import org.apiguardian.api.API; -import org.reactivestreams.Publisher; -import org.springframework.beans.factory.ObjectFactory; -import org.springframework.core.Ordered; -import org.springframework.data.auditing.ReactiveIsNewAwareAuditingHandler; -import org.springframework.data.mapping.callback.EntityCallback; - -/** - * Reactive {@link EntityCallback} to populate auditing related fields on an entity about to be bound to a record. - * - * @author Michael J. Simons - * @soundtrack Iron Maiden - The Number Of The Beast - * @deprecated since 6.0.2, please use {@link org.springframework.data.neo4j.core.mapping.callback.AuditingBeforeBindCallback}. - */ -@API(status = API.Status.DEPRECATED, since = "6.0") -@Deprecated -public final class ReactiveAuditingBeforeBindCallback implements ReactiveBeforeBindCallback, Ordered { - - private final org.springframework.data.neo4j.core.mapping.callback.ReactiveAuditingBeforeBindCallback delegate; - - public ReactiveAuditingBeforeBindCallback(ObjectFactory auditingHandlerFactory) { - - this.delegate = new org.springframework.data.neo4j.core.mapping.callback.ReactiveAuditingBeforeBindCallback( - auditingHandlerFactory); - } - - @Override - public Publisher onBeforeBind(Object entity) { - return delegate.onBeforeBind(entity); - } - - @Override - public int getOrder() { - return delegate.getOrder(); - } -} diff --git a/src/main/java/org/springframework/data/neo4j/repository/event/ReactiveBeforeBindCallback.java b/src/main/java/org/springframework/data/neo4j/repository/event/ReactiveBeforeBindCallback.java deleted file mode 100644 index ff0f4bb7a..000000000 --- a/src/main/java/org/springframework/data/neo4j/repository/event/ReactiveBeforeBindCallback.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2011-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.neo4j.repository.event; - -import org.apiguardian.api.API; -import org.reactivestreams.Publisher; -import org.springframework.data.mapping.callback.EntityCallback; -import org.springframework.data.mapping.callback.ReactiveEntityCallbacks; - -/** - * Entity callback triggered before an Entity is bound to a record (represented by a {@link java.util.Map - * java.util.Map<String, Object>}). - * - * @param The type of the entity. - * @author Michael J. Simons - * @soundtrack Iron Maiden - Killers - * @see ReactiveEntityCallbacks - * @since 6.0 - * @deprecated since 6.0.2, please use {@link org.springframework.data.neo4j.core.mapping.callback.ReactiveAuditingBeforeBindCallback}. - */ -@FunctionalInterface -@API(status = API.Status.DEPRECATED, since = "6.0") -@Deprecated -public interface ReactiveBeforeBindCallback extends EntityCallback { - - /** - * Entity callback method invoked before a domain object is saved. Can return either the same or a modified instance - * of the domain object. This method is called before converting the {@code entity} to a {@link java.util.Map}, so the - * outcome of this callback is used to create the record for the domain object. - * - * @param entity the domain object to save. - * @return the domain object to be persisted. - */ - Publisher onBeforeBind(T entity); -}