The cross-domain loading feature allows you to load the General Interface runtime and your application from different security domains, increasing deployment flexibility and allowing you to do the following:
In a build of GI that supports cross-domain loading all XML and XSL data file have been converted into a JSONP-like format, which supports loading across domains. For example, the file JSX/locale/messages.xml, <data jsxnamespace="propsbundle" locales=""> <locale> <!-- jsx3.lang.ClassLoader --> <record jsxid="boot.env_reset" jsxtext="Error redefining JSX environment parameter {0} from ''{1}'' to ''{2}''."/> <record jsxid="boot.class_err" jsxtext="Could not load class {0}."/> <record jsxid="boot.class_ex" jsxtext="Error loading class {0}: {1}"/> <record jsxid="boot.class_undef" jsxtext="Loaded JavaScript file {0} but class {1} was not defined."/> ... becomes JSX/locale/messages.xml.js, jsx3.net.Request.xdr( "jsx:/locale/messages.xml", "<data jsxnamespace=\"propsbundle\" locales=\"\">\n\n <locale>\n <record jsxid=\"boot.env_reset\" jsxtext=\"Error redefining JSX environment parameter {0} from ''{1}'' to ''{2}''.\"/>\n <record jsxid=\"boot.class_err\" jsxtext=\"Could not load class {0}.\"/>\n <record jsxid=\"boot.class_ex\" jsxtext=\"Error loading class {0}: {1}\"/>\n <record jsxid=\"boot.class_undef\" jsxtext=\"Loaded JavaScript file {0} but class {1} was not defined.\"/>\n ... "); This conversion is completely automated by the build process, which uses the new JsEncodeTask task to compile the XML/XSL resources. The task is turned off by default to avoid some code and data bloat. To enable it you must set the build.gi.xd build property to true, either in build/user.properties or on the command line: $> ant -Dbuild.gi.xd=true
A pre-built cross-domain ready distribution of GI is available for download as well. If you want to host your application on a separate domain as well, you must process the XML and XSL resources in your application in a similar manner. You can do so using the same Ant task that General Interface uses. There is also a command line interface for the encoder that comes with the General Interface source distribution: $> cd WORKSPACE/JSXAPPS/myApp $> find . -name "*.xml" -or -name "*.xsl" \| xargs \ sh GISRC/build/tools/bin/jsencode.sh -user ../ DeploymentWhen deploying an application cross-domain you must modify the GI launch page to indicate the domains from which resources should be loaded in the cross-domain manner. Consider the following example:
Then the launch page should include the following: <script type="text/javascript" src="http://cdn.host.com/gi/3.9.0/JSX/js/JSX30.js" jsxapppath="http://apps.example.com/JSXAPPS/myApp/" jsxxd="http://cdn.host.com/ http://apps.example.com/"> The two URLs in the jsxxd attribute indicate the cross-domain sites. Any resource whose path begins with one of these prefixes will be assumed to exist in the JSONP-like syntax and will be loaded in the cross-domain manner. Synchronous LoadingSince the introduction of the Asynchronous Modular Platform in Release 3.7, General Interface relies less and less on synchronous loading. Some public APIs still trigger synchronous loading, however. These APIs are still available to use in applications, but they will not work if you deploy the GI runtime or your application cross-domain as described above. This is because the JSONP technique for cross-domain data access works only asynchronously. The following are examples of synchronous APIs. You must not use any of these in a cross-domain deployment.
In addition, dynamic class loading relies on synchronous loading. Dynamic class loading occurs when an application loads a component file and one or more of the classes used in the component file is not already loaded. There are several possible workarounds to dynamic class loading:
|
Contents
|
