Spicefactory Forum Index Spicefactory
Discuss Spicefactory Open Source Projects
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Parsley messaging and sublcasses.

 
Post new topic   Reply to topic    Spicefactory Forum Index -> Spicefactory - General Discussions
View previous topic :: View next topic  
Author Message
nickrjensen



Joined: 21 Sep 2009
Posts: 2
Location: NYC

PostPosted: Tue Sep 22, 2009 12:03 am    Post subject: Parsley messaging and sublcasses. Reply with quote

I have noticed some interesting behavior when sending and receiving messages from subclasses. Given the following context:

Code:

<Object id="myContext">
   
   // Sender extends BaseSender
   <Sender id="senderPM" />

   // Receiver extends BaseReceiver
   <Receiver id="receiverPM" />

</Object>


Now if Sender is a subclass of BaseSender and the message being sent out is actually dispatched from the BaseSender class, the Receiver will not get the message. However, if the Sender class is the one dispatching the message, everything works as expected. Now the weird part. The same is NOT true for the Receiver. If Receiver is a subclass of BaseReceiver, I can hear the message in both the BaseReceiver class, AND the Receiver class.

It seems like this is incorrect behavior. Any thoughts?
Back to top
View user's profile Send private message
Jens Halm
Site Admin


Joined: 21 Sep 2007
Posts: 1498
Location: Cologne Germany

PostPosted: Tue Sep 22, 2009 12:31 am    Post subject: Reply with quote

It depends on how you configured the objects. If you are using [ManagedEvents] metadata tags you should be aware of the fact that those tags are not inherited. It's a quirk of describeType I cannot do much about. Parsing superclasses additionally is not an option due to performance reasons (just think about the hundreds of properties and methods of UIComponent which would be parsed multiple times then).

But this is just blind guessing since I don't know how you configured the sender. Unfortunately there are some severe limitations in describeType and also in the ApplicationDomain class which cause some trouble for IOC containers.

If I'm right with my guess there are only two workarounds: Repeat the [ManagedEvents] tag on the subclass or use the <ManagedEvents> MXML tag instead.
_________________
Jens Halm
Spicefactory
Back to top
View user's profile Send private message
nickrjensen



Joined: 21 Sep 2009
Posts: 2
Location: NYC

PostPosted: Tue Sep 22, 2009 12:58 am    Post subject: Reply with quote

Thanks for your reply. Repeating the [ManagedEvents] tag isn't really ideal - I'll probably resort to adding it to the Container.

I understand that traversing and parsing all the superclasses is not the right thing to do. But one thing still confuses me - It does seem like there is some level of class traversing going on with the Receiving end. In my example above the [MessageHandler] tag is decorating a function in the BaseReceiver class, but the class defined in the Container is Receiver, and yet the message is still received.
Back to top
View user's profile Send private message
Jens Halm
Site Admin


Joined: 21 Sep 2007
Posts: 1498
Location: Cologne Germany

PostPosted: Tue Sep 22, 2009 1:11 am    Post subject: Reply with quote

Metadata on methods is available in subclasses as long as you do not override the method. In each case where you are not sure you could just call describeType(MyReceiverSubclass) and examine which tags are in there and which are not.

While thinking about it I realized that I might add a [InheritMetadata] tag to a future release (2.2 since 2.1 is almost done). This way you could explicitly instruct the container to parse the superclass too. As long as you don't use it on anything that extends UIComponent or any other dinosaur class performance should be okay then.
_________________
Jens Halm
Spicefactory
Back to top
View user's profile Send private message
verveguy



Joined: 22 Sep 2009
Posts: 30
Location: Raleigh, NC

PostPosted: Wed Sep 23, 2009 1:16 am    Post subject: How about caching the supertype information? Reply with quote

Jens,

I've done a fair bit of reflective type-tree walking (see xobj project on bitbucket) and found myself needing to aggressively cache the metadata obtained from types for performance reasons.

What reasons do you see why you couldn't do the same in this case and keep the extracted information cached against the type in a simple dict for fast access?
Back to top
View user's profile Send private message
Jens Halm
Site Admin


Joined: 21 Sep 2007
Posts: 1498
Location: Cologne Germany

PostPosted: Wed Sep 23, 2009 1:26 am    Post subject: Reply with quote

In fact, this is exactly what I'm doing in the Spicelib Reflection API, just look into the ClassInfo class. It even caches per ApplicationDomain so that you can purge the reflection cache for a single domain in case you are unloading a module for example.

But... for UIComponents and other heavy classes describeType is so slow that even with caching it is virtually impossible to walk the full inheritance tree for components. Application startup would be unacceptably slow then. Even without walking the inheritance tree it is sometimes necessary to skip the regular Parsley view wiring if there are too many components which get wired at the same time. I got this feedback from several people working on large applications. This really is a deficiency of how describeType works and I cannot do much about it. The Flash Player definitely needs a fast and efficient Reflection API.
_________________
Jens Halm
Spicefactory
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Spicefactory Forum Index -> Spicefactory - General Discussions All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group