In Function Compute, the handler is the entry point that the runtime invokes when your function is triggered. Because Java uses packages to organize classes, the handler format for Java functions differs from other runtimes and must include the package name.
Prerequisites
Before you begin, ensure that you have:
Access to the Function Compute console
A Java project with a defined handler method
Handler format
Set the Handler parameter using the following format:
[Package name].[Class name]::[Method name]Each part maps directly to your Java source code:
| Part | Maps to | Example |
|---|---|---|
[Package name] | The package declaration at the top of your file | example |
[Class name] | The public class containing the handler method | HelloFC |
[Method name] | The method Function Compute calls when the function runs | handleRequest |
For example, if your code looks like this:
package example;
public class HelloFC {
public String handleRequest(String input, Context context) {
// function logic
}
}Set the handler to example.HelloFC::handleRequest.
Configure the handler in the console
Log on to the Function Compute console. In the left-side navigation pane, click Functions.
In the top navigation bar, select a region. On the Functions page, click Create Function.
On the Create Function page, select Event Function. In the Code section, select a Java runtime.
In the Advanced Settings section, set the Handler parameter to the value matching your code structure.
