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

@@ -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);
}
}