Interface ContextService<C>
-
- Type Parameters:
C
- Generic type for the context.
- All Known Implementing Classes:
ContextServiceImpl
public interface ContextService<C>
A service to get and enter context to run tasks with. The service is aimed to be used for the tasks which contains Cumulocity API calls. Context contains credentials to use as authorization to Cumulocity platform.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <V> V
callWithinContext(C context, Callable<V> task)
Enters context to run with Callable taskC
getContext()
Gets entered contextboolean
isInContext()
Returnstrue
if context is found.void
runWithinContext(C context, Runnable task)
Enters context to run with Runnable taskRunnable
withinContext(C context, Runnable task)
Enters context to run with Runnable task and returns the task with context<V> Callable<V>
withinContext(C context, Callable<V> task)
Enters context to run with Callable task and returns the task with context
-
-
-
Method Detail
-
getContext
C getContext()
Gets entered context- Returns:
- entered context
- Throws:
IllegalStateException
- if not within any context
-
isInContext
boolean isInContext()
Returnstrue
if context is found.- Returns:
true
if context is found;false
otherwise
-
runWithinContext
void runWithinContext(C context, Runnable task)
Enters context to run with Runnable task- Parameters:
context
- the credentials to access the Cumulocity platformtask
- Runnable task
-
callWithinContext
<V> V callWithinContext(C context, Callable<V> task)
Enters context to run with Callable task- Type Parameters:
V
- generic type of Callable- Parameters:
context
- the credentials to access the Cumulocity platformtask
- Callable task- Returns:
- the returned value from the Callable task
-
withinContext
Runnable withinContext(C context, Runnable task)
Enters context to run with Runnable task and returns the task with context- Parameters:
context
- the credentials to access the Cumulocity platformtask
- Runnable task- Returns:
- Runnable task with context
-
withinContext
<V> Callable<V> withinContext(C context, Callable<V> task)
Enters context to run with Callable task and returns the task with context- Type Parameters:
V
- generic type of Callable- Parameters:
context
- the credentials to access the Cumulocity platformtask
- Callable task- Returns:
- Callable task with context
-
-