SGF-562 - Include attribute to enable BeanFactoryLocator support in Annotation config.
(cherry picked from commit bcce3c0351e4094012ee272fd558f19efdc04f2c) Signed-off-by: John Blum <jblum@pivotal.io>
This commit is contained in:
@@ -299,6 +299,7 @@ public abstract class AbstractCacheConfiguration implements BeanClassLoaderAware
|
||||
|
||||
setLogLevel((String) cacheMetadataAttributes.get("logLevel"));
|
||||
setName((String) cacheMetadataAttributes.get("name"));
|
||||
setUseBeanFactoryLocator(Boolean.TRUE.equals(cacheMetadataAttributes.get("useBeanFactoryLocator")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -507,7 +508,7 @@ public abstract class AbstractCacheConfiguration implements BeanClassLoaderAware
|
||||
* @see #getAnnotationType()
|
||||
*/
|
||||
protected boolean isTypedCacheApplication(Class<? extends Annotation> annotationType,
|
||||
AnnotationMetadata importMetadata) {
|
||||
AnnotationMetadata importMetadata) {
|
||||
|
||||
return (annotationType.equals(getAnnotationType()) && importMetadata.hasAnnotation(getAnnotationTypeName()));
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ import java.lang.annotation.Target;
|
||||
import org.apache.geode.cache.control.ResourceManager;
|
||||
import org.apache.geode.cache.server.CacheServer;
|
||||
import org.apache.geode.cache.server.ClientSubscriptionConfig;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.access.BeanFactoryLocator;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.data.gemfire.server.SubscriptionEvictionPolicy;
|
||||
@@ -41,7 +43,7 @@ import org.springframework.data.gemfire.server.SubscriptionEvictionPolicy;
|
||||
* @author John Blum
|
||||
* @see org.springframework.context.annotation.Configuration
|
||||
* @see org.springframework.context.annotation.Import
|
||||
* @see org.springframework.data.gemfire.config.annotation.PeerCacheConfiguration
|
||||
* @see org.springframework.data.gemfire.config.annotation.CacheServerConfiguration
|
||||
* @see org.apache.geode.cache.control.ResourceManager
|
||||
* @see org.apache.geode.cache.server.CacheServer
|
||||
* @see org.apache.geode.cache.server.ClientSubscriptionConfig
|
||||
@@ -233,6 +235,15 @@ public @interface CacheServerApplication {
|
||||
*/
|
||||
SubscriptionEvictionPolicy subscriptionEvictionPolicy() default SubscriptionEvictionPolicy.NONE;
|
||||
|
||||
/**
|
||||
* Determines whether the Spring {@link BeanFactoryLocator} should be enabled to lookup
|
||||
* the Spring {@link BeanFactory} to auto-wire and configure/initialize GemFire components
|
||||
* created in a non-Spring managed, GemFire context.
|
||||
*
|
||||
* Defaults to {@literal false}.
|
||||
*/
|
||||
boolean useBeanFactoryLocator() default false;
|
||||
|
||||
/**
|
||||
* Configures whether this GemFire cache member node would pull it's configuration meta-data
|
||||
* from the cluster-based Cluster Configuration service.
|
||||
|
||||
@@ -26,6 +26,8 @@ import java.lang.annotation.Target;
|
||||
|
||||
import org.apache.geode.cache.client.PoolFactory;
|
||||
import org.apache.geode.cache.control.ResourceManager;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.access.BeanFactoryLocator;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.data.gemfire.GemfireUtils;
|
||||
@@ -256,6 +258,15 @@ public @interface ClientCacheApplication {
|
||||
*/
|
||||
boolean threadLocalConnections() default PoolFactory.DEFAULT_THREAD_LOCAL_CONNECTIONS;
|
||||
|
||||
/**
|
||||
* Determines whether the Spring {@link BeanFactoryLocator} should be enabled to lookup
|
||||
* the Spring {@link BeanFactory} to auto-wire and configure/initialize GemFire components
|
||||
* created in a non-Spring managed, GemFire context.
|
||||
*
|
||||
* Defaults to {@literal false}.
|
||||
*/
|
||||
boolean useBeanFactoryLocator() default false;
|
||||
|
||||
@interface Locator {
|
||||
|
||||
String host() default "localhost";
|
||||
|
||||
@@ -25,6 +25,8 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.apache.geode.cache.control.ResourceManager;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.access.BeanFactoryLocator;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
@@ -128,6 +130,15 @@ public @interface PeerCacheApplication {
|
||||
*/
|
||||
int searchTimeout() default 300;
|
||||
|
||||
/**
|
||||
* Determines whether the Spring {@link BeanFactoryLocator} should be enabled to lookup
|
||||
* the Spring {@link BeanFactory} to auto-wire and configure/initialize GemFire components
|
||||
* created in a non-Spring managed, GemFire context.
|
||||
*
|
||||
* Defaults to {@literal false}.
|
||||
*/
|
||||
boolean useBeanFactoryLocator() default false;
|
||||
|
||||
/**
|
||||
* Configures whether this GemFire cache member node would pull it's configuration meta-data
|
||||
* from the cluster-based Cluster Configuration service.
|
||||
|
||||
@@ -123,7 +123,7 @@ public abstract class EmbeddedServiceConfigurationSupport implements ImportBeanD
|
||||
* @see org.springframework.beans.factory.BeanFactory
|
||||
*/
|
||||
protected BeanFactory getBeanFactory() {
|
||||
org.apache.shiro.util.Assert.state(this.beanFactory != null, "BeanFactory was not properly initialized");
|
||||
Assert.state(this.beanFactory != null, "BeanFactory was not properly initialized");
|
||||
return this.beanFactory;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public abstract class EmbeddedServiceConfigurationSupport implements ImportBeanD
|
||||
*/
|
||||
@Override
|
||||
public final void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
|
||||
BeanDefinitionRegistry registry) {
|
||||
BeanDefinitionRegistry registry) {
|
||||
|
||||
if (isAnnotationPresent(importingClassMetadata)) {
|
||||
Map<String, Object> annotationAttributes = getAnnotationAttributes(importingClassMetadata);
|
||||
@@ -144,12 +144,12 @@ public abstract class EmbeddedServiceConfigurationSupport implements ImportBeanD
|
||||
/* (non-Javadoc) */
|
||||
@SuppressWarnings("unused")
|
||||
protected void registerBeanDefinitions(AnnotationMetadata importingClassMetaData,
|
||||
Map<String, Object> annotationAttributes, BeanDefinitionRegistry registry) {
|
||||
Map<String, Object> annotationAttributes, BeanDefinitionRegistry registry) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected void setGemFireProperties(AnnotationMetadata importingClassMetadata,
|
||||
Map<String, Object> annotationAttributes, BeanDefinitionRegistry registry) {
|
||||
Map<String, Object> annotationAttributes, BeanDefinitionRegistry registry) {
|
||||
|
||||
Properties gemfireProperties = toGemFireProperties(annotationAttributes);
|
||||
|
||||
@@ -183,7 +183,7 @@ public abstract class EmbeddedServiceConfigurationSupport implements ImportBeanD
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected void registerGemFirePropertiesBeanPostProcessor(BeanDefinitionRegistry registry,
|
||||
Properties customGemFireProperties) {
|
||||
Properties customGemFireProperties) {
|
||||
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
GemFirePropertiesBeanPostProcessor.class);
|
||||
|
||||
Reference in New Issue
Block a user