更新时间:2021-07-11 17:19:28
AWS Lambda提供了有限的Java运行时来执行AWS Java Lambda处理程序.由于代码在共享的多租户环境中运行,因此出于安全目的,这些限制在逻辑上很像访问文件系统等.为了执行程序,您的类应实现RequestHandler
接口并实现handleRequest
方法.这是官方文档中的示例
AWS Lambda provides limited Java runtime to execute AWS Java Lambda handlers. The limitations are logical like access to file system, etc for security purposes as the code runs in a shared multi-tenanted environment. In order to execute a program, your class should implement the RequestHandler
interface and implement the handleRequest
method. Here is the sample from the official documentation
package example;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
public class Hello implements RequestHandler<Integer, String>{
public String handleRequest(Integer myCount, Context context) {
return String.valueOf(myCount);
}
}