DATAGEODE-76 - When SDG Annotation config is used to configure and bootstrap an Apache Geode server, automatically register the Administrative Functions.

This commit is contained in:
John Blum
2017-12-15 19:53:37 -08:00
parent 2daf115aa7
commit be32170cb6
3 changed files with 67 additions and 20 deletions

View File

@@ -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();
}
}

View File

@@ -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 {

View File

@@ -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) {