some final clean up for 3.1.0.M1

This commit is contained in:
David Turanski
2013-02-11 12:39:20 -05:00
parent 30cf17682c
commit 699f3bad51
26 changed files with 31 additions and 267 deletions

View File

@@ -1,56 +0,0 @@
/*
* Copyright 2002-2013 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;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
/**
*
* Work around to ensure dependent disk stores are created before gateway senders
*
* @author David Turanski
*
*/
public class GemfireBeanPostProcessor implements BeanPostProcessor, BeanFactoryAware {
private DefaultListableBeanFactory beanFactory;
/* (non-Javadoc)
* @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
*/
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
/* (non-Javadoc)
* @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
*/
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
/* (non-Javadoc)
* @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory)
*/
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory = (DefaultListableBeanFactory)beanFactory;
}
}

View File

@@ -24,8 +24,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import com.gemstone.gemfire.cache.RegionService;
import com.gemstone.gemfire.cache.client.Pool;
import com.gemstone.gemfire.cache.client.PoolManager;
import com.gemstone.gemfire.cache.client.ClientCache;
import com.gemstone.gemfire.cache.query.Index;
import com.gemstone.gemfire.cache.query.IndexExistsException;
import com.gemstone.gemfire.cache.query.QueryService;
@@ -34,12 +33,12 @@ import com.gemstone.gemfire.cache.query.QueryService;
* Factory bean for easy declarative creation of GemFire Indexes.
*
* @author Costin Leau
* @author David Turanski
*/
public class IndexFactoryBean implements InitializingBean, BeanNameAware, FactoryBean<Index> {
private Index index;
private QueryService queryService;
private String poolName;
private RegionService cache;
private String beanName;
private String name;
@@ -52,16 +51,12 @@ public class IndexFactoryBean implements InitializingBean, BeanNameAware, Factor
public void afterPropertiesSet() throws Exception {
if (queryService == null) {
if (cache != null) {
Assert.isTrue(!ClientCache.class.isAssignableFrom(cache.getClass()),
"You cannot create an index from a client cache");
queryService = cache.getQueryService();
}
}
if (queryService != null && StringUtils.hasText(poolName)) {
Pool pool = PoolManager.find(poolName);
Assert.notNull(pool, "No pool named [" + poolName + "] found");
queryService = pool.getQueryService();
}
Assert.notNull(queryService, "Query service required for index creation");
Assert.hasText(expression, "Index expression is required");
Assert.hasText(from, "Index from clause (regionPath) is required");
@@ -82,7 +77,7 @@ public class IndexFactoryBean implements InitializingBean, BeanNameAware, Factor
private Index createIndex(QueryService queryService, String indexName) throws Exception {
Index existingIndex = null;
for (Index idx : queryService.getIndexes()) {
if (idx.getName().equals(indexName)) {
existingIndex = idx;
@@ -154,7 +149,7 @@ public class IndexFactoryBean implements InitializingBean, BeanNameAware, Factor
* @param cache cache used for creating indexes.
*/
public void setCache(RegionService cache) {
this.queryService = cache.getQueryService();
this.cache = cache;
}
/**
@@ -166,15 +161,6 @@ public class IndexFactoryBean implements InitializingBean, BeanNameAware, Factor
this.queryService = service;
}
/**
* Sets the beanName of the {@link Pool} used for used for creating indexes.
*
* @param poolName the beanName of the pool used for creating indexes.
*/
public void setPoolName(String poolName) {
this.poolName = poolName;
}
public void setBeanName(String name) {
this.beanName = name;
}

View File

@@ -19,7 +19,7 @@ import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.data.gemfire.function.execution.GemfireFunctionOperations;
import org.springframework.data.gemfire.function.execution.GemfireOnServersFunctionTemplate;
import org.springframework.data.gemfire.repository.support.ListRegionsOnServerFunction;
import org.springframework.data.gemfire.support.ListRegionsOnServerFunction;
import org.springframework.util.Assert;
import com.gemstone.gemfire.cache.Region;

View File

@@ -42,7 +42,7 @@ class ClientCacheParser extends CacheParser {
@Override
protected void postProcessDynamicRegionSupport(Element element, BeanDefinitionBuilder dynamicRegionSupport) {
ParsingUtils.setPropertyValue(element, dynamicRegionSupport, "pool-name");
ParsingUtils.setPropertyValue(element, dynamicRegionSupport, "pool-name");
}
}

View File

@@ -13,17 +13,13 @@
package org.springframework.data.gemfire.function;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.ObjectUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;
import com.gemstone.gemfire.cache.execute.Function;
import com.gemstone.gemfire.cache.execute.FunctionContext;
import com.gemstone.gemfire.cache.execute.ResultSender;

View File

@@ -25,7 +25,6 @@ import org.springframework.beans.factory.FactoryBean;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import com.gemstone.gemfire.cache.execute.FunctionException;
import com.gemstone.gemfire.cache.execute.FunctionService;
/**
@@ -120,31 +119,4 @@ public class GemfireFunctionProxyFactoryBean implements FactoryBean<Object>, Met
this.serviceProxy = proxyFactory.getProxy(this.beanClassLoader);
this.initialized = true;
}
/*
* Match the result to the declared return type
*/
private Object extractResult(Iterable<?> results, Class<?> returnType) {
Object result = null;
if (results != null) {
if (Iterable.class.isAssignableFrom(returnType)) {
result = results;
} else {
int nonNullItems = 0;
for (Object obj : results) {
if (obj != null) {
if (++nonNullItems > 1) {
throw new FunctionException("multiple results found for single valued return type");
} else {
result = obj;
}
}
}
}
if (logger.isDebugEnabled()) {
logger.debug("returning result as " + result.getClass().getName());
}
}
return result;
}
}

View File

@@ -15,7 +15,6 @@ package org.springframework.data.gemfire.function.execution;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
import com.gemstone.gemfire.cache.client.ClientCache;
import com.gemstone.gemfire.cache.client.Pool;
import com.gemstone.gemfire.cache.client.PoolManager;
import com.gemstone.gemfire.cache.execute.Execution;

View File

@@ -25,6 +25,7 @@ import org.springframework.data.gemfire.listener.adapter.ContinuousQueryListener
* @author Costin Leau
* @see ContinuousQueryListenerAdapter
*/
@SuppressWarnings("serial")
public class GemfireListenerExecutionFailedException extends InvalidDataAccessApiUsageException {
/**

View File

@@ -52,14 +52,4 @@ public class GemfirePersistentProperty extends AnnotationBasedPersistentProperty
protected Association<GemfirePersistentProperty> createAssociation() {
return new Association<GemfirePersistentProperty>(this, null);
}
@Override
public boolean isAssociation() {
return field.isAnnotationPresent(RegionRef.class) || super.isAssociation();
}
public RegionRef geRegionRef() {
return getField().getAnnotation(RegionRef.class);
}
}

View File

@@ -1,36 +0,0 @@
/*
* Copyright 2010-2013 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.mapping;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.data.annotation.Reference;
/**
* @author David Turanski
*
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Documented
@Reference
public @interface RegionRef {
String value() default "";
}

View File

@@ -43,7 +43,6 @@ public class Regions implements Iterable<Region<?, ?>> {
* @param regions must not be {@literal null}.
* @param context must not be {@literal null}.
*/
@SuppressWarnings("unchecked")
public Regions(Iterable<Region<?, ?>> regions, MappingContext<? extends GemfirePersistentEntity<?>, ?> context) {
Assert.notNull(regions);

View File

@@ -1,78 +0,0 @@
/*
* Copyright 2002-2013 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.repository.support;
import java.util.ArrayList;
import java.util.List;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.execute.Function;
import com.gemstone.gemfire.cache.execute.FunctionContext;
/**
* @author David Turanski
*
*/
@SuppressWarnings("serial")
public class ListRegionsOnServerFunction implements Function {
/* (non-Javadoc)
* @see com.gemstone.gemfire.cache.execute.Function#hasResult()
*/
@Override
public boolean hasResult() {
return true;
}
/* (non-Javadoc)
* @see com.gemstone.gemfire.cache.execute.Function#execute(com.gemstone.gemfire.cache.execute.FunctionContext)
*/
@Override
public void execute(FunctionContext context) {
Cache cache = CacheFactory.getAnyInstance();
List<String> regionNames = new ArrayList<String>();
for (Region<?,?> region: cache.rootRegions()) {
regionNames.add(region.getName());
}
context.getResultSender().lastResult(regionNames);
}
/* (non-Javadoc)
* @see com.gemstone.gemfire.cache.execute.Function#getId()
*/
@Override
public String getId() {
return this.getClass().getName();
}
/* (non-Javadoc)
* @see com.gemstone.gemfire.cache.execute.Function#optimizeForWrite()
*/
@Override
public boolean optimizeForWrite() {
return false;
}
/* (non-Javadoc)
* @see com.gemstone.gemfire.cache.execute.Function#isHA()
*/
@Override
public boolean isHA() {
return false;
}
}