From 39bad3963ca48b21a9d1d8c4e6cf40ddd72e984c Mon Sep 17 00:00:00 2001 From: Andrew Su Date: Wed, 4 May 2022 17:38:07 -0400 Subject: [PATCH] feat: Add configuration for Java buildpack The detect now checks for func.yaml OR they explicitly defined an environment variable for the function class or the default function name. Signed-off-by: Andrew Su --- buildpacks/java/README.md | 17 +++- buildpacks/java/buildpack.toml | 12 +++ buildpacks/java/java/build.go | 15 ++-- buildpacks/java/java/detect.go | 65 +++++++------- buildpacks/java/java/func_yaml_envs.go | 81 ++++++++++++++++++ buildpacks/java/java/function.go | 36 +++----- .../JavaFunctionInvokerApplication.java | 2 - .../src/main/resources/application.properties | 3 +- .../cloudevents/txt-to-pdf-maven/Makefile | 2 +- .../cloudevents/txt-to-pdf-maven/README.md | 2 +- .../http/request-response-gradle/README.md | 6 +- .../com/vmware/functions/Handler.class | Bin 1638 -> 0 bytes .../http/request-response-maven/README.md | 6 +- .../java/com/vmware/functions/Handler.java | 7 ++ .../com/vmware/functions/Handler.class | Bin 1638 -> 0 bytes templates/java/cloudevents-gradle/README.md | 2 +- .../functions/{Hire.java => Handler.java} | 2 +- .../functions/{Hire.java => Handler.java} | 2 +- templates/java/http-gradle/README.md | 2 +- .../functions/{Hire.java => Handler.java} | 2 +- templates/java/http-maven/README.md | 2 +- .../functions/{Hire.java => Handler.java} | 2 +- 22 files changed, 193 insertions(+), 75 deletions(-) create mode 100644 buildpacks/java/java/func_yaml_envs.go delete mode 100644 samples/java/http/request-response-gradle/target/classes/com/vmware/functions/Handler.class delete mode 100644 samples/java/http/request-response-maven/target/classes/com/vmware/functions/Handler.class rename templates/java/cloudevents-gradle/src/main/java/functions/{Hire.java => Handler.java} (95%) rename templates/java/cloudevents-maven/src/main/java/functions/{Hire.java => Handler.java} (95%) rename templates/java/http-gradle/src/main/java/functions/{Hire.java => Handler.java} (93%) rename templates/java/http-maven/src/main/java/functions/{Hire.java => Handler.java} (93%) diff --git a/buildpacks/java/README.md b/buildpacks/java/README.md index 01bc5e28..2e1b6932 100644 --- a/buildpacks/java/README.md +++ b/buildpacks/java/README.md @@ -4,20 +4,29 @@ The Java Function Buildpack is a Cloud Native Buildpack that provides a Spring B ## Behaviour This buildpack will participate if any of the following conditions are met: -* A file with the name `func.yaml` is detected +* A buildpack configuration variable `BP_FUNCTION` is explicitly set. +* A file with the name `func.yaml` is detected. The buildpack will do the following if detection passed: * Request for a JRE to be installed -* Contributes the Spring Boot application to a layer marked `launch` with the layer's path prepended to `$CLASSPATH` +* Contributes the function invoker to a layer marked `launch` with the layer's path prepended to `$CLASSPATH` * Contributes environment variables defined in `func.yaml` to the `launch` layer +* Contributes environment variables to configure the invoker if any configuration variables are defined. (Overrides anything from `func.yaml`) + +## Configuration + +| Environment Variable | Description | +|----------------------|-------------| +| `$BP_FUNCTION` | Configure the function to load. If the function lives in the default package: ``. If the function lives in their own package: `.`. Defaults to `functions.Handler` | +| `$BP_DEFAULT_FUNCTION` | Configure the default function. By specifying this property, a function with the name can be accessed via the `/` path. Defaults to empty. | ## Getting started To get started you'll need to create a directory where your function will be defined. From within this directory we require a few files to properly detect this as a Java function: -* `func.yaml`: We use this to configure the runtime environment variables. See the [Knative Func CLI docs](https://github.com/knative-sandbox/kn-plugin-func/blob/main/docs/guides/func_yaml.md) for more details. +* `func.yaml` (optional): We use this to configure the runtime environment variables. See the [Knative Func CLI docs](https://github.com/knative-sandbox/kn-plugin-func/blob/main/docs/guides/func_yaml.md) for more details. * `pom.xml` or `build.gradle`: These are used by the other Java buildpacks to compile your function. -* Java package in folder `src/main/java/functions`: This is the default location your function will be detected. If you do choose to use another package to store your functions, you will need to [set a new search location](#TODO). +* Java package in folder `src/main/java/functions`: This is the default location your function will be detected. If you do choose to use another package to store your functions, you will need to define where your function is located with the `BP_FUNCTION` configuration for the buildpack. ## Compiling Your Function To compile your function with the buildpack, we've provided a builder which has all the pre-requisites ready to go. diff --git a/buildpacks/java/buildpack.toml b/buildpacks/java/buildpack.toml index 6fc343e7..b2ce85d4 100644 --- a/buildpacks/java/buildpack.toml +++ b/buildpacks/java/buildpack.toml @@ -13,6 +13,18 @@ api = "0.6" include-files = ["README.md", "bin/build", "bin/detect", "bin/main", "buildpack.toml", "VERSION"] pre-package = "./build.sh" + [[metadata.configurations]] + build = true + default = "functions.Handler" + description = "The function to run. It must be in the format of ., if it is in the default package then just " + name = "BP_FUNCTION" + + [[metadata.configurations]] + build = true + default = "" + description = "The default function name. In the event there are multiple functions. Specifying the name of the function will make it accessible through the root path '/'" + name = "BP_DEFAULT_FUNCTION" + [[metadata.dependencies]] id = "invoker" name = "Java Invoker" diff --git a/buildpacks/java/java/build.go b/buildpacks/java/java/build.go index a3fe5036..b638c007 100644 --- a/buildpacks/java/java/build.go +++ b/buildpacks/java/java/build.go @@ -22,7 +22,7 @@ func (b Build) Build(context libcnb.BuildContext) (libcnb.BuildResult, error) { b.Logger.Title(context.Buildpack) result := libcnb.NewBuildResult() - _, err := libpak.NewConfigurationResolver(context.Buildpack, &b.Logger) + cr, err := libpak.NewConfigurationResolver(context.Buildpack, &b.Logger) if err != nil { return libcnb.BuildResult{}, fmt.Errorf("unable to create configuration resolver\n%w", err) } @@ -47,6 +47,11 @@ func (b Build) Build(context libcnb.BuildContext) (libcnb.BuildResult, error) { if !ok { return result, nil } + if e.Metadata["has_func_yaml"] == true { + envs := NewFuncYamlEnvs(context.Application.Path) + envs.Logger = b.Logger + result.Layers = append(result.Layers, envs) + } dep, err := dr.Resolve("invoker", "") if err != nil { @@ -71,10 +76,10 @@ func (b Build) Build(context libcnb.BuildContext) (libcnb.BuildResult, error) { result.BOM.Entries = append(result.BOM.Entries, be) } - f := NewFunction(e, context.Application.Path) - if err != nil { - return libcnb.BuildResult{}, fmt.Errorf("unable to create function\n%w", err) - } + funcDef, _ := cr.Resolve("BP_FUNCTION") + defaultDef, _ := cr.Resolve("BP_DEFAULT_FUNCTION") + + f := NewFunction(funcDef, defaultDef, context.Application.Path) f.Logger = b.Logger result.Layers = append(result.Layers, f) diff --git a/buildpacks/java/java/detect.go b/buildpacks/java/java/detect.go index 49e84576..27225584 100644 --- a/buildpacks/java/java/detect.go +++ b/buildpacks/java/java/detect.go @@ -9,6 +9,7 @@ import ( "path/filepath" "github.com/buildpacks/libcnb" + "github.com/paketo-buildpacks/libpak" "github.com/paketo-buildpacks/libpak/bard" knfn "knative.dev/kn-plugin-func" ) @@ -17,22 +18,45 @@ type Detect struct { Logger bard.Logger } -func (d Detect) Detect(context libcnb.DetectContext) (libcnb.DetectResult, error) { - result := libcnb.DetectResult{} +func (d Detect) checkConfigs(cr libpak.ConfigurationResolver) bool { + if _, defined := cr.Resolve("BP_FUNCTION"); defined { + return true + } + + if _, defined := cr.Resolve("BP_DEFAULT_FUNCTION"); defined { + return true + } + + return false +} - configFile := filepath.Join(context.Application.Path, knfn.ConfigFile) +func (d Detect) checkFuncYaml(appPath string) bool { + configFile := filepath.Join(appPath, knfn.ConfigFile) _, err := os.Stat(configFile) if err != nil { - d.logf(fmt.Sprintf("unable to find file '%s'", configFile)) - return result, nil + d.Logger.Bodyf("unable to find file '%s'", configFile) + return false } - f, err := knfn.NewFunction(context.Application.Path) + return true +} + +func (d Detect) Detect(context libcnb.DetectContext) (libcnb.DetectResult, error) { + result := libcnb.DetectResult{} + + appPath := context.Application.Path + funcYamlPass := d.checkFuncYaml(appPath) + + cr, err := libpak.NewConfigurationResolver(context.Buildpack, &d.Logger) if err != nil { - return result, fmt.Errorf("parsing function config: %v", err) + return result, fmt.Errorf("unable to create configuration resolver: %v", err) } - envs := envsToMap(f.Envs) + configPass := d.checkConfigs(cr) + if err != nil { + d.Logger.Bodyf("unable to check buildpack configurations: %v", err) + return result, nil + } result.Plans = append(result.Plans, libcnb.BuildPlan{ Provides: []libcnb.BuildPlanProvide{ @@ -44,8 +68,8 @@ func (d Detect) Detect(context libcnb.DetectContext) (libcnb.DetectResult, error { Name: "java-function", Metadata: map[string]interface{}{ - "launch": true, - "envs": envs, + "launch": true, + "has_func_yaml": funcYamlPass, }, }, { @@ -60,25 +84,6 @@ func (d Detect) Detect(context libcnb.DetectContext) (libcnb.DetectResult, error }, }) - result.Pass = true + result.Pass = funcYamlPass || configPass return result, nil } - -func (d Detect) logf(format string, args ...interface{}) { - d.Logger.Infof(format, args...) -} - -func envsToMap(envs knfn.Envs) map[string]string { - result := map[string]string{} - - for _, e := range envs { - key := *e.Name - val := "" - if e.Value != nil { - val = *e.Value - } - result[key] = val - } - - return result -} diff --git a/buildpacks/java/java/func_yaml_envs.go b/buildpacks/java/java/func_yaml_envs.go new file mode 100644 index 00000000..552e1f59 --- /dev/null +++ b/buildpacks/java/java/func_yaml_envs.go @@ -0,0 +1,81 @@ +// Copyright 2021-2022 VMware, Inc. +// SPDX-License-Identifier: BSD-2-Clause + +package java + +import ( + "os" + "path/filepath" + + "github.com/buildpacks/libcnb" + "github.com/paketo-buildpacks/libpak" + "github.com/paketo-buildpacks/libpak/bard" + knfn "knative.dev/kn-plugin-func" +) + +type FuncYamlEnvs struct { + LayerContributor libpak.LayerContributor + Logger bard.Logger + + Envs map[string]string +} + +func NewFuncYamlEnvs(applicationPath string) FuncYamlEnvs { + envs := getFuncYamlEnvs(applicationPath) + return FuncYamlEnvs{ + LayerContributor: libpak.NewLayerContributor( + "func-yaml-envs", + envs, + libcnb.LayerTypes{ + Launch: true, + }, + ), + Envs: envs, + } +} + +func (f FuncYamlEnvs) Contribute(layer libcnb.Layer) (libcnb.Layer, error) { + f.LayerContributor.Logger = f.Logger + return f.LayerContributor.Contribute(layer, func() (libcnb.Layer, error) { + for k, v := range f.Envs { + layer.LaunchEnvironment.Default(k, v) + } + return layer, nil + }) +} + +func (f FuncYamlEnvs) Name() string { + return f.LayerContributor.Name +} + +func getFuncYamlEnvs(applicationPath string) map[string]string { + envs := map[string]string{} + + configFile := filepath.Join(applicationPath, knfn.ConfigFile) + _, err := os.Stat(configFile) + if err != nil { + return envs + } + + f, err := knfn.NewFunction(applicationPath) + if err != nil { + return envs + } + + return envsToMap(f.Envs) +} + +func envsToMap(envs knfn.Envs) map[string]string { + result := map[string]string{} + + for _, e := range envs { + key := *e.Name + val := "" + if e.Value != nil { + val = *e.Value + } + result[key] = val + } + + return result +} diff --git a/buildpacks/java/java/function.go b/buildpacks/java/java/function.go index 6df7f713..5304130e 100644 --- a/buildpacks/java/java/function.go +++ b/buildpacks/java/java/function.go @@ -4,8 +4,6 @@ package java import ( - "strings" - "github.com/buildpacks/libcnb" "github.com/paketo-buildpacks/libpak" "github.com/paketo-buildpacks/libpak/bard" @@ -15,24 +13,25 @@ type Function struct { LayerContributor libpak.LayerContributor Logger bard.Logger - ApplicationPath string - Handler string - Envs map[string]interface{} + ApplicationPath string + Function string + DefaultFunction string } -func NewFunction(plan libcnb.BuildpackPlanEntry, applicationPath string) Function { - envs := plan.Metadata["envs"].(map[string]interface{}) - +func NewFunction(function string, defaultFunc string, applicationPath string) Function { return Function{ ApplicationPath: applicationPath, LayerContributor: libpak.NewLayerContributor( - plan.Name, - envs, + "java-function", + map[string]string{ + "function": function, + }, libcnb.LayerTypes{ Launch: true, }, ), - Envs: envs, + Function: function, + DefaultFunction: defaultFunc, } } @@ -40,20 +39,13 @@ func (f Function) Contribute(layer libcnb.Layer) (libcnb.Layer, error) { f.LayerContributor.Logger = f.Logger return f.LayerContributor.Contribute(layer, func() (libcnb.Layer, error) { - if len(f.Handler) > 0 { - if strings.ContainsAny(f.Handler, ".") { - layer.LaunchEnvironment.Default("SPRING_CLOUD_FUNCTION_FUNCTION_CLASS", f.Handler) - } else { - layer.LaunchEnvironment.Default("SPRING_CLOUD_FUNCTION_DEFINITION", f.Handler) - } - } - layer.LaunchEnvironment.Default("SPRING_CLOUD_FUNCTION_LOCATION", f.ApplicationPath) + layer.LaunchEnvironment.Default("SPRING_CLOUD_FUNCTION_FUNCTION_CLASS", f.Function) // Function lives here - for k, v := range f.Envs { - layer.LaunchEnvironment.Default(k, v) + if len(f.DefaultFunction) > 0 { + layer.LaunchEnvironment.Default("SPRING_CLOUD_FUNCTION_DEFINITION", f.DefaultFunction) } - + return layer, nil }) } diff --git a/invokers/java/src/main/java/com/vmware/functions/JavaFunctionInvokerApplication.java b/invokers/java/src/main/java/com/vmware/functions/JavaFunctionInvokerApplication.java index bca9e189..aac34117 100644 --- a/invokers/java/src/main/java/com/vmware/functions/JavaFunctionInvokerApplication.java +++ b/invokers/java/src/main/java/com/vmware/functions/JavaFunctionInvokerApplication.java @@ -8,8 +8,6 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import java.util.function.Function; - @SpringBootApplication public class JavaFunctionInvokerApplication { public static void main(String[] args) { diff --git a/invokers/java/src/main/resources/application.properties b/invokers/java/src/main/resources/application.properties index 5a19521b..7fb7cdc8 100644 --- a/invokers/java/src/main/resources/application.properties +++ b/invokers/java/src/main/resources/application.properties @@ -1 +1,2 @@ -spring.cloud.function.location:/workspace \ No newline at end of file +spring.cloud.function.location:/workspace +spring.cloud.function.scan.enabled:false diff --git a/samples/java/cloudevents/txt-to-pdf-maven/Makefile b/samples/java/cloudevents/txt-to-pdf-maven/Makefile index 01b22482..847605d4 100644 --- a/samples/java/cloudevents/txt-to-pdf-maven/Makefile +++ b/samples/java/cloudevents/txt-to-pdf-maven/Makefile @@ -5,7 +5,7 @@ FUNCTION_IMAGE ?= us.gcr.io/daisy-284300/functions/demo:txttopdfjava FUNCTION := out/image $(FUNCTION): @mkdir -p $(@D) - pack build $(FUNCTION_IMAGE) --path ./spring-java-fn/ --builder ghcr.io/vmware-tanzu/function-buildpacks-for-knative/functions-builder:0.0.10 + pack build $(FUNCTION_IMAGE) --path ./spring-java-fn/ --builder ghcr.io/vmware-tanzu/function-buildpacks-for-knative/functions-builder:0.0.10 --env BP_FUNCTION=com.example.demo.DemoApplication --env BP_DEFAULT_FUNCTION=func printf $(FUNCTION_IMAGE) > $@ build: $(FUNCTION) diff --git a/samples/java/cloudevents/txt-to-pdf-maven/README.md b/samples/java/cloudevents/txt-to-pdf-maven/README.md index 2909ad8a..aed2fce0 100644 --- a/samples/java/cloudevents/txt-to-pdf-maven/README.md +++ b/samples/java/cloudevents/txt-to-pdf-maven/README.md @@ -106,7 +106,7 @@ If you encounter any Knative errors while re-deploying the app, be sure to delet ``` ## Legacy Deployment YAML - +``` apiVersion: v1 kind: Secret metadata: diff --git a/samples/java/http/request-response-gradle/README.md b/samples/java/http/request-response-gradle/README.md index 1fcac2ad..ad3e404f 100644 --- a/samples/java/http/request-response-gradle/README.md +++ b/samples/java/http/request-response-gradle/README.md @@ -1,3 +1,7 @@ # request-response -This is a sample function for how to create and send HTTP requests via our Java HTTP function. \ No newline at end of file +This is a sample function for how to create and send HTTP requests via our Java HTTP function. + +# Building + +To build this sample, use the latest buildpack and build with `--env BP_FUNCTION=com.vmware.functions.Handler` set on the `pack` cli command. diff --git a/samples/java/http/request-response-gradle/target/classes/com/vmware/functions/Handler.class b/samples/java/http/request-response-gradle/target/classes/com/vmware/functions/Handler.class deleted file mode 100644 index 66ce26b6e5ca7a2e92f7c86c6e671284c71528e4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1638 zcma)7+foxj5IqAS2_Z@hih?L!5CaN}H@pO~gwoQgcqwDSgHMxW2m_m$)a)$CU+I$; z4}O5E7O-zYl)^c!*~i3@}X9b<5jp?Qr5}be`EPNl7{*JVDkoT~)=1SX&u!#z24fi% z8RoTVdO_RCw+wHIeQkEVn%358OEHhLI7j$RNRDfzgx__a2SK@4q)IRM zb*-%UY`t}@wq!FjF1NCZFyvo3O0H~b<2SA{ z47jE!cIz_asyZ}v@lv|h%g4>U=z51?wI}*cm+;VPs%NK;BJP*Jy5(lUA{)fO|PG zEa!0z*U9oh0oSQyuay#}^CgNP10wxK7qh+i$>1rClm4nSy&^KHC20UqcLFKe(cq$Y zhE5)>jMky~Z^(Y7%>Z)rcGsZY2)*->0p?2B`s&XOsmt&7TNrF6gE%nb94jJ z&yejCnfWqQ`M?mtfwff5{^}CW))$6Rcnr G6Mq0EK(NUG diff --git a/samples/java/http/request-response-maven/README.md b/samples/java/http/request-response-maven/README.md index 1fcac2ad..5e2d961c 100644 --- a/samples/java/http/request-response-maven/README.md +++ b/samples/java/http/request-response-maven/README.md @@ -1,3 +1,7 @@ # request-response -This is a sample function for how to create and send HTTP requests via our Java HTTP function. \ No newline at end of file +This is a sample function for how to create and send HTTP requests via our Java HTTP function. + +# Building + +To build this sample, use the latest buildpack and build with `--env BP_FUNCTION=com.vmware.functions.Handler` set on the `pack` cli command. \ No newline at end of file diff --git a/samples/java/http/request-response-maven/src/main/java/com/vmware/functions/Handler.java b/samples/java/http/request-response-maven/src/main/java/com/vmware/functions/Handler.java index a58e7342..d4be3d62 100644 --- a/samples/java/http/request-response-maven/src/main/java/com/vmware/functions/Handler.java +++ b/samples/java/http/request-response-maven/src/main/java/com/vmware/functions/Handler.java @@ -39,4 +39,11 @@ public Function hello() { } }; } + + @Bean + public Function bye() { + return in -> { + return "bye"; + }; + } } diff --git a/samples/java/http/request-response-maven/target/classes/com/vmware/functions/Handler.class b/samples/java/http/request-response-maven/target/classes/com/vmware/functions/Handler.class deleted file mode 100644 index 66ce26b6e5ca7a2e92f7c86c6e671284c71528e4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1638 zcma)7+foxj5IqAS2_Z@hih?L!5CaN}H@pO~gwoQgcqwDSgHMxW2m_m$)a)$CU+I$; z4}O5E7O-zYl)^c!*~i3@}X9b<5jp?Qr5}be`EPNl7{*JVDkoT~)=1SX&u!#z24fi% z8RoTVdO_RCw+wHIeQkEVn%358OEHhLI7j$RNRDfzgx__a2SK@4q)IRM zb*-%UY`t}@wq!FjF1NCZFyvo3O0H~b<2SA{ z47jE!cIz_asyZ}v@lv|h%g4>U=z51?wI}*cm+;VPs%NK;BJP*Jy5(lUA{)fO|PG zEa!0z*U9oh0oSQyuay#}^CgNP10wxK7qh+i$>1rClm4nSy&^KHC20UqcLFKe(cq$Y zhE5)>jMky~Z^(Y7%>Z)rcGsZY2)*->0p?2B`s&XOsmt&7TNrF6gE%nb94jJ z&yejCnfWqQ`M?mtfwff5{^}CW))$6Rcnr G6Mq0EK(NUG diff --git a/templates/java/cloudevents-gradle/README.md b/templates/java/cloudevents-gradle/README.md index 7143080f..2a4db9b4 100644 --- a/templates/java/cloudevents-gradle/README.md +++ b/templates/java/cloudevents-gradle/README.md @@ -2,7 +2,7 @@ ## Getting Started -Navigate to `Hire.java` and replace the code in the function body as desired. +Navigate to `Handler.java` and replace the code in the function body as desired. ## Testing diff --git a/templates/java/cloudevents-gradle/src/main/java/functions/Hire.java b/templates/java/cloudevents-gradle/src/main/java/functions/Handler.java similarity index 95% rename from templates/java/cloudevents-gradle/src/main/java/functions/Hire.java rename to templates/java/cloudevents-gradle/src/main/java/functions/Handler.java index 3d7c6ff1..d5f34f09 100644 --- a/templates/java/cloudevents-gradle/src/main/java/functions/Hire.java +++ b/templates/java/cloudevents-gradle/src/main/java/functions/Handler.java @@ -31,7 +31,7 @@ If this is the only function defined, it may be accessed via "/" path. */ -public class Hire implements Function, Message> { +public class Handler implements Function, Message> { @Override public Message apply(Message msg) { String ceType = (String) msg.getHeaders().get("ce-type"); diff --git a/templates/java/cloudevents-maven/src/main/java/functions/Hire.java b/templates/java/cloudevents-maven/src/main/java/functions/Handler.java similarity index 95% rename from templates/java/cloudevents-maven/src/main/java/functions/Hire.java rename to templates/java/cloudevents-maven/src/main/java/functions/Handler.java index 3d7c6ff1..d5f34f09 100644 --- a/templates/java/cloudevents-maven/src/main/java/functions/Hire.java +++ b/templates/java/cloudevents-maven/src/main/java/functions/Handler.java @@ -31,7 +31,7 @@ If this is the only function defined, it may be accessed via "/" path. */ -public class Hire implements Function, Message> { +public class Handler implements Function, Message> { @Override public Message apply(Message msg) { String ceType = (String) msg.getHeaders().get("ce-type"); diff --git a/templates/java/http-gradle/README.md b/templates/java/http-gradle/README.md index d715ed47..78f12a1c 100644 --- a/templates/java/http-gradle/README.md +++ b/templates/java/http-gradle/README.md @@ -2,7 +2,7 @@ ## Getting Started -Navigate to `Hire.java` and replace the code in the function body as desired. +Navigate to `Handler.java` and replace the code in the function body as desired. ## Testing diff --git a/templates/java/http-gradle/src/main/java/functions/Hire.java b/templates/java/http-gradle/src/main/java/functions/Handler.java similarity index 93% rename from templates/java/http-gradle/src/main/java/functions/Hire.java rename to templates/java/http-gradle/src/main/java/functions/Handler.java index aa49eb84..7397b1cc 100644 --- a/templates/java/http-gradle/src/main/java/functions/Hire.java +++ b/templates/java/http-gradle/src/main/java/functions/Handler.java @@ -19,7 +19,7 @@ If this is the only function defined, it may be accessed via "/" path. */ -public class Hire implements Function { +public class Handler implements Function { @Override public Employee apply(Person person) { System.out.printf("Person: first(%s) last(%s)\n", person.getFirstName(), person.getLastName()); diff --git a/templates/java/http-maven/README.md b/templates/java/http-maven/README.md index 6d69681f..f4d60831 100644 --- a/templates/java/http-maven/README.md +++ b/templates/java/http-maven/README.md @@ -2,7 +2,7 @@ ## Getting Started -Navigate to `Hire.java` and replace the code in the function body as desired. +Navigate to `Handler.java` and replace the code in the function body as desired. ## Testing diff --git a/templates/java/http-maven/src/main/java/functions/Hire.java b/templates/java/http-maven/src/main/java/functions/Handler.java similarity index 93% rename from templates/java/http-maven/src/main/java/functions/Hire.java rename to templates/java/http-maven/src/main/java/functions/Handler.java index aa49eb84..7397b1cc 100644 --- a/templates/java/http-maven/src/main/java/functions/Hire.java +++ b/templates/java/http-maven/src/main/java/functions/Handler.java @@ -19,7 +19,7 @@ If this is the only function defined, it may be accessed via "/" path. */ -public class Hire implements Function { +public class Handler implements Function { @Override public Employee apply(Person person) { System.out.printf("Person: first(%s) last(%s)\n", person.getFirstName(), person.getLastName());