qickrooms / flex-mojos

Automatically exported from code.google.com/p/flex-mojos
0 stars 0 forks source link

mojo-generator: (new feature) support for custom type mappings #66

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
GAS3 lets users specify a AS3 type factory that can be used to customize
the type mapping between Java and AS3 types. It would be nice if users of
flex-mojo could make use of this very powerful feature, too.

The attached patch implements a typeMappings configuration parameter that
lets users specify any number of mappings from Java class to AS3 class. The
typeMappings parameter is not typed as java.util.Map because that would
make the POM XML a little cumbersome. For example, 

<typeMappings>
    <some.very.deep.package.SomeLongClassName>
        mx.util.Foo
    </some.very.deep.package.SomeLongClassName>
</typeMappings

Instead, this patch implements the typeMappings parameter as a string
array, each string being a pair of class names separated by whitespace:

<typeMappings>
    <mappping>
        some.very.deep.package.SomeLongClassName mx.util.Foo
    </mapping>
</typeMappings

Some more background info on why this feature is be needed:

In some cases GAS3 generates GaniteDS-specific ActionScript code. For
example, any property typed as java.util.Map is mapped to an AS3 property
typed as org.granite.collections.IMap. The generated code would not work
with BlazeDS because BlazDS serializes java.util.Map as an Object with
dynamic properties for each map entry. Using the typeMappings feature we
can work around this problem by overriding the AS3 type for java.util.Map
to be Object:

<typeMappings>
    <mapping>java.util.Map Object</mapping>
</typeMappings>

With this mapping the generated code works with BlazeDS.

Original issue reported on code.google.com by Hannes.S...@gmail.com on 8 Jul 2008 at 12:45

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by velo...@gmail.com on 8 Jul 2008 at 1:44

GoogleCodeExporter commented 9 years ago
Done at revision 563

Original comment by velo...@gmail.com on 8 Jul 2008 at 1:45

GoogleCodeExporter commented 9 years ago
Hi Velo,

thanks for applying my patches that quickly! It's a pleasure to be working with 
you.
Can I ask you one more favor? Would it be possible to release
generator-mojo-2.0-alpha3 anytime soon? Or do you have a public snapshot 
repository
where we can get generator-mojo-2.0-alpha3-SNAPSHOT from?

If you have any questions you can reach me 

H a n n e s . S c h m i d t A T g m a i l . c o m

-- Hannes

Original comment by Hannes.S...@gmail.com on 8 Jul 2008 at 6:27

GoogleCodeExporter commented 9 years ago
Hi ,
I am using Blazeds and using granite -gas to generate my VO classes.
Creating hashmaps in java and the corresponding variable in actionscript is 
IMap.
Can I somhow make it work with blazeds??
Right now I get bind error:TypeError: Error #1034: Type Coercion failed: cannot
convert Object@4447f39 to org.granite.collections.IMap.
Thanks,Mittul.

Original comment by mitt...@gmail.com on 23 Nov 2009 at 6:31