J2ASTask

2005年11月22日(火) 12:14

JavaのクラスからFlexのRemote Service用のActionScriptを生成するantタスクをRevDBから切り出しました(バージョンアップもしてます0.1→0.2)。

The ant task which forms the ActionScript for the Remote Service of the Flex from class of Java was quarried out from the RevcDb, (doing also version rise, 0.1 where it increases -> 0.2).

(ものすごいJ2ASは、ここではなくて、こっちです。)


J2ASTaskの用途は、ものすごいJ2ASとは違い、Macromedia FlexのRemote Service限定です。
Remote Serviceで用いるJavaとのマッピングActionScriptは、プロパティとマッピング指定のみが必要で、かつ面倒くさい単純作業となるため作成しました。
Use of the J2ASTask is different from the tremendous J2AS, it is Remote Service limitation of the Macromedia Flex.
Only the property and mapping appointment being necessary, at the same time because it becomes troublesome monotonous work, it drew up the mapping ActionScript of the Java which is used with the Remote Service.

機能(Function)
  • 特定のパッケージに含まれる全てのJavaクラスをActionScriptに変換する
    All Java classes which are included in the package of specification are converted to the ActionScript
  • JavaクラスのパッケージをActionScript上のパッケージに変換する
    The package of Java class is converted to the package on the ActionScript
  • Javaの型をなんとなくActionScriptの型にする
    Type of the Java how it is not and makes type of the ActionScript
  • ActionScriptのプロパティ宣言の直上にJavaの型をコメントでメモとして出力する
    It outputs type of the Java to just above of property declaration of the ActionScript with comment as memo
  • ActionScriptファイルはワークディレクトリに書き出す(毎回上書きする)
    It writes out the ActionScript file in the work directory, (each time it superscribes)
必要な物(Requirements)
  • log4j-1.2.9.jar
  • commons-logging.jar
  • commons-io-1.1.jar
  • commons-collections-3.1.jar
  • velocity-1.4.jar
使用方法(usage)
antから使用します。
You use from the ant.

j2asタスクをbuild.xmlに宣言します

J2as task is declared to the build.xml
	<taskdef name="j2as"
classname="net.everes.j2as.ant.J2AsTask">
<classpath>
<pathelement location="./lib/J2AsTask-0.2.jar" />
<pathelement location="./lib/log4j-1.2.9.jar" />
<pathelement location="./lib/commons-logging.jar" />
<pathelement location="./lib/commons-io-1.1.jar" />
<pathelement location="./lib/commons-collections-3.1.jar" />
<pathelement location="./lib/velocity-1.4.jar" />
</classpath>
</taskdef>

j2asタスクをtargetに指定します

J2as task is appointed to the target
	<target name="j2as.model">
<j2as
work="./work"
classDir="./classes"
targetPackage="net.everes.j2as.model"
projectName="j2as"
packageMapping="net.everes.j2as.model:model,net.everes.j2as.data:data"
/>
</target>
  • work: ワークディレクトリ。ここにActionScriptファイルが生成されます。
    Work directory. The ActionScript file is formed here.
  • classDir: 対象のクラスの含まれるディレクトリを指定する(パッケージは含まない。クラスパス)
    Appoints the directory where class of object is included (the package is not included. CLASSPATH)
  • targetPackage: 対象のパッケージを指定する
    The package of the object is appointed
  • projectName: (省略可)JavaのプロパティがNumber,Boolean,Date,Listにマッピングできなかった場合に、Javaのクラス名に projectNameのパッケージが見つかった場合は、そのパッケージ文字列以降をActionScriptのクラス名としてマッピングする。
    (Abbreviation yes) the property of the Java when when in the Number, the Boolean, the Date and the List mapping it is not possible, the package of the projectName is found in class name of the Java, mapping it does with after that package character string as a class name of the ActionScript.
  • packageMapping:(省略可)JavaのクラスパッケージとActionScriptのクラスパッケージのマッピング情報を指定する。「:」で区切られたJavaのパッケージとActionScriptのパッケージペアを「,」で区切って複数指定可能
    (Abbreviation yes) mapping information of the package of the Java and the package of the ActionScript is appointed. ": " With ", " with dividing the package of the Java which was divided and the package pair of the ActionScript, plural designated possibilities
※親クラスを自動的にリバースしたりはしませんので、必要なだけj2asタスクタグを使用してください。
It's not reverses super class automatically, please use as much as the necessary j2as task tag.
※変換されるプロパティは、publicなアクセサを持つものだけです The property which is converted is the public just those which have accesser method.


Feedbacks

Tags