[ engine demonstrations | engine overview | imnmotion.com | Stephen W. Cote ]
Engine Demonstration #2 exemplifies an engine implementation that leverages the TaskService to load an application level configuration file and an engine configuration file. The files required for this demonstration are as follows:
The purpose of this demonstration is to show how an engine is started and configured using a series of tasks. In Demonstration #1, the engine loads the engine configuration engine_config.xml directly. In this demonstration, the task responsible for loading the engine depends on the window having loaded, an application configuration file, config.xml, being loaded asynchronously, and the engine configuration, engine_config.xml, being loaded asynchronously.
If you see the text Engine Loaded in the following block, then the demonstration succeeded. If the engine is not started text does not vanish, you may be using an unsupported browser or there may be a bug in the software.
The Engine for Web Applications should start almost immediately. If this message does not disappear, there may be a bug with the software, a connectivity problem to the server, or you may be using an unsupported browser.
The following HTML represents the engine declaration used for this demonstration. Please note that auto loading is disabled for the pre-configured public release, and must be enabled for the EngineService to automatically inspect the page for engine elements.
<div is-engine = "1" engine-id="oEngine" engine-onload = "handle_engine_load()" engine-action = "/path/tasks.xml" engine-action-type = "xml" engine-handler = "engine_driver" engine-handler-type = "import-task" engine-config = "demonstration_2" class = "some css class" > <!-- VOLATILE_CONTENT --> </div>
The following XML is the task list used to load the configuration files.
<?xml version="1.0" encoding="iso-8859-1" ?>
<tasks>
<task
id="engine_driver"
action-type="default"
action="[nothing]"
handler-type="event"
handler="engine_service_initialized"
>
<task
rid = "load_application_config"
auto-execute="1"
/>
<task
rid = "load_engine_config"
auto-execute="1"
/>
<depends
rid="dom_event_window_load"
/>
</task>
<task
id="load_engine_config"
action-type="xml"
action="/path/engine_config.xml"
handler-type="default"
handler="[nothing]"
/>
<task
id="load_application_config"
action-type="xml"
action="/path/config.xml"
handler-type="script"
handler="#cdata"
>
<![CDATA[
/*
Note: the context of the script exposes
a number of internal references,
some of which are used here.
*/
if(
t.object_config.status.external_tasks_loaded
&&
_js_validate_package("org.cote.js.util.driver")
&&
_js_validate_package("org.cote.js.util.config")
){
var _a = org.cote.js.util.driver.ApplicationDriver.object_config;
_a.pointers.application_config = org.cote.js.util.config.newInstance();
_a.pointers.application_config.setElementParentName("driver-config");
_a.pointers.application_config.parseConfig(o.data);
_a.status.config_loaded = 1;
_m.setReportThreshold(_a.pointers.application_config.getParam('log_level'));
}
t.returnDependency("load_application_config");
]]>
</task>
</tasks>
The following output is from the subscription to the send messages publication.