Class DefaultInterlinkClient
java.lang.Object
com.broadleafcommerce.data.tracking.core.interlink.DefaultInterlinkClient
- All Implemented Interfaces:
InterlinkClient
Default implementation of
InterlinkClient-
Constructor Summary
ConstructorsConstructorDescriptionDefaultInterlinkClient(List<InterlinkReflectionInfo> reflectionInfos, InterlinkProperties interlinkProperties, InterlinkWebClient webClient, ContextInfoHandlerMethodArgumentResolver argumentResolver, com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectconstructParameter(InterlinkRequest request, InterlinkReflectionInfo reflectionInfo, org.springframework.web.util.UriComponents uriComponents, Class<?> type, int parameterIndex) Create a method parameter for a local, reflective callprotected ContextInfoextractContext(InterlinkRequest request, org.springframework.web.util.UriComponents uriComponents, Method method) Create aContextInfoinstance based on the provided call information.protected ContextInfoHandlerMethodArgumentResolverprotected InterlinkPropertiesprotected com.fasterxml.jackson.databind.ObjectMapperprotected List<InterlinkReflectionInfo>protected org.springframework.web.reactive.function.client.WebClientinvoke(InterlinkRequest request) Execute a request against another microserviceprotected booleanisLoopback(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.protected StringperformLocalCall(InterlinkRequest request, InterlinkReflectionInfo reflectionInfo, org.springframework.web.util.UriComponents uriComponents) Make a reflective call to the target endpoint methodprotected voidperformRemoteDelete(InterlinkRequest request, org.springframework.web.util.UriComponents uriComponents) Make a remote HTTP DELETE callprotected StringperformRemoteGet(InterlinkRequest request, org.springframework.web.util.UriComponents uriComponents) Make a remote HTTP GET callprotected StringperformRemotePatch(InterlinkRequest request, org.springframework.web.util.UriComponents uriComponents) Make a remote HTTP PATCH callprotected StringperformRemotePost(InterlinkRequest request, org.springframework.web.util.UriComponents uriComponents) Make a remote HTTP POST callprotected StringperformRemotePut(InterlinkRequest request, org.springframework.web.util.UriComponents uriComponents) Make a remote HTTP PUT callprotected voidUpdateInterlinkRequest.getUri()template variables with values harvested from any availableInterlinkRequest.getArguments().
-
Constructor Details
-
DefaultInterlinkClient
public DefaultInterlinkClient(List<InterlinkReflectionInfo> reflectionInfos, InterlinkProperties interlinkProperties, @Nullable InterlinkWebClient webClient, @Nullable ContextInfoHandlerMethodArgumentResolver argumentResolver, @Nullable com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
invoke
Description copied from interface:InterlinkClientExecute a request against another microservice- Specified by:
invokein interfaceInterlinkClient- 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
UpdateInterlinkRequest.getUri()template variables with values harvested from any availableInterlinkRequest.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 callreflectionInfo- An object containing information specifically about theMethodto calluriComponents- 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 callreflectionInfo- An object containing information specifically about theMethodto calluriComponents- The URI information related to the endpoint. This is useful during ContextInfo creation, if applicable.type- The method parameter typeparameterIndex- 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 calluriComponents- 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 calluriComponents- 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 calluriComponents- 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 calluriComponents- 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 calluriComponents- 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 aContextInfoinstance based on the provided call information. Used during local, reflective calls.- Parameters:
request- The request object containing information about the calluriComponents- The URI information related to the endpointmethod- The method being called- Returns:
- The constructed ContextInfo instance
-
isLoopback
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 callfallbackDetection- 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
-
getInterlinkProperties
-
getWebClient
protected org.springframework.web.reactive.function.client.WebClient getWebClient() -
getArgumentResolver
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
-