acceleoによるmodel2 text変換

30
Acceleo による Model2Text 変換 ©Actier, Inc. All rights reserved.

Upload: norihito-ohshima

Post on 16-Jul-2015

503 views

Category:

Technology


9 download

TRANSCRIPT

Page 1: Acceleoによるmodel2 text変換

Acceleo による Model2Text 変換

©Actier, Inc. All rights reserved.

Page 2: Acceleoによるmodel2 text変換

自己紹介

名前 : 大島則人

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

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

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

©Actier, Inc. All rights reserved.

Page 3: Acceleoによるmodel2 text変換

アジェンダ

Model2Text

サンプルに触れる

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

まとめ

©Actier, Inc. All rights reserved.

Page 4: Acceleoによるmodel2 text変換

©Actier, Inc. All rights reserved.

Model2Text

Page 5: Acceleoによるmodel2 text変換

Model2Text 変換とは?

©Actier, Inc. All rights reserved.

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

Page 6: Acceleoによるmodel2 text変換

Model2Text 変換とは?

©Actier, Inc. All rights reserved.

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

Page 7: Acceleoによるmodel2 text変換

Model2Text 変換とは?

©Actier, Inc. All rights reserved.

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

Page 8: Acceleoによるmodel2 text変換

Model2Text を利用すると

©Actier, Inc. All rights reserved.

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

Page 9: Acceleoによるmodel2 text変換

UML ツールにあるよね?

©Actier, Inc. All rights reserved.

有ります!

Page 10: Acceleoによるmodel2 text変換

UML ツールにあるよね?

©Actier, Inc. All rights reserved.

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

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

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

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

Page 11: Acceleoによるmodel2 text変換

※ 補足 : UML 以外のモデル

©Actier, Inc. All rights reserved.

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

Page 12: Acceleoによるmodel2 text変換

※ 補足 : UML 以外のモデル

©Actier, Inc. All rights reserved.

以下は UML の XMI 表現

Page 13: Acceleoによるmodel2 text変換

Acceleo の利用

©Actier, Inc. All rights reserved.

Page 14: Acceleoによるmodel2 text変換

Acceleo の利用

©Actier, Inc. All rights reserved.

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

OMG準拠/UMLと相性が良い

Page 15: Acceleoによるmodel2 text変換

©Actier, Inc. All rights reserved.

サンプルに触れる

Page 16: Acceleoによるmodel2 text変換

Acceleo 環境構築

©Actier, Inc. All rights reserved.

Page 17: Acceleoによるmodel2 text変換

Acceleo 環境構築

©Actier, Inc. All rights reserved.

Page 18: Acceleoによるmodel2 text変換

Acceleo 環境構築

©Actier, Inc. All rights reserved.

Page 19: Acceleoによるmodel2 text変換

Model2Text 変換デモ

©Actier, Inc. All rights reserved.

Page 20: Acceleoによるmodel2 text変換

©Actier, Inc. All rights reserved.

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

Page 21: Acceleoによるmodel2 text変換

Model2Text 変換の活用

©Actier, Inc. All rights reserved.

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

エンティティ

標準 CRUD サービス

DDL

クラス + UML Profile 拡張

Validation モジュール Factory

Page 22: Acceleoによるmodel2 text変換

Model2Text 変換の活用

©Actier, Inc. All rights reserved.

Page 23: Acceleoによるmodel2 text変換

Model2Text 変換の活用

©Actier, Inc. All rights reserved.

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

Hook Operation

サービステンプレート

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

Generation Gap

Page 24: Acceleoによるmodel2 text変換

Model2Text 変換の活用

©Actier, Inc. All rights reserved.

Page 25: Acceleoによるmodel2 text変換

Model2Text 変換の活用

©Actier, Inc. All rights reserved.

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

UML の拡張(外部DSL化)

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

Master / Transaction / Event / View

Page 26: Acceleoによるmodel2 text変換

Model2Text 変換の活用

©Actier, Inc. All rights reserved.

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

DI の Annotation 埋め込み

Flyweight / Builder パターン適用

Immutable オブジェクトの利用

Spring Framework の各種設定

Page 27: Acceleoによるmodel2 text変換

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);

}

}

Page 28: Acceleoによるmodel2 text変換

Model2Text 変換の活用

©Actier, Inc. All rights reserved.

開発環境の整備

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

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

Maven + Jenkins + SCM を活用

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

Page 29: Acceleoによるmodel2 text変換

©Actier, Inc. All rights reserved.

まとめ

Page 30: Acceleoによるmodel2 text変換

Model2Text 変換

©Actier, Inc. All rights reserved.

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

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

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