UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009)

Synthesis of State Machine from Communication Diagrams by Using Petri Nets

T. Miyamoto†,H.Kurahata†, T. Fujii‡, R. Hosokawa‡

†Osaka University, Japan ‡Osaka Gas Information System Research Institute, Japan

c 2009 T. Miyamoto, Osaka University 1/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Outline

1 Introduction

2 Choreography Realization

3 Construct State Machine by Using Petri Nets

4 Conclusions

c 2009 T. Miyamoto, Osaka University 2/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Introduction

1 Introduction

2 Choreography Realization

3 Construct State Machine by Using Petri Nets

4 Conclusions

c 2009 T. Miyamoto, Osaka University 3/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Introduction SOA (Service Oriented Architecture)

Service Unit providing a specific function Example Customer management, Shipping, etc. Key Principles by Thomas Erl (2004) Loose coupling Service contract Autonomy Reusability Composability Discoverability System Composition of services Application Business processes, Embedded system

c 2009 T. Miyamoto, Osaka University 4/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Introduction Motivation

Requirements Not easy to draw a detailed design from req. Much easier to write an abstract spec. Abstrat Spec. Great help if a detailed design is generated from abstract spec.

Improve quality of the developed system if Detailed Design automatically generated from a good spec.

Objective Implementation Construct a detailed design from an abstract spec.

c 2009 T. Miyamoto, Osaka University 5/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Choreography Realization

1 Introduction

2 Choreography Realization

3 Construct State Machine by Using Petri Nets

4 Conclusions

c 2009 T. Miyamoto, Osaka University 6/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Choreography Realization Choreography Realization Problem

(C, I):Choreography model C : Choreography Messages between services Observable events of services I : Set of service implementations L(C) : Behavior allowed be choreography C L(I) : Behavior generated by service implementations I

Realizability problem Given: C Is C realizable? When realizable, obtain service implementations I.

C is realizable : ∃I, such that L(C)=L(I) C is weakly realizable : ∃I such that L(C) ⊇L(I)

c 2009 T. Miyamoto, Osaka University 7/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Choreography Realization Choreography Description Languages

Conversation Protocol Sequence chart

Communication (Collaboration) Process algebra Petri net [J. Su, T. Bultan, X. Fu, and X. Zhao: Towards a Theory of Web Service Choreographies, 2007] Partial order among messages

c 2009 T. Miyamoto, Osaka University 8/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Choreography Realization Service Implementation Description Language

Statechart Mealey automaton UML state machine Labelled transition system Petri net

[T. Bultan, X. Fu, R. Hull, and J. Su: Conversation Specification: A New Approach to Design and Analysis of

E-Service Composition, 2003]

c 2009 T. Miyamoto, Osaka University 9/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Choreography Realization Related Works on Service Implementation Construction

Authors Choreography Service Impl. T. Bultan et al.[9] Collabo. Diagram Mealy Automaton G. Sala¨un et al. Process Algebra - J. Hanson et al. Mealy Automaton Mealy Automaton D. Harel[2] LSC Statechart J. Whittle et al.[3] MSC & OCL Statechart S. Leue et al.[4] MSC ROOM model R. Lorenz et al.[7] Po-set Petri net

c 2009 T. Miyamoto, Osaka University 10/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Choreography Realization Conversation Protocol [J. Hanson et al.]

[J. Su, T. Bultan, X. Fu, and X. Zhao: Towards a Theory of Web Service Choreographies, 2007]

c 2009 T. Miyamoto, Osaka University 11/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Choreography Realization Direct Projection [T. Bultan et al.[9]] a b c

M s : a set of messages and observable d events of service s ⇒s :partialorderonM s {a,b,c,d} State machine (Σ,S,s0,δ,F) a Σ=M s {b,c,d} s S ⊆ 2M s b c s0 = M {c,d} {b,d} δ S × → S : Σ c F = {∅} {d} b d ∅

c 2009 T. Miyamoto, Osaka University 12/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Construct State Machine by Using Petri Nets

1 Introduction

2 Choreography Realization

3 Construct State Machine by Using Petri Nets

4 Conclusions

c 2009 T. Miyamoto, Osaka University 13/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Construct State Machine by Using Petri Nets Our Method

Problem Input C = {(M,⇒)} : choreography M : a set of messages ⇒ : a partial order relation on M Output I = SM : a set of state machines Subject to L(C) ⊆L(I)

Use communication diagram and message relation table to define partial order Use Petri nets to marge partial orders Try to use composite state of state machine for readability

c 2009 T. Miyamoto, Osaka University 14/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Construct State Machine by Using Petri Nets Construction Flow

Extended ROOM Model Message Relation Table 1.define message Communication Diagram relation tables a service2 service1 service3 b 2.make message Petri nets

service1 service1 State Machine Model Merged MPN Model (service1) MPN Model

service2 service2 5. convert to state machine Merged MPN Model MPN Model

Reachability Graph

࡮ ࡮ ࡮ ࡮ 4. construct reachability graph 3. merge message Petri nets

c 2009 T. Miyamoto, Osaka University 15/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Construct State Machine by Using Petri Nets Communication Diagram to Draw Global Behavior

c 2009 T. Miyamoto, Osaka University 16/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Construct State Machine by Using Petri Nets Use Table to Define Partial Order

c 2009 T. Miyamoto, Osaka University 17/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Construct State Machine by Using Petri Nets Derive a Petri Net for Each Service from a CD

c 2009 T. Miyamoto, Osaka University 18/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Construct State Machine by Using Petri Nets Gather Petri Nets for Each Service

c 2009 T. Miyamoto, Osaka University 19/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Construct State Machine by Using Petri Nets Marge Nodes on Petri Net

c 2009 T. Miyamoto, Osaka University 20/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Construct State Machine by Using Petri Nets Marge Nodes on Petri Net

c 2009 T. Miyamoto, Osaka University 21/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Construct State Machine by Using Petri Nets Marge Nodes on Petri Net

c 2009 T. Miyamoto, Osaka University 22/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Construct State Machine by Using Petri Nets Marge Nodes on Petri Net

c 2009 T. Miyamoto, Osaka University 23/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Construct State Machine by Using Petri Nets Construct Reachability Graph of Petri Net

c 2009 T. Miyamoto, Osaka University 24/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Construct State Machine by Using Petri Nets Simplify the Reachability Graph

c 2009 T. Miyamoto, Osaka University 25/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Construct State Machine by Using Petri Nets Simplify the Reachability Graph

c 2009 T. Miyamoto, Osaka University 26/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Construct State Machine by Using Petri Nets Simplify the Reachability Graph

c 2009 T. Miyamoto, Osaka University 27/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Construct State Machine by Using Petri Nets Simplify the Reachability Graph

c 2009 T. Miyamoto, Osaka University 28/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Construct State Machine by Using Petri Nets Simplify the Reachability Graph

c 2009 T. Miyamoto, Osaka University 29/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Construct State Machine by Using Petri Nets Convert the Reachability Graph to State Machine

c 2009 T. Miyamoto, Osaka University 30/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Conclusions

1 Introduction

2 Choreography Realization

3 Construct State Machine by Using Petri Nets

4 Conclusions

c 2009 T. Miyamoto, Osaka University 31/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Conclusions Conclusions

Construct State Machine from Communication Diagrams Use communication diagram and message relation table to define partial order Use Petri nets to marge partial orders Try to use composite state of state machine for readability

c 2009 T. Miyamoto, Osaka University 32/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Appendix Communication Diagram

Communication diagram Collaboration diagram UML 2.x 1.x predecessor No Yes

1/A1:shipReq :Customer :Shipping A2:shipInfo

1/B1:productInfo 1:order A2,B3,C2/2:orderReply A1/B2:shipType :Invoicing B3:invoice :Vendor

1/C1:productShcedule :Scheduling A2/C2:shipShcedule

[T. Bultan and X. Fu, Specification of

Realizable Service Conversations Using

[OMG Unified Modeling Language, Superstructure] Collaboration Diagrams, 2008]

c 2009 T. Miyamoto, Osaka University 33/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Appendix Purchase Order Process [WS-BPEL 2.0]

1/A1:shipReq :Customer :Shipping A2:shipInfo

1/B1:productInfo 1:order A2,B3,C2/2:orderReply A1/B2:shipType :Invoicing B3:invoice :Vendor

1/C1:productShcedule :Scheduling A2/C2:shipShcedule

[T. Bultan and X. Fu, Specification of Realizable Service Conversations Using Collaboration Diagrams, 2008]

c 2009 T. Miyamoto, Osaka University 34/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Appendix Partial Order for Vendor Process

1:order

1/B1:productInfo 1/A1:shipReq 1/C1:productShcedule

A1/B2:shipType A2:shipInfo

B3:invoice A2/C2:shipShcedule

A2,B3,C2/2:orderReply

[T. Bultan and X. Fu, Specification of Realizable Service Conversations Using Collaboration Diagrams, 2008]

c 2009 T. Miyamoto, Osaka University 35/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Appendix Service Implementation for Vendor Process

1

A1 B1 C1

B1 A1 B1 C1 A1 A2 C1

B2 A2 B1 A2 B1 A1 C1 C1

A2 A2 by direct projection C1 C2 B3 C1 B2 B2 B1 same by our method A2 A2 C1 C2 C1 B3 B3 B2 B1 not adequate for revise B3 A2 C1 C2 B2

C2 B3

2

c 2009 T. Miyamoto, Osaka University 36/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Appendix Use Composite States

1

A1 B1 C1

(source.oclIsKindOf(Pseudostate) B2 A2 and source.kind = #fork) implies (target.oclIsKindOf(State) B3

C2

2

c 2009 T. Miyamoto, Osaka University 37/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Appendix Use Composite States

1

A1 B1 C1 (self.kind = #fork) implies self.outgoing->forAll (t1, t2 |

B2 t1<>t2 implies A2 (self.stateMachine.LCA(t1.target,

B3 t2.target).

C2 container.isOrthogonal))

2

c 2009 T. Miyamoto, Osaka University 38/39 UML & FM 09 @ IME, Rio de Janeiro(Dec. 8, 2009) Appendix State Machine Diagram and

State Machine Diagram Activity Diagram Concurrency Orthogonal Regions Petri Nets Node State Transition (Place) (Transition)

[OMG Unified Modeling Language, Superstructure]

c 2009 T. Miyamoto, Osaka University 39/39