class documentation

class InterceptorManager:

Constructor: InterceptorManager()

View In Hierarchy

Manager for interceptors. This class is responsible for registering interceptors and calling the appropriate interceptor handlers when a request is processed by the CSE. It maintains a registry of all interceptor handlers and their metadata, and uses this registry to find and call the appropriate handlers for each request.

Method __init__ Initialize the InterceptorManager with an empty registry and cache.
Method interceptErrorResponse Call the interceptor handlers for the REQUEST_ERROR_RESPONSE phase.
Method interceptRequestPostProcessing Call the interceptor handlers for the REQUEST_POST_PROCESSING phase.
Method interceptRequestPreProcessing Call the interceptor handlers for the REQUEST_PRE_PROCESSING phase.
Method register Register an interceptor with the InterceptorManager. This method is called when an interceptor plugin is loaded and instantiated.
Method _findHandlers Find and return the list of interceptor handlers for the given phase, operation, and resource type.
Instance Variable _cache Cache for interceptor handler lookups. The keys are InterceptorFilter tuples and the values are lists of InterceptorHandlerInfo objects that match the filter. This cache is used to speed up the lookup of interceptor handlers for each request...
Instance Variable _registry The registry of interceptor handlers. This is a list of InterceptorHandlerInfo objects that contain the handler function and its metadata (phase, operation, resource, priority). This registry is populated when interceptors are registered with the InterceptorManager.
def __init__(self):

Initialize the InterceptorManager with an empty registry and cache.

def interceptErrorResponse(self, request: CSERequest, result: Result):

Call the interceptor handlers for the REQUEST_ERROR_RESPONSE phase.

Parameters
request:CSERequestThe incoming CSERequest object that is being processed.
result:ResultThe Result object that is the response to the request, which can be modified by the interceptor handlers.
def interceptRequestPostProcessing(self, request: CSERequest, result: Result):

Call the interceptor handlers for the REQUEST_POST_PROCESSING phase.

Parameters
request:CSERequestThe incoming CSERequest object that is being processed.
result:ResultThe Result object that is the response to the request, which can be modified by the interceptor handlers.
def interceptRequestPreProcessing(self, request: CSERequest):

Call the interceptor handlers for the REQUEST_PRE_PROCESSING phase.

Parameters
request:CSERequestThe incoming CSERequest object that is being processed.
def register(self, interceptor: Interceptor, pluginName: str):

Register an interceptor with the InterceptorManager. This method is called when an interceptor plugin is loaded and instantiated.

pluginName: The name of the plugin that the interceptor belongs to.

Parameters
interceptor:InterceptorThe interceptor instance to register. This instance should have its handler methods decorated with @intercept.
pluginName:strUndocumented
def _findHandlers(self, filter: InterceptorFilter) -> list:

Find and return the list of interceptor handlers for the given phase, operation, and resource type.

This method uses caching to improve performance. The cache is invalidated whenever a new interceptor is registered.

Parameters
filter:InterceptorFilterA tuple of (phase, operation, resource) to find handlers for. Each element can be a specific value or None to match all.
Returns
listA list of interceptor handlers sorted by priority, or an empty list if no handlers are found.

Cache for interceptor handler lookups. The keys are InterceptorFilter tuples and the values are lists of InterceptorHandlerInfo objects that match the filter. This cache is used to speed up the lookup of interceptor handlers for each request. The cache is invalidated whenever a new interceptor is registered.

_registry: list[InterceptorHandlerInfo] =

The registry of interceptor handlers. This is a list of InterceptorHandlerInfo objects that contain the handler function and its metadata (phase, operation, resource, priority). This registry is populated when interceptors are registered with the InterceptorManager.