RE: [flexcoders] Java enum in Flex3
Thanks, Seth. I'd read the article, but your e-mail clarifies the issues. I've looked over our usage and I think we're safe for now, but this is sort of a time bomb, and it might make sense to fall back to just Strings. The only alternative I see is ensuring to use .equals() everywhere, which is tricky, especially when dealing with collections and other data structures (since they'll already be using the standard '==' equality checks). -- Maciek Sakrejda Truviso, Inc. http://www.truviso.com -Original Message- From: Seth Hodgson Reply-To: flexcoders@yahoogroups.com To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Java enum in Flex3 Date: Wed, 4 Feb 2009 21:14:29 -0800 Hi Maciek, I don't know anything about Granite Data Services but a quick google search returns this: http://www.graniteds.org/jira/browse/GDS-228 The reason why they're getting multiple instances of their "enum" AS classes during deserialization is layed out in the post I linked to below - without a readResolve() hook in the Player there's no way to support reading singletons out of the AMF stream. This means that you have potentially many duplicate instances of each enum value floating around in the AVM. It looks like they've defined an equals() method as an attempt to work around this, but while that's a standard method defined on Java's base Object class there is no equals() method defined in the core ECMAScript/ActionScript libraries. If I were using client side enums in ActionScript, I'd expect simple equality checks to work correctly and they won't with this approach. Each of these classes will also add a bit to your swf size, but that's a minor concern unless you're using tons of enums :) I don't know what other value these classes may provide, perhaps some help with data validation, but be careful in your code anywhere you're expecting them to actually be singletons because they generally won't be. Best, Seth From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Maciek Sakrejda Sent: Wednesday, February 04, 2009 5:38 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Java enum in Flex3 Interesting. Any thoughts on Granite Data Services' approach? There is a custom externalization process for Java Enum objects, and a granite Enum class in ActionScript that all your (generated) Enums extend. The enum class takes care of reading/writing. The writeExternal() method just writes the name of the Enum; readExternal() tries to find the name of the object in the constants defined by the Enum. The RemoteAlias metadata is set up as for a standard Java class. Are we asking for trouble in using this method? Is there something inherently dangerous here? -- Maciek Sakrejda Truviso, Inc. http://www.truviso.com -Original Message- From: Seth Hodgson Reply-To: flexcoders@yahoogroups.com To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Java enum in Flex3 Date: Wed, 4 Feb 2009 16:20:33 -0800 BlazeDS and LCDS roundtrip Java enums to the client and back as Strings. That's the only good option at present, and here's an in-depth explanation: http://greetingsfromoakland.blogspot.com/2009/02/enums.html Best, Seth From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of sunmoorthy1 Sent: Monday, December 29, 2008 1:18 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Java enum in Flex3 How to convert java enum values into Flex3 object. Any one went thru this problem? Please give your experties? Sundar
Re: [flexcoders] Java enum in Flex3
I'm kicking off a blaze-ds project this weekend, and I'll be doing typesafe java<->flex enums, when I figure it out I'll blog about it and post it here :) It'll probably just require a small amount of custom unmarshalling code, there's a lot of undocumented flexibility in mx.rpc.* -Josh Thu, Feb 5, 2009 at 11:37 AM, Maciek Sakrejda wrote: > Interesting. Any thoughts on Granite Data Services' approach? There is a > custom externalization process for Java Enum objects, and a granite Enum > class in ActionScript that all your (generated) Enums extend. The enum > class takes care of reading/writing. The writeExternal() method just > writes the name of the Enum; readExternal() tries to find the name of > the object in the constants defined by the Enum. The RemoteAlias > metadata is set up as for a standard Java class. > > Are we asking for trouble in using this method? Is there something > inherently dangerous here? > -- > Maciek Sakrejda > Truviso, Inc. > http://www.truviso.com > > > -Original Message- > From: Seth Hodgson > > Reply-To: flexcoders@yahoogroups.com > To: flexcoders@yahoogroups.com < > flexcoders@yahoogroups.com > > Subject: RE: [flexcoders] Java enum in Flex3 > Date: Wed, 4 Feb 2009 16:20:33 -0800 > > BlazeDS and LCDS roundtrip Java enums to the client and back as Strings. > That's the only good option at present, and here's an in-depth > explanation: http://greetingsfromoakland.blogspot.com/2009/02/enums.html > > Best, > Seth > > From: flexcoders@yahoogroups.com [mailto: > flexcoders@yahoogroups.com ] On > Behalf Of sunmoorthy1 > Sent: Monday, December 29, 2008 1:18 PM > To: flexcoders@yahoogroups.com > Subject: [flexcoders] Java enum in Flex3 > > How to convert java enum values into Flex3 object. > Any one went thru this problem? > Please give your experties? > > Sundar > > > -- "Therefore, send not to know For whom the bell tolls. It tolls for thee." Josh 'G-Funk' McDonald - j...@joshmcdonald.info - http://twitter.com/sophistifunk - http://flex.joshmcdonald.info/
RE: [flexcoders] Java enum in Flex3
Hi Maciek, I don't know anything about Granite Data Services but a quick google search returns this: http://www.graniteds.org/jira/browse/GDS-228 The reason why they're getting multiple instances of their "enum" AS classes during deserialization is layed out in the post I linked to below - without a readResolve() hook in the Player there's no way to support reading singletons out of the AMF stream. This means that you have potentially many duplicate instances of each enum value floating around in the AVM. It looks like they've defined an equals() method as an attempt to work around this, but while that's a standard method defined on Java's base Object class there is no equals() method defined in the core ECMAScript/ActionScript libraries. If I were using client side enums in ActionScript, I'd expect simple equality checks to work correctly and they won't with this approach. Each of these classes will also add a bit to your swf size, but that's a minor concern unless you're using tons of enums :) I don't know what other value these classes may provide, perhaps some help with data validation, but be careful in your code anywhere you're expecting them to actually be singletons because they generally won't be. Best, Seth From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Maciek Sakrejda Sent: Wednesday, February 04, 2009 5:38 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Java enum in Flex3 Interesting. Any thoughts on Granite Data Services' approach? There is a custom externalization process for Java Enum objects, and a granite Enum class in ActionScript that all your (generated) Enums extend. The enum class takes care of reading/writing. The writeExternal() method just writes the name of the Enum; readExternal() tries to find the name of the object in the constants defined by the Enum. The RemoteAlias metadata is set up as for a standard Java class. Are we asking for trouble in using this method? Is there something inherently dangerous here? -- Maciek Sakrejda Truviso, Inc. http://www.truviso.com -Original Message- From: Seth Hodgson Reply-To: flexcoders@yahoogroups.com To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Java enum in Flex3 Date: Wed, 4 Feb 2009 16:20:33 -0800 BlazeDS and LCDS roundtrip Java enums to the client and back as Strings. That's the only good option at present, and here's an in-depth explanation: http://greetingsfromoakland.blogspot.com/2009/02/enums.html Best, Seth From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of sunmoorthy1 Sent: Monday, December 29, 2008 1:18 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Java enum in Flex3 How to convert java enum values into Flex3 object. Any one went thru this problem? Please give your experties? Sundar
RE: [flexcoders] Java enum in Flex3
Interesting. Any thoughts on Granite Data Services' approach? There is a custom externalization process for Java Enum objects, and a granite Enum class in ActionScript that all your (generated) Enums extend. The enum class takes care of reading/writing. The writeExternal() method just writes the name of the Enum; readExternal() tries to find the name of the object in the constants defined by the Enum. The RemoteAlias metadata is set up as for a standard Java class. Are we asking for trouble in using this method? Is there something inherently dangerous here? -- Maciek Sakrejda Truviso, Inc. http://www.truviso.com -Original Message- From: Seth Hodgson Reply-To: flexcoders@yahoogroups.com To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Java enum in Flex3 Date: Wed, 4 Feb 2009 16:20:33 -0800 BlazeDS and LCDS roundtrip Java enums to the client and back as Strings. That's the only good option at present, and here's an in-depth explanation: http://greetingsfromoakland.blogspot.com/2009/02/enums.html Best, Seth From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of sunmoorthy1 Sent: Monday, December 29, 2008 1:18 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Java enum in Flex3 How to convert java enum values into Flex3 object. Any one went thru this problem? Please give your experties? Sundar
RE: [flexcoders] Java enum in Flex3
BlazeDS and LCDS roundtrip Java enums to the client and back as Strings. That's the only good option at present, and here's an in-depth explanation: http://greetingsfromoakland.blogspot.com/2009/02/enums.html Best, Seth From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of sunmoorthy1 Sent: Monday, December 29, 2008 1:18 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Java enum in Flex3 How to convert java enum values into Flex3 object. Any one went thru this problem? Please give your experties? Sundar