7 Replies Latest reply: Jun 23, 2011 6:08 AM by RedBall23 RSS

    Problem using LazyModuleLoadPolicy

    RedBall23 Community Member

      Hi,

       

      I have problem using the LazyModuleLoadPolicy and ModuleMessageInterceptor.

      In the context file I defined:

       

      <module:LazyModuleLoadPolicyTag objectId="lazyLoadPolicy" type="{SendContactEvent}"/>
      <module:ModuleMessageInterceptor type="{SendContactEvent}"/>
      
      

       

      I am using a view stack with auto creation policy.

      I dispatch SendContactEvent from module A and in module B I handle the event.

      If I don't use the lazy loading everything works fine.

      I'm getting the following exceptions:

      Dispatch message '[Event type="none" bubbles=false cancelable=false eventPhase=2]' with 3 receiver(s)
      Message Target threw Error 
      Error: Attempt to call resume on MessageProcessor in illegal state: active
           at org.spicefactory.parsley.core.messaging.impl::DefaultMessageProcessor/illegalState()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-core/org/spicefactory/parsley/core/messaging/impl/DefaultMessageProcessor.as:86]
           at org.spicefactory.parsley.core.messaging.impl::DefaultMessageProcessor/resume()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-core/org/spicefactory/parsley/core/messaging/impl/DefaultMessageProcessor.as:111]
           at com.adobe.cairngorm.module::LazyModuleLoadPolicy/interceptModuleMessage()[C:\devhome\workspaces\Flex\Module\src\com\adobe\cairngorm\module\LazyModuleLoadPolicy.as:52]
           at Function/http://adobe.com/AS3/2006/builtin::apply()
           at org.spicefactory.lib.reflect::Method/invoke()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/spicelib-reflect/org/spicefactory/lib/reflect/Method.as:87]
           at org.spicefactory.parsley.processor.messaging.receiver::AbstractMessageHandler/invokeMethod()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-config/org/spicefactory/parsley/processor/messaging/receiver/AbstractMessageHandler.as:173]
           at org.spicefactory.parsley.processor.messaging.receiver::MessageHandler/handleMessage()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-config/org/spicefactory/parsley/processor/messaging/receiver/MessageHandler.as:76]
           at org.spicefactory.parsley.core.messaging.impl::DefaultMessageProcessor/invokeTarget()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-core/org/spicefactory/parsley/core/messaging/impl/DefaultMessageProcessor.as:228]
           at Processor/proceed()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-core/org/spicefactory/parsley/core/messaging/impl/DefaultMessageProcessor.as:342]
           at org.spicefactory.parsley.core.messaging.impl::DefaultMessageProcessor/processReceivers()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-core/org/spicefactory/parsley/core/messaging/impl/DefaultMessageProcessor.as:127]
           at org.spicefactory.parsley.core.messaging.impl::DefaultMessageProcessor/start()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-core/org/spicefactory/parsley/core/messaging/impl/DefaultMessageProcessor.as:164]
           at org.spicefactory.parsley.core.messaging.impl::DefaultMessageRouter/dispatchMessage()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-core/org/spicefactory/parsley/core/messaging/impl/DefaultMessageRouter.as:50]
           at org.spicefactory.parsley.core.scope.impl::DefaultScopeManager/doDispatchMessage()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-core/org/spicefactory/parsley/core/scope/impl/DefaultScopeManager.as:199]
           at org.spicefactory.parsley.core.scope.impl::DefaultScopeManager/dispatchMessage()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-core/org/spicefactory/parsley/core/scope/impl/DefaultScopeManager.as:178]
           at org.spicefactory.parsley.core.messaging.impl::MessageDispatcher/dispatchMessage()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-core/org/spicefactory/parsley/core/messaging/impl/MessageDispatcher.as:54]
           at app::AppStartPM/navigateToGames()[C:\devhome\workspaces\Flex\ModulesTest\src\app\AppStartPM.as:17]
           at app::AppStart/__gamesButton_click()[C:\devhome\workspaces\Flex\ModulesTest\src\app\AppStart.mxml:59]
      Select 0 out of 0 error handlers
      Unhandled error - continue message processing
      Message Target threw Error 
      Error: Attempt to call resume on MessageProcessor in illegal state: active
           at org.spicefactory.parsley.core.messaging.impl::DefaultMessageProcessor/illegalState()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-core/org/spicefactory/parsley/core/messaging/impl/DefaultMessageProcessor.as:86]
           at org.spicefactory.parsley.core.messaging.impl::DefaultMessageProcessor/resume()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-core/org/spicefactory/parsley/core/messaging/impl/DefaultMessageProcessor.as:111]
           at com.adobe.cairngorm.module::ModuleMessageDispatcher/interceptModuleMessage()[C:\devhome\workspaces\Flex\Module\src\com\adobe\cairngorm\module\ModuleMessageDispatcher.as:80]
           at Function/http://adobe.com/AS3/2006/builtin::apply()
           at org.spicefactory.lib.reflect::Method/invoke()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/spicelib-reflect/org/spicefactory/lib/reflect/Method.as:87]
           at org.spicefactory.parsley.processor.messaging.receiver::AbstractMessageHandler/invokeMethod()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-config/org/spicefactory/parsley/processor/messaging/receiver/AbstractMessageHandler.as:173]
           at org.spicefactory.parsley.processor.messaging.receiver::MessageHandler/handleMessage()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-config/org/spicefactory/parsley/processor/messaging/receiver/MessageHandler.as:76]
           at org.spicefactory.parsley.core.messaging.impl::DefaultMessageProcessor/invokeTarget()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-core/org/spicefactory/parsley/core/messaging/impl/DefaultMessageProcessor.as:228]
           at Processor/proceed()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-core/org/spicefactory/parsley/core/messaging/impl/DefaultMessageProcessor.as:342]
           at org.spicefactory.parsley.core.messaging.impl::DefaultMessageProcessor/processReceivers()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-core/org/spicefactory/parsley/core/messaging/impl/DefaultMessageProcessor.as:127]
           at org.spicefactory.parsley.core.messaging.impl::DefaultMessageProcessor/start()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-core/org/spicefactory/parsley/core/messaging/impl/DefaultMessageProcessor.as:164]
           at org.spicefactory.parsley.core.messaging.impl::DefaultMessageRouter/dispatchMessage()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-core/org/spicefactory/parsley/core/messaging/impl/DefaultMessageRouter.as:50]
           at org.spicefactory.parsley.core.scope.impl::DefaultScopeManager/doDispatchMessage()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-core/org/spicefactory/parsley/core/scope/impl/DefaultScopeManager.as:199]
           at org.spicefactory.parsley.core.scope.impl::DefaultScopeManager/dispatchMessage()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-core/org/spicefactory/parsley/core/scope/impl/DefaultScopeManager.as:178]
           at org.spicefactory.parsley.core.messaging.impl::MessageDispatcher/dispatchMessage()[/Users/jenshalm/Projects/SpicefactoryProduction/Parsley/parsley-core/org/spicefactory/parsley/core/messaging/impl/MessageDispatcher.as:54]
           at app::AppStartPM/navigateToGames()[C:\devhome\workspaces\Flex\ModulesTest\src\app\AppStartPM.as:17]
           at app::AppStart/__gamesButton_click()[C:\devhome\workspaces\Flex\ModulesTest\src\app\AppStart.mxml:59]
      Select 0 out of 0 error handlers
      

       

      My lazy module loader defined as follows:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Canvas 
          xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx"
          xmlns:module="com.adobe.cairngorm.module.*"
          xmlns:parsley="http://www.spicefactory.org/parsley"
          xmlns:local="*">
      
          <fx:Script>
              <![CDATA[
                  import com.adobe.cairngorm.module.ILoadPolicy;
                  import com.adobe.cairngorm.module.IModuleManager;
                  import com.adobe.cairngorm.module.ModuleViewLoaderSkin;
                 
                     private var _moduleId:String;
                              private var _moduleManager:IModuleManager;
                     private var _lazyLoadPolicy:ILoadPolicy;
      
                     [Bindable]
                     public function get moduleId():String
                     {
                          return _moduleId;
                     }
      
                     public function set moduleId(value:String):void
                     {
                          _moduleId = value;
                     }
                     
                     [Bindable]
                     public function get moduleManager():IModuleManager
                     {
                          return _moduleManager;
                     }
      
                     public function set moduleManager(value:IModuleManager):void
                     {
                          _moduleManager = value;
                     }
      
                     
                     
                     [Bindable]
                     public function get lazyLoadPolicy():ILoadPolicy
                     {
                          return _lazyLoadPolicy;
                     }
                     
                     [Inject(id="lazyLoadPolicy")]
                     public function set lazyLoadPolicy(value:ILoadPolicy):void
                     {
                          _lazyLoadPolicy = value;
                     }
                     
              ]]>
          </fx:Script>
      
          <fx:Declarations>
              <parsley:Configure/>
          </fx:Declarations>
      
          <module:ModuleViewLoader id="moduleLoader"
              left="3" right="3" top="20" bottom="3"
              moduleId="{ moduleId }"
              moduleManager="{ moduleManager }"
              skinClass="com.adobe.cairngorm.module.ModuleViewLoaderSkin"
              visible="{this.visible}"
              loadPolicy="{ lazyLoadPolicy }"/>
      </mx:Canvas>
      
       
      

       

      Does anybody has an idea?

       

      Thanks!

        • 1. Re: Problem using LazyModuleLoadPolicy
          popoliton

          I had the same problem when I used the lazy loading and couldn't solve it..

           

          help!

          • 2. Re: Problem using LazyModuleLoadPolicy
            Nicolas Yuen Adobe Employee

            Hi guys,

             

            As mentionned in another thread it would really help if one of you could open a jira ticket with a sample application on our bug tracker:

             

            https://bugs.adobe.com/jira/browse/CGM

             

            I'll do what I can to have a look at it this week.

             

            Thx

            • 3. Re: Problem using LazyModuleLoadPolicy
              RedBall23 Community Member

              Hi Nicolas,

               

              How can you open a new issue in the link you sent me?

              I created a new user but can't log in because I don't have permissions..

               

              Thanks alot!

              Assaf

              • 4. Re: Problem using LazyModuleLoadPolicy
                RedBall23 Community Member

                Hi Nicolas,

                 

                I'm writing again because I still can't upload a sample application because I don't have permission to log in.

                Can you help me?

                 

                Thanks,

                Assaf

                • 5. Re: Problem using LazyModuleLoadPolicy
                  Nicolas Yuen Adobe Employee

                  HI Assaf,

                   

                  We're having a look at the Jira issue, in the meantime please post the sample and description here and I'll create the bug myself.

                   

                  Thanks

                  • 6. Re: Problem using LazyModuleLoadPolicy
                    Nicolas Yuen Adobe Employee

                    Can you PM me your account ID on JIRA, IT reported an issue lately with some account creation.

                    • 7. Re: Problem using LazyModuleLoadPolicy
                      RedBall23 Community Member

                      Hi Nicolas,

                       

                      Below is my code without using the LazyModuleLoadPolicy, can you tell me what I need to change/add in order to set the lazy loading?

                      The main application have two buttons, each one navigates to a different module.

                       

                       

                      Is there any reason to use the LazyModuleLoadPolicy at all?

                      Using a view stack with automatic creation policy and basic loading policy will have the same effect..

                       

                      Thanks!!

                       

                       

                      --Code--

                       

                      App.mxml:

                      <?xml version="1.0" encoding="utf-8"?>
                      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                        xmlns:s="library://ns.adobe.com/flex/spark" 
                                        xmlns:mx="library://ns.adobe.com/flex/mx" 
                                        xmlns:ns="http://www.spicefactory.org/parsley" 
                                        xmlns:ns1="http://ns.adobe.com/cairngorm" 
                                        xmlns:local="*"
                                        width="100%" height="100%">
                           
                           <fx:Script>
                                <![CDATA[
                                     import com.adobe.cairngorm.navigation.NavigationEvent;
                                     
                                     [MessageDispatcher]
                                     public var dispatcher:Function;
                                     
                                     protected function button1_clickHandler(event:MouseEvent):void
                                     {
                                          dispatcher(NavigationEvent.createNavigateToEvent(ContentDestination.MODULE_A));
                                     }
                                     
                                     protected function button2_clickHandler(event:MouseEvent):void
                                     {
                                          dispatcher(NavigationEvent.createNavigateToEvent(ContentDestination.MODULE_B));     
                                     }
                                     
                                ]]>
                           </fx:Script>
                           
                           <fx:Declarations>
                                <ns:ContextBuilder>
                                     <ns1:CairngormModuleSupport/>
                                     <ns1:CairngormNavigationSupport />
                                     <ns:FlexConfig type="{AppCtx}"/>
                                </ns:ContextBuilder>
                                <ns:Configure/>
                                
                           </fx:Declarations>
                           <s:VGroup width="100%" height="100%">
                                <s:HGroup width="100%" height="100%">
                                     <s:Button label="moduleA" click="button1_clickHandler(event)"/>
                                     <s:Button label="moduleB" click="button2_clickHandler(event)"/>
                                </s:HGroup>
                                <local:ContentViewStack/>
                           </s:VGroup>
                      </s:Application>
                      
                       
                      

                       

                      AppCtx.mxml:

                      <?xml version="1.0" encoding="utf-8"?>
                      <fx:Object xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                 xmlns:s="library://ns.adobe.com/flex/spark" 
                                 xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:ns="http://ns.adobe.com/cairngorm">
                           <fx:Script>
                                <![CDATA[
                                     import org.spicefactory.lib.reflect.ClassInfo;
                                ]]>
                           </fx:Script>
                           <fx:Declarations>
                                <ns:ParsleyModuleDescriptor objectId="moduleA" url="moduleA/ModuleA.swf" applicationDomain="{ClassInfo.currentDomain}"/>
                                <ns:ParsleyModuleDescriptor objectId="moduleB" url="moduleB/ModuleB.swf" applicationDomain="{ClassInfo.currentDomain}"/>
                           </fx:Declarations>
                      </fx:Object>
                      
                      
                      

                       

                       

                       

                      BasicViewLoader.mxml:

                      <?xml version="1.0" encoding="utf-8"?>
                      <module:ViewLoader xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                             xmlns:s="library://ns.adobe.com/flex/spark" 
                                             xmlns:mx="library://ns.adobe.com/flex/mx" 
                                             xmlns:module="com.adobe.cairngorm.module.*">
                           <module:loadPolicy>
                                <module:BasicLoadPolicy/>
                           </module:loadPolicy>
                      </module:ViewLoader>
                      

                       

                       

                      ContentDestination.as:

                      package  
                      {
                           public class ContentDestination
                           {
                                public static const MODULE_A:String = "content.modulea";
                                public static const MODULE_B:String = "content.moduleb";
                           }
                      }
                      

                       

                       

                      ContentViewStack.mxml

                      <?xml version="1.0" encoding="utf-8"?>
                      <mx:ViewStack xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                       xmlns:s="library://ns.adobe.com/flex/spark" 
                                       xmlns:mx="library://ns.adobe.com/flex/mx" 
                                       xmlns:ns="http://www.spicefactory.org/parsley" 
                                       xmlns:local="*"
                                       width="100%" height="100%" >
                           <fx:Metadata>
                                [Waypoint]
                           </fx:Metadata>
                           <fx:Script>
                                <![CDATA[
                                     import com.adobe.cairngorm.module.IModuleManager;
                                     
                                     [Bindable]
                                     [Inject(id="moduleA")]
                                     public var moduleA:IModuleManager;
                                     
                                     [Bindable]
                                     [Inject(id="moduleB")]
                                     public var moduleB:IModuleManager;
                                ]]>
                           </fx:Script>
                           
                           <fx:Declarations>
                                <ns:Configure/>
                           </fx:Declarations>
                           <s:NavigatorContent automationName="{ContentDestination.MODULE_A}"
                                                    width="100%" height="100%">
                                <local:BasicViewLoader moduleManager="{moduleA}"
                                                            width="100%" height="100%"/>
                           </s:NavigatorContent>
                           
                           <s:NavigatorContent automationName="{ContentDestination.MODULE_B}"
                                                    width="100%" height="100%">
                                <local:BasicViewLoader moduleManager="{moduleB}"
                                                            width="100%" height="100%"/>
                           </s:NavigatorContent>
                      </mx:ViewStack>
                      

                       

                       

                       

                      ModuleA.mxml (in src.moduleA)

                      <?xml version="1.0" encoding="utf-8"?>
                      <mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                   xmlns:s="library://ns.adobe.com/flex/spark" 
                                   xmlns:mx="library://ns.adobe.com/flex/mx" 
                                   layout="absolute" width="100%" height="100%">
                           <s:Label text="Module A" fontSize="30"/>     
                      </mx:Module>
                      

                       

                       

                      ModuleB.mxml (in src.moduleB)

                      <?xml version="1.0" encoding="utf-8"?>
                      <mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                   xmlns:s="library://ns.adobe.com/flex/spark" 
                                   xmlns:mx="library://ns.adobe.com/flex/mx" 
                                   layout="absolute" width="100%" height="100%"> 
                           <s:Label text="Module B" fontSize="30"/>
                      </mx:Module>