Scope of services

Jun 12, 2007 at 2:09 PM
I am not clear about a couple of things:
In a module you can declare a service either as a global service or only at module level.
So does a service that is declared as a global service stay active at the application level?

What is the scope of hte service that is declared at a module level? what is its scope? session level??

Jun 12, 2007 at 4:25 PM
I would check out the documentation at:

Inspecting the Software Factory Assets > Application Blocks > Composite Web Application Block > Design > Services

There is a area called Locating Services that introduces one to the concept of Composition Containers and how services are located.

Here is some text from that section:

"When a module attempts to locate a service, the Composite Web Application Block first examines the collection of services in the container for the module (Local Service). If the service is not found, the application block looks in the collection of services in the root container (Global Service). This means a module can override the global services available in the root container, yet leave the global service unchanged for use by other modules."

The point is that local services are stored in the services collection in a module container. Global services are stored in the services collection in the root container. When a service is requested, the Composite Web Application Block looks in the local container before going to the global container.




David Hayden
Microsoft MVP C#
Aug 1, 2007 at 12:30 AM
Edited Aug 1, 2007 at 1:00 AM

Both the Root level and Module level CompositionContainers are stored at the Application level and not the session level. See the code below that exists within Microsoft.Practices.CompositeWeb.WebClientApplication.

protected virtual void CreateRootContainer()
  if (RootContainer == null)
    lock (_lockObject)
      if (RootContainer == null)
        CompositionContainer container = new CompositionContainer();
        Application[ApplicationConstants.RootContainer] = container;

The root CompositonContainer contains the collection of all the module level containers.