From be32170cb65f4101ded9dbce8a2cee72c2a56f92 Mon Sep 17 00:00:00 2001 From: John Blum Date: Fri, 15 Dec 2017 19:53:37 -0800 Subject: [PATCH] DATAGEODE-76 - When SDG Annotation config is used to configure and bootstrap an Apache Geode server, automatically register the Administrative Functions. --- .../AdministrativeConfiguration.java | 63 +++++++++++++++++++ .../annotation/PeerCacheConfiguration.java | 4 ++ ...eClusterConfigurationIntegrationTests.java | 20 ------ 3 files changed, 67 insertions(+), 20 deletions(-) create mode 100644 src/main/java/org/springframework/data/gemfire/config/annotation/AdministrativeConfiguration.java diff --git a/src/main/java/org/springframework/data/gemfire/config/annotation/AdministrativeConfiguration.java b/src/main/java/org/springframework/data/gemfire/config/annotation/AdministrativeConfiguration.java new file mode 100644 index 00000000..cd545f1a --- /dev/null +++ b/src/main/java/org/springframework/data/gemfire/config/annotation/AdministrativeConfiguration.java @@ -0,0 +1,63 @@ +/* + * Copyright 2017 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 + * + * http://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.gemfire.config.annotation; + +import org.apache.geode.cache.execute.Function; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.gemfire.config.admin.functions.CreateIndexFunction; +import org.springframework.data.gemfire.config.admin.functions.CreateRegionFunction; +import org.springframework.data.gemfire.config.admin.functions.ListIndexesFunction; +import org.springframework.data.gemfire.function.config.EnableGemfireFunctions; + +/** + * The {@link AdministrativeConfiguration} class is a Spring {@link Configuration @Configuration} class that registers + * SDG Administrative {@link Function Functions} used by SDG's {@link EnableClusterConfiguration} without HTTP enabled. + * + * Additionally, this class enable's SDG {@link Function} implementations so that the internal SDG administrative + * {@link Function Functions} are properly created and registered in Apache Geode. + * + * @author John Blum + * @see org.apache.geode.cache.execute.Function + * @see org.springframework.context.annotation.Bean + * @see org.springframework.context.annotation.Configuration + * @see org.springframework.data.gemfire.config.admin.functions.CreateIndexFunction + * @see org.springframework.data.gemfire.config.admin.functions.CreateRegionFunction + * @see org.springframework.data.gemfire.config.admin.functions.ListIndexesFunction + * @see org.springframework.data.gemfire.function.config.EnableGemfireFunctions + * @since 2.0.3 + */ +@Configuration +@EnableGemfireFunctions +@SuppressWarnings("unused") +public class AdministrativeConfiguration { + + @Bean + public CreateIndexFunction createIndexFunction() { + return new CreateIndexFunction(); + } + + @Bean + public CreateRegionFunction createRegionFunction() { + return new CreateRegionFunction(); + } + + @Bean + public ListIndexesFunction listIndexFunction() { + return new ListIndexesFunction(); + } +} diff --git a/src/main/java/org/springframework/data/gemfire/config/annotation/PeerCacheConfiguration.java b/src/main/java/org/springframework/data/gemfire/config/annotation/PeerCacheConfiguration.java index cbf64836..c9c7eaad 100644 --- a/src/main/java/org/springframework/data/gemfire/config/annotation/PeerCacheConfiguration.java +++ b/src/main/java/org/springframework/data/gemfire/config/annotation/PeerCacheConfiguration.java @@ -31,6 +31,7 @@ import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; import org.springframework.core.type.AnnotationMetadata; import org.springframework.data.gemfire.CacheFactoryBean; import org.springframework.util.StringUtils; @@ -43,10 +44,13 @@ import org.springframework.util.StringUtils; * @see org.apache.geode.cache.Cache * @see org.springframework.context.annotation.Bean * @see org.springframework.context.annotation.Configuration + * @see org.springframework.context.annotation.Import * @see org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration + * @see org.springframework.data.gemfire.config.annotation.AdministrativeConfiguration * @since 1.9.0 */ @Configuration +@Import(AdministrativeConfiguration.class) @SuppressWarnings("unused") public class PeerCacheConfiguration extends AbstractCacheConfiguration { diff --git a/src/test/java/org/springframework/data/gemfire/config/annotation/EnableClusterConfigurationIntegrationTests.java b/src/test/java/org/springframework/data/gemfire/config/annotation/EnableClusterConfigurationIntegrationTests.java index fdf07156..221bdbfe 100644 --- a/src/test/java/org/springframework/data/gemfire/config/annotation/EnableClusterConfigurationIntegrationTests.java +++ b/src/test/java/org/springframework/data/gemfire/config/annotation/EnableClusterConfigurationIntegrationTests.java @@ -42,11 +42,7 @@ import org.springframework.data.gemfire.PartitionedRegionFactoryBean; import org.springframework.data.gemfire.ReplicatedRegionFactoryBean; import org.springframework.data.gemfire.client.ClientRegionFactoryBean; import org.springframework.data.gemfire.config.admin.GemfireAdminOperations; -import org.springframework.data.gemfire.config.admin.functions.CreateIndexFunction; -import org.springframework.data.gemfire.config.admin.functions.CreateRegionFunction; -import org.springframework.data.gemfire.config.admin.functions.ListIndexesFunction; import org.springframework.data.gemfire.config.admin.remote.RestHttpGemfireAdminTemplate; -import org.springframework.data.gemfire.function.config.EnableGemfireFunctions; import org.springframework.data.gemfire.process.ProcessWrapper; import org.springframework.data.gemfire.support.ConnectionEndpoint; import org.springframework.data.gemfire.test.support.ClientServerIntegrationTestsSupport; @@ -193,7 +189,6 @@ public class EnableClusterConfigurationIntegrationTests extends ClientServerInte } @CacheServerApplication(name = "EnableClusterConfigurationIntegrationTests", logLevel = LOG_LEVEL) - @EnableGemfireFunctions static class GemFireServerConfiguration { public static void main(String[] args) { @@ -204,21 +199,6 @@ public class EnableClusterConfigurationIntegrationTests extends ClientServerInte applicationContext.registerShutdownHook(); } - @Bean - CreateIndexFunction createIndexFunction() { - return new CreateIndexFunction(); - } - - @Bean - CreateRegionFunction createRegionFunction() { - return new CreateRegionFunction(); - } - - @Bean - ListIndexesFunction listIndexesFunction() { - return new ListIndexesFunction(); - } - @Bean CacheServerConfigurer cacheServerPortConfigurer( @Value("${" + GEMFIRE_CACHE_SERVER_PORT_PROPERTY + ":40404}") int port) {