Class DefaultInterlinkClient

java.lang.Object
com.broadleafcommerce.data.tracking.core.interlink.DefaultInterlinkClient
All Implemented Interfaces:
InterlinkClient

public class DefaultInterlinkClient extends Object implements InterlinkClient
Default implementation of InterlinkClient
  • Constructor Details

  • Method Details

    • invoke

      @Nullable public String invoke(InterlinkRequest request)
      Description copied from interface: InterlinkClient
      Execute a request against another microservice
      Specified by:
      invoke in interface InterlinkClient
      Parameters:
      request - Information about the request
      Returns:
      The response from the call to the other microservice. The response JSON is returned raw. If required, this response can be converted to a concreate POJO via Jackson's ObjectMapper.
    • replaceUrlTemplateVariables

      protected void replaceUrlTemplateVariables(InterlinkRequest request)
      Update InterlinkRequest.getUri() template variables with values harvested from any available InterlinkRequest.getArguments().
      Parameters:
      request - The request containing the uri to update
    • performLocalCall

      protected String performLocalCall(InterlinkRequest request, InterlinkReflectionInfo reflectionInfo, org.springframework.web.util.UriComponents uriComponents)
      Make a reflective call to the target endpoint method
      Parameters:
      request - The request object containing information about the call
      reflectionInfo - An object containing information specifically about the Method to call
      uriComponents - The URI information related to the endpoint. This is useful during ContextInfo creation, if applicable.
      Returns:
      The JSON resulting from the method call (similar to what you would get from a standard HTTP remote call)
    • constructParameter

      protected Object constructParameter(InterlinkRequest request, InterlinkReflectionInfo reflectionInfo, org.springframework.web.util.UriComponents uriComponents, Class<?> type, int parameterIndex)
      Create a method parameter for a local, reflective call
      Parameters:
      request - The request object containing information about the call
      reflectionInfo - An object containing information specifically about the Method to call
      uriComponents - The URI information related to the endpoint. This is useful during ContextInfo creation, if applicable.
      type - The method parameter type
      parameterIndex - The method parameter index
      Returns:
      The constructed method parameter, suitable for passing to a reflective call of the method
    • performRemoteGet

      protected String performRemoteGet(InterlinkRequest request, org.springframework.web.util.UriComponents uriComponents)
      Make a remote HTTP GET call
      Parameters:
      request - The request object containing information about the call
      uriComponents - The URI information related to the endpoint. This is useful during ContextInfo creation, if applicable.
      Returns:
      The JSON resulting from the call
    • performRemotePost

      protected String performRemotePost(InterlinkRequest request, org.springframework.web.util.UriComponents uriComponents)
      Make a remote HTTP POST call
      Parameters:
      request - The request object containing information about the call
      uriComponents - The URI information related to the endpoint. This is useful during ContextInfo creation, if applicable.
      Returns:
      The JSON resulting from the call
    • performRemotePatch

      protected String performRemotePatch(InterlinkRequest request, org.springframework.web.util.UriComponents uriComponents)
      Make a remote HTTP PATCH call
      Parameters:
      request - The request object containing information about the call
      uriComponents - The URI information related to the endpoint. This is useful during ContextInfo creation, if applicable.
      Returns:
      The JSON resulting from the call
    • performRemotePut

      protected String performRemotePut(InterlinkRequest request, org.springframework.web.util.UriComponents uriComponents)
      Make a remote HTTP PUT call
      Parameters:
      request - The request object containing information about the call
      uriComponents - The URI information related to the endpoint. This is useful during ContextInfo creation, if applicable.
      Returns:
      The JSON resulting from the call
    • performRemoteDelete

      protected void performRemoteDelete(InterlinkRequest request, org.springframework.web.util.UriComponents uriComponents)
      Make a remote HTTP DELETE call
      Parameters:
      request - The request object containing information about the call
      uriComponents - The URI information related to the endpoint. This is useful during ContextInfo creation, if applicable.
    • extractContext

      @Nullable protected ContextInfo extractContext(InterlinkRequest request, org.springframework.web.util.UriComponents uriComponents, Method method)
      Create a ContextInfo instance based on the provided call information. Used during local, reflective calls.
      Parameters:
      request - The request object containing information about the call
      uriComponents - The URI information related to the endpoint
      method - The method being called
      Returns:
      The constructed ContextInfo instance
    • isLoopback

      protected boolean isLoopback(String uri, Supplier<Boolean> fallbackDetection)
      Whether the target URI represents a link to a service that is co-located in the same flexpackage as the caller.
      Parameters:
      uri - The URI of the example remote call
      fallbackDetection - Supplier providing an alternate method of loopback applicability. This is used should the determination via URI be unavailable.
      Returns:
      Whether loopback is valid, in which case, making reflective calls is an option.
    • getReflectionInfos

      protected List<InterlinkReflectionInfo> getReflectionInfos()
    • getInterlinkProperties

      protected InterlinkProperties getInterlinkProperties()
    • getWebClient

      protected org.springframework.web.reactive.function.client.WebClient getWebClient()
    • getArgumentResolver

      protected ContextInfoHandlerMethodArgumentResolver getArgumentResolver()
    • getObjectMapper

      protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()