You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by PKumar <pr...@gmail.com> on 2017/02/19 14:25:33 UTC

FlexJS:Reflection API

Hi,

I am using the "registerClassAlias" in my AMFlibrary,but getting the below
mentioned error on compilation. Also getting the reference  error inside
"registerClassAlias". Please check & suggest.

*registerClassAlias(unTypeObject['_explicitType'],getClassByAlias(unTypeObject['_explicitType']));*


Feb 19, 2017 7:53:17 PM com.google.javascript.jscomp.LoggerErrorManager
println
SEVERE:
E:/FlexJSWorkspace/TestAMFJS/bin/js-debug/org/apache/flex/reflection/AccessorDefinition.js:12:
ERROR - required "org.apache.flex.reflection.TypeDefinition" namespace not
provided yet
goog.require('org.apache.flex.reflection.TypeDefinition');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Feb 19, 2017 7:53:17 PM com.google.javascript.jscomp.LoggerErrorManager
println
SEVERE:
E:/FlexJSWorkspace/TestAMFJS/bin/js-debug/org/apache/flex/reflection/AccessorDefinition.js:13:
ERROR - required "org.apache.flex.reflection.VariableDefinition" namespace
not provided yet
goog.require('org.apache.flex.reflection.VariableDefinition');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Feb 19, 2017 7:53:17 PM com.google.javascript.jscomp.LoggerErrorManager
println
SEVERE:
E:/FlexJSWorkspace/TestAMFJS/bin/js-debug/org/apache/flex/reflection/MethodDefinition.js:14:
ERROR - required "org.apache.flex.reflection.TypeDefinition" namespace not
provided yet
goog.require('org.apache.flex.reflection.TypeDefinition');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Feb 19, 2017 7:53:17 PM com.google.javascript.jscomp.LoggerErrorManager
println
SEVERE:
E:/FlexJSWorkspace/TestAMFJS/bin/js-debug/org/apache/flex/reflection/ParameterDefinition.js:13:
ERROR - required "org.apache.flex.reflection.TypeDefinition" namespace not
provided yet
goog.require('org.apache.flex.reflection.TypeDefinition');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Feb 19, 2017 7:53:17 PM com.google.javascript.jscomp.LoggerErrorManager
println
SEVERE:
E:/FlexJSWorkspace/TestAMFJS/bin/js-debug/org/apache/flex/reflection/TypeDefinition.js:15:
ERROR - required "org.apache.flex.reflection.VariableDefinition" namespace
not provided yet
goog.require('org.apache.flex.reflection.VariableDefinition');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Feb 19, 2017 7:53:17 PM com.google.javascript.jscomp.LoggerErrorManager
printSummary
WARNING: 5 error(s), 0 warning(s)
The project 'TestAMFJS' has been successfully compiled and optimized.
E:\FlexJSWorkspace\TestAMFJS\libs\AMFService.swc The definition Event
depended on by flexjs.amf.events.FaultEvent in the SWC
E:\FlexJSWorkspace\TestAMFJS\libs\AMFService.swc could not be found


E:\FlexJSWorkspace\TestAMFJS\libs\AMFService.swc The definition window
depended on by flexjs.amf.AMFService in the SWC
E:\FlexJSWorkspace\TestAMFJS\libs\AMFService.swc could not be found


E:\FlexJSWorkspace\TestAMFJS\libs\AMFService.swc The definition Event
depended on by flexjs.amf.events.ResultEvent in the SWC
E:\FlexJSWorkspace\TestAMFJS\libs\AMFService.swc could not be found


14.571596851 seconds



-----
Regards,
Prashant
--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/FlexJS-Reflection-API-tp14701.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: FlexJS:Reflection API

Posted by Alex Harui <ah...@adobe.com>.

On 2/22/17, 10:59 AM, "PKumar" <pr...@gmail.com> wrote:

>As suggested, I am planning to create one class for handling the
>rgisterClassAlias related code. This class will hold array of VO class &
>alias name that need to register for AMF de-serialization. I will call
>registerClassAlias on same array before calling blazeDS call.

That's fine for starters, but IMO, it would be a bonus if you could
introspect the top-level class and find all the sub-types via Reflection.
That would reduce pain on the developers forgetting to add one of their
sub-types to the list.

Thanks,
-Alex


Re: FlexJS:Reflection API

Posted by PKumar <pr...@gmail.com>.
As suggested, I am planning to create one class for handling the
rgisterClassAlias related code. This class will hold array of VO class &
alias name that need to register for AMF de-serialization. I will call
registerClassAlias on same array before calling blazeDS call.

Regards,
Prashant



-----
Regards,
Prashant
--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/FlexJS-Reflection-API-tp14701p14722.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: FlexJS:Reflection API

Posted by Alex Harui <ah...@adobe.com>.

On 2/21/17, 10:28 AM, "PKumar" <pr...@gmail.com> wrote:

>Thanks for clarification Alex & Greg,
>
>I have resolve this issue. I have removed the registerClassAlias code from
>library and placed it in Main application.
>
>one question, i want to ask here is,
>
>is it possible to implement "[RemoteClass]" metadata in FlexJS?
>

You can add the [RemoteClass] metadata to your ValueObjects and use the
Reflection APIs to find out if a class has that metadata and what value it
has.  I don't want to have the compiler generate the registerClassAlias
call like it used to for Flex.  IMO, that is a framework-level thing.  The
compiler should not presume when those calls should be made.

I think the cost of adding [RemoteClass] to Basic Collections is still
PAYG.  It should all go in the reflection structure that is only kept in
the output if someone is using Reflection APIs.

Then the next decision is to figure out the best way to call
registerClassAlias on the classes involved.  As I mentioned in my last
post, I think it would be reasonable for folks to have to register the
top-level class and have framework code introspect that class and make the
appropriate registerClassAlias calls.

My 2 cents,
-Alex


Re: FlexJS:Reflection API

Posted by PKumar <pr...@gmail.com>.
Thanks for clarification Alex & Greg,

I have resolve this issue. I have removed the registerClassAlias code from
library and placed it in Main application.

one question, i want to ask here is,

is it possible to implement "[RemoteClass]" metadata in FlexJS? 



-----
Regards,
Prashant
--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/FlexJS-Reflection-API-tp14701p14716.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: FlexJS:Reflection API

Posted by Alex Harui <ah...@adobe.com>.
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.

HTH,
-Alex

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

>>
>> Regarding,
>> registerClassAlias(unTypeObject['_explicitType'],
>> getClassByAlias(unTypeObject['_explicitType']))
>>
>> - I am getting the data from blazeDs and blazeDS adding the
>>"_explicitType"
>> 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
>registerClassAlias
>call (it should return null if the alias is not already registered).
>
>
>
>
>> - Same _explicitType class, i am having inside my project in same
>>package
>> structure.
>> - One point to note here is that i added registerClassAlias inside my
>>AMF
>> 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 -
>I
>don't think that is close to the original functionality in flash player
>for
>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
>any
>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
>instead
>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
>generic
>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
>no-one
>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.
>>


Re: FlexJS:Reflection API

Posted by Greg Dove <gr...@gmail.com>.
>
> Regarding,
> registerClassAlias(unTypeObject['_explicitType'],
> getClassByAlias(unTypeObject['_explicitType']))
>
> - I am getting the data from blazeDs and blazeDS adding the "_explicitType"
> 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 registerClassAlias
call (it should return null if the alias is not already registered).




> - Same _explicitType class, i am having inside my project in same package
> structure.
> - One point to note here is that i added registerClassAlias inside my AMF
> 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 - I
don't think that is close to the original functionality in flash player for
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 any
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 instead
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 generic
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 no-one
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.
>

Re: FlexJS:Reflection API

Posted by PKumar <pr...@gmail.com>.
Greg,

Regarding,
registerClassAlias(unTypeObject['_explicitType'],
getClassByAlias(unTypeObject['_explicitType'])) 

- I am getting the data from blazeDs and blazeDS adding the "_explicitType"
to every object. 
- I am just picking "_explicitType" and registering that class using
registerClassAlias()
- Same _explicitType class, i am having inside my project in same package
structure.
- One point to note here is that i added registerClassAlias inside my AMF
library not in main application. means library project not having the
"_explicitType" class.






-----
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.

Re: FlexJS:Reflection API

Posted by Greg Dove <gr...@gmail.com>.
registerClassAlias(unTypeObject['_explicitType'],
getClassByAlias(unTypeObject['_explicitType']))


Aside  from the issue with TypeDefinition being missing, I think the class
aliases should be declared explicitly elsewhere. Using

registerClassAlias("vopackage.MyVo",vopackage.MyVo);

I don't think [RemoteClass] metadata was set up for Falconjx yet to do this
(unless Alex or someone else did it) so that means doing this explicitly in
code somewhere early in code before first use for amf deserialization
purposes. Then it should be

getClassByAlias(unTypeObject['_explicitType']) during deserialization to
retrieve the related class, instantiate and populate fields etc. I would
not expect to see registerclassalias used in this way above (unless I
really misunderstand what is the intention here)

-Greg
[sent from my phone]

On 20/02/2017 4:51 AM, "Alex Harui" <ah...@adobe.com> wrote:

>
>
> On 2/19/17, 7:17 AM, "PKumar" <pr...@gmail.com> wrote:
>
> >Do i  need to include it explicitly? i am using the flash Builder 4.7 to
> >develop library project.
>
> Hopefully not.  It looks like your problem is in building the JS version.
> Are you using the Launch Configurations to build the JS version?  If so,
> post a link to the entire console output.  It will show what SWCs it used.
>
> HTH,
> -Alex
>
>

Re: FlexJS:Reflection API

Posted by Alex Harui <ah...@adobe.com>.
Hi Prashant,

Try adding -remove-circulars compiler option to JS compile.

Thanks,
-Alex

On 2/20/17, 10:18 AM, "PKumar" <pr...@gmail.com> wrote:

>Alex,
>
>Please check the attached console output.
>
>Error.txt
><http://apache-flex-users.2333346.n4.nabble.com/file/n14712/Error.txt>
>
>
>
>-----
>Regards,
>Prashant
>--
>View this message in context:
>http://apache-flex-users.2333346.n4.nabble.com/FlexJS-Reflection-API-tp147
>01p14712.html
>Sent from the Apache Flex Users mailing list archive at Nabble.com.


Re: FlexJS:Reflection API

Posted by PKumar <pr...@gmail.com>.
Alex,

Please check the attached console output.

Error.txt
<http://apache-flex-users.2333346.n4.nabble.com/file/n14712/Error.txt>  



-----
Regards,
Prashant
--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/FlexJS-Reflection-API-tp14701p14712.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: FlexJS:Reflection API

Posted by Alex Harui <ah...@adobe.com>.

On 2/19/17, 7:17 AM, "PKumar" <pr...@gmail.com> wrote:

>Do i  need to include it explicitly? i am using the flash Builder 4.7 to
>develop library project.

Hopefully not.  It looks like your problem is in building the JS version.
Are you using the Launch Configurations to build the JS version?  If so,
post a link to the entire console output.  It will show what SWCs it used.

HTH,
-Alex


Re: FlexJS:Reflection API

Posted by PKumar <pr...@gmail.com>.
Do i  need to include it explicitly? i am using the flash Builder 4.7 to
develop library project.



-----
Regards,
Prashant
--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/FlexJS-Reflection-API-tp14701p14704.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: FlexJS:Reflection API

Posted by Alex Harui <ah...@adobe.com>.
Are you sure the Reflection.swc is in the -library-path?

-Alex

On 2/19/17, 6:25 AM, "PKumar" <pr...@gmail.com> wrote:

>Hi,
>
>I am using the "registerClassAlias" in my AMFlibrary,but getting the below
>mentioned error on compilation. Also getting the reference  error inside
>"registerClassAlias". Please check & suggest.
>
>*registerClassAlias(unTypeObject['_explicitType'],getClassByAlias(unTypeOb
>ject['_explicitType']));*
>
>
>Feb 19, 2017 7:53:17 PM com.google.javascript.jscomp.LoggerErrorManager
>println
>SEVERE:
>E:/FlexJSWorkspace/TestAMFJS/bin/js-debug/org/apache/flex/reflection/Acces
>sorDefinition.js:12:
>ERROR - required "org.apache.flex.reflection.TypeDefinition" namespace not
>provided yet
>goog.require('org.apache.flex.reflection.TypeDefinition');
>^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>Feb 19, 2017 7:53:17 PM com.google.javascript.jscomp.LoggerErrorManager
>println
>SEVERE:
>E:/FlexJSWorkspace/TestAMFJS/bin/js-debug/org/apache/flex/reflection/Acces
>sorDefinition.js:13:
>ERROR - required "org.apache.flex.reflection.VariableDefinition" namespace
>not provided yet
>goog.require('org.apache.flex.reflection.VariableDefinition');
>^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>Feb 19, 2017 7:53:17 PM com.google.javascript.jscomp.LoggerErrorManager
>println
>SEVERE:
>E:/FlexJSWorkspace/TestAMFJS/bin/js-debug/org/apache/flex/reflection/Metho
>dDefinition.js:14:
>ERROR - required "org.apache.flex.reflection.TypeDefinition" namespace not
>provided yet
>goog.require('org.apache.flex.reflection.TypeDefinition');
>^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>Feb 19, 2017 7:53:17 PM com.google.javascript.jscomp.LoggerErrorManager
>println
>SEVERE:
>E:/FlexJSWorkspace/TestAMFJS/bin/js-debug/org/apache/flex/reflection/Param
>eterDefinition.js:13:
>ERROR - required "org.apache.flex.reflection.TypeDefinition" namespace not
>provided yet
>goog.require('org.apache.flex.reflection.TypeDefinition');
>^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>Feb 19, 2017 7:53:17 PM com.google.javascript.jscomp.LoggerErrorManager
>println
>SEVERE:
>E:/FlexJSWorkspace/TestAMFJS/bin/js-debug/org/apache/flex/reflection/TypeD
>efinition.js:15:
>ERROR - required "org.apache.flex.reflection.VariableDefinition" namespace
>not provided yet
>goog.require('org.apache.flex.reflection.VariableDefinition');
>^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>Feb 19, 2017 7:53:17 PM com.google.javascript.jscomp.LoggerErrorManager
>printSummary
>WARNING: 5 error(s), 0 warning(s)
>The project 'TestAMFJS' has been successfully compiled and optimized.
>E:\FlexJSWorkspace\TestAMFJS\libs\AMFService.swc The definition Event
>depended on by flexjs.amf.events.FaultEvent in the SWC
>E:\FlexJSWorkspace\TestAMFJS\libs\AMFService.swc could not be found
>
>
>E:\FlexJSWorkspace\TestAMFJS\libs\AMFService.swc The definition window
>depended on by flexjs.amf.AMFService in the SWC
>E:\FlexJSWorkspace\TestAMFJS\libs\AMFService.swc could not be found
>
>
>E:\FlexJSWorkspace\TestAMFJS\libs\AMFService.swc The definition Event
>depended on by flexjs.amf.events.ResultEvent in the SWC
>E:\FlexJSWorkspace\TestAMFJS\libs\AMFService.swc could not be found
>
>
>14.571596851 seconds
>
>
>
>-----
>Regards,
>Prashant
>--
>View this message in context:
>http://apache-flex-users.2333346.n4.nabble.com/FlexJS-Reflection-API-tp147
>01.html
>Sent from the Apache Flex Users mailing list archive at Nabble.com.