MTCoord'05 - PowerPoint PPT Presentation

About This Presentation
Title:

MTCoord'05

Description:

MTCoord'05 Roles as Coordination Construct: Introducing powerJava M. Baldoni1, G. Boella1, L. van der Torre2 1 Dipartimento di Informatica Universit degli Studi di ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 22
Provided by: unil96
Category:

less

Transcript and Presenter's Notes

Title: MTCoord'05


1
MTCoord'05
  • Roles as Coordination Construct
  • Introducing powerJava
  • M. Baldoni1, G. Boella1, L. van der Torre2
  • 1 Dipartimento di Informatica
  • Università degli Studi di Torino
  • 2 SEN3 CWI Amsterdam and Delft
  • University of Technology

2
Data vs Control driven coordination
  • Data-driven coordination (typical of OO)
  • computation evolves driven by the data involved
    in the coordination
  • Control-driven coordination
  • computation evolves according to events following
    state changes
  • Separation between coordination and computation
    (different processes)
  • Black-boxes with input/output interfaces
  • Dynamic reconfiguration

3
(No Transcript)
4
(No Transcript)
5
Aim of the work
  • Coordination models often refer to some metaphor
    Shared dataspace, Blackboard model, Actor model,
    Chemical model, Channel model, ...
  • Aim of this work To introduce the role
    metaphor in OO programming (Java) for allowing
    control-driven coordination
  • powerJava A proposal of extension of Java with
    roles

6
A proposal the role metaphor
  • It is a basic metaphor in social and organization
    theories
  • Role often defined as the description of an
    expected behaviour
  • Used to distribute responsabilities, obligations,
    and rights among the entities of an organization
  • Playing a role means acquiring specific powers
    (given by the organization)
  • For playing a role some requirements are needed
  • Roles (as entities endowed with powers) are a
    means to coordinate the behavior within an
    organization

7
(No Transcript)
8
(No Transcript)
9
Introducing roles in Java powerJava
  • We define roles as instances associated at
    runtime to objects (their players)
  • The extension of objects to roles is transparent
    to the programmer
  • The language is extended preserving the
    characteristics of the original language to make
    its use natural to the Java programmer
  • The current implementation requires a
    preprocessing (by JavaCC) step to produce a pure
    Java program

10
(No Transcript)
11
(No Transcript)
12
Role implementation as inner classes
  • Role implementation
  • Java inner classes that implement the powers
    specified by the role definition
  • keyword realizes
  • keyword that
  • A role implementation has access to the state of
    the institution (like inner classes w.r.t. outer
    classes)
  • that is used to invoke methods (requirements) of
    the player

role Philosopher playedby PhilosopherReq void
eat() void think() class Table
... class PhilosopherImpl realizes
Philosopher ... public void eat()
... public void think()
that.processData()
13
Role instance creation
  • Roles created similarly to instances of inner
    classes
  • Implicit parameter of type requirements (the
    player of the role)
  • Each role instance has a reference to the
    instance of its institution, like an instance of
    an Java inner class has a reference to its outer
    class (directly provided by Java compiler)

interface PhilosopherReq void putData( ...
) void processData() class Consumer
implements PhilosopherReq public void
putData( ... ) ... public
void processData() ...
... Consumer consumer new
Consumer() ... Philosopher phil new
table.PhilosopherImpl(consumer) ...
14
Playing a role
  • Role instances do not exist by themselves
  • Role powers are invoked starting from the
    associated players
  • Cast to a role casting the player of a role to
    the role implementation instance it refers to (it
    is necessary to specify the institution the role
    belongs to)
  • Delegation mechanism

role Philosopher playedby PhilosopherReq void
eat() void think() ... Consumer
consumer new Consumer() ... Philosopher phil
new table.PhilosopherImpl(consumer) ...
((table.Philosopher) consumer).eat() ((table.Ph
ilosopher) consumer).think() ((table.Philosopher
Impl) consumer).myEat()
15
Overview
  • Overall model using a UML class diagram
  • Translation in pure Java by means of a
    pre-processor built by JavaCC (http//www.powerjav
    a.org)

16
(No Transcript)
17
(No Transcript)
18
(No Transcript)
19
Summary of the example
table
  • Sequence diagram of the dinning philosophers
  • The coordination happens all inside the table
    throgh the roles

20
powerJava pre-processesing
  • JavaCC (Java Compiler Compiler) using Java 1.4.2
    grammar
  • Role specifications are translated into
    interfaces
  • Role implementations are traslated into inner
    classes whose constructors are extedend
    appropriately
  • Players are modified in order to manage a list of
    roles
  • Role casting is translated into an instruction
    that allows to find the corresponding roles
    inside its list (using the name of the role and
    the instance of institution), then delegating
    this object for the execution of the power

21
Conclusions
  • By roles we implement control-driven coordination
    in an OO language
  • powerJava introduces roles in Java preserving the
    natural OO programming style (expecially for the
    use of interfaces)
  • Type checking is demanded to the Java compiler
  • On-going work studying a notion of type for the
    role definition and implementation
  • powerJava shares some features with Object Teams,
    Caesar, AspectJ, Traits, Mixins, its originality
    mainly stands in the use of interfaces, a key
    choice to support modularity and reuse
Write a Comment
User Comments (0)
About PowerShow.com