Instantiating UcompOS Global (Continuum) Variables at Startup

In my post about UcompOS Shared Objects, I described how the UcompOS Portal furnishes a Shared Object Implementation that can be written to and read by any UcompOS entity in the UcompOS Continuum.

In a large-scale UcompOS Rich Portal Application, you very likely may find a need to share complex data across multiple UcompOS entities.

One effective approach to this challenge is to use the UcompOSGlobalManagerProxy class’s setSharedObject(), getSharedObject(), and getSharedObjects() methods.

These methods get/set shared objects on the UcompOS Portal at run-time.

But what if you want to populate the UcompOS Portal’s shared Object at start-up even before any UcompOS applications are launched?

As of the version 0.4.1 Milestone release of UcompOS RPF, there is a way to do this.

The key is a new <globalVariables/> element that can be added as a child element to the root <applications/> element in a dock manifest and as a child element to the root <application/> element in a UcompOS application manifest.

Below is a simple example of this in action in the dock manifest of my Educator 2 software application being built entirely on top of the UcompOS RPF:

<?xml version="1.0" encoding="utf-8"?>
	<application background="true" default="true">

Each global variable is wrapped in a <globalVariable/> element with child <key/> and <value/> elements.

All global variables in the dock manifest will automatically be added to the UcompOS Portal’s Shared Object implementation and will immediately be available to all UcompOS entities.

String Substitutions in Manifest Files

In the above example, notice I am instantiating global variable named _PROTOCOL and _DOMAIN_. And then notice that those strings appear in my <application/> element.

A string substitution will automatically take place here such that the <application/> value will be after the substitution.

As mentioned earlier, the <globalVariables> element is supported in both application manifests and dock manifests so you can also establish global variables in this fashion when launching a UcompOS application.

Typing Shared Objects

The <value/> element supports an optional type attribute such that you can articulate the data type of a Shared Object.

The best way to show how this is accomplished is with examples:


	<value type="Array">


	<value type="Object">

The type attribute can also be of type uint, int, Boolean, Number and String. The default data type is String. Also, the <item/> element supports the type attribute for Arrays and Objects.

Also, nesting of complex data structures is supported, so you can implement an Array of Arrays, or an Array of Objects, etc.

Shared Object Model Implemented into UcompOS RPF

As of the UcompOS RPF Public Alpha Release 0.1.13 that I posted last night, there is a new Shared Object implementation model.

On the UcompOS Portal, there is a run-time Object that can be used to share information across multiple entities in a UcompOS implementation.

Note that at this time this is just a run-time Object.  This is NOT an implementation of the Local Shared Object that gets permanently housed in the Flash Player’s local storage infrastructure.

The UcompOSGlobalManagerProxy has three new methods: setSharedObject();, getSharedObject();, and getSharedObjects();.

I’ll describe each of them below:

public function setSharedObject(key:String, value:Object):void

This sets a property named key on the UcompOS Portal shared object and assigns it a value of value.

A very important point is that when this method is called, the UcompOS Portal dispatches a UcompOS Continuum event of type UcompOSGlobalManagerProxy.SHARED_OBJECT with properties of key and value such that each entity in the Continuum is notified when a Shared Object value is updated.  This could easily enable two disparate UcompOS Applications to update their interfaces in real-time according to model changes implemented by the other.

public function getSharedObject(key:String):void

This retrieves the value on the UcompOS Portal shared object in the property key.

The information is received asynchronously by listening for an SDKEvent of type UcompOSGlobalManagerProxy.SHARED_OBJECT and testing the value of the event object’s key property.

public function getSharedObjects(keys:Array):void

This retrieves multiple shared objects simultaneously.  Each member of the keys array is the name of a property on the UcompOS Portal shared object.

The data is retrieved asynchronously by listening for an SDKEvent of type UcompOSGlobalManagerProxy.SHARED_OBJECTS whose data Object will have a sharedObjects property that is an Object.  Each property name requested in the keys array is a property name in the sharedObjects Object with its value the value of the corresponding item on the UcompOS Portal shared object.