The Handler class is the entrance point for our project because AWS Lambda runtime calls it first. You already know that AWS will invoke the handleRequest method for each invocation of Lambda function. To create the object, Lambda runtime uses the default constructor of the class where the Handler is. So, to inject dependencies to our class, we will use this knowledge and initiate the injection when the default constructor is called. Moreover, Lambda runtime will keep a cached copy of an object once it is initiated and shared among different invocations of your Lambda function. It means that the injection will not happen for every invocation and, although we cannot predict when a new instance of Handler class will be created, will be cached.
We can start adding a Guice injector as a static field in the Handler class:
public...