単一のモデル記述からサーバー側のJavaクラス、ORマッピング、およびクライアント側のASクラスを作成できますか?

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

質問

JavaサーバーアプリケーションとFlexクライアントアプリケーションがあります。私のデータモデルには、データベースなど、サーバー側のJavaコードとクライアント側のASコードで基本的に同じであるUserなどの典型的なオブジェクトがあります。つまり、ASクラスとJavaクラスのパブリックフィールドの名前は同じであり、それらのクラスと同じ名前のデータベーステーブル内のそれぞれのフィールドと同じタイプと値を持っています。

JavaクラスとDBテーブルを一致させるには、任意のORMを使用できます。 Javaクラスから自動生成されたASクラス(および理想的には一致するRemotingボイラープレートコード)を持つツールはありますか? BlazeDS を少し見ましたが、そのようなツールがありますが、少なくとも私はそれについて何も見つけることができませんでした。

もちろん、完璧な世界では、データ項目を一度記述し、DDL、Javaコード、ASコードをすべて自動生成します。そのようなツールは存在し、十分に使用可能ですか?

ああ、ソース形式がprotobufファイルになれば素晴らしいと思います...

注: これはこれ。そこの答えは、少なくとも「誰もが使用する」一般的なツールがないことを示しているようです。または、高品質で評判が高い。

役に立ちましたか?

他のヒント

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top