When you define a definition for an element, you specify how to create the element and define the dependency to other elements. In fact, the definition is a template from which to create an element, you can create multiple instances of element from the definition.
The attribute Scope specifies how many instances of element you can create from the definition. The ElementFactory supports two scopes:
Supported scopes
singleton
There is only one instance for the element definition in one ElementFactory.
prototype
The element instance is created every time on the invocation of getElement(String id).
Note It is not required to define attribute Scope in every element definition. There is a default Scope value singleton. To change the default scope of the element, see Customizing ElementFactory for more detail.
When the scope is defined to singleton, there is only one instance for the definition. In other words, there is only one instance for each element id. The singleton instance is cached in ElementFactory. On the sequence invocation of getElement(String id), the cached instance will be returned instead of creating a new instance.
The following diagram shows how the singleton scope works:
Following is a sample definition for singleton scope: