flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: FlexJS:Reflection API
Date Tue, 21 Feb 2017 08:19:13 GMT
I agree with Greg.

In regular Flex, the [RemoteClass] metadata causes the compiler to call
registerClassAlias for you.  The FlexJS compilers do not do that, and I
would like to avoid that, because it might register classes too early (at
startup, instead of just-in-time before deserialization) and it might make
classes available for deserialization that you didn't intend to make
available, which further exposes you to hacking.

In theory, all of the types involved in deserializing an AMF payload are
known and available to the AMF library.  So the FlexJS AMF Library may
need a "registerClasses" API where you pass in the top-level data
structure and it uses the Reflection APIs to introspect the data types and
call registerClassAlias them.

But then, in the actual AMF decoding, I would not expect calls to
registerClassAlias, only getClassByAlias.


On 2/20/17, 12:26 PM, "Greg Dove" <greg.dove@gmail.com> wrote:

>> Regarding,
>> registerClassAlias(unTypeObject['_explicitType'],
>> getClassByAlias(unTypeObject['_explicitType']))
>> - I am getting the data from blazeDs and blazeDS adding the
>> to every object.
>Great - I assume _explicitType is the alias used to retrieve the class
>clientside, this seems clear to me.
>> - I am just picking "_explicitType" and registering that class using
>> registerClassAlias()
>Using registerClassAlias here is what seems unusual to me.
>registerClassAlias normally occurs early in an application startup or at
>some point before any amf data has been received from any remote server.
>registerClassAlias needs to be done *before* getClassByAlias will work, so
>it does not seem correct to use getClassByAlias inside a
>call (it should return null if the alias is not already registered).
>> - Same _explicitType class, i am having inside my project in same
>> structure.
>> - One point to note here is that i added registerClassAlias inside my
>> library not in main application. means library project not having the
>> "_explicitType" class.
>I hope I have understood what you are doing correctly.
>I would not expect registerClassAlias to be used inside the amf library -
>don't think that is close to the original functionality in flash player
>amf deserialization.
>I would expect an amf library to perhaps use getClassByAlias, but not
>registerClassAlias. In a traditional Flex 4 project, registerClassAlias
>should happen before any amf remoting activity as well. In Flex 4 (and
>earlier Flex) registerClassAlias was often implemented by metadata on the
>class and early reference to the class in terms of dependencies, which I
>suspect ran the registerClassAlias code in a static initializer, before
>amf deserialization takes place.
>Maybe there are some javascript tricks for converting/casting an untyped
>object to a typed object without instantiating anything new that I don't
>know about because I am unfamiliar, but if not then I expect the most
>efficient implementation would include an attempt to getClassByAlias from
>the explictType data at a lower level inside the amf library code, before
>the 'unTypeObject' js object is created from the amf data. If
>getClassByAlias returns a class (and not null) then it would be preferable
>to instantiate that class and populate the instance fields directly
>of creating a generic js object and adding _explicitType field (which is
>then later replaced with the typed object after inspecting _explicitType
>value and attempting getClassByAlias).
>However, this deeper level of integration is probably easier to do in a
>future custom FlexJS implementation for amf, unless the library you are
>using has a configurable runtime override of what it in instantiates for
>the alias information it receives, instead of simply creating a new
>object every time.
>If I have made this sound too complicated, sorry I was trying not to.
>Please ask me to clarify any of my points if this does not seem clear.
>Perhaps I have the wrong interpretation of what you are doing and none of
>this is relevant.
>I hope to get back to some work on FlexJS soon and perhaps I can look at a
>custom amf implementation in the js side as part of the framework if
>else has gotten to it yet.
>> -----
>> Regards,
>> Prashant
>> --
>> View this message in context: http://apache-flex-users.
>> 2333346.n4.nabble.com/FlexJS-Reflection-API-tp14701p14711.html
>> Sent from the Apache Flex Users mailing list archive at Nabble.com.

View raw message