OpenAjax Hub 2.0 Specification Managed Hub Containers
From MemberWiki
NOTE: This wiki page holds part of the OpenAjax Hub 2.0 Specification.
Contents |
7 Developing Managed Hub Containers
Introduction
Within the Managed Hub, a Container encapsulates a particular Client Application and manages the Client Application's life cycle, including loading/initialization and destruction. Any attempts by the Client Application to publish messages or subscribe to messages are performed via the Client Application's Container.
Refer to the Managed Hub Overview chapter for an introduction to the Managed Hub and its various components, particularly its notion of "Client Applications", "Containers" and "Hub Clients".
Built-in Containers
The reference implementation of OpenAjax Hub 2.0 ships with two built-in container types:
- IframeContainer - This container sandboxes its Client Application into an HTML
<iframe>element. Any messages to/from the Client Application are marshalled across the iframe boundary between the Client Application and the Manager Application. - InlineContainer - This container places its Client Application within the same browser frame as the Manager Application. The InlineContainer tends to be faster and require less memory than the IframeContainer. However, it does not sandbox or isolate the Client Application.
Custom Containers
The Managed Hub provides an extensible architecture for custom Containers. An implementation of the OpenAjax Hub may support additional Containers beyond the two required built-in Containers listed above.
A "Container implementation" consists of two parts:
- a Container and
- a HubClient.
These parts SHOULD be implemented as JavaScript "classes" similar to the class design used by OpenAjax.hub.IframeContainer, OpenAjax.hub.InlineContainer, OpenAjax.hub.IframeContainer and OpenAjax.hub.InlineHubClient. The mechanisms that a custom Container and its HubClient use to communicate with each other are not specified by this standard.
Custom Container implementations must support all of the OpenAjax.hub.Container APIs and all of the OpenAjax.hub.HubClient APIs. For example, suppose you have a custom Container that leverages client-side Java for message passing. You might name the JavaScript classes for the custom Container the following:
-
MyOrg.OpenAjax.hub.JavaContainer -
MyOrg.OpenAjax.hub.JavaHubClient
Then, a Manager Application could create a Container via:
var container = new MyOrg.OpenAjax.hub.JavaContainer(managedHub, clientId, params);
And a Client Application could create a HubClient and connect to the Managed Hub via:
var hubClient= new MyOrg.OpenAjax.hub.JavaHubClient(params); hubClient.connect(onCompleteCallback);
The params objects accepted by the Container and HubClient constructors may contain custom properties as well as the standard properties associated with Container and HubClient. When custom properties are used by a custom Container or HubClient, they SHOULD be encapsulated in a sub-object, e.g. params.MyOrg.JavaContainer.myPropName1 or params.MyOrg.JavaHubClient.myPropName2.
URL parameter handling
Implementations of IframeContainer load clients inside of iframes. Such implementations SHOULD obey the following URL-related rules:
- Implementations of Containers and HubClients SHOULD preserve URL parameters that the manager application has included within any URL strings.
- Containers that are not under development within OpenAjax Alliance SHOULD NOT use URL parameters that begin with the string 'oah'. All URL parameters that begin with 'oah' SHOULD be considered reserved for future OpenAjax Alliance specifications.
