See AWS Java 1.0 - Release Notes for more information.
|Java AWS Lambda GET Operation|
|Java AWS Lambda POST Operation|
|Java AWS Lambda PUT Operation|
|Java AWS Lambda DELETE Operation|
|Java AWS Lambda ANY Operation|
Java AWS Lambda Function
|Java Call to AWS Lambda Function|
In what situation should you install this extension?
The AWSJava extension is responsible of creating objects describing Amazon Web Service (AWS) lambda functions but only in the context of java technology. (Similarly the NodeJS extension is responsible of AWS lambda Functions created for the nodejs runtime). To run fully, this extension needs to add a Universal Analysis Unit and to switch on the HTML5 language. This allows analyzing serverless configuration (YAML) files used to define the lambda functions. This is particularly necessary for the creation of operation-type objects like Java AWS Lambda GET Operation and the Java AWS Lambda Function object. The complementary analysis responsible of creating Java Call to AWS Lambda Function objects is based on the analysis of java files and it will be launched without any further requirement upon installation of the com.castsoftware.awsjava plugin.
The resolution of handler methods in present version of the analyzer relies on the interpretation of serverless configuration files. If these files are missing (or a different framework is used) no server-side objects are expected to be created.
Server side (serverless framework)
Below a typical serverless configuration file serverless.yml is presented (any name is supported, with both 'yml' and 'yaml' extensions, but the latter extension might require to be added explicitly in the Analysis Unit configuration in CAST-MS).
The com.castsoftware.awsjava will analyze the .yml file and it will create a JAVA AWS Lambda Function object only for the meanweather lambda function, because of the runtime java8.
In the example above the lambda function weather belongs to the nodejs4.3 runtime because of the global runtime set in the "provider" element and not being specified otherwise as in meanweather. Thus the former is not handled by the com.castsoftware.awsjava analyzer (it will be handled by the NodeJS extension).
The links between the Java AWS Lambda Function object and the actual java method (if present and resolved) will be done at application-level and indicated with a line in the log similar to:
As an example, we can analyze one of the samples provided by Amazon lambda-java8-dynamodb.
The events field in the serverless file links a URL to a given Lambda function. This connection is represented by a Java AWS Lambda GET Operation object.
The call-back code to be executed after invocation of the Lambda function:
The results of the analysis as shown in Enlighten:
Similar results are expected for the predefined interface com.amazonaws.services.lambda.runtime.RequestStreamHandler.
The following two annotations (equally named) are supported (one for Android and the other one for Java applications):
The example below reproduced from the official documentation https://docs.aws.amazon.com/lambda/latest/dg/with-android-example.html, illustrates how one can define (but not implemented) the lambda function by annotating the AndroidBackendLambdaFunction method.
The @LambdaFunction annotation maps the specific client method to the same-name Lambda function. The expected behavior of the JEE analyzer is to resolve the actual Lambda Function invocation via method calls (elsewhere) to the annotated interface methods. The com.castsoftware.awsjava extension on the other hand will create a Java Call to AWS Lambda Function object and the respective incoming callLink from the annotated interface method AndroidBackendLambdaFunction.
The extension com.castsoftware.wbslinker is responsible of matching Java Call to AWS Lambda Function objects to Lambda Function objects such as Java AWS Lambda Function.
- A single inheritance depth level is only supported for classes implementing predefined interfaces such as RequestHandler andRequestStreamHandler when searching for handler methods. However overriding/overloading of the handler methods is not fully supported.
- No custom lambda function resolver is supported, i.e. that passed to lambdaFunctionNameResolver (conntected to the building of LambdaInvokerFactory).