using Assert

This commit is contained in:
Mark Fisher
2009-12-06 23:59:32 +00:00
parent 36f6ec07d6
commit df39fcd14e

View File

@@ -71,12 +71,17 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint implements Factory
private volatile boolean initialized; private volatile boolean initialized;
private final Object initializationMonitor = new Object(); private final Object initializationMonitor = new Object();
private Map<String, GatewayMethodDefinition> methodToChannelMap; private Map<String, GatewayMethodDefinition> methodToChannelMap;
/**
* Set the interface class that the generated proxy should implement.
* If none is provided explicitly, the default is MessageHandler.
*/
public void setServiceInterface(Class<?> serviceInterface) { public void setServiceInterface(Class<?> serviceInterface) {
if (serviceInterface != null && !serviceInterface.isInterface()) { Assert.notNull(serviceInterface, "'serviceInterface' must not be null");
throw new IllegalArgumentException("'serviceInterface' must be an interface"); Assert.isTrue(serviceInterface.isInterface(), "'serviceInterface' must be an interface");
}
this.serviceInterface = serviceInterface; this.serviceInterface = serviceInterface;
} }
@@ -137,9 +142,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint implements Factory
if (this.initialized) { if (this.initialized) {
return; return;
} }
if (this.serviceInterface == null) { Assert.notNull(this.serviceInterface, "'serviceInterface' must not be null");
throw new IllegalArgumentException("'serviceInterface' must not be null");
}
Method[] methods = this.serviceInterface.getDeclaredMethods(); Method[] methods = this.serviceInterface.getDeclaredMethods();
for (Method method : methods) { for (Method method : methods) {
MessagingGateway gateway = this.createGatewayForMethod(method); MessagingGateway gateway = this.createGatewayForMethod(method);