Execution context

Almost every method in service implementation contract receives an instance of com.hcl.unica.system.model.request.ExecutionContext class.

This object contains all the contextual information that is necessary for a service to perform its operation. The following are the methods in ExecutionContext class, which can be used to obtain various types of information during service execution:
  • T getRequest()

    This method can be used to obtain the input, or request, object passed to the service when it is executed using executeService method discussed in Service invocation (The T return type is the type parameter corresponding to the generic argument used for defining the service).

  • Map<String, Object> getAttributes()

    Returns a Map which can be used to store and retrieve custom attributes during service execution. It is useful for carrying execution specific temporary information across multiple callbacks. For example, if the implementation of buildRequest method from the RestService interface or HttpService interface needs to share some information with transformResponse method, it can share it using this attribute Map.

    It is important to note that Content Integration Framework creates a separate instance of ExecutionContext for each individual service invocation. Hence, context attributes cannot be shared across multiple service executions. Their scope is limited to individual service execution.

  • ServiceConfig getServiceConfig()

    This method returns an instance of com.hcl.unica.system.integration.config.ServiceConfig class. ServiceConfig object holds the configurations made in service declaration file for the respective service.

  • SystemConfig getSystemConfig()

    This method returns an instance of com.hcl.unica.system.integration.config.SystemConfig class. SystemConfig object contains all the configurations made in Unica Platform for the target system. In case of multi-partitioned configurations, this object will be appropriately populated by Content Integration Framework to hold partition-specific configuration for the concerned client application. To know the various system configuration settings in Unica Platform, see Unica Content Integration Administrator's Guide.

  • void setAttributes(Map<String, Object>)

    This method can be used to set attributes in ExecutionContext, which can be then be obtained in other areas of the service implementation. This is useful for sharing custom contextual information during service execution. Scope of the attributes stored in execution context is limited to the current execution flow only. Attributes cannot be shared across multiple execution flows of the same service.

  • Locale getUserLocale ()

    This method can be used to obtain signed in user’s locale.

  • String localized(String key, String defaultText)

    Returns the localized text for the given key. If translation does not exist for the given key, returns the default text.

InboundHttpRequestContext<T>

This class inherits from ExecutionContext<T> and holds the context information relevant to the inbound RESTful service. In addition to the methods inherited from ExecutionContext, it provides following methods for obtaining HTTP request details:
  • Map<String, Object> getPathVariables()

    Inbound RESTful services can use path variables while defining the endpoint signature. Path variables allow designing dynamic URLs, wherein certain portions of the URL carry value specific to the given request context. This method can be used to obtain path variables thus defined & their values.

  • Map<String, Object> getRequestParams()

    This method can be used to obtain request parameters & their values.

  • Map<String, Object> getRequestHeaders()

    This method can be used to obtain request headers & their values.