@Singleton public abstract class AbstractContextService extends AbstractSreService implements ContextService
This service is thread-safe.
Modifier and Type | Field and Description |
---|---|
protected ReadWriteLock |
lock
The lock resource.
|
protected Logger |
logger
The logger for this service.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractContextService(rootContext : Context,
logger : LoggingService,
factories : javax.inject.Provider<Factories>)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
Context |
createContext(contextID : UUID,
defaultSpaceID : UUID,
owner : Agent)
Create a new context instance and register it into the internal repository.
|
Context |
createContextWithoutRegistration(contextID : UUID,
defaultSpaceID : UUID,
owner : Agent)
Create a new context instance and do not register it into the repository.
|
protected Logger |
createLogger(loggingService : LoggingService)
Create the instance of the logger for this service.
|
Context |
getContext(contextID : UUID)
Replies an existing context instance.
|
protected abstract Map<UUID,Context> |
getContextInternalStructure()
Replies the internal data structure for storing the contexts.
|
Context |
getRootContext()
Replies the root context.
|
protected abstract Context |
newContextInstance(contextID : UUID,
defaultSpaceID : UUID,
owner : Agent)
Create a context instance.
|
void |
onStart()
Do something when starting the service.
|
void |
onStop()
Do something when stopping the service.
|
Context |
removeContext(contextID : UUID)
Remove the context instance.
|
doStart, doStop
addListener, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, doCancelStart, failureCause, isRunning, notifyFailed, notifyStarted, notifyStopped, startAsync, state, stopAsync, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getAllContexts
protected val
lock : ReadWriteLock
AbstractContextService
protected val
logger : Logger
AbstractContextService
protected new
(rootContext : Context,
logger : LoggingService,
factories : javax.inject.Provider<Factories>)
rootContext
- the root context.logger
- the logging service to be used.factories
- the provider of factories tool.@Pure
protected def
createLogger(loggingService : LoggingService) : Logger
AbstractContextService
loggingService
- the logging service.public def
onStart() : void
AbstractSreService
This function is called from AbstractSreService.doStart()
onStart
in class AbstractSreService
public def
onStop() : void
AbstractSreService
This function is called from AbstractSreService.doStop()
onStop
in class AbstractSreService
@Pure
protected abstract def
getContextInternalStructure() : Map<UUID,Context>
AbstractContextService
This function is not thread-safe.
public final def
createContextWithoutRegistration(contextID : UUID,
defaultSpaceID : UUID,
owner : Agent) : Context
ContextService
createContextWithoutRegistration
in interface ContextService
contextID
- the id of the context to create.defaultSpaceID
- the id of the default space of the context to create.owner
- is the owner of the context. If null
, the context is the root context.public final def
createContext(contextID : UUID,
defaultSpaceID : UUID,
owner : Agent) : Context
ContextService
createContext
in interface ContextService
contextID
- the id of the context to create.defaultSpaceID
- the id of the default space of the context to create.owner
- is the owner of the context. If null
, the context is the root context.@Pure
public def
getContext(contextID : UUID) : Context
ContextService
getContext
in interface ContextService
contextID
- the id of the context to createnull
.public def
removeContext(contextID : UUID) : Context
ContextService
removeContext
in interface ContextService
contextID
- the id of the context to removenull
if no context with the given ID was found.protected abstract def
newContextInstance(contextID : UUID,
defaultSpaceID : UUID,
owner : Agent) : Context
AbstractContextService
This function is not thread-safe.
contextID
- the identifier of the context.defaultSpaceId
- the identifier of the default space in the context.owner
- is the owner of the context. If null
, the context is the root context@Pure
public def
getRootContext() : Context
ContextService
getRootContext
in interface ContextService
Copyright © 2021 the original authors or authors.