Handler for azure sample calls super in different method

If FooHandler extends AzureSpringBootRequestHandler apparently
Azure cannot extract the generic types Foo and Bar.
This commit is contained in:
Dave Syer
2018-01-24 14:24:13 +00:00
parent 7604de3ca7
commit b0bddd3160
10 changed files with 111 additions and 82 deletions

View File

@@ -1,4 +0,0 @@
#!/bin/sh
cd $(dirname $0)
PATH="$PWD/node/":$PATH
node "node/node_modules/npm/bin/npm-cli.js" "$@"

View File

@@ -23,30 +23,25 @@
<maven.compiler.target>1.8</maven.compiler.target>
<functionAppName>function-sample-azure</functionAppName>
<functionAppRegion>westus</functionAppRegion>
<start-class>example.FooConfig</start-class>
<reactor.version>3.1.2.RELEASE</reactor.version>
<start-class>example.Config</start-class>
</properties>
<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-functions-java-core</artifactId>
<version>1.0.0-beta-2</version>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-adapter-azure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-web</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-adapter-azure</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.1.2.RELEASE</version>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-functions-java-core</artifactId>
<version>1.0.0-beta-2</version>
<scope>provided</scope>
</dependency>
<!-- Test -->
@@ -62,6 +57,18 @@
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-dependencies</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
@@ -78,28 +85,6 @@
</pluginManagement>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<configuration>
<nodeVersion>v8.8.1</nodeVersion>
</configuration>
<executions>
<execution>
<id>install-npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>npm-install</id>
<goals>
<goal>npm</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-functions-maven-plugin</artifactId>
@@ -132,9 +117,7 @@
<resource>
<directory>${project.basedir}/src/main/azure</directory>
<includes>
<include>uppercase/**</include>
<include>host.json</include>
<include>local.settings.json</include>
<include>**</include>
</includes>
</resource>
</resources>
@@ -154,6 +137,28 @@
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>azure</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<inherited>false</inherited>
<configuration>
<attach>false</attach>
<descriptor>${basedir}/src/assembly/azure.xml</descriptor>
<outputDirectory>${project.build.directory}/azure-functions</outputDirectory>
<appendAssemblyId>false</appendAssemblyId>
<finalName>${functionAppName}</finalName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@@ -0,0 +1,20 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>azure</id>
<formats>
<format>zip</format>
</formats>
<baseDirectory></baseDirectory>
<fileSets>
<fileSet>
<directory>${project.build.directory}/azure-functions/${functionAppName}</directory>
<outputDirectory></outputDirectory>
<includes>
<include>*-azure.jar</include>
<include>**/*.json</include>
</includes>
</fileSet>
</fileSets>
</assembly>

View File

@@ -1,2 +1,3 @@
{
"functionTimeout": "00:10:00"
}

View File

@@ -1,16 +1,22 @@
{
"scriptFile" : "../function-sample-azure-1.0.0.BUILD-SNAPSHOT-azure.jar",
"entryPoint" : "example.FooHandler.handleRequest",
"bindings" : [ {
"type" : "httpTrigger",
"name" : "foo",
"direction" : "in",
"authLevel" : "anonymous",
"methods" : [ "get", "post" ]
}, {
"type" : "http",
"name" : "$return",
"direction" : "out"
} ],
"disabled" : false
"scriptFile": "../function-sample-azure-1.0.0.BUILD-SNAPSHOT-azure.jar",
"entryPoint": "example.FooHandler.execute",
"bindings": [
{
"type": "httpTrigger",
"name": "foo",
"direction": "in",
"authLevel": "anonymous",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"name": "$return",
"direction": "out"
}
],
"disabled": false
}

View File

@@ -23,15 +23,15 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
class FooConfig {
public class Config {
public static void main(String[] args) throws Exception {
SpringApplication.run(Config.class, args);
}
@Bean
public Function<Foo, Bar> uppercase() {
return value -> new Bar(value.getValue().toUpperCase());
}
public static void main(String[] args) throws Exception {
SpringApplication.run(FooConfig.class, args);
return foo -> new Bar(foo.getValue().toUpperCase());
}
}

View File

@@ -17,8 +17,6 @@
package example;
import com.microsoft.azure.serverless.functions.ExecutionContext;
import com.microsoft.azure.serverless.functions.annotation.HttpOutput;
import com.microsoft.azure.serverless.functions.annotation.HttpTrigger;
import org.springframework.cloud.function.adapter.azure.AzureSpringBootRequestHandler;
@@ -27,12 +25,8 @@ import org.springframework.cloud.function.adapter.azure.AzureSpringBootRequestHa
*/
public class FooHandler extends AzureSpringBootRequestHandler<Foo, Bar> {
@Override
public @HttpOutput(name = "bar") Bar handleRequest(
@HttpTrigger(name = "foo", methods = { "get", "post" }) Foo foo,
ExecutionContext context) {
context.getLogger().info("Invoking entry point method");
return (Bar) super.handleRequest(foo, context);
public Bar execute(Foo foo, ExecutionContext context) {
return handleRequest(foo, context);
}
}