Polishing, fixed checkstyles, added author tag
Resolves #256 Resolves #260
This commit is contained in:
@@ -35,7 +35,7 @@ import org.springframework.messaging.support.GenericMessage;
|
|||||||
/**
|
/**
|
||||||
* @author Dave Syer
|
* @author Dave Syer
|
||||||
* @author Oleg Zhurakousky
|
* @author Oleg Zhurakousky
|
||||||
*
|
* @author Semyon Fishman
|
||||||
*/
|
*/
|
||||||
public class SpringBootApiGatewayRequestHandler extends
|
public class SpringBootApiGatewayRequestHandler extends
|
||||||
SpringBootRequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
|
SpringBootRequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
|
||||||
@@ -128,10 +128,12 @@ public class SpringBootApiGatewayRequestHandler extends
|
|||||||
@Override
|
@Override
|
||||||
public Object handleRequest(APIGatewayProxyRequestEvent event, Context context) {
|
public Object handleRequest(APIGatewayProxyRequestEvent event, Context context) {
|
||||||
Object response = super.handleRequest(event, context);
|
Object response = super.handleRequest(event, context);
|
||||||
if (returnsOutput())
|
if (returnsOutput()) {
|
||||||
return response;
|
return response;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
return new APIGatewayProxyResponseEvent()
|
return new APIGatewayProxyResponseEvent()
|
||||||
.withStatusCode(HttpStatus.OK.value());
|
.withStatusCode(HttpStatus.OK.value());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import org.springframework.util.ClassUtils;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Dave Syer
|
* @author Dave Syer
|
||||||
|
* @author Semyon Fishman
|
||||||
*/
|
*/
|
||||||
public class SpringFunctionInitializer implements Closeable {
|
public class SpringFunctionInitializer implements Closeable {
|
||||||
|
|
||||||
@@ -127,7 +128,6 @@ public class SpringFunctionInitializer implements Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
protected void initialize() {
|
protected void initialize() {
|
||||||
if (!this.initialized.compareAndSet(false, true)) {
|
if (!this.initialized.compareAndSet(false, true)) {
|
||||||
return;
|
return;
|
||||||
@@ -147,17 +147,22 @@ public class SpringFunctionInitializer implements Closeable {
|
|||||||
|
|
||||||
private String resolveName(Class<?> type) {
|
private String resolveName(Class<?> type) {
|
||||||
String functionName = context.getEnvironment().getProperty("function.name");
|
String functionName = context.getEnvironment().getProperty("function.name");
|
||||||
if (functionName != null)
|
if (functionName != null) {
|
||||||
return functionName;
|
return functionName;
|
||||||
else if (type.isAssignableFrom(Function.class))
|
}
|
||||||
|
else if (type.isAssignableFrom(Function.class)) {
|
||||||
return "function";
|
return "function";
|
||||||
else if (type.isAssignableFrom(Consumer.class))
|
}
|
||||||
|
else if (type.isAssignableFrom(Consumer.class)) {
|
||||||
return "consumer";
|
return "consumer";
|
||||||
else if (type.isAssignableFrom(Supplier.class))
|
}
|
||||||
|
else if (type.isAssignableFrom(Supplier.class)) {
|
||||||
return "supplier";
|
return "supplier";
|
||||||
|
}
|
||||||
throw new IllegalStateException("Unknown type " + type);
|
throw new IllegalStateException("Unknown type " + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private void initFunctionConsumerOrSupplierFromContext() {
|
private void initFunctionConsumerOrSupplierFromContext() {
|
||||||
String name = resolveName(Function.class);
|
String name = resolveName(Function.class);
|
||||||
if (context.containsBean(name) && context.getBean(name) instanceof Function) {
|
if (context.containsBean(name) && context.getBean(name) instanceof Function) {
|
||||||
@@ -181,18 +186,21 @@ public class SpringFunctionInitializer implements Closeable {
|
|||||||
private void initFunctionConsumerOrSupplierFromCatalog() {
|
private void initFunctionConsumerOrSupplierFromCatalog() {
|
||||||
String name = resolveName(Function.class);
|
String name = resolveName(Function.class);
|
||||||
this.function = this.catalog.lookup(Function.class, name);
|
this.function = this.catalog.lookup(Function.class, name);
|
||||||
if (this.function != null)
|
if (this.function != null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
name = resolveName(Consumer.class);
|
name = resolveName(Consumer.class);
|
||||||
this.consumer = this.catalog.lookup(Consumer.class, name);
|
this.consumer = this.catalog.lookup(Consumer.class, name);
|
||||||
if (this.consumer != null)
|
if (this.consumer != null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
name = resolveName(Supplier.class);
|
name = resolveName(Supplier.class);
|
||||||
this.supplier = this.catalog.lookup(Supplier.class, name);
|
this.supplier = this.catalog.lookup(Supplier.class, name);
|
||||||
if (this.supplier != null)
|
if (this.supplier != null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.catalog.size() == 1) {
|
if (this.catalog.size() == 1) {
|
||||||
Iterator<String> names = this.catalog.getNames(Function.class).iterator();
|
Iterator<String> names = this.catalog.getNames(Function.class).iterator();
|
||||||
@@ -231,14 +239,16 @@ public class SpringFunctionInitializer implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Object function() {
|
protected Object function() {
|
||||||
if (this.function != null)
|
if (this.function != null) {
|
||||||
return this.function;
|
return this.function;
|
||||||
else if (this.consumer != null)
|
}
|
||||||
|
else if (this.consumer != null) {
|
||||||
return this.consumer;
|
return this.consumer;
|
||||||
else if (this.supplier != null)
|
}
|
||||||
|
else if (this.supplier != null) {
|
||||||
return this.supplier;
|
return this.supplier;
|
||||||
else
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean acceptsInput() {
|
protected boolean acceptsInput() {
|
||||||
|
|||||||
Reference in New Issue
Block a user