一千萬個為什麽

搜索

在加載Flex應用程序之前加載XML配置文件

我們使用XML文件作為應用程序中幾個參數的外部配置文件(包括UI組件的默認值和某些服務層對象的屬性值)。我們的想法是能夠在Flex應用程序初始化其任何組件之前加載XML配置文件。這是至關重要的,因為XML加載是在flex中同步處理的,這可能會導致應用程序中的競爭條件。

For example: the configuration file holds the endpoint URL of a web service used to obtain data from the server. The URL resides in the xml because we want to allow our users to alter the endpoint URL according to their environment. Now because the endpoint URL is retrieved only after the xml has been completely loaded, some of the application's components might be invoking operations on this web service before it is initialized with the correct endpoint. The trivial solution would have been to suspend the initialization of the application until the complete event is dispatched by the loader. But it appears that this solution is far from being trivial. I haven't found a single solution that allows me to load the xml before any other object in the application.

任何人都可以就此事提出建議或評論嗎?

問候, 沙哈爾

最佳答案

您不能進行同步操作,在這種情況下,我會選擇以下方法:在您的應用程序調度後,創建完成事件加載xml。需要從xml加載數據的所有用戶交互都被禁用,並且尚未啟動所有其他後臺操作。

加載xml後,調度一個事件來發出信號。事件處理程序應創建遠程對象,Web服務等,啟用UI操作或運行與UI交互無關的I/O操作。

轉載註明原文: 在加載Flex應用程序之前加載XML配置文件