在ATG中$ scope = global是什么意思? [英] What does it mean by $scope=global in ATG..?

查看:131
本文介绍了在ATG中$ scope = global是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据文档


全局:组件在所有用户之间共享。
会话:为每个用户提供了组件的单独的实例

这意味着,对于全局组件,整个核系统只有一个实例。.
如果为真,那么它对于诸如'/ atg / dynamo / transaction / TransactionManager'之类的组件以及大多数液滴的有效性如何。 ?
因为这些组件一次被多个用户使用

Is that means, for global component, there is only one instance for the whole nucleus system.. If this is true, how does it valid for components like ‘/atg/dynamo/transaction/TransactionManager’ and most of the droplets..? Because those components are used by several users at a single moment

编辑:

我理解 TransactionManager行为。根据定义,应该有一个事务管理器,并且他应该为每个事务保留事务对象。
但是我的问题仍然适用于液滴,如foreach,switch等(大多数液滴在全局范围内)
如果整个核系统只有一个对应类的实例,不是吗?

I understood the ‘TransactionManager’ behavior. According to the definition there should be single transaction manager, and he should keep transaction objects per each transaction. But my question is still valid for droplets like, foreach, switch, etc (most of them are globally scoped) If there is only one instance of corresponding class for the whole nucleus system, isn't it having bad effects on performance?

推荐答案

从历史上看,ATG中存在三种不同类型的作用域。现在增加到5,增加了Window(通常仅在CSC应用程序中使用,因此请尽量不要使用它)和Prototype(增加以支持Endeca弹药盒处理程序的使用)。

Historically there were three different types of scope available in ATG. This has now increased to 5, with the addition of Window (generally only used in the CSC application so try not to use it) and Prototype (added to support the use of Endeca Cartridge Handlers).

正如您在文档中强调的那样,全局组件一次实例化并由所有用户共享,而会话组件为给定会话创建一次,并由该会话的所有请求共享。类似地,为使用它的每个请求重新实例化一个请求范围的组件。

As you highlight from the documentation, global component is instantiated once and is shared by all users, while a session component is created once for a given session and is shared by all requests of that session. Similarly a request scoped component is freshly instantiated for each request that uses it.

从性能的角度来看,解决现有组件(例如,像ForEach这样的全局范围内的组件)的路径要花费一些时间,但是实例化一个

因此,对于 ForEach Droplet实例化一次,但是在 service 方法中,它实际上是从请求中提取参数:

So in the case of a ForEach droplet it gets instantiated once but in the service method it actually extracts the parameters from the request:

String elementName = pRequest.getParameter(ELEMENT_NAME);

这意味着全局范围内的组件是线程安全的,因为它仅从当前请求中获取参数。因此,通常,如果一个组件可以由多个用户共享,而不必担心同步,则应在全局范围内与会话或请求范围内进行同步。 (经验法则应该是,如果您的Droplet是请求范围的,则您可能做错了)。

This means that your globally scoped component is thread safe in that it only takes in parameter from the current request. So in general, if a component can be shared by multiple users, without worrying about synchronisation, it should be globally scoped versus session or request scoped. (The rule of thumb should be that if your droplet is request scoped, you are likely doing it wrong).

这篇关于在ATG中$ scope = global是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆