Code polishing and general cleanup
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
* Copyright 2016-2018 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.
|
||||
@@ -19,7 +19,6 @@ package org.springframework.cloud.function.context.catalog;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
@@ -66,28 +65,18 @@ public class InMemoryFunctionCatalog
|
||||
|
||||
@Override
|
||||
public <T> void register(FunctionRegistration<T> registration) {
|
||||
FunctionRegistrationEvent event;
|
||||
Class<?> type;
|
||||
Class<?> type = Object.class;
|
||||
if (registration.getTarget() instanceof Function) {
|
||||
type = Function.class;
|
||||
event = new FunctionRegistrationEvent(this, Function.class,
|
||||
registration.getNames());
|
||||
}
|
||||
else if (registration.getTarget() instanceof Supplier) {
|
||||
type = Supplier.class;
|
||||
event = new FunctionRegistrationEvent(this, Supplier.class,
|
||||
registration.getNames());
|
||||
}
|
||||
else if (registration.getTarget() instanceof Consumer) {
|
||||
type = Consumer.class;
|
||||
event = new FunctionRegistrationEvent(this, Consumer.class,
|
||||
registration.getNames());
|
||||
}
|
||||
else {
|
||||
type = Object.class;
|
||||
event = new FunctionRegistrationEvent(this, Object.class,
|
||||
registration.getNames());
|
||||
}
|
||||
FunctionRegistrationEvent event = new FunctionRegistrationEvent(this, type, registration.getNames());
|
||||
|
||||
registrations.put(registration.getTarget(), registration);
|
||||
FunctionRegistration<T> wrapped = registration.wrap();
|
||||
if (wrapped != registration) {
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract class MessageUtils {
|
||||
* isolated class loader, then the message will be created with the target class
|
||||
* loader (therefore the {@link Message} class must be on the classpath of the target
|
||||
* class loader).
|
||||
*
|
||||
*
|
||||
* @param handler the function that will be applied to the message
|
||||
* @param payload the payload of the message
|
||||
* @param headers the headers for the message
|
||||
@@ -71,10 +71,10 @@ public abstract class MessageUtils {
|
||||
|
||||
/**
|
||||
* Convert a message from the handler into one that is safe to consume in the caller's
|
||||
* class laoder. If the handler is a wrapper for a function in an isolated class
|
||||
* class loader. If the handler is a wrapper for a function in an isolated class
|
||||
* loader, then the message will be created with the target class loader (therefore
|
||||
* the {@link Message} class must be on the classpath of the target class loader).
|
||||
*
|
||||
*
|
||||
* @param handler the function that generated the message
|
||||
* @param message the message to convert
|
||||
* @return a message with the correct class loader
|
||||
|
||||
Reference in New Issue
Block a user