129. Deploying a Packaged Function
Spring Cloud Function provides a "deployer" library that allows you to launch a jar file (or exploded archive, or set of jar files) with an isolated class loader and expose the functions defined in it. This is quite a powerful tool that would allow you to, for instance, adapt a function to a range of different input-output adapters without changing the target jar file. Serverless platforms often have this kind of feature built in, so you could see it as a building block for a function invoker in such a platform (indeed the Riff Java function invoker uses this library).
The standard entry point of the API is the Spring configuration annotation
@EnableFunctionDeployer . If that is used in a Spring Boot application the deployer kicks in and looks for some configuration to tell it where to find the function jar. At a minimum the user has to provide a
function.location which is a URL or resource location for the archive containing the functions. It can optionally use a
maven: prefix to locate the artifact via a dependency lookup (see
FunctionProperties for complete details). A Spring Boot application is bootstrapped from the jar file, using the
MANIFEST.MF to locate a start class, so that a standard Spring Boot fat jar works well, for example. If the target jar can be launched successfully then the result is a function registered in the main application’s
FunctionCatalog . The registered function can be applied by code in the main application, even though it was created in an isolated class loader (by deault).