Static
Static Decorators
Using static decorators, a script can declare environment behavior that is picked up and merged into the runtime. Because static decorators are processed at compile-time, they must not include variables in their declarations.
Only object expressions, array literals, primitives, and numeric literals preceded by the -
unary expression are allowed.
Stored objects, scripts and policies can be named, and must be unique. If declared with a static decorator, a developer can override named items by duplicating the name and assigning a greater weight. See each decorator's documentation for runtime sorting details. the default weight is 0
.
Any number of decorators may stack on top of one another and will all be added to the runtime. Although their order is determined by weight and priority (depending on the type), not the order in which they are declared.
If two or more similarly named static decorator declarations are made that share the same weight, the one selected is arbitrary and must be determined via examining the environment runtime to determined which was selected (org.runtime
). As such, it's recommended to always assign weights to named declarations.
When combining static environment decorators with runtime decorators, the order of the decorators does not apply; static decorators are always applied prior to the script being allocated a sandbox.
In the following example, the principal will be c_service_account_with_site_manager_role
even though @as
precedes @route
(which runs as the runtime caller by default) because @as
is evaluated at runtime. Also, the route will only allow a caller with the c_site_manager
role to run the route because the @as
decorator does not assign the c_service_account_with_site_manager_role
until after the @route
has been evaluated.
Last updated
Was this helpful?