GH-718 Improve support for Function bean definition
Added sample for functional bean definition
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package example;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.cloud.function.context.FunctionRegistration;
|
||||
import org.springframework.cloud.function.context.FunctionType;
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
|
||||
@SpringBootConfiguration
|
||||
public class FunctionConfiguration implements ApplicationContextInitializer<GenericApplicationContext> {
|
||||
|
||||
/*
|
||||
* You need this main method (empty) or explicit <start-class>example.FunctionConfiguration</start-class>
|
||||
* in the POM to ensure boot plug-in makes the correct entry
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// empty unless using Custom runtime at which point it should include
|
||||
// FunctionalSpringApplication.run(FunctionConfiguration.class, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(GenericApplicationContext context) {
|
||||
Function<String, String> function = (str) -> str + str.toUpperCase();
|
||||
context.registerBean("uppercase", FunctionRegistration.class,
|
||||
() -> new FunctionRegistration<>(function).type(
|
||||
FunctionType.from(String.class).to(String.class)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
logging.level.org.springframework.cloud=DEBUG
|
||||
#spring.cloud.function.web.export.enabled=false
|
||||
#spring.main.web-application-type=none
|
||||
#spring.functional.enabled=true
|
||||
@@ -0,0 +1,20 @@
|
||||
log4j.rootCategory=DEBUG, LAMBDA
|
||||
PID=????
|
||||
LOG_LEVEL_PATTERN=%5p
|
||||
LOG_PATTERN=[%d{yyyy-MM-dd HH:mm:ss.SSS}] boot%X{context} - ${PID} ${LOG_LEVEL_PATTERN} [%t] --- %c{1}: %m%n
|
||||
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
|
||||
log4j.appender.LAMBDA=com.amazonaws.services.lambda.runtime.log4j.LambdaAppender
|
||||
log4j.appender.LAMBDA.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.LAMBDA.layout.conversionPattern=${LOG_PATTERN}
|
||||
log4j.category.org.apache.catalina.startup.DigesterFactory=ERROR
|
||||
log4j.category.org.apache.catalina.util.LifecycleBase=ERROR
|
||||
log4j.category.org.apache.coyote.http11.Http11NioProtocol=WARN
|
||||
log4j.category.org.apache.sshd.common.util.SecurityUtils
|
||||
log4j.category.org.apache.tomcat.util.net.NioSelectorPool=WARN
|
||||
log4j.category.org.crsh.plugin=WARN
|
||||
log4j.category.org.crsh.ssh=WARN
|
||||
log4j.category.org.eclipse.jetty.util.component.AbstractLifeCycle=ERROR
|
||||
log4j.category.org.hibernate.validator.internal.util.Version=WARN
|
||||
log4j.category.org.springframework.boot.actuate.autoconfigure.CrshAutoConfiguration=WARN
|
||||
log4j.category.org.springframework.boot.actuate.endpoint.jmx=WARN
|
||||
log4j.category.org.thymeleaf=WARN
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2012-2019 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package example;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class MapTests {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user