Class ExternalResourceLockProvider
- java.lang.Object
-
- com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
-
- com.broadleafcommerce.cartoperation.service.provider.external.ExternalResourceLockProvider
-
- All Implemented Interfaces:
ResourceLockProvider
public class ExternalResourceLockProvider extends AbstractExternalProvider implements ResourceLockProvider
Obtains and releases locks in an external service (cart services over HTTP).- Author:
- Jacob Mitash
-
-
Constructor Summary
Constructors Constructor Description ExternalResourceLockProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalCartProperties properties)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <T> T
executeRequest(Supplier<T> request)
Executes a request with default Web Client error handling.protected String
getServiceClient()
protected org.springframework.core.ParameterizedTypeReference<Map<String,String>>
getStringMapType()
String
obtainLock(@NonNull String contextId, @NonNull String conceptKey, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Obtains a resource lock.void
releaseLock(@NonNull String token, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Releases a resource lock using a token.-
Methods inherited from class com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
getHeaders, getObjectMapper, getTypeFactory, getWebClient, pageableToParams, uriVars
-
-
-
-
Constructor Detail
-
ExternalResourceLockProvider
public ExternalResourceLockProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalCartProperties properties)
-
-
Method Detail
-
obtainLock
public String obtainLock(@NonNull @NonNull String contextId, @NonNull @NonNull String conceptKey, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:ResourceLockProvider
Obtains a resource lock.- Specified by:
obtainLock
in interfaceResourceLockProvider
- Parameters:
contextId
- the context ID of the entity to lockconceptKey
- some key indicating what is being locked or by whocontextInfo
- the context of the request- Returns:
- a token that can be used to release the lock
-
releaseLock
public void releaseLock(@NonNull @NonNull String token, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:ResourceLockProvider
Releases a resource lock using a token. The token should be obtained viaResourceLockProvider.obtainLock(String, String, ContextInfo)
.- Specified by:
releaseLock
in interfaceResourceLockProvider
- Parameters:
token
- the token tied to the lock which should be releasedcontextInfo
- the context of the request
-
executeRequest
protected <T> T executeRequest(Supplier<T> request)
Description copied from class:AbstractExternalProvider
Executes a request with default Web Client error handling.- Overrides:
executeRequest
in classAbstractExternalProvider
- Type Parameters:
T
- the return type of the request operation- Parameters:
request
- the request to execute- Returns:
- the value generated by the supplier
-
getStringMapType
protected org.springframework.core.ParameterizedTypeReference<Map<String,String>> getStringMapType()
-
getServiceClient
protected String getServiceClient()
-
-