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

Post on 20-Dec-2015

217 views 3 download

transcript

Software interactions

David Emsellememsellem@essi.fr

I3S Laboratory, France

http://noah.essi.fr

Software interactions

Overviewhttp://noah.essi.fr

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

Needs

class Agenda {

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

List meetingTable; …}

Needs

class Agenda {

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

List meetingTable;; Display display; …}

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; …}

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; …}

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

Software interactions

Life cyclehttp://noah.essi.fr

Interactions: Life cycle

Interaction notification(Object obj, Display display){

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

Interaction service

agenda1 display1

patterns

interactions

registerPatternInteraction notification(Object obj, Display display){

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

Pattern registration

Interaction service

agenda1 display1

patterns

interactions

Interactions: Life cycle

Instanciate(notification,[agenda1,display1])notification

Interaction service

agenda1 display1

patterns

interactions

Pattern instantiation

Interactions: Life cycle

addRulenotification

Interaction service

agenda1 display1

patterns

interactions

notification#1

addMeeting()

getName()

Interactions: Life cycle

Pattern instantiation

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

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

Instanciate(security,[agenda1,securityService1])

Interaction service

agenda1

patterns

interactions

addMeeting()

getName()

notification

notification#1

security

securityService1

display1

Interactions: Life cycle

Pattern instantiation

agenda1

addRule

addMeeting()

getName()

securityService1

display1

Interaction service

patterns

interactions

notification

notification#1

security

security#1

Interactions: Life cycle

Pattern instantiation

agenda1

addMeeting()

getName()

securityService1

display1

Interaction service

patterns

interactions

notification

notification#1

security

security#1

+=

Merging

Rule merging

Interactions: Life cycle

agenda1

addMeeting()

getName()

securityService1

display1

Interaction service

patterns

interactions

notification

notification#1

security

security#1

Invocation

AddMeeting

Interactions: Life cycle

Software interactions

Implementation

http://noah.essi.fr

Last year : Java

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

.Net extension (May 2003 )

Specialized rotor version (Sept. 2003)

Java + J2EE-Jonas

Java : component registration

RMIRegistry

JavaObject

JavaObject

JVM 1 JVM 2

RMI

RMI

General architecture

Java : interaction instantiation

RMIRegistry

RMI ISL

JavaObject

JavaObject

JVM 1 JVM 2

ISL

ISL

General architecture

.Net : component registration

RMIRegistry

HTTPObject

.NET Remoting

JavaObject

JavaObject

JVM 1 JVM 2 Remote .NET Process 1

General architecture

RMIRegistry

HTTPObject

.NET Remoting

JavaObject

JavaObject

JVM 1 JVM 2 Remote .NET Process 1

IML

ISL

IML

SOAP

General architecture

.Net : interaction instantiation

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

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

Interaction Service

.NET – Life cycle

patterns

interactions

Interaction notification(Object obj, Display display){

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

display1agenda1

Interaction Service

.NET – Life cycle

patterns

notification

registerPatternInteraction notification(Object obj, Display display){

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

display1agenda1

Pattern Registration

Interaction Service

.NET – Life cycle

patterns

notification

interactions

notification#1

Instanciante(notification,[agenda1,display1])

display1agenda1

Interaction instantiation

Interaction Service

.NET – Life cycle

patterns

notification

interactions

notification#1

Java to XML marshallingXMLXML

display1agenda1

Interaction instantiation

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

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

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

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 }

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

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

Interaction Service

.NET – Life cycle

patterns

notification

interactions

notification#1

display1securityService1agenda1

addMeeting()

getName()

?

security

security#1

AddMeeting

Invocation

Merged rule isn’t yetresolved

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

Interaction Service

.NET – Life cycle

patterns

notification

interactions

notification#1

display1securityService1agenda1

addMeeting()

getName()

?

security

security#1

AddMeeting

+=MergingMerging

Web Service

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

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

Class instrumentation (1)

class Agenda : IAgenda{

public void addMeeting (Meeting m){

<user code…>

} …

}

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

• 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

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

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

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

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

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

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

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

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

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

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

Questions

http://noah.essi.fr