Can I create server-side Java classes, OR mapping, and client-side AS classes from a single model description?

StackOverflow https://stackoverflow.com/questions/1000163

Question

I have a Java server application and a Flex client application. For my data model, I have typical objects, like User etc., that are basically the same in the database, the server-side Java code and the client-side AS code. I. e., the public fields of my AS and Java classes are named identically, and have the same types and values as the respective fields in the database table which has the same name as those classes.

For the Java classes and the DB tables to match, I can use any ORM. Are there any tools to have the AS classes (and, ideally, the matching Remoting boilerplate code) autogenerated from the Java ones as well? I had a short look at BlazeDS, but it didn't seem to have tools like that, at least I couldn't find anything about it.

Of course, in a perfect world, I'd describe my data items once and have the DDL, Java code and AS code all autogenerated. Does such a tool exist, and is it usable enough?

Oh yeah, and it would be great if the source format could be protobuf files...

Note: This seems to be the same question as this one. The answers there seem to indicate that at least there's no common tool that "everybody uses" or that has a reputation for high quality.

Was it helpful?

OTHER TIPS

The only tools that I know of are for generating AS classes from server code are the wizards built into Flex builder for autogenerating AS remote classes from ColdFusion CFC's for use with a ColdFusion based AMF service.

What may be useful to remember though is that once the serialized object has been received by Flex and an instance of mx.utils.ObjectProxy has been created for it (this relates to the flex RemoteObject class and AMF based services, but I imagine that a Protocol Buffer extension would follow the same pattern), the process of casting the proxy to an Actionscript class isn't all that complicated. As long as your Actionscript class has properties or accessors with names that match the properties on the serialized object, and an Remote Object alias that matches the type of the serialized object, then you can cast the object proxy to the remote class without having to do any extra work.

Like I said, I'm not aware of a tool that does what you want, but It wouldn't be too difficult to create a tool to read the type and public properties from your Java classes, or extract that same metadata from your protocol buffer files, and write some Actionscript code off that Metadata. If you can't find a solution that fits your needs, you might consider writing an Ant task or a script or something to do it for you. Thats what I would do anyway.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top