software interactions david emsellem [email protected] i3s laboratory, france

56
Software interactions David Emsellem [email protected] I3S Laboratory, France

Post on 20-Dec-2015

219 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Software interactions

David [email protected]

I3S Laboratory, France

http://noah.essi.fr

Page 2: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Software interactions

Overviewhttp://noah.essi.fr

Page 3: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Needs

• No modification on the component• Reusability

• Dynamically• no recompilation• no application restart

storage

storage

no

tifi

cati

on

notification

collaboration

security

Add capabilities to components, compose and coordinate them

Page 4: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Needs

class Agenda {

void addMeeting (Meeting m) throws Exception{ meetingTable.add(m); }

List meetingTable; …}

Page 5: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Needs

class Agenda {

void addMeeting (Meeting m) throws Exception{ meetingTable.add(m); display.notify("addMeeting: "+m.toString( )); }

List meetingTable;; Display display; …}

Page 6: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Needs

class Agenda {

void addMeeting (Meeting m) throws Exception{ if (security.ckeck(…)) { meetingTable.add(m); display.notify("addMeeting: "+m.toString( )); } else { throw new Exception("Invalid operation"); } }

List meetingTable;; Display display; SecurityService security; …}

Page 7: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Needs

class Agenda {

void addMeeting (Meeting m) throws Exception{ if (security.ckeck(…)) { meetingTable.add(m);

database.store(getFullName( ),this); display.notify("addMeeting: "+m.toString( )); } else { throw new Exception("Invalid operation"); } }

List meetingTable;; Display display; SecurityService security; Database database; …}

Page 8: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Needs

void addMeeting(Meeting m) throws Exception{ if (security.ckeck(…)) { meetingTable.add(m); } else { throw new Exception("Invalid operation"); }}

void addMeeting(Meeting m) { meetingTable.add(m); display.notify("addMeeting: " +m.toString());}

void addMeeting(Meeting m) { meetingTable.add(m); }

Persistance

Security

Default behaviour

Notification

+

+

+void addMeeting(Meeting m) { meetingTable.add(m); database.store(getFullName(),this); }

Page 9: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Software interactions

Life cyclehttp://noah.essi.fr

Page 10: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Interactions: Life cycle

Interaction notification(Object obj, Display display){

obj.* -> obj._call // display.notify(_call)}

Interaction service

agenda1 display1

patterns

interactions

Page 11: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

registerPatternInteraction notification(Object obj, Display display){

obj.* -> obj._call // display.notify(_call)}

Pattern registration

Interaction service

agenda1 display1

patterns

interactions

Interactions: Life cycle

Page 12: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Instanciate(notification,[agenda1,display1])notification

Interaction service

agenda1 display1

patterns

interactions

Pattern instantiation

Interactions: Life cycle

Page 13: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

addRulenotification

Interaction service

agenda1 display1

patterns

interactions

notification#1

addMeeting()

getName()

Interactions: Life cycle

Pattern instantiation

Page 14: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

interaction security(Object obj, SecurityService service){

obj.addMeeting() -> if service.check(_call) then obj._call else exception    "UnauthorizedUser" endif }

securityService1

notification

Interaction service

agenda1 display1

patterns

interactions

notification#1

addMeeting()

getName()

Interactions: Life cycle

Page 15: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

registerPattern

Interaction service

agenda1

patterns

interactions

addMeeting()

getName()

notification

notification#1

security

securityService1

display1 Pattern registration

interaction security(Object obj, SecurityService service){

obj.addMeeting() -> if service.check(_call) then obj._call else exception    "UnauthorizedUser" endif }

Interactions: Life cycle

Page 16: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Instanciate(security,[agenda1,securityService1])

Interaction service

agenda1

patterns

interactions

addMeeting()

getName()

notification

notification#1

security

securityService1

display1

Interactions: Life cycle

Pattern instantiation

Page 17: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

agenda1

addRule

addMeeting()

getName()

securityService1

display1

Interaction service

patterns

interactions

notification

notification#1

security

security#1

Interactions: Life cycle

Pattern instantiation

Page 18: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

agenda1

addMeeting()

getName()

securityService1

display1

Interaction service

patterns

interactions

notification

notification#1

security

security#1

+=

Merging

Rule merging

Interactions: Life cycle

Page 19: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

agenda1

addMeeting()

getName()

securityService1

display1

Interaction service

patterns

interactions

notification

notification#1

security

security#1

Invocation

AddMeeting

Interactions: Life cycle

Page 20: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Software interactions

Implementation

http://noah.essi.fr

Page 21: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Last year : Java

• Released version– http://noah.essi.fr

.Net extension (May 2003 )

Specialized rotor version (Sept. 2003)

Java + J2EE-Jonas

Page 22: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Java : component registration

RMIRegistry

JavaObject

JavaObject

JVM 1 JVM 2

RMI

RMI

General architecture

Page 23: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Java : interaction instantiation

RMIRegistry

RMI ISL

JavaObject

JavaObject

JVM 1 JVM 2

ISL

ISL

General architecture

Page 24: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

.Net : component registration

RMIRegistry

HTTPObject

.NET Remoting

JavaObject

JavaObject

JVM 1 JVM 2 Remote .NET Process 1

General architecture

Page 25: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

RMIRegistry

HTTPObject

.NET Remoting

JavaObject

JavaObject

JVM 1 JVM 2 Remote .NET Process 1

IML

ISL

IML

SOAP

General architecture

.Net : interaction instantiation

Page 26: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

RMIRegistry

HTTPObject

TCPObject

.NET Remoting .NET Remoting

JavaObject

JavaObject

JVM 1 JVM 2 Remote .NET Process 1

Remote .NET Process 2

General architecture

.Net : component registration

Page 27: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

General architecture

RMIRegistry

HTTPObject

TCPObject

.NET Remoting .NET Remoting

JavaObject

JavaObject

JVM 1 JVM 2 Remote .NET Process 1

Remote .NET Process 2

Bridge

.NET RemotingIML

IMLSOAP

IML

ISL

.NET : interaction instantiation

Page 28: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Interaction Service

.NET – Life cycle

patterns

interactions

Interaction notification(Object obj, Display display){

obj.* -> obj._call // display.notify(_reifiedCall)}

display1agenda1

Page 29: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Interaction Service

.NET – Life cycle

patterns

notification

registerPatternInteraction notification(Object obj, Display display){

obj.* -> obj._call // display.notify(_reifiedCall)}

display1agenda1

Pattern Registration

Page 30: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Interaction Service

.NET – Life cycle

patterns

notification

interactions

notification#1

Instanciante(notification,[agenda1,display1])

display1agenda1

Interaction instantiation

Page 31: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Interaction Service

.NET – Life cycle

patterns

notification

interactions

notification#1

Java to XML marshallingXMLXML

display1agenda1

Interaction instantiation

Page 32: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Interaction Service

.NET – Life cycle

patterns

notification

interactions

notification#1

XMLXML

XMLXML

display1agenda1

.NET objects published via HTTPare directly accessible from Java as simple Web Services. For other components a proxy is used to reach .NET world

Interaction instantiation

Java to XML marshalling

Page 33: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Interaction Service

.NET – Life cycle

patterns

notification

interactions

notification#1

Serialization Java → XML

Envoi des règlesHTTP - WebServices

XMLXML

XMLXML

display1agenda1

addMeeting()

getName()

Interaction instantiation

XML to .NET unmarshalling

Page 34: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Interaction Service

.NET – Life cycle

patterns

interactions

interaction security(Object obj, SecurityService service){

obj.addMeeting() -> if service.check(_reifiedCall) then obj._call else throw  new UnauthorizedUser() endif }

notification

notification#1

display1securityService1agenda1

addMeeting()

getName()

Page 35: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Interaction Service

.NET – Life cycle

patterns

notificationregisterPattern

notification

security

notification#1

display1securityService1agenda1

addMeeting()

getName()

Pattern registration

interaction security(Object obj, SecurityService service){

obj.addMeeting() -> if service.check(_reifiedCall) then obj._call else throw  new UnauthorizedUser() endif }

Page 36: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Interaction Service

.NET – Life cycle

patterns

notification

interactions

notification#1

notification

security

notification#1

security#1

display1securityService1agenda1

addMeeting()

getName()

Instanciate(security,[agenda1,securityService1])

Interaction instantiation

Page 37: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Interaction Service

.NET – Life cycle

patterns

notification

interactions

notification#1

display1securityService1agenda1

Rule sendingHTTP – Web Services

XMLXML

XMLXML

addMeeting()

getName()

?

security

security#1

Interaction instantiation

Java to XML marshalling

XML to Java unmarshalling

Page 38: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Interaction Service

.NET – Life cycle

patterns

notification

interactions

notification#1

display1securityService1agenda1

addMeeting()

getName()

?

security

security#1

AddMeeting

Invocation

Merged rule isn’t yetresolved

Page 39: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Interaction Service

.NET – Life cycle

patterns

notification

interactions

notification#1

display1securityService1agenda1

addMeeting()

getName()

?

security

security#1

AddMeeting

mergeRule()

Call to a Java merging Web Service

Rules are marshalled from .NET to XML, and then unmarshalledfrom XML to their correspondingJava representation

MergingWeb Service

Page 40: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Interaction Service

.NET – Life cycle

patterns

notification

interactions

notification#1

display1securityService1agenda1

addMeeting()

getName()

?

security

security#1

AddMeeting

+=MergingMerging

Web Service

Page 41: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Interaction Service

.NET – Life cycle

patterns

notification

interactions

notification#1

display1securityService1agenda1

addMeeting()

getName()

security

security#1

AddMeeting

mergeRule() return

Return merging result

to the component

MergingWeb Service

Page 42: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Interaction Service

.NET – Life cycle

patterns

notification

interactions

notification#1

display1securityService1agenda1

addMeeting()

getName()

security

security#1

AddMeetingRule execution

Next execution doesn’tneed a new merging

Page 43: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Class instrumentation (1)

class Agenda : IAgenda{

public void addMeeting (Meeting m){

<user code…>

} …

}

Page 44: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

class Agenda : IAgenda{

public void addMeeting_Intercepted (Meeting m){

<user code…>

} public void addMeeting (Meeting m){ if (methodTable.isSlotOn(1)){ methodTable.invoke(1,new Object[]{m}) } else { addMeeting_Intercepted(m); } }

private NoahMethodTable methodtable;

….

}

Class instrumentation (2)

• Each business method needs to be wrapped

• An additional field handles instance vtable

• Special control methods are added to the class (addRule, removeRule …)

Page 45: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

• 2 methods for handling the « same » method behaviour

2 MethodDesc, IL code, stubs, vtable slots …

• Interception cost is paid even if no instance has redefined the behaviour of the corresponding method

• When executing an alternative behaviour we also pay the cost of creation of the parameters array

Class instrumentation (3) : drawbacks

Page 46: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Another approach: working with the rotor code

Advantages

• access to the object memory representation

• Allows us to avoid the class instrumentation stage

• Principle: each user method can potentially be redefined

Methods are wrapped on a as-needed basis When no instance has modified a method behaviour,

we don’t intercept the call

• access to the invocation mechanism

• Rules can be executed by the execution engine

• We can try to suppress the rule interpretation stage

Page 47: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

EEClass

inde

x Objectheader

Instancedata

FieldDesc

MethodDesc

Prebtub pointer Prestub

Application Domain

ClassLoader

Module

Assembly

Interfacemap

JMI ThunkCompiled

code

Sync record

SyncBlock table SyncBlock

GCDesc

MethodTable

Runtime data structures in rotor

Page 48: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

EEClass

inde

x Objectheader

Instancedata

FieldDesc

MethodDesc

Prebtub pointer Prestub

Application Domain

ClassLoader

Module

Assembly

Interfacemap

JMI ThunkCompiled

code

Sync record

SyncBlock table SyncBlock

GCDesc

MethodTable

Runtime data structures in rotor

Page 49: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

JMI Thunk

native code

GCDesc

MethodTable

GCDesc

m_pMethodTable

Instance data

SLOT[0]

..

SLOT[n]

SLOT[i] Prologue

User Code

Epilogue

method tablesinstances

Runtime data structures in rotor

Page 50: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

JMI Thunk

native code

GCDesc

MethodTable

GCDesc

m_pMethodTable

m_pInstanceMT

Instance data

SLOT[0]

..

SLOT[n]

SLOT[i] Prologue

User Code

Epilogue

method tablesinstances

NULL

Interacting object instance has an extra field: its own Vtable

Runtime data structures in rotor

Page 51: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

JMI Thunk

native code

GCDesc

MethodTable

GCDesc

m_pMethodTable

m_pInstanceMT

Instance data

SLOT[0]

..

SLOT[n]

SLOT[i] Prologue

User Code

Epilogue

method tablesinstances

NULL

addRule

What happens when adding a rule?

Runtime data structures in rotor

Page 52: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

JMI Thunk

native code

GCDesc

MethodTable

GCDesc

m_pMethodTable

m_pInstanceMT

Instance data

SLOT[0]

..

SLOT[n]

SLOT[i]

[ 0 ]

..

[ n ]

[ i ]

method tablesinstances

#

Prologue

User Code

Epilogue

A per-instance vtable is built

Runtime data structures in rotor

Page 53: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

JMI Thunk

native code

GCDesc

MethodTable

GCDesc

m_pMethodTable

m_pInstanceMT

Instance data

SLOT[0]

..

SLOT[n]

SLOT[i]

[ 0 ]

..

[ n ]

[ i ]

interacting rule code(no prologue)

method tablesinstances

#

Prologue

User Code

Epilogue

Rule instances are JIT compiled to native code (IL like)

Runtime data structures in rotor

Page 54: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

JMI Thunk

native code

GCDesc

MethodTable

GCDesc

m_pMethodTable

m_pInstanceMT

Instance data

SLOT[0]

..

SLOT[n]

SLOT[i]

[ 0 ]

..

[ n ]

[ i ]

interacting rule code(no prologue)

Prologue

User Code

Epilogue

mov eax [this + 4] // m_pInstanceMT cmp eax 0 // if null je userCode // default behaviour mov eax [eax +12] // dispatch instanceMT cmp eax 0 je userCode call eax // user code addr on stack

method tablesinstances

#

Target method is updated• MethodDesc is marked , and while it’s beeing (re)jitted a stub is added just after the prologue

Runtime data structures in rotor

Page 55: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Conclusion

• We have a way to express interactions between components in a language independent way (ISL)

• The same server manages interactions for Java and .NET components

• A Rotor version will take benefits of the runtime knowledge to achieve some optimizations

• Available as a single library, and graphical tools to control the interaction graph of the application

Page 56: Software interactions David Emsellem emsellem@essi.fr I3S Laboratory, France

Questions

http://noah.essi.fr