OpenAjax Hub Specification v04 Libraries
From MemberWiki
(The most current version of the OpenAjax Hub Specification is at http://www.openajax.org/member/wiki/OpenAjax_Hub_Specification.
(This wiki page holds a portion of the version 0.4 internal editorial draft for the OpenAjax Hub 1.0 Specification. The home wiki page for the version 0.4 draft specification is at http://www.openajax.org/member/wiki/OpenAjax_Hub_Specification_04. Version 0.4 is preserved for historical reasons and is very much out of date. A key point about version 0.4 is that it was the most recent version of the Hub spec before the March 2007 InteropFest.))
Contents |
Library Management
Library Management Features
The OpenAjax Hub provides the following APIs for registering libraries, unregistering libraries, and querying about previously registered libraries:
- OpenAjax.registerLibrary()
- OpenAjax.unregisterLibrary()
Conformance Requirements
OpenAjax Conformance Requirement (Libraries): Library Registration
To be OpenAjax Conformant, libraries MUST register themselves properly via OpenAjax.registerLibrary() at the time when the <script> tag(s) that includes the given library is processed (i.e., when the JavaScript files are fetched and then parsed by the browser's JavaScript's engine).
OpenAjax Conformance Requirement (Libraries): Read-only OpenAjax.libraries
To be OpenAjax Conformant, libraries MUST treat OpenAjax.libraries as a read-only public variable.
APIs
OpenAjax.registerLibrary(prefix, namespaceURI, version[, extraData])
Registers an Ajax library with the OpenAjax Hub.
Parameters
- prefix
- A unique string that identifies the library being registered. This string should be suitable as the prefix within an xmlns attribute, such as xmlns:foo="http://example.com".
- namespaceURI
- A namespace URI string suitable for use with xmlns attribute, such as xmlns:foo="http://example.com".
- version
- Version number in the form of #[.#]*, such as "1", "1.1" or "1.20.2". This value allows script to determine which version of a particular Ajax library has been loaded, using equal/greater-than/less-than comparisons. The first (whole number) value should reflect the library's major release number. The second value should reflect the "dot release" number. The third value is for minor bug fixes releases. It is acceptable to include other values (4th, 5th, etc.) although probably not useful.
- extraData
- Optional, can be null. An arbitrary Object holding extra information about the library. This field might be used to hold build or release numbers or indicate alpha/beta status.
Return value
None.
Module
This method is part of the core. (Note: For a discussion of the Hub's modules, see http://www.openajax.org/member/wiki/OpenAjax_Hub_Specification_v04_Bootstrapping_Modularization_Inclusion.)
OpenAjax.unregisterLibrary(prefix)
Unregisters an Ajax library with the OpenAjax Hub.
Parameters
- prefix
- The unique string that identifies the library that was registered.
Return value
None.
Module
This method is part of the core. (Note: For a discussion of the Hub's modules, see http://www.openajax.org/member/wiki/OpenAjax_Hub_Specification_v04_Bootstrapping_Modularization_Inclusion.)
Public variables
OpenAjax.libraries
This variable holds the list of libraries that have registered themselves with the OpenAjax Hub. OpenAjax-conformant libraries must treat this as a read-only variable.
OpenAjax.libraries is a JavaScript associative array, where OpenAjax.libraries contains a <prefix> property for each library that has registered itself via OpenAjax.registerLibrary(). For example, if the FooLib library has prefix foo and has registered itself via OpenAjax.registerLibrary(), then there will be a OpenAjax.libraries.foo property. The OpenAjax.libraries.foo property must point to an object that in turn will have four properties, 'prefix', 'namespaceURI', 'version', and 'extraData', which will hold the corresponding values that were passed to OpenAjax.registerLibrary(). Therefore, the 'version' for FooLib can be found at: OpenAjax.libraries.foo.version
(Note: if parameter 'extraData' was not passed to OpenAjax.registerLibrary(), then the Hub implementation must set the 'extraData' property on OpenAjax.libraries.foo to null.)
Module
This method is part of the core. (Note: For a discussion of the Hub's modules, see http://www.openajax.org/member/wiki/OpenAjax_Hub_Specification_v04_Bootstrapping_Modularization_Inclusion.)
