renaming classes, etc

This commit is contained in:
David Turanski
2012-12-22 09:55:40 -05:00
parent e18e603000
commit 074eee56fd
40 changed files with 237 additions and 176 deletions

View File

@@ -72,6 +72,7 @@ public class ClientCacheFactoryBean extends CacheFactoryBean {
if (pdxReadSerialized != null) {
factory.setPdxReadSerialized(pdxReadSerialized);
}
}
}

View File

@@ -179,7 +179,7 @@ public class PoolFactoryBean implements FactoryBean<Pool>, InitializingBean,
.setSubscriptionMessageTrackingTimeout(subscriptionMessageTrackingTimeout);
poolFactory.setSubscriptionRedundancy(subscriptionRedundancy);
poolFactory.setThreadLocalConnections(threadLocalConnections);
pool = poolFactory.create(name);
}
}

View File

@@ -19,7 +19,6 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;
@@ -57,7 +56,7 @@ public class PojoFunctionWrapper implements Function {
this.functionArgumentResolver = new FunctionContextInjectingArgumentResolver(method);
this.id = StringUtils.hasText(id) ? id : ClassUtils.getQualifiedMethodName(method);
this.id = StringUtils.hasText(id) ? id : method.getName();
this.target = target;
this.method = method;

View File

@@ -20,6 +20,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* Base class for function execution bean definition builders
* @author David Turanski
@@ -54,16 +55,18 @@ abstract class AbstractFunctionExecutionBeanDefinitionBuilder {
BeanDefinitionBuilder functionTemplateBuilder = getGemfireOperationsBeanDefinitionBuilder(registry);
functionTemplateBuilder.setLazyInit(true);
String resultCollectorRef = (String)configuration.getAttribute("resultCollector");
if (StringUtils.hasText(resultCollectorRef)){
functionTemplateBuilder.addPropertyReference("resultCollector",resultCollectorRef);
}
AbstractBeanDefinition functionTemplate = functionTemplateBuilder
.getBeanDefinition();
String functionTemplateName = BeanDefinitionReaderUtils.registerWithGeneratedName(functionTemplate, registry);
builder.addConstructorArgReference(functionTemplateName);
builder.addPropertyValue("functionId", (String)configuration.getAttribute("id"));
return builder.getBeanDefinition();
}

View File

@@ -69,6 +69,7 @@ public class FunctionExecutionBeanDefinitionRegistrar implements ImportBeanDefin
if (!StringUtils.hasLength(beanName)) {
beanName = BeanDefinitionReaderUtils.generateBeanName(beanDefinition, registry);
}
AbstractFunctionExecutionBeanDefinitionBuilder builder = FunctionExecutionBeanDefinitionBuilderFactory
.newInstance(new FunctionExecutionConfiguration(beanDefinition, functionExecutionAnnotation));

View File

@@ -26,7 +26,6 @@ import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter;
import org.springframework.core.type.filter.TypeFilter;
import org.springframework.data.gemfire.function.execution.FunctionExecution;
import org.springframework.util.Assert;
/**
@@ -68,7 +67,7 @@ class FunctionExecutionComponentProvider extends ClassPathScanningCandidateCompo
/**
* Custom extension of {@link #addIncludeFilter(TypeFilter)} to extend the added {@link TypeFilter}. For the
* {@link TypeFilter} handed we'll have two filters registered: one additionally enforcing the
* {@link FunctionExecutionDefinition} annotation, the other one forcing the extension of {@link FunctionExecution}.
* {@link FunctionExecutionDefinition} annotation, the other one forcing the extension of {@link AbstractFunctionExecution}.
*
* @see ClassPathScanningCandidateComponentProvider#addIncludeFilter(TypeFilter)
*/

View File

@@ -28,8 +28,7 @@ import java.lang.annotation.Target;
@Target({ElementType.METHOD})
public @interface GemfireFunction {
/**
* The name of the registered function. If not provided the fully qualified method name will be used,
* e.g., 'com.example.SomeClass.someMethod'
* The name of the registered function. If not provided the simple method name will be used
* @return the function id
*/
String id() default "";

View File

@@ -28,12 +28,14 @@ import java.lang.annotation.Target;
public @interface OnMember {
/**
* The bean name and also the default name of the registered function, if single method on the interface.
* If multiple methods declared use the (@link FunctionId) annotation on each method
* @return the function id
* The bean name
*/
String id() default "";
/**
* Optional ResultCollector bean reference
*/
String resultCollector() default "";
//TODO SpEL expression for DistributedMember?

View File

@@ -27,12 +27,15 @@ import java.lang.annotation.Target;
public @interface OnMembers {
/**
* The bean name and also the default name of the registered function, if single method on the interface.
* If multiple methods declared use the (@link FunctionId) annotation on each method
* @return the function id
* The bean name
*/
String id() default "";
/**
* Optional ResultCollector bean reference
*/
String resultCollector() default "";
//TODO SpEL expression for DistributedMembers?
/**

View File

@@ -27,12 +27,15 @@ import java.lang.annotation.Target;
public @interface OnRegion {
/**
* The bean name and also the default name of the registered function, if single method on the interface.
* If multiple methods declared use the (@link FunctionId) annotation on each method
* @return the function id
* The bean name
*/
String id() default "";
/**
* Optional ResultCollector bean reference
*/
String resultCollector() default "";
/**
* The reference to the bean id of the region
* @return the region id

View File

@@ -27,12 +27,15 @@ import java.lang.annotation.Target;
public @interface OnServer {
/**
* The bean name and also the default name of the registered function, if single method on the interface.
* If multiple methods declared use the (@link FunctionId) annotation on each method
* @return the function id
* The bean name
*/
String id() default "";
/**
* Optional ResultCollector bean reference
*/
String resultCollector() default "";
/**
* The pool bean id (optional)
* @return

View File

@@ -27,12 +27,15 @@ import java.lang.annotation.Target;
public @interface OnServers {
/**
* The bean name and also the default name of the registered function, if single method on the interface.
* If multiple methods declared use the (@link FunctionId) annotation on each method
* @return the function id
* The bean name
*/
String id() default "";
/**
* Optional ResultCollector bean reference
*/
String resultCollector() default "";
/**
* The pool bean name (optional)
* @return

View File

@@ -30,61 +30,57 @@ import com.gemstone.gemfire.cache.execute.ResultCollector;
/**
* Base class for * Creating a GemFire {@link Execution} using {@link FunctionService}
* Protected setters support method chaining
* @author David Turanski
*/
public abstract class FunctionExecution {
abstract class AbstractFunctionExecution {
protected final Log logger = LogFactory.getLog(this.getClass());
private volatile ResultCollector<?, ?> collector;
private volatile ResultCollector<?, ?> resultCollector;
private Object[] args;
private Function function;
private String functionId;
private long timeout;
public FunctionExecution(Function function, Object... args) {
public AbstractFunctionExecution(Function function, Object... args) {
Assert.notNull(function,"function cannot be null");
this.function = function;
this.functionId = function.getId();
this.args = args;
}
public FunctionExecution(String functionId, Object... args) {
public AbstractFunctionExecution(String functionId, Object... args) {
Assert.isTrue(StringUtils.hasLength(functionId),"functionId cannot be null or empty");
this.functionId = functionId;
this.args = args;
}
protected FunctionExecution() {
AbstractFunctionExecution() {
}
ResultCollector<?, ?> getCollector() {
return resultCollector;
}
public ResultCollector<?, ?> getCollector() {
return collector;
}
public Object[] getArgs() {
Object[] getArgs() {
return args;
}
public String getFunctionId() {
String getFunctionId() {
return functionId;
}
public Function getFunction() {
Function getFunction() {
return function;
}
public void setCollector(ResultCollector<?,?> collector) {
this.collector = collector;
}
long getTimeout() {
return timeout;
}
@SuppressWarnings("unchecked")
public <T> Iterable<T> execute() {
<T> Iterable<T> execute() {
Execution execution = this.getExecution();
if (getKeys() != null) {
execution = execution.withFilter(getKeys());
@@ -93,22 +89,24 @@ public abstract class FunctionExecution {
execution = execution.withCollector(getCollector());
}
ResultCollector<?,?> resultsCollector = null;
ResultCollector<?,?> resultCollector = null;
execution = execution.withArgs(getArgs());
if (isRegisteredFunction()){
resultsCollector = (ResultCollector<?,?>) execution.execute(functionId);
resultCollector = (ResultCollector<?,?>) execution.execute(functionId);
} else {
resultsCollector = (ResultCollector<?,?>) execution.execute(function);
resultCollector = (ResultCollector<?,?>) execution.execute(function);
}
logger.debug("ResultsCollector:" + resultCollector.getClass().getName());
Iterable<T> results = null;
if (this.timeout > 0 ){
try {
results= (Iterable<T>)resultsCollector.getResult(this.timeout, TimeUnit.MILLISECONDS);
results= (Iterable<T>)resultCollector.getResult(this.timeout, TimeUnit.MILLISECONDS);
}
catch (FunctionException e) {
throw new RuntimeException(e);
@@ -118,14 +116,14 @@ public abstract class FunctionExecution {
}
} else {
results = (Iterable<T>) resultsCollector.getResult();
results = (Iterable<T>) resultCollector.getResult();
}
return replaceSingletonNullCollectionWithEmptyList(results);
}
public <T> T executeAndExtract() {
<T> T executeAndExtract() {
Iterable<T> results = this.execute();
if (results == null || !results.iterator().hasNext()) {
return null;
@@ -136,17 +134,17 @@ public abstract class FunctionExecution {
protected abstract Execution getExecution();
protected FunctionExecution setFunctionId(String functionId) {
protected AbstractFunctionExecution setFunctionId(String functionId) {
this.functionId = functionId;
return this;
}
protected FunctionExecution setFunction(Function function) {
protected AbstractFunctionExecution setFunction(Function function) {
this.function = function;
return this;
}
protected FunctionExecution setArgs(Object... args) {
protected AbstractFunctionExecution setArgs(Object... args) {
this.args = args;
return this;
}
@@ -155,14 +153,16 @@ public abstract class FunctionExecution {
return null;
}
public FunctionExecution setTimeout(long timeout) {
protected AbstractFunctionExecution setTimeout(long timeout) {
this.timeout = timeout;
return this;
}
protected AbstractFunctionExecution setResultCollector(ResultCollector<?,?> resultCollector) {
this.resultCollector = resultCollector;
return this;
}
public long getTimeout() {
return timeout;
}
/**
* @return

View File

@@ -17,6 +17,7 @@ import org.apache.commons.logging.LogFactory;
import com.gemstone.gemfire.cache.execute.Execution;
import com.gemstone.gemfire.cache.execute.Function;
import com.gemstone.gemfire.cache.execute.ResultCollector;
/**
*
@@ -29,40 +30,38 @@ abstract class AbstractFunctionTemplate implements GemfireFunctionOperations {
protected Log log = LogFactory.getLog(this.getClass());
protected long timeout;
protected volatile ResultCollector<?, ?> resultCollector;
@Override
public <T> Iterable<T> execute(Function function, Object... args) {
FunctionExecution functionExecution = getFunctionExecution()
AbstractFunctionExecution functionExecution = getFunctionExecution()
.setArgs(args)
.setFunction(function)
.setTimeout(timeout);
.setFunction(function);
return execute(functionExecution);
}
@Override
public <T> T executeAndExtract(Function function, Object... args) {
FunctionExecution functionExecution = getFunctionExecution()
AbstractFunctionExecution functionExecution = getFunctionExecution()
.setArgs(args)
.setFunction(function)
.setTimeout(timeout);
.setFunction(function);
return executeAndExtract(functionExecution);
}
@Override
public <T> Iterable<T> execute(String functionId, Object... args) {
FunctionExecution functionExecution = getFunctionExecution()
AbstractFunctionExecution functionExecution = getFunctionExecution()
.setArgs(args)
.setFunctionId(functionId)
.setTimeout(timeout);
.setFunctionId(functionId);
return execute(functionExecution);
}
@Override
public <T> T executeAndExtract(String functionId, Object... args) {
FunctionExecution functionExecution = getFunctionExecution()
AbstractFunctionExecution functionExecution = getFunctionExecution()
.setArgs(args)
.setFunctionId(functionId)
.setTimeout(timeout);
.setFunctionId(functionId);
return executeAndExtract(functionExecution);
}
@@ -73,13 +72,15 @@ abstract class AbstractFunctionTemplate implements GemfireFunctionOperations {
}
protected <T> Iterable<T> execute(FunctionExecution execution) {
execution.setTimeout(timeout);
protected <T> Iterable<T> execute(AbstractFunctionExecution execution) {
execution.setTimeout(timeout)
.setResultCollector(resultCollector);
return execution.execute();
}
protected <T> T executeAndExtract(FunctionExecution execution) {
execution.setTimeout(timeout);
protected <T> T executeAndExtract(AbstractFunctionExecution execution) {
execution.setTimeout(timeout)
.setResultCollector(resultCollector);
return execution.executeAndExtract();
}
@@ -87,5 +88,13 @@ abstract class AbstractFunctionTemplate implements GemfireFunctionOperations {
this.timeout = timeout;
}
protected abstract FunctionExecution getFunctionExecution();
public void setResultCollector(ResultCollector<?,?> resultCollector) {
this.resultCollector = resultCollector;
}
public ResultCollector<?,?> getResultCollector() {
return this.resultCollector;
}
protected abstract AbstractFunctionExecution getFunctionExecution();
}

View File

@@ -19,7 +19,7 @@ import com.gemstone.gemfire.cache.execute.FunctionService;
* @author David Turanski
*
*/
public class AllMembersFunctionExecution extends FunctionExecution {
public class AllMembersFunctionExecution extends AbstractFunctionExecution {
@Override
protected Execution getExecution() {

View File

@@ -19,7 +19,7 @@ import com.gemstone.gemfire.cache.execute.FunctionService;
* @author David Turanski
*
*/
public class DefaultMemberFunctionExecution extends FunctionExecution {
public class DefaultMemberFunctionExecution extends AbstractFunctionExecution {
@Override
protected Execution getExecution() {

View File

@@ -22,7 +22,7 @@ import com.gemstone.gemfire.distributed.DistributedMember;
* @author David Turanski
*
*/
public class DistributedMemberFunctionExecution extends FunctionExecution {
public class DistributedMemberFunctionExecution extends AbstractFunctionExecution {
private final DistributedMember distributedMember;

View File

@@ -22,7 +22,7 @@ import com.gemstone.gemfire.distributed.DistributedMember;
* @author David Turanski
*
*/
public class DistributedMembersFunctionExecution extends FunctionExecution {
public class DistributedMembersFunctionExecution extends AbstractFunctionExecution {
private final Set<DistributedMember> distributedMembers;
/**

View File

@@ -41,7 +41,7 @@ abstract class FunctionExecutionMethodMetadata<T extends MethodMetadata > {
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
T mmd = newMetadataInstance(method);
if (mmd.getFunctionId() == null) {
mmd.setFunctionId(serviceInterface.getName() + "." + method.getName());
mmd.setFunctionId(method.getName());
}
methodMetadata.put(method, mmd);

View File

@@ -22,12 +22,11 @@ import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.data.gemfire.function.config.FunctionId;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import com.gemstone.gemfire.cache.execute.FunctionException;
import com.gemstone.gemfire.cache.execute.FunctionService;
/**
* A proxy Factory Bean for all non-region function execution interfaces
@@ -35,7 +34,7 @@ import com.gemstone.gemfire.cache.execute.FunctionException;
* @author David Turanski
*
*/
public class GemfireFunctionProxyFactoryBean implements FactoryBean<Object>, MethodInterceptor, BeanClassLoaderAware, InitializingBean {
public class GemfireFunctionProxyFactoryBean implements FactoryBean<Object>, MethodInterceptor, BeanClassLoaderAware {
protected volatile ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
@@ -45,7 +44,7 @@ public class GemfireFunctionProxyFactoryBean implements FactoryBean<Object>, Met
private volatile boolean initialized;
protected String functionId;
//protected String functionId;
protected Log logger = LogFactory.getLog(this.getClass());
@@ -123,20 +122,6 @@ public class GemfireFunctionProxyFactoryBean implements FactoryBean<Object>, Met
this.serviceProxy = proxyFactory.getProxy(this.beanClassLoader);
this.initialized = true;
}
protected String annotatedFunctionId(Method method) {
FunctionId functionIdAnnotation = method.getAnnotation(FunctionId.class);
return (functionIdAnnotation == null) ? null: functionIdAnnotation.value();
}
/**
* Optional to set a default function Id for a single method interface with no {code}@FunctionId{code} annotations
* @param functionId
*/
public void setFunctionId(String functionId) {
this.functionId = functionId;
}
/*
* Match the result to the declared return type
@@ -164,16 +149,4 @@ public class GemfireFunctionProxyFactoryBean implements FactoryBean<Object>, Met
}
return result;
}
/* (non-Javadoc)
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
@Override
public void afterPropertiesSet() throws Exception {
if (this.functionId != null) {
if (this.methodMetadata.isSingletonInterface()) {
this.methodMetadata.getSingletonMethodMetada().setFunctionId(this.functionId);
}
}
}
}

View File

@@ -41,7 +41,7 @@ public class GemfireOnMemberFunctionTemplate extends AbstractFunctionTemplate {
}
protected FunctionExecution getFunctionExecution() {
protected AbstractFunctionExecution getFunctionExecution() {
if (distributedMember == null && groups == null) {
return new DefaultMemberFunctionExecution();
} else if (distributedMember == null) {

View File

@@ -42,7 +42,7 @@ public class GemfireOnMembersFunctionTemplate extends AbstractFunctionTemplate
}
protected FunctionExecution getFunctionExecution() {
protected AbstractFunctionExecution getFunctionExecution() {
if (distributedMembers == null && groups == null) {
return new AllMembersFunctionExecution();
} else if (distributedMembers == null) {

View File

@@ -66,7 +66,7 @@ public class GemfireOnRegionFunctionTemplate extends AbstractFunctionTemplate i
}
@Override
protected FunctionExecution getFunctionExecution() {
protected AbstractFunctionExecution getFunctionExecution() {
return new RegionFunctionExecution(this.region);
}

View File

@@ -37,7 +37,7 @@ public class GemfireOnServerFunctionTemplate extends AbstractFunctionTemplate {
}
@Override
protected FunctionExecution getFunctionExecution() {
protected AbstractFunctionExecution getFunctionExecution() {
if (this.pool == null) {
return new ServerFunctionExecution(this.cache);
}

View File

@@ -37,7 +37,7 @@ public class GemfireOnServersFunctionTemplate extends AbstractFunctionTemplate
}
@Override
protected FunctionExecution getFunctionExecution() {
protected AbstractFunctionExecution getFunctionExecution() {
if (this.pool == null) {
return new ServersFunctionExecution(this.cache);
}

View File

@@ -21,7 +21,7 @@ import com.gemstone.gemfire.cache.execute.FunctionService;
* @author David Turanski
*
*/
public class GroupMemberFunctionExecution extends FunctionExecution {
public class GroupMemberFunctionExecution extends AbstractFunctionExecution {
private final String groups[];

View File

@@ -21,7 +21,7 @@ import com.gemstone.gemfire.cache.execute.FunctionService;
* @author David Turanski
*
*/
public class GroupMembersFunctionExecution extends FunctionExecution {
public class GroupMembersFunctionExecution extends AbstractFunctionExecution {
private final String groups[];

View File

@@ -26,7 +26,7 @@ import com.gemstone.gemfire.cache.execute.FunctionService;
* @author David Turanski
*
*/
public class PoolServerFunctionExecution extends FunctionExecution implements InitializingBean {
public class PoolServerFunctionExecution extends AbstractFunctionExecution implements InitializingBean {
private Pool pool;

View File

@@ -23,7 +23,7 @@ import com.gemstone.gemfire.cache.execute.FunctionService;
* @author David Turanski
*
*/
public class PoolServersFunctionExecution extends FunctionExecution {
public class PoolServersFunctionExecution extends AbstractFunctionExecution {
private final Pool pool;

View File

@@ -25,7 +25,7 @@ import com.gemstone.gemfire.cache.execute.FunctionService;
* @author David Turanski
*
*/
public class RegionFunctionExecution extends FunctionExecution {
public class RegionFunctionExecution extends AbstractFunctionExecution {
private final Region<?, ?> region;

View File

@@ -23,7 +23,7 @@ import com.gemstone.gemfire.cache.execute.FunctionService;
* @author David Turanski
*
*/
public class ServerFunctionExecution extends FunctionExecution {
public class ServerFunctionExecution extends AbstractFunctionExecution {
private RegionService regionService;

View File

@@ -23,7 +23,7 @@ import com.gemstone.gemfire.cache.execute.FunctionService;
* @author David Turanski
*
*/
public class ServersFunctionExecution extends FunctionExecution {
public class ServersFunctionExecution extends AbstractFunctionExecution {
private final RegionService regionService;