Interface ContextPool
-
public interface ContextPool
Context pool manages contexts of all plugins.Plugin context must be first registered by a plugin during its construction. Obtaining plugin contexts is reliable only during plugin initialization, performed after the construction.
Context pool does not have to be thread safe.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CompilerContext
getCompilerContext(long pluginID)
Get registered Compiler context.<T extends CompilerContext>
TgetCompilerContext(long pluginID, java.lang.Class<T> contextInterface)
Get registered Compiler context.<T extends CompilerContext>
TgetCompilerContext(long pluginID, java.lang.Class<T> contextInterface, int index)
Get registered compiler context.<T extends Context>
TgetContext(long pluginID, java.lang.Class<T> contextInterface, int index)
Get registered plugin context.CPUContext
getCPUContext(long pluginID)
Get registered CPU context.<T extends CPUContext>
TgetCPUContext(long pluginID, java.lang.Class<T> contextInterface)
Get registered CPU context.<T extends CPUContext>
TgetCPUContext(long pluginID, java.lang.Class<T> contextInterface, int index)
Get registered CPU context.<DataType,T extends DeviceContext<DataType>>
TgetDeviceContext(long pluginID, java.lang.Class<T> contextInterface)
Get registered Device context.<DataType,T extends DeviceContext<DataType>>
TgetDeviceContext(long pluginID, java.lang.Class<T> contextInterface, int index)
Get registered Device context.<CellType,T extends MemoryContext<CellType>>
TgetMemoryContext(long pluginID, java.lang.Class<T> contextInterface)
Get registered Memory context.<CellType,T extends MemoryContext<CellType>>
TgetMemoryContext(long pluginID, java.lang.Class<T> contextInterface, int index)
Get registered memory context.void
register(long pluginID, Context context, java.lang.Class<? extends Context> contextInterface)
Register plugin context.boolean
unregister(long pluginID, java.lang.Class<? extends Context> contextInterface)
Unregisters all contexts registered under given context interface.
-
-
-
Method Detail
-
register
void register(long pluginID, Context context, java.lang.Class<? extends Context> contextInterface) throws ContextAlreadyRegisteredException, InvalidContextException
Register plugin context.Method should be called during plugin construction, not later.
There are several requirements for plugin contexts, for more information
Context
documentation.Context interface is used as "key" under which the context object will be registered. In later time, the context can be obtained by this context interface "key". A plugin can register multiple context objects under the same context interface. In that case, each context will have assigned an index, starting from 0, in order of context registration.
- Parameters:
pluginID
- owner plugin IDcontext
- The context object that the plugin want to registercontextInterface
- plugin context interface- Throws:
ContextAlreadyRegisteredException
- Raised when given plugin context is already registered.InvalidContextException
- Raised when given plugin context and its interface does not fulfill the requirements.
-
unregister
boolean unregister(long pluginID, java.lang.Class<? extends Context> contextInterface) throws InvalidContextException
Unregisters all contexts registered under given context interface.It will do it only if the plugin has the permission. The permission is approved if and only if the contexts are implemented inside the plugin.
- Parameters:
pluginID
- owner plugin IDcontextInterface
- context interface class- Returns:
- true if all plugin contexts registered under provided context interface were unregistered successfully, false otherwise.
- Throws:
InvalidContextException
- Raised when given plugin context interface does not fulfill the requirements.
-
getContext
<T extends Context> T getContext(long pluginID, java.lang.Class<T> contextInterface, int index) throws InvalidContextException, ContextNotFoundException
Get registered plugin context.NOTE: it can be reliably called in
Plugin.initialize()
.- Type Parameters:
T
- Specific context type- Parameters:
pluginID
- plugin IDcontextInterface
- context interface classindex
- 0-based index of the context object.- Returns:
- plugin context object
- Throws:
InvalidContextException
- Raised when given plugin context and its interface does not fulfill the requirements.ContextNotFoundException
- Raised when requested plugin context does not exist or if the plugin is not allowed to get it
-
getCPUContext
CPUContext getCPUContext(long pluginID) throws InvalidContextException, ContextNotFoundException
Get registered CPU context.If the plugin has registered more than one
CPUContext
, the first one is returned. This method can be reliably called in the implementation ofPlugin.initialize()
method.- Parameters:
pluginID
- plugin ID- Returns:
- plugin context object
- Throws:
InvalidContextException
- Raised when given plugin context and its interface does not fulfill the requirements.ContextNotFoundException
- Raised when requested plugin context does not exist or if the plugin is not allowed to get it
-
getCPUContext
<T extends CPUContext> T getCPUContext(long pluginID, java.lang.Class<T> contextInterface) throws InvalidContextException, ContextNotFoundException
Get registered CPU context.If the plugin has registered more than one
CPUContext
, the first one is returned. This method can be reliably called in the implementation ofPlugin.initialize()
method.- Type Parameters:
T
- Specific CPU context- Parameters:
pluginID
- plugin IDcontextInterface
- context interface class- Returns:
- plugin context object
- Throws:
InvalidContextException
- Raised when given plugin context and its interface does not fulfill the requirements.ContextNotFoundException
- Raised when requested plugin context does not exist or if the plugin is not allowed to get it
-
getCPUContext
<T extends CPUContext> T getCPUContext(long pluginID, java.lang.Class<T> contextInterface, int index) throws InvalidContextException, ContextNotFoundException
Get registered CPU context.If the plugin has registered more than one
CPUContext
, the index specifies the one in order as they were registered. This method can be reliably called in the implementation ofPlugin.initialize()
method.- Type Parameters:
T
- Specific CPU Context- Parameters:
pluginID
- plugin IDcontextInterface
- context interface classindex
- 0-based index of the context object.- Returns:
- plugin context object
- Throws:
InvalidContextException
- Raised when given plugin context and its interface does not fulfill the requirements.ContextNotFoundException
- Raised when requested plugin context does not exist or if the plugin is not allowed to get it
-
getCompilerContext
CompilerContext getCompilerContext(long pluginID) throws InvalidContextException, ContextNotFoundException
Get registered Compiler context.If the plugin has registered more than one
CompilerContext
, the first one is returned. This method can be reliably called in the implementation ofPlugin.initialize()
method.- Parameters:
pluginID
- plugin ID- Returns:
- plugin context object
- Throws:
InvalidContextException
- Raised when given plugin context and its interface does not fulfill the requirements.ContextNotFoundException
- Raised when requested plugin context does not exist or if the plugin is not allowed to get it
-
getCompilerContext
<T extends CompilerContext> T getCompilerContext(long pluginID, java.lang.Class<T> contextInterface) throws InvalidContextException, ContextNotFoundException
Get registered Compiler context.If the plugin has registered more than one
CompilerContext
, the first one is returned. This method can be reliably called in the implementation ofPlugin.initialize()
method.- Type Parameters:
T
- Specific compiler context- Parameters:
pluginID
- plugin IDcontextInterface
- context interface class- Returns:
- plugin context object
- Throws:
InvalidContextException
- Raised when given plugin context and its interface does not fulfill the requirements.ContextNotFoundException
- Raised when requested plugin context does not exist or if the plugin is not allowed to get it
-
getCompilerContext
<T extends CompilerContext> T getCompilerContext(long pluginID, java.lang.Class<T> contextInterface, int index) throws InvalidContextException, ContextNotFoundException
Get registered compiler context.If the plugin has registered more than one
CompilerContext
, the index specifies the one in order as they were registered. This method can be reliably called in the implementation ofPlugin.initialize()
method.- Type Parameters:
T
- Specific compiler context- Parameters:
pluginID
- plugin IDcontextInterface
- context interface classindex
- 0-based index of the context object.- Returns:
- plugin context object
- Throws:
InvalidContextException
- Raised when given plugin context and its interface does not fulfill the requirements.ContextNotFoundException
- Raised when requested plugin context does not exist or if the plugin is not allowed to get it
-
getMemoryContext
<CellType,T extends MemoryContext<CellType>> T getMemoryContext(long pluginID, java.lang.Class<T> contextInterface) throws InvalidContextException, ContextNotFoundException
Get registered Memory context.If the plugin has registered more than one
MemoryContext
, the first one is returned. This method can be reliably called in the implementation ofPlugin.initialize()
method.- Type Parameters:
CellType
- Cell typeT
- Specific memory context- Parameters:
pluginID
- plugin IDcontextInterface
- context interface class- Returns:
- plugin context object
- Throws:
InvalidContextException
- Raised when given plugin context and its interface does not fulfill the requirements.ContextNotFoundException
- Raised when requested plugin context does not exist or if the plugin is not allowed to get it
-
getMemoryContext
<CellType,T extends MemoryContext<CellType>> T getMemoryContext(long pluginID, java.lang.Class<T> contextInterface, int index) throws InvalidContextException, ContextNotFoundException
Get registered memory context.If the plugin has registered more than one
MemoryContext
, the index specifies the one in order as they were registered. This method can be reliably called in the implementation ofPlugin.initialize()
method.- Type Parameters:
CellType
- Cell typeT
- Specific memory context- Parameters:
pluginID
- plugin IDcontextInterface
- context interface classindex
- 0-based index of the context object.- Returns:
- plugin context object
- Throws:
InvalidContextException
- Raised when given plugin context and its interface does not fulfill the requirements.ContextNotFoundException
- Raised when requested plugin context does not exist or if the plugin is not allowed to get it
-
getDeviceContext
<DataType,T extends DeviceContext<DataType>> T getDeviceContext(long pluginID, java.lang.Class<T> contextInterface) throws InvalidContextException, ContextNotFoundException
Get registered Device context.If the plugin has registered more than one
DeviceContext
, the first one is returned. This method can be reliably called in the implementation ofPlugin.initialize()
method.- Type Parameters:
DataType
- Data typeT
- Specific device context- Parameters:
pluginID
- plugin IDcontextInterface
- context interface class- Returns:
- plugin context object
- Throws:
InvalidContextException
- Raised when given plugin context and its interface does not fulfill the requirements.ContextNotFoundException
- Raised when requested plugin context does not exist or if the plugin is not allowed to get it
-
getDeviceContext
<DataType,T extends DeviceContext<DataType>> T getDeviceContext(long pluginID, java.lang.Class<T> contextInterface, int index) throws InvalidContextException, ContextNotFoundException
Get registered Device context.If the plugin has registered more than one
DeviceContext
, the index specifies the one in order as they were registered. This method can be reliably called in the implementation ofPlugin.initialize()
method.- Type Parameters:
DataType
- Data typeT
- Specific device context- Parameters:
pluginID
- plugin IDcontextInterface
- context interface classindex
- 0-based index of the context object.- Returns:
- plugin context object
- Throws:
InvalidContextException
- Raised when given plugin context and its interface does not fulfill the requirements.ContextNotFoundException
- Raised when requested plugin context does not exist or if the plugin is not allowed to get it
-
-