ATG Component Scopes And Rules

Scope is a nucleus variable.The nucleus properties are processed by $ sign in the configuration files.

Global: If a component has a global scope, its’ instance is shared by users across all the session that exist for the application. Any user which accesses the application can change the value of the global scope component. (This means that the state of the component is the same for all users of the application.).Global Scope componets are generally used for Droplet.
One component copy shares every user.
Example: $class=com.jungle.Animal
                $scope=global
                 Name=Lion
                 Age=15

NOTE: If we do not specify $ scope variable, and it is not specifies in any of the upper-layer of the component. Nucleus consider is scope as “global” by default.

Session: For a component scoped as session, a separate instance is providing for each session (or user). ATG uses cookies and re-written URL’s to identify requests originating a single browser session. If session is inactive (request are not made) for a specific period time. Session scoped components are remove from that session and any runtime value of these component are last.
One component copy shares only one user.
Example :$class = com.jungle.Animal
                 $scope = session

Request: For each request for component, a new instance will be generated for that component. After the request completes, the instance is lost and all it’s runtime value with it. Even if two requests are generated for a component in same session, nucleus will create two separate instance for the requested component. Request scope components are generally used for from handling. This is because, we don’t want our from to manipulated by multiple request in same session or globally by user across the world. the same session come in at the same time.
One Component copy share for every request..
Example: $class=com.jungle.Animal
                $Scope=request

Note:  A very important point which needed to here is that, a component can always refer to component which a scope equal to greater then it’s own scope.
 See in below component scope diagram:




Rules:
1.You can inject request/session/global scoped component into a request scope component Ex: ProfileFromHandler can have Tools/manager.
2.You can inject session/global scoped component into a session scope component EX: Session scope Manager should have only session scope component or global scoped Tools/Manager injected in it.
3.You can inject only global scope component into global scope component Ex: Droplet which is global Scope can only hold other global scoped component injected into it.
4.Always pass the request or session scope objects to global scope component method instead of resolve component.

2 comments:

Unknown said...

could you explain other scope in ATG?

Unknown said...
This comment has been removed by the author.