Class ContextServiceImpl<C>
- java.lang.Object
-
- com.cumulocity.microservice.context.ContextServiceImpl<C>
-
- All Implemented Interfaces:
ContextService<C>
public class ContextServiceImpl<C> extends Object implements ContextService<C>
-
-
Constructor Summary
Constructors Constructor Description ContextServiceImpl(Class<C> c)
-
Method Summary
All Methods Instance Methods Concrete 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
public C getContext()
Description copied from interface:ContextService
Gets entered context- Specified by:
getContext
in interfaceContextService<C>
- Returns:
- entered context
-
isInContext
public boolean isInContext()
Description copied from interface:ContextService
Returnstrue
if context is found.- Specified by:
isInContext
in interfaceContextService<C>
- Returns:
true
if context is found;false
otherwise
-
runWithinContext
public void runWithinContext(C context, Runnable task)
Description copied from interface:ContextService
Enters context to run with Runnable task- Specified by:
runWithinContext
in interfaceContextService<C>
- Parameters:
context
- the credentials to access the Cumulocity platformtask
- Runnable task
-
callWithinContext
public <V> V callWithinContext(C context, Callable<V> task)
Description copied from interface:ContextService
Enters context to run with Callable task- Specified by:
callWithinContext
in interfaceContextService<C>
- 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
public Runnable withinContext(C context, Runnable task)
Description copied from interface:ContextService
Enters context to run with Runnable task and returns the task with context- Specified by:
withinContext
in interfaceContextService<C>
- Parameters:
context
- the credentials to access the Cumulocity platformtask
- Runnable task- Returns:
- Runnable task with context
-
withinContext
public <V> Callable<V> withinContext(C context, Callable<V> task)
Description copied from interface:ContextService
Enters context to run with Callable task and returns the task with context- Specified by:
withinContext
in interfaceContextService<C>
- Type Parameters:
V
- generic type of Callable- Parameters:
context
- the credentials to access the Cumulocity platformtask
- Callable task- Returns:
- Callable task with context
-
-