Generalized Layer Activation Mechanism for Context-Oriented Programming

Context-oriented programming (COP) languages modularize context-dependent behaviors in multiple classes into layers. These languages have layer activation mechanisms so that the behaviors in layers take effect on a particular unit of computation during a particular period of time. Existing COP languages have different layer activation mechanisms, and each of them has its own advantages. However, since these mechanisms interfere with each other in terms of extent (time duration) and scope (a set of units of computations) of activation, combining them into a single language is not trivial. We propose a generalized layer activation mechanism based on contexts and subscribers to implement the different activation mechanisms in existing COP languages in a single language called ServalCJ. We formalize the operational semantics of ServalCJ as a small calculus and prove priority preservation, i.e., ensuring that layer prioritization, which resolves the interference between layers, is preserved during computation. To prove this property, we give a formal definition of layer priority that is general so that we can discuss the priorities of layers in other COP calculi and implementations. We implement a ServalCJ compiler, and demonstrate its effectiveness through several example applications.

[1]  Michael Haupt,et al.  Event-Specific Software Composition in Context-Oriented Programming , 2010, SC@TOOLS.

[2]  Patrick Th. Eugster,et al.  EventJava: An Extension of Java for Event Correlation , 2009, ECOOP.

[3]  Alexandre Bergel,et al.  Context-Aware Aspects , 2006, SC@ETAPS.

[4]  Hidehiko Masuhara,et al.  Introducing Composite Layers in EventCJ , 2013 .

[5]  Gary T. Leavens,et al.  Ptolemy: A Language with Quantified, Typed Events , 2008, ECOOP.

[6]  Shigeru Chiba,et al.  Method slots: supporting methods, events, and advices by a single language construct , 2013, LNCS Trans. Aspect Oriented Softw. Dev..

[7]  Michael Haupt,et al.  ContextJ: Context-oriented Programming with Java , 2011 .

[8]  Takuo Watanabe,et al.  LEAD++: an object-oriented language based on a reflective model for dynamic software adaptation , 1999, Proceedings Technology of Object-Oriented Languages and Systems (Cat. No.PR00393).

[9]  Atsushi Igarashi,et al.  A Type System for Dynamic Layer Composition , 2012 .

[10]  Kim Mens,et al.  Subjective-C - Bringing Context to Mobile Platform Programming , 2010, SLE.

[11]  Michael Haupt,et al.  A comparison of context-oriented programming languages , 2009, COP@ECOOP.

[12]  Oscar Nierstrasz,et al.  Context-oriented Programming , 2008, J. Object Technol..

[13]  Hidehiko Masuhara,et al.  Featherweight EventCJ: a core calculus for a context-oriented language with event-based per-instance layer transition , 2011, COP@ECOOP.

[14]  Martin Odersky,et al.  Scalable component abstractions , 2005, OOPSLA '05.

[15]  Matteo Pradella,et al.  ContextErlang: introducing context-oriented programming in the actor model , 2012, AOSD '12.

[16]  Robert Hirschfeld,et al.  An open implementation for context-oriented layer composition in ContextJS , 2011, Sci. Comput. Program..

[17]  Oscar Nierstrasz,et al.  Context-oriented programming: beyond layers , 2007, ICDL '07.

[18]  Atsushi Igarashi,et al.  ContextFJ: a minimal core calculus for context-oriented programming , 2011, FOAL.

[19]  Hidehiko Masuhara,et al.  Improving the development of context-dependent Java applications with ContextJ , 2009, COP@ECOOP.

[20]  Martin D. Westhead,et al.  A methodology for benchmarking Java Grande applications , 1999, JAVA '99.

[21]  Coen De Roover,et al.  Interruptible context-dependent executions: a fresh look at programming context-aware applications , 2012, Onward! 2012.

[22]  Philip Wadler,et al.  Featherweight Java: a minimal core calculus for Java and GJ , 1999, OOPSLA '99.

[23]  Hidehiko Masuhara,et al.  EventCJ: a context-oriented programming language with declarative event-based context transition , 2011, AOSD '11.

[24]  Robert Hirschfeld,et al.  Language constructs for context-oriented programming: an overview of ContextL , 2005, DLS '05.

[25]  Somayeh Malakuti,et al.  Evolution of composition filters to event composition , 2012, SAC '12.

[26]  Randall B. Smith,et al.  Self: The power of simplicity , 1987, OOPSLA 1987.

[27]  Ondrej Lhoták,et al.  abc : An Extensible AspectJ Compiler , 2006, LNCS Trans. Aspect Oriented Softw. Dev..

[28]  Somayeh Malakuti,et al.  Event Modules - Modularizing Domain-Specific Crosscutting RV Concerns , 2014, LNCS Trans. Aspect Oriented Softw. Dev..

[29]  Kim Mens,et al.  Context traits: dynamic behaviour adaptation through run-time trait recomposition , 2013, AOSD.

[30]  William G. Griswold,et al.  An Overview of AspectJ , 2001, ECOOP.

[31]  Kim Mens,et al.  Context-Oriented Programming with the Ambient Object System , 2008, J. Univers. Comput. Sci..

[32]  Takuo Watanabe,et al.  LEAD: a linguistic approach to dynamic adaptability for practical applications , 1998, Systems Implementation 2000.

[33]  Hidehiko Masuhara,et al.  Context holders: realizing multiple layer activation mechanisms in a single context-oriented language , 2014, FOAL.