com.github.bordertech.taskmaster.service.ServiceHelperProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of taskmaster-service-helper Show documentation
Show all versions of taskmaster-service-helper Show documentation
Task Master provides a invoke service helper API.
package com.github.bordertech.taskmaster.service;
import com.github.bordertech.taskmaster.service.exception.AsyncServiceException;
import com.github.bordertech.taskmaster.service.exception.RejectedServiceException;
import java.io.Serializable;
import javax.cache.Cache;
import javax.cache.expiry.Duration;
/**
* Service invocation helper provider.
*/
public interface ServiceHelperProvider {
/**
* Provide a default result holder cache with the default duration.
*
* @return the default result holder cache instance
*/
Cache getDefaultResultHolderCache();
/**
* Provide a result holder cache with an assigned cache name with default duration.
*
* @param name the cache name
* @return the cache instance
*/
Cache getResultHolderCache(final String name);
/**
* Provide a result holder cache with an assigned cache name and duration.
*
* @param name the cache name
* @param duration the time to live for cached items
* @return the cache instance
*/
Cache getResultHolderCache(final String name, final Duration duration);
/**
* Handle an async service call.
*
* @param cache the result holder cache
* @param cacheKey the key for the result holder
* @param criteria the criteria
* @param action the service action
* @param the criteria type
* @param the service response
* @return the result or null if still processing
* @throws RejectedServiceException if the task cannot be scheduled for execution
*/
ResultHolder handleAsyncServiceCall(final Cache cache,
final String cacheKey, final S criteria, final ServiceAction action) throws RejectedServiceException;
/**
* Handle an async service call with a designated thread pool.
*
* @param cache the result holder cache
* @param cacheKey the key for the result holder
* @param criteria the criteria
* @param action the service action
* @param pool service thread pool
* @param the criteria type
* @param the service response
* @return the result or null if still processing
* @throws RejectedServiceException if the task cannot be scheduled for execution
*/
ResultHolder handleAsyncServiceCall(final Cache cache,
final String cacheKey, final S criteria, final ServiceAction action, final String pool) throws RejectedServiceException;
/**
*
* Handle a cached service call.
*
* @param cache the result holder cache
* @param cacheKey the key for the result holder
* @param criteria the criteria
* @param action the service action
* @param the criteria type
* @param the service response
* @return the result
*/
ResultHolder handleCachedServiceCall(final Cache cache,
final String cacheKey, final S criteria, final ServiceAction action);
/**
* Handle a service call.
*
* @param criteria the criteria
* @param action the service action
* @param the criteria type
* @param the service response
* @return the result
*/
ResultHolder handleServiceCall(final S criteria, final ServiceAction action);
/**
*
* Handle a cached service call with a particular call type.
*
* @param cache the result holder cache
* @param cacheKey the key for the result holder
* @param criteria the criteria
* @param action the service action
* @param callType the call type
* @param the criteria type
* @param the service response
* @return the result or null if still processing an async call
* @throws RejectedServiceException if the task cannot be scheduled for execution
*/
ResultHolder handleServiceCallType(final Cache cache,
final String cacheKey, final S criteria, final ServiceAction action, final CallType callType) throws RejectedServiceException;
/**
*
* Handle a cached service call with a particular call type and predefined pool.
*
* @param cache the result holder cache
* @param cacheKey the key for the result holder
* @param criteria the criteria
* @param action the service action
* @param callType the call type
* @param pool service thread pool
* @param the criteria type
* @param the service response
* @return the result or null if still processing an async call
* @throws RejectedServiceException if the task cannot be scheduled for execution
*/
ResultHolder handleServiceCallType(final Cache cache,
final String cacheKey, final S criteria, final ServiceAction action, final CallType callType, final String pool) throws RejectedServiceException;
/**
* This is the method that checks if the processing task has completed.
*
* It the task is complete it will return the result and put the result in the result cache.
*
*
* @param cache the result holder cache
* @param cacheKey the key for the result holder
* @param the criteria type
* @param the service response
* @return the result or null if still processing
* @throws AsyncServiceException an exception while processing an Async task
*/
ResultHolder checkASyncResult(final Cache cache,
final String cacheKey) throws AsyncServiceException;
}