Change FunctionCatalog to key off Class<?>
Makes it possible to support other "function" types in the future. The user is always taking a risk with the lookup that the object returned has the generic type desired (but that hasn't changed with this commit). FunctionCatalog is a lot simpler as a result and also a lot more flexible.
This commit is contained in:
@@ -99,17 +99,17 @@ public class SpringFunctionInitializer implements Closeable {
|
||||
this.function = context.getBean(name, Function.class);
|
||||
}
|
||||
else {
|
||||
this.function = this.catalog.lookupFunction(name);
|
||||
this.function = this.catalog.lookup(Function.class, name);
|
||||
if (this.function == null) {
|
||||
if (defaultName) {
|
||||
name = "consumer";
|
||||
}
|
||||
this.consumer = this.catalog.lookupConsumer(name);
|
||||
this.consumer = this.catalog.lookup(Consumer.class, name);
|
||||
if (this.consumer == null) {
|
||||
if (defaultName) {
|
||||
name = "supplier";
|
||||
}
|
||||
this.supplier = this.catalog.lookupSupplier(name);
|
||||
this.supplier = this.catalog.lookup(Supplier.class, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,8 +105,8 @@ public class AzureSpringFunctionInitializer implements Closeable {
|
||||
this.function = context.getBean(name, Function.class);
|
||||
}
|
||||
else {
|
||||
Set<String> functionNames = this.catalog.getFunctionNames();
|
||||
this.function = this.catalog.lookupFunction(functionNames.iterator().next());
|
||||
Set<String> functionNames = this.catalog.getNames(Function.class);
|
||||
this.function = this.catalog.lookup(Function.class, functionNames.iterator().next());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,11 +64,11 @@ public class OpenWhiskFunctionInitializer {
|
||||
String name = this.properties.getName();
|
||||
String type = this.properties.getType();
|
||||
if ("function".equals(type)) {
|
||||
this.function = this.catalog.lookupFunction(name);
|
||||
this.function = this.catalog.lookup(Function.class, name);
|
||||
} else if ("consumer".equals(type)) {
|
||||
this.consumer = this.catalog.lookupConsumer(name);
|
||||
this.consumer = this.catalog.lookup(Consumer.class, name);
|
||||
} else if ("supplier".equals(type)) {
|
||||
this.supplier = this.catalog.lookupSupplier(name);
|
||||
this.supplier = this.catalog.lookup(Supplier.class, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user