Class ExternalResourceLockProvider
java.lang.Object
com.broadleafcommerce.orderoperation.service.provider.external.AbstractExternalProvider
com.broadleafcommerce.orderoperation.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
-
Field Summary
Fields inherited from class com.broadleafcommerce.orderoperation.service.provider.external.AbstractExternalProvider
ENTITY_NOT_FOUND, RSQL_FILTER_PARAM -
Constructor Summary
ConstructorsConstructorDescriptionExternalResourceLockProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalOrderProperties properties) -
Method Summary
Modifier and TypeMethodDescriptionprotected <T> TexecuteRequest(Supplier<T> request) Executes a request with default Web Client error handling.voidfinishLock(@NonNull String token, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Update the status of the lock to indicate the associated process is complete.protected ExternalOrderPropertiesprotected Stringprotected StringobtainLock(@NonNull String contextId, @NonNull String conceptKey, @NonNull String url, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) obtainLock(@NonNull String contextId, @NonNull String conceptKey, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Obtains a permanent resource lock, typically used for idempotency messages.obtainTemporalLock(@NonNull String contextId, @NonNull String conceptKey, Duration lockTtl, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Obtains a temporal resource lock.voidreleaseLock(@NonNull String token, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Releases a resource lock using a token.Methods inherited from class com.broadleafcommerce.orderoperation.service.provider.external.AbstractExternalProvider
addOffsetOrPageNumber, buildNotFoundException, getHeaders, getObjectMapper, getTypeFactory, getWebClient, isEntityNotFound, pageableToParamsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.orderoperation.service.provider.ResourceLockProvider
obtainTemporalLock
-
Constructor Details
-
ExternalResourceLockProvider
public ExternalResourceLockProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalOrderProperties properties)
-
-
Method Details
-
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:ResourceLockProviderObtains a permanent resource lock, typically used for idempotency messages.- Specified by:
obtainLockin 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
-
obtainTemporalLock
public String obtainTemporalLock(@NonNull @NonNull String contextId, @NonNull @NonNull String conceptKey, @Nullable Duration lockTtl, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:ResourceLockProviderObtains a temporal resource lock. This lock is automatically released afterlockTtlif specified. By default, if thelockTtlis null, the duration configured via the "broadleaf.order.web.order-lock-ttl" property will be used.- Specified by:
obtainTemporalLockin interfaceResourceLockProvider- Parameters:
contextId- the context ID of the entity to lockconceptKey- some key indicating what is being locked or by wholockTtl- amount of time that an order lock is held, before it expirescontextInfo- 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:ResourceLockProviderReleases a resource lock using a token. The token should be obtained viaResourceLockProvider.obtainLock(String, String, ContextInfo).- Specified by:
releaseLockin interfaceResourceLockProvider- Parameters:
token- the token tied to the lock which should be releasedcontextInfo- the context of the request
-
finishLock
public void finishLock(@NonNull @NonNull String token, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:ResourceLockProviderUpdate the status of the lock to indicate the associated process is complete.- Specified by:
finishLockin interfaceResourceLockProvider- Parameters:
token- The unique token that was provided when the lock was obtainedcontextInfo- the context of the request
-
executeRequest
Description copied from class:AbstractExternalProviderExecutes a request with default Web Client error handling.- Overrides:
executeRequestin classAbstractExternalProvider- Type Parameters:
T- the return type of the request operation- Parameters:
request- the request to execute- Returns:
- the value generated by the supplier
-
obtainLock
-
getStringMapType
-
getServiceClient
-
getProperties
-