Over a million developers have joined DZone.

AMF - Problems When Serializing Between Java and ActionScript

· Java Zone

Microservices! They are everywhere, or at least, the term is. When should you use a microservice architecture? What factors should be considered when making that decision? Do the benefits outweigh the costs? Why is everyone so excited about them, anyway?  Brought to you in partnership with IBM.

Below are some tips and tricks when dealing with serialization between Java and ActionScript. I’ve spent some time and encountered some frustrations (especially when I was too tired) trying to understand why the value is not properly sent over the wire so I decided to document all of my mistakes. Over the time I will edit this post to add new insights

  • if something seems wrong turn on debugging in services-config.xml
  • a property must have a public getter and setter in order to be serialized. I know that is strange (why should I have a setter when it’s not needed?) but that’s it. I do not like it all because sometimes it breaks encapsulation
  • you should take care to map the ActionScript class with the corresponding Java class using the metadata. For example [RemoteClass(alias="com.foo.model.MyClass")]
  • verify that the ActionScript object is included in the SWF file. If your project does not have a reference to the AS file then it will not be included in the resulting SWF so the Java class will be serialized to a generic object
  • you cannot serialize maps that have integers as keys See this bug
  • when serializing Hibernate entities be sure that all of them are initialized or use some kind of Open Session in View pattern - or better build a value object to contain only the data you really need.
  • a NULL number in Java is converted to 0 in ActionScript
  • a Long number from Java cannot be properly converted to Number in ActionScript - you will lose precision, so you should send it packed in a different way

From http://cornelcreanga.com/

Discover how the Watson team is further developing SDKs in Java, Node.js, Python, iOS, and Android to access these services and make programming easy. Brought to you in partnership with IBM.

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}