`
timcuisw
  • 浏览: 19708 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
最近访客 更多访客>>
社区版块
存档分类
最新评论

Red scope和context (翻译官方wiki)(转载)

阅读更多

最近在研究Red5,FMS,苦于没有什么中文文档,硬着头皮去啃官方资料,突然发现自己英语也还可以应付,越看越觉得:还是英文简单,没歧义,不像中文那么博大精深,呵呵,废话不多说了.

    This page explains Scope and Context in Red5. The Scope model in Red5 that supports Application model is an extension to the Application model in FMS. The Context model in Red5 has no counterpart in FMS. These two concepts are Red5 specific.
     
    这篇文章解释Red5里的Scope和Context.Red5的Scope模型是对FMS中Application模型的一种扩展,Context模型在FMS中没有副本,Scope和Context这两个概念是Red5独有的.

    
    Resources are managed in Red5 in a tree. Each node of a tree is called a scope. If the scope is a leaf node, it is called a BasicScope and if the scope contains child scopes, it is called a Scope. There're two pre-defined BasicScopes in Red5, SharedObject Scope and BroadcastStream Scope.

    Red5中,所有资源形成一颗树,每一个节点被称为scope,如果该节点是个叶子节点,那它被称为BasicScope,如果该节点还有子节点,那它被称为Scope.Red5里有两种预先定义好的BasicScope:SharedObject Scope和BroadcastStream Scope.

    Each Application has its own Scope hierarchy and the root scope is WebScope. There's a global scope defined in Red5 that aims to provide common resource sharing across Applications namely GlobalScope. The GlobalScope is the parent of all WebScopes. Other scopes in between are all instances of Scope. Each scope takes a name. The GlobalScope is named "default". The WebScope is named per Application context name. The Scope is named per path name. The SharedObject Scope is named per SharedObject's name. The BroadcastStream Scope is named per Stream's name.

    每一个应用都有自己的Scope等级体系,根就是WebScope(即此应用的实例)。Red5定义了一个全局scope意在提供一个通用的资源供各个应用共享,称之为GlobalScope。GlobalScope是所有的WebScope的父节点,其余的中间scopes都是Scope的实例。每一个scope有一个名称。GlobalScope的名称是:default。每一个WebScope的名字就是该应用上下文的名称。中间的Scope的名字就是它所在路径的名称。SharedObject Scope的名字就是SharedOjbect的名字,BroadcastStream Scope的名字就是Stream的名字。

    Except GlobalScope and BasicScopes, all Scopes can be connected by a client. A Scope object might be created as a result of a connection request from a client. For example, a client could issue a request to connect to oflaDemo/room0 when the room0 scope does not exist. After the establishment of the connection, room0 is created. If the url contains many intermediate scopes, all these scopes will be created. For example, oflaDemo/lobby0/room0 is requested and neither lobby0 or room0 exist. lobby0 and room0 will be created accordingly. Then the connection is tied to room0 scope.

    除了GlobalScope和BasicScopes外,其余scope都可以被一个client连接。一个客户端请求连接的结果会被用来创建一个Scop对象.例如:一个客户端请求一个连接来连oflaDemo/room0,而此时room0的scope并未存在,当创建了这个连接后,room0的scope被创建了,如果请求的url里包含了中间多个scope,所有的scope都会相应地被创建.

比如:url为:oflaDemo/lobby0/room0,此时room0和lobby0都不存在,那他们都会被相应的创建,然后,连接指向了room0这个scope。


    A Context is stuck to a Scope object and provides additional services to the scope object. Context objects can be obtained by calling IContext.getScope(). Context wraps the spring application context so that the services can be declared as spring beans and looked up from Context. Other services include "clientRegistry", "serviceInvoker", "persistenceStore", "mappingStrategy" and resource resolver that backs the resource resolver provided in Scope.


    一个Context是和一个Scope对象绑定在一起的,它用来给scope object提供额外的功能.Context对象可以通过IContext.getScope()来获得.Context包装了spring的application context,因此,spring里声明的各种bean在此都可以使用.

    Context can be inherited. This means a Scope may not define a context and instead use its parent's context directly. Only GlobalScope and WebScope use their own Context object.

    Context可以被继承.这就是说一个Scope可以继承它的父节点的Context而无需自己在定义一个context,只有GlobalScope和WebScope必须使用它们自己的Context对象.

 

文章原地址:http://myzhangjl.blog.sohu.com/93966697.html

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics