diff --git a/spring-cloud-function-adapters/spring-cloud-function-adapter-aws/.jdk8 b/spring-cloud-function-adapters/spring-cloud-function-adapter-aws/.jdk8 deleted file mode 100644 index e69de29bb..000000000 diff --git a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/.jdk8 b/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/.jdk8 deleted file mode 100644 index e69de29bb..000000000 diff --git a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/README.adoc b/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/README.adoc deleted file mode 100644 index 6a74c8709..000000000 --- a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/README.adoc +++ /dev/null @@ -1,19 +0,0 @@ -//// -DO NOT EDIT THIS FILE. IT WAS GENERATED. -Manual changes to this file will be lost when it is generated again. -Edit the files in the src/main/asciidoc/ directory instead. -//// - -== Quick Start - -Unresolved directive in openwhisk-readme.adoc - include::./adapters/openwhisk-quick-start.adoc[] - -== Examples - -The following examples are built based on the details and explanations above, on how to deploy Spring Cloud Functions on to https://openwhisk.apache.org/[OpenWhisk] - -* https://github.com/redhat-developer-demos/ow-scf-fruiteason[Spring Cloud Function PoF Example]. This example shows how to use Spring Cloud Functions by defining simple Plain Old Function (POF) - -* https://github.com/redhat-developer-demos/ow-scf-greeter[Spring Cloud Function Application Example]. This example shows how to use Spring Cloud Functions with a complete Spring Boot Application that has functions defined by extending `java.util.function.Function` interfaces. - -The base docker images used for above examples is available https://github.com/redhat-developer-demos/openwhisk-scf-docker[here]. \ No newline at end of file diff --git a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/pom.xml b/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/pom.xml deleted file mode 100644 index 149ca38b5..000000000 --- a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/pom.xml +++ /dev/null @@ -1,97 +0,0 @@ - - - 4.0.0 - - spring-cloud-function-adapter-openwhisk - jar - - spring-cloud-function-adapter-openwhisk - Apache OpenWhisk Adapter for Spring Cloud Function - - - org.springframework.cloud - spring-cloud-function-adapter-parent - 4.0.0-SNAPSHOT - - - - - org.springframework.cloud - spring-cloud-function-context - - - org.springframework.boot - spring-boot-starter-web - - - io.projectreactor - reactor-core - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.boot - spring-boot-configuration-processor - true - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.springframework.boot.experimental - spring-boot-thin-layout - ${wrapper.version} - - - - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - diff --git a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/FunctionProperties.java b/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/FunctionProperties.java deleted file mode 100644 index 1a24fbe66..000000000 --- a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/FunctionProperties.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 org.springframework.cloud.function.adapter.openwhisk; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * @author Mark Fisher - */ -@ConfigurationProperties(prefix = "function") -public class FunctionProperties { - - private String name = "function"; - - private String type = "function"; - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public String getType() { - return this.type; - } - - public void setType(String type) { - this.type = type; - } - -} diff --git a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskActionApplication.java b/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskActionApplication.java deleted file mode 100644 index dc0dd5ed5..000000000 --- a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskActionApplication.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 org.springframework.cloud.function.adapter.openwhisk; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.properties.EnableConfigurationProperties; - -/** - * @author Mark Fisher - */ -// @checkstyle:off -@SpringBootApplication -@EnableConfigurationProperties(FunctionProperties.class) -public class OpenWhiskActionApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenWhiskActionApplication.class, args); - } - -} -// @checkstyle:on diff --git a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskActionHandler.java b/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskActionHandler.java deleted file mode 100644 index 138e6d1a8..000000000 --- a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskActionHandler.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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 org.springframework.cloud.function.adapter.openwhisk; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.reactivestreams.Publisher; -import reactor.core.publisher.Flux; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author Mark Fisher - * @author Kamesh Sampath - */ -@RestController -public class OpenWhiskActionHandler extends OpenWhiskFunctionInitializer { - - private static final String NO_INPUT_PROVIDED = "No input provided"; - - private static Log logger = LogFactory.getLog(OpenWhiskFunctionInitializer.class); - - @Autowired - private ObjectMapper mapper; - - public OpenWhiskActionHandler() { - super(); - } - - @PostMapping("/init") - public void init(@RequestBody OpenWhiskInitRequest request) { - initialize(); - } - - @PostMapping(value = "/run", consumes = "application/json", produces = "application/json") - public Object run(@RequestBody OpenWhiskActionRequest request) { - Object input = convertEvent(request.getValue()); - Object result = NO_INPUT_PROVIDED; - if (input != null) { - Publisher output = apply(extract(input)); - result = result(input, output); - } - return serializeBody(result); - } - - private Object result(Object input, Publisher output) { - List result = new ArrayList<>(); - for (Object value : Flux.from(output).toIterable()) { - result.add(value); - } - if (isSingleValue(input) && result.size() == 1) { - return result.get(0); - } - return result; - } - - private boolean isSingleValue(Object input) { - return !(input instanceof Collection); - } - - private Flux extract(Object input) { - if (input instanceof Collection) { - return Flux.fromIterable((Iterable) input); - } - return Flux.just(input); - } - - protected Object convertEvent(Map value) { - // just expecting "payload" for now - if (logger.isDebugEnabled()) { - logger.info("Action Request Value:" + value); - } - if (value != null) { - Object payload = value.get("payload"); - return convertToFunctionParamType(payload); - } - return null; - } - - private Object convertToFunctionParamType(Object payload) { - try { - return this.mapper.convertValue(payload, getInputType()); - } - catch (Exception e) { - throw new IllegalStateException("Cannot convert event payload", e); - } - } - - private String serializeBody(Object body) { - try { - return "{\"result\":" + this.mapper.writeValueAsString(body) + "}"; - } - catch (JsonProcessingException e) { - throw new IllegalStateException("Cannot convert output", e); - } - } - -} diff --git a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskActionRequest.java b/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskActionRequest.java deleted file mode 100644 index dc8435ae0..000000000 --- a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskActionRequest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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 org.springframework.cloud.function.adapter.openwhisk; - -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * @author Mark Fisher - */ -public class OpenWhiskActionRequest { - - @JsonProperty("action_name") - private String actionName; - - @JsonProperty("activation_id") - private String activationId; - - @JsonProperty("api_key") - private String apiKey; - - private String deadline; - - private String namespace; - - private Map value; - - public String getActionName() { - return this.actionName; - } - - public void setActionName(String actionName) { - this.actionName = actionName; - } - - public String getActivationId() { - return this.activationId; - } - - public void setActivationId(String activationId) { - this.activationId = activationId; - } - - public String getApiKey() { - return this.apiKey; - } - - public void setApiKey(String apiKey) { - this.apiKey = apiKey; - } - - public String getDeadline() { - return this.deadline; - } - - public void setDeadline(String deadline) { - this.deadline = deadline; - } - - public String getNamespace() { - return this.namespace; - } - - public void setNamespace(String namespace) { - this.namespace = namespace; - } - - public Map getValue() { - return this.value; - } - - public void setValue(Map value) { - this.value = value; - } - -} diff --git a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskFunctionInitializer.java b/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskFunctionInitializer.java deleted file mode 100644 index 248a4abe8..000000000 --- a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskFunctionInitializer.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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 org.springframework.cloud.function.adapter.openwhisk; - -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.function.Supplier; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.reactivestreams.Publisher; -import reactor.core.publisher.Flux; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cloud.function.context.FunctionCatalog; -import org.springframework.cloud.function.context.catalog.FunctionInspector; - -/** - * @author Dave Syer - * @author Mark Fisher - * @author Kamesh Sampath - */ -public class OpenWhiskFunctionInitializer { - - private static Log logger = LogFactory.getLog(OpenWhiskFunctionInitializer.class); - - private Function, Publisher> function; - - private Consumer> consumer; - - private Supplier> supplier; - - private AtomicBoolean initialized = new AtomicBoolean(); - - @Autowired(required = false) - private FunctionInspector inspector; - - @Autowired - private FunctionCatalog catalog; - - @Autowired - private FunctionProperties properties; - - protected void initialize() { - logger.info("Initializing - OpenWhisk Function Initializer"); - if (!this.initialized.compareAndSet(false, true)) { - return; - } - String name = this.properties.getName(); - String type = this.properties.getType(); - if ("function".equals(type)) { - this.function = this.catalog.lookup(Function.class, name); - } - else if ("consumer".equals(type)) { - this.consumer = this.catalog.lookup(Consumer.class, name); - } - else if ("supplier".equals(type)) { - this.supplier = this.catalog.lookup(Supplier.class, name); - } - } - - protected Class getInputType() { - if (this.inspector != null) { - return this.inspector.getInputType(function()); - } - return Object.class; - } - - private Object function() { - return this.function != null ? this.function - : (this.consumer != null ? this.consumer : this.supplier); - } - - protected Publisher apply(Publisher input) { - if (this.function != null) { - return this.function.apply(input); - } - if (this.consumer != null) { - this.consumer.accept(input); - return Flux.empty(); - } - if (this.supplier != null) { - return this.supplier.get(); - } - throw new IllegalStateException("No function defined"); - } - -} diff --git a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskInitRequest.java b/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskInitRequest.java deleted file mode 100644 index 224828d07..000000000 --- a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskInitRequest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 org.springframework.cloud.function.adapter.openwhisk; - -/** - * @author Mark Fisher - */ -public class OpenWhiskInitRequest { - - private String name; - - private boolean binary; - - private String main; - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public boolean isBinary() { - return this.binary; - } - - public void setBinary(boolean binary) { - this.binary = binary; - } - - public String getMain() { - return this.main; - } - - public void setMain(String main) { - this.main = main; - } - -} diff --git a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/test/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskActionHandlerTest.java b/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/test/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskActionHandlerTest.java deleted file mode 100644 index f8f7e8409..000000000 --- a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/test/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskActionHandlerTest.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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 org.springframework.cloud.function.adapter.openwhisk; - -import java.util.HashMap; -import java.util.Map; -import java.util.function.Function; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.function.context.config.ContextFunctionCatalogAutoConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.context.annotation.Scope; -import org.springframework.test.context.TestPropertySource; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Kamesh Sampath - */ -@SpringBootTest -@EnableAutoConfiguration -@TestPropertySource(locations = "classpath:/application-test.properties") -public class OpenWhiskActionHandlerTest { - - @Autowired - OpenWhiskActionHandler actionHandler; - - @Autowired - ObjectMapper mapper; - - @Test - public void testHandlerWithPayload() { - Map testData = new HashMap<>(); - testData.put("name", "Spring"); - Map eventData = new HashMap<>(); - eventData.put("payload", testData); - this.actionHandler.init(new OpenWhiskInitRequest()); - OpenWhiskActionRequest actionRequest = new OpenWhiskActionRequest(); - actionRequest.setActionName("test_action"); - actionRequest.setValue(eventData); - Object result = this.actionHandler.run(actionRequest); - assertThat(result).isNotNull(); - assertThat(result).isEqualTo( - "{\"result\":{\"name\":\"Spring\",\"message\":\"Hello, Spring\"}}"); - } - - @Test - public void testHandlerWithoutPayload() { - Map testData = new HashMap<>(); - testData.put("name", "Spring"); - this.actionHandler.init(new OpenWhiskInitRequest()); - OpenWhiskActionRequest actionRequest = new OpenWhiskActionRequest(); - actionRequest.setActionName("test_action"); - Object result = this.actionHandler.run(actionRequest); - assertThat(result).isNotNull(); - assertThat(result).isEqualTo("{\"result\":\"No input provided\"}"); - } - - @Configuration - @Import({ ContextFunctionCatalogAutoConfiguration.class, - JacksonAutoConfiguration.class }) - protected static class OWFunctionConfig { - - @Bean - public Function greeter() { - return v -> new OpenWhiskActionHandlerTest.Greetings(v.getName()); - } - - @Bean - @Scope("prototype") - public OpenWhiskActionHandler actionHandler() { - return new OpenWhiskActionHandler(); - } - - @Bean - public FunctionProperties properties() { - return new FunctionProperties(); - } - - } - - protected static class Greetings { - - private final String GREETINGS_FORMAT = "Hello, %s"; - - private String name; - - private String message; - - public Greetings() { - } - - public Greetings(String name) { - this.name = name; - setMessage(""); - } - - public String getMessage() { - return this.message; - } - - public void setMessage(String message) { - this.message = String.format(this.GREETINGS_FORMAT, - this.name != null ? this.name : "nobody"); - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - } - -} diff --git a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/test/resources/application-test.properties b/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/test/resources/application-test.properties deleted file mode 100644 index de376ab09..000000000 --- a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/test/resources/application-test.properties +++ /dev/null @@ -1,2 +0,0 @@ -function.name:greeter -function.type:function diff --git a/spring-cloud-function-task/.jdk8 b/spring-cloud-function-task/.jdk8 deleted file mode 100644 index e69de29bb..000000000 diff --git a/spring-cloud-function-task/pom.xml b/spring-cloud-function-task/pom.xml deleted file mode 100644 index 5731b90d5..000000000 --- a/spring-cloud-function-task/pom.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - 4.0.0 - - spring-cloud-function-task - jar - Spring Cloud Function Task Support - Spring Cloud Function Task Support - - - org.springframework.cloud - spring-cloud-function-parent - 4.0.0-SNAPSHOT - - - - - org.springframework.cloud - spring-cloud-starter-task - - - org.springframework.cloud - spring-cloud-function-context - - - io.projectreactor - reactor-core - - - org.springframework.boot - spring-boot-starter-logging - - - org.springframework.boot - spring-boot-configuration-processor - true - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.springframework.boot.experimental - spring-boot-thin-layout - ${wrapper.version} - - - - - - diff --git a/spring-cloud-function-task/src/main/java/org/springframework/cloud/function/task/TaskApplication.java b/spring-cloud-function-task/src/main/java/org/springframework/cloud/function/task/TaskApplication.java deleted file mode 100644 index 6011e848b..000000000 --- a/spring-cloud-function-task/src/main/java/org/springframework/cloud/function/task/TaskApplication.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 org.springframework.cloud.function.task; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * @author Mark Fisher - */ -// @checkstyle:off -@SpringBootApplication(proxyBeanMethods = false) -public class TaskApplication { - - public static void main(String[] args) { - SpringApplication.run(TaskApplication.class, args); - } - -} -// @checkstyle:on diff --git a/spring-cloud-function-task/src/main/java/org/springframework/cloud/function/task/TaskConfiguration.java b/spring-cloud-function-task/src/main/java/org/springframework/cloud/function/task/TaskConfiguration.java deleted file mode 100644 index f7f48f8ea..000000000 --- a/spring-cloud-function-task/src/main/java/org/springframework/cloud/function/task/TaskConfiguration.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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 org.springframework.cloud.function.task; - -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.function.Supplier; - -import org.reactivestreams.Publisher; -import reactor.core.publisher.Mono; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.function.context.FunctionCatalog; -import org.springframework.cloud.task.configuration.EnableTask; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @author Mark Fisher - */ -@Configuration(proxyBeanMethods = false) -@EnableTask -@EnableConfigurationProperties(TaskConfigurationProperties.class) -@ConditionalOnClass({ EnableTask.class }) -public class TaskConfiguration { - - @Autowired - private TaskConfigurationProperties properties; - - @Bean - public CommandLineRunner commandLineRunner(FunctionCatalog registry) { - final Supplier> supplier = registry.lookup(Supplier.class, this.properties.getSupplier()); - final Function, Publisher> function = registry.lookup(Function.class, - this.properties.getFunction()); - final Consumer> consumer = consumer(registry); - CommandLineRunner runner = new CommandLineRunner() { - - @Override - public void run(String... args) throws Exception { - consumer.accept(function.apply(supplier.get())); - } - }; - return runner; - } - - private Consumer> consumer(FunctionCatalog registry) { - Consumer> consumer = registry.lookup(Consumer.class, this.properties.getConsumer()); - if (consumer != null) { - return consumer; - } - Function, Publisher> function = registry.lookup(Function.class, - this.properties.getConsumer()); - return flux -> Mono.from(function.apply(flux)).subscribe(); - } - -} diff --git a/spring-cloud-function-task/src/main/java/org/springframework/cloud/function/task/TaskConfigurationProperties.java b/spring-cloud-function-task/src/main/java/org/springframework/cloud/function/task/TaskConfigurationProperties.java deleted file mode 100644 index 71a6b345f..000000000 --- a/spring-cloud-function-task/src/main/java/org/springframework/cloud/function/task/TaskConfigurationProperties.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 org.springframework.cloud.function.task; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * @author Mark Fisher - */ -@ConfigurationProperties(prefix = "spring.cloud.function.task") -public class TaskConfigurationProperties { - - private String supplier; - - private String function; - - private String consumer; - - public String getSupplier() { - return this.supplier; - } - - public void setSupplier(String supplier) { - this.supplier = supplier; - } - - public String getFunction() { - return this.function; - } - - public void setFunction(String function) { - this.function = function; - } - - public String getConsumer() { - return this.consumer; - } - - public void setConsumer(String consumer) { - this.consumer = consumer; - } - -} diff --git a/spring-cloud-function-task/src/main/resources/META-INF/spring.factories b/spring-cloud-function-task/src/main/resources/META-INF/spring.factories deleted file mode 100644 index d1a315e33..000000000 --- a/spring-cloud-function-task/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.springframework.cloud.function.task.TaskConfiguration