You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Services and Contexts are one of the more confusing concepts in REEF. The glossary gives you a brief overview of the concept, this page shall provide a more in depth look at how they are implemented. At the core, Contexts are formed by a stack of injectors. The one at the very bottom is called the Root Context, the one on the very top of that stack is called the Active context (hence the event name). The two can be one and the same, that is: There is only one context required. You can instantiate a Task on top of it:

Task
Context B
Context A
RootContext

The semantics are that the Task is instantiated on a fork of the injector held by Context B. That means that whatever is already instantiated as part of Context B will be a singleton, and those instances get passed into the Task. This is immensely useful when e.g. passing state between subsequent Tasks. That state can be kept within the Context B.

Also, Context B's injector is a fork of the one held by Context A. Hence, all the objects instantiated for it are available in Context B and therefore the Task. This is useful when stringing together pipelines of different operators: Each operator has its own Context, and the one below these is used to keep state between operators.

But what about Services?

So far, we haven't touched on Services at all. In fact, Services aren't really needed to understand the concepts behind Contexts. However, their implementation can't be understood without them. Services solve a

  • No labels