Class DefaultOAuth2AuthorizedClientEntityCleanupServices
java.lang.Object
com.broadleafcommerce.auth.client.service.DefaultOAuth2AuthorizedClientEntityCleanupServices
A camel cluster service instance that will periodically cleanup
OAuth2AuthorizedClientEntity
in the datastore. getPause()
is used to determine
the amount of time to wait between cleanup runs. The pause is used as a measure to throttle
database activity resulting from cleaning up. The batch size is also involved in throttling the
effect of this cleanup service by controlling the count of items checked for expiration.
Note, because this is a cluster service, only one instance will run in the cluster at a time. If
an instance of auth service goes down, another instance of
DefaultOAuth2AuthorizedClientEntityCleanupServices
will start to maintain a consistent
count of 1 instance in the cluster.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
Whether this service has been started and is actively scheduling tasks. -
Constructor Summary
ConstructorsConstructorDescriptionDefaultOAuth2AuthorizedClientEntityCleanupServices
(OAuth2AuthorizedClientCleanupProperties cleanupProperties, OAuth2AuthorizedClientEntityService<OAuth2AuthorizedClientEntity> oAuth2AuthorizedClientEntityService, org.springframework.scheduling.TaskScheduler scheduler, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
cleanup()
protected OAuth2AuthorizedClientCleanupProperties
Properties configuring cleanup behavior.Contains the response received from the last execution ofcleanup()
(if executed).The entity service to which CRUD calls will be delegated.protected int
getPause()
protected Random
Used to add a bit of randomness in intervals between cleanup jobs.protected List<ScheduledFuture<?>>
The tasks that have been scheduled by this service.protected org.springframework.scheduling.TaskScheduler
The scheduler used to queue tasks.protected com.broadleafcommerce.common.extension.TypeFactory
boolean
Whether this service has been started and is actively scheduling tasks.void
start()
Starts the cleanup process by scheduling the first task for now.void
stop()
Stops the cleanup process by cancelling all scheduled tasks.
-
Field Details
-
started
protected boolean startedWhether this service has been started and is actively scheduling tasks.
-
-
Constructor Details
-
DefaultOAuth2AuthorizedClientEntityCleanupServices
public DefaultOAuth2AuthorizedClientEntityCleanupServices(OAuth2AuthorizedClientCleanupProperties cleanupProperties, OAuth2AuthorizedClientEntityService<OAuth2AuthorizedClientEntity> oAuth2AuthorizedClientEntityService, org.springframework.scheduling.TaskScheduler scheduler, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
start
public void start()Starts the cleanup process by scheduling the first task for now. -
stop
public void stop()Stops the cleanup process by cancelling all scheduled tasks. -
cleanup
protected void cleanup() -
getPause
protected int getPause()- Returns:
- the seconds to pause between the current execution of a batch and the next. This is not necessarily deterministic and can be random (within a range)
-
buildCleanupRequest
protected OAuth2AuthorizedClientEntityCleanupRequest buildCleanupRequest(@Nullable OAuth2AuthorizedClientEntityCleanupResponse lastResponse) -
getCleanupProperties
Properties configuring cleanup behavior. -
getOAuth2AuthorizedClientEntityService
protected OAuth2AuthorizedClientEntityService<OAuth2AuthorizedClientEntity> getOAuth2AuthorizedClientEntityService()The entity service to which CRUD calls will be delegated. -
getScheduler
protected org.springframework.scheduling.TaskScheduler getScheduler()The scheduler used to queue tasks. This should typically be a single-threadThreadPoolTaskScheduler
. -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getRandom
Used to add a bit of randomness in intervals between cleanup jobs. -
isStarted
public boolean isStarted()Whether this service has been started and is actively scheduling tasks. -
getScheduledTasks
The tasks that have been scheduled by this service. -
getLastEndingResponse
Contains the response received from the last execution ofcleanup()
(if executed). Used to prepare the next request.
-