Runtime Specialization Java has never been so dynamic before Stephan Herrmann Simply Retail.
Two Camps Strict Rules No Ceremony compiler detects errors Freedom Modularity Flexibility separate maintenance self modifying code Enforced Boundaries code modifjes language blame assignment prevention Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015 # 2
Building Blocks Boundary inside vs. outside What I get lots of existing building blocks to choose from can compose them into my application What I don't get the right to open the box to make changes Near miss looks like a good match but doesn't totally fjt Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015 # 3
Near Miss Adjust requirements to the building block? not competitive Drop existing, build your own expensive Why do we have the problem? technical impossibility rules about boundaries Envy those who don't have these rules unlimited adaptation unanticipated adaptation Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015 # 4
Unanticipated Adaptation Example: Missing Listener Infrastructure WatchDisplay StopWatch time +clear() +clear() +start() +start() +stop() +stop() update() tick() < Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015 # 5
Unanticipated Adaptation Example: Missing Listener Infrastructure WatchDisplay StopWatch time +clear() +clear() +start() +start() +stop() +stop() update() tick() WANTED: Method Call Interception infra structure solution language solution Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015 # 6
Unanticipated Adaptation « playedBy » WatchDisplay StopWatch time +clear() +clear() +start() +start() +stop() +stop() update() tick() update ← after tick Method call interception in Object Teams: „callin“ method binding fmavors: before, after, replace Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015 # 7
Demo: Stop Watch Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015 # 8
Unanticipated Adaptation Base Role « playedBy » WatchDisplay StopWatch time +clear() +clear() +start() +start() +stop() +stop() update() tick() update ← after tick Method call interception in Object Teams: „callin“ method binding fmavors: before, after, replace Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015 # 9
The Role Playing Metaphor playedBy Relationship « playedBy » Person Employee Employee Person name salary salary name Role Base Properties :Student «base» joe: Person matr=0815 Dynamism : » e s name=”joe” a b « roles can come and go :Employee «base» (same base object) salary=100 Multiplicities: one base can play several roles :Employee (difgerent/same role types) salary=2000 Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015 # 10
Summary Role Playing playedBy protected class WatchDisplay extends JFrame similar to inheritance playedBy StopWatch { connects instances callin update <- after advance; method call interception callout void start() -> void start(); void stop() -> void stop(); method forwarding void clear() -> void reset(); regardless of visibility } Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015 # 11
Good or Bad? Moralists City: boundaries must not be violated! Fire site: boundaries are bad! With power comes responsibility Give developers all the means necessary ● For controlling roles ● In a modular way Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015 # 12
Controlling Roles Off On c :Company c :Company if (c.isActive()) name name hire(Person p) hire(Person p) «playedBy» :Person :Employee officePhoneNo phoneNo getPhoneNo() getPhoneNo() getPhoneNo ← getPhoneNo getPhoneNo() Roles depend on context contexts are reifjed as Teams Each team instance can be (de)activated active team instances contribute to the system state dispatch considers system state Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015 # 13
Controlling Roles (2) Globally active teams part of the top-level system defjnition ● plain application: -Dot.teamconfjg=... ● OT/Equinox: extension point aspectBinding Scope of activation per-thread ALL_THREADS while a certain code block is executing ... Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015 # 14
Demo: Flight Booking Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015 # 15
Integration – Technically Weave hooks into the byte code build time load time runtime Execute on a standard JVM application ● -javaagent: OT/Equinox ● WeavingHook (OSGi standard) Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015 # 16
Phases Development of building blocks variability model extension points Composition to an application wire & confjgure building blocks New in OT/J New in OT/J unanticipated adaptation Deployment more wiring & confjguration New in OT/J Neon Operation New in OT/J Neon runtime adaptation → http://www.eclipse.org/objectteams Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015 # 17
Recommend
More recommend