Java programming model
Cloud Functions provides four Java programming models which are based on the Function and YcFunction interfaces, the HttpServlet class, and Spring Boot. The first three ways of setting a function handler involve implementing custom implementations of these interfaces or classes, while the last one involves uploading the application in its original form without any changes.
The difference between the Function and YcFunction models is the availability of the invocation context. For example, if you need to work with Yandex Cloud services using the SDK, we recommend opting for YcFunction. With the HttpServlet model, you can fully manage the return value and HTTP method used to invoke the function, and, like the YcFunction model, provides access to the invocation context.
There are two separate types for the Function and YcFunction models: byte[] and String. They are used differently from other types. If you use them as the handler argument type, the runtime will not convert the incoming request into JSON and instead will provide it directly to the user-defined handler, unless ?integration=raw is used.
Note
The jsoniterJSON.
Handler requirements
No matter which model you select, the project can be uploaded as source code, a JAR archive, or a Maven project. The class that contains the handler must also meet the following requirements:
-
It must be public.
-
It must have a public no-argument constructor.
It is provided by default. However, if you created your own constructor with arguments, you should also create a no-argument one.
-
It must not be generic
.