Acceleoによるmodel2 text変換

Preview:

Citation preview

Acceleo による Model2Text 変換

©Actier, Inc. All rights reserved.

自己紹介

名前 : 大島則人

所属 : 株式会社アクティア 代表取締役社長

URL : http://www.actier.co.jp

技術領域Java アーキテクトモデル駆動型ソフトウェア開発

©Actier, Inc. All rights reserved.

アジェンダ

Model2Text

サンプルに触れる

株式会社アクティアでの取り組み

まとめ

©Actier, Inc. All rights reserved.

©Actier, Inc. All rights reserved.

Model2Text

Model2Text 変換とは?

©Actier, Inc. All rights reserved.

モデルの情報を読み取り!

Model2Text 変換とは?

©Actier, Inc. All rights reserved.

“プログラム” を利用して

Model2Text 変換とは?

©Actier, Inc. All rights reserved.

テキストファイルを作る!

Model2Text を利用すると

©Actier, Inc. All rights reserved.

UML で作成したクラスモデルをそのままコードに変換できる

UML ツールにあるよね?

©Actier, Inc. All rights reserved.

有ります!

UML ツールにあるよね?

©Actier, Inc. All rights reserved.

Model2Text 変換プログラムを使うのはなぜ?

1) UML等のツール依存の問題

2) UML 以外のモデルをサポートできない

3) 自動ビルドのフローに乗せにくい

※ 補足 : UML 以外のモデル

©Actier, Inc. All rights reserved.

MOF XMI を使ってテキスト表現できるものを”モデル”として扱える

※ 補足 : UML 以外のモデル

©Actier, Inc. All rights reserved.

以下は UML の XMI 表現

Acceleo の利用

©Actier, Inc. All rights reserved.

Acceleo の利用

©Actier, Inc. All rights reserved.

OMG が定めた Model Transformation Language の実装!

OMG準拠/UMLと相性が良い

©Actier, Inc. All rights reserved.

サンプルに触れる

Acceleo 環境構築

©Actier, Inc. All rights reserved.

Acceleo 環境構築

©Actier, Inc. All rights reserved.

Acceleo 環境構築

©Actier, Inc. All rights reserved.

Model2Text 変換デモ

©Actier, Inc. All rights reserved.

©Actier, Inc. All rights reserved.

株式会社アクティアでの取り組み

Model2Text 変換の活用

©Actier, Inc. All rights reserved.

UML クラス設計からの Java ソースコード生成

エンティティ

標準 CRUD サービス

DDL

クラス + UML Profile 拡張

Validation モジュール Factory

Model2Text 変換の活用

©Actier, Inc. All rights reserved.

Model2Text 変換の活用

©Actier, Inc. All rights reserved.

ビジネスロジックは自分でコーディング

Hook Operation

サービステンプレート

作成したロジックを上書きしない工夫

Generation Gap

Model2Text 変換の活用

©Actier, Inc. All rights reserved.

Model2Text 変換の活用

©Actier, Inc. All rights reserved.

UMLクラス => Java クラスとしない工夫

UML の拡張(外部DSL化)

エンティティタイプ毎に CRUD サービス実装を切り替え

Master / Transaction / Event / View

Model2Text 変換の活用

©Actier, Inc. All rights reserved.

適用したいコード規約に準拠

DI の Annotation 埋め込み

Flyweight / Builder パターン適用

Immutable オブジェクトの利用

Spring Framework の各種設定

Model2Text 変換の活用

©Actier, Inc. All rights reserved.

Flyweight パターン

public class 受注ID {

private static final List<受注ID> cache;

private final String value;

private 受注ID(String value) {

this.value = value;

} // コンストラクタ利用禁止

public static final 受注ID build(String value) {

// cache があれば cache から返すreturn new 受注ID(value);

}

}

Model2Text 変換の活用

©Actier, Inc. All rights reserved.

開発環境の整備

ビルドプロセスでコード生成

仕様変更による影響を継続チェック

Maven + Jenkins + SCM を活用

生成コードのバージョン管理(タグ付け)

©Actier, Inc. All rights reserved.

まとめ

Model2Text 変換

©Actier, Inc. All rights reserved.

UML等のXMI表現されたモデルを入力とするテンプレート変換

入力モデルは XML 表現ができれば良い→ Excel / JSON => 独自PG => XML でも活用可能

テキストに変換するだけの仕組みでしかない→ 活用方法は十分な検討が必要