Abstract
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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
We use the term “context” to indicate the temporal context.
- 2.
- 3.
The simulator source code is available at https://github.com/ServalCJ/mazesimulator.git.
- 4.
This case study was inspired by the real maze-solving Pololu 3pi Robot (http://www.pololu.com/product/975). The simulator’s behavior follows the sample program provided by the 3pi Robot distribution.
- 5.
Among them, only the last algorithm can solve mazes with loops.
- 6.
The same discussion is also applicable to the program editor example.
- 7.
While we consider the definitions that are independent from the activation mechanisms, we still assume that layers and constructs of the host language are based on ContextFJ-like calculi, e.g., we assume the existence of mbody and substitution-based reduction for proceed.
- 8.
To speak of the layer priority, we focus on which partial method executes first rather than the ordering of the activated layers.
- 9.
All \(\varLambda _i\) are empty before v is created.
- 10.
The source code of the compiler is available at https://github.com/ServalCJ/pl.git. Per-thread activation is currently not implemented.
- 11.
Precisely, only instances that have globally activated layers are added to the list to reduce the performance degradation.
- 12.
By “overhead,” we mean the overhead against the mechanism where the global activation time is constant with respect to the number of instances.
References
Amano, N., Watanabe, T.: LEAD: a linguistic approach to dynamic adaptability for practical applications. In: Proceedings of the IFIP TC2 WG2.4 Working Conference on Systems Implementation 2000: Languages, Methods and Tools, pp. 277–290 (1998)
Amano, N., Watanabe, T.: LEAD++: an object-oriented language based on a reflective model fordynamic software adaptation. In: Technology of Object-Oriented Languages and Systems (TOOLS31), pp. 41–50 (1999)
Aotani, T., Kamina, T., Masuhara, H.: Featherweight EventCJ: a core calculus for a context-oriented language with event-based per-instance layer transition. In: COP 2011 (2011)
Aotani, T., Kamina, T., Masuhara, H.: Context holders: realizing multiple layer activation mechanisms in asingle context-oriented language. In: FOAL 2014, pp. 3–6 (2014)
Appeltauer, M., Hirschfeld, R., Haupt, M., Lincke, J., Perscheid, M.: A comparison of context-oriented programming languages. In: COP 2009, pp. 1–6 (2009)
Appeltauer, M., Hirschfeld, R., Haupt, M., Masuhara, H.: ContextJ: context-oriented programming with Java. Comput. Softw. 28(1), 272–292 (2011)
Appeltauer, M., Hirschfeld, R., Masuhara, H.: Improving the development of context-dependent Java application with ContextJ. In: COP 2009 (2009)
Appeltauer, M., Hirschfeld, R., Masuhara, H., Haupt, M., Kawauchi, K.: Event-specific software composition in context-oriented programming. In: Baudry, B., Wohlstadter, E. (eds.) SC 2010. LNCS, vol. 6144, pp. 50–65. Springer, Heidelberg (2010). doi:10.1007/978-3-642-14046-4_4
Avgustinov, P., et al.: abc: an extensible AspectJ compiler. In: Rashid, A., Aksit, M. (eds.) Transactions on Aspect-Oriented Software Development I. LNCS, vol. 3880, pp. 293–334. Springer, Heidelberg (2006). doi:10.1007/11687061_9
Bainomugisha, E., Vallejos, J., De Roover, C., Carreton, A.L., De Meuter, W.: Interruptible context-dependent executions: a fresh look atprogramming context-aware applications. In: Onward! 2012, pp. 67–84 (2012)
Bull, J.M., Smith, L.A., Westhead, M.D., Henty, D.S., Davey. R.A.: A methodology for benchmarking Java Grande applications. In: Proceedings of ACM 1999 Java Grande Conference, pp. 81–88 (1999)
Costanza, P., Hirschfeld, R.: Language constructs for context-oriented programming - an overview of ContextL. In: Dynamic Language Symposium (DLS) 2005, pp. 1–10 (2005)
Eugster, P., Jayaram, K.R.: EventJava: an extension of Java for event correlation. In: Drossopoulou, S. (ed.) ECOOP 2009. LNCS, vol. 5653, pp. 570–594. Springer, Heidelberg (2009). doi:10.1007/978-3-642-03013-0_26
González, S., Cardozo, N., Mens, K., Cádiz, A., Libbrecht, J.-C., Goffaux, J.: Subjective-C: bringing context to mobile platform. In: Malloy, B., Staab, S., Brand, M. (eds.) SLE 2010. LNCS, vol. 6563, pp. 246–265. Springer, Heidelberg (2011). doi:10.1007/978-3-642-19440-5_15
González, S., Mens, K., Cádiz, A.: Context-oriented programming with the ambient object systems. J. Univ. Comput. Sci. 14(20), 3307–3332 (2008)
González, S., Mens, K., Colacioiu, M., Cazzola, W.: Context traits: dynamic behaviour adaptation through run-time traitrecomposition. In: AOSD 2013, pp. 209–220 (2013)
Hirschfeld, R., Costanza, P., Nierstrasz, O.: Context-oriented programming. J. Object Technol. 7(3), 125–151 (2008)
Hirschfeld, R., Igarashi, A., Masuhara, H.: ContextFJ: a minimal core calculus for context-orientedprogramming. In: FOAL 2011, pp. 19–23 (2011)
Igarashi, A., Hirschfeld, R., Masuhara, H.: A type system for dynamic layer composition. In: FOOL 2012 (2012)
Igarashi, A., Pierce, B., Wadler, P.: Featherweight Java: a minimal core calculus for Java and GJ. ACM TOPLAS 23(3), 396–450 (2001)
Kamina, T., Aotani, T., Masuhara, H.: EventCJ: a context-oriented programming language with declarative event-based context transition. In: AOSD 2011, pp. 253–264 (2011)
Kamina, T., Aotani, T., Masuhara, H.: Introducing composite layers in EventCJ. IPSJ Trans. Program. 6(1), 1–8 (2013)
Kiczales, G., Hilsdale, E., Hugunin, J., Kersten, M., Palm, J., Griswold, W.G.: An overview of AspectJ. In: Knudsen, J.L. (ed.) ECOOP 2001. LNCS, vol. 2072, pp. 327–354. Springer, Heidelberg (2001). doi:10.1007/3-540-45337-7_18
Lincke, J., Appeltauer, M., Steinert, B., Hirschfeld, R.: An open implementation for context-oriented layer composition in ContextJS. Sci. Comput. Program. 76(12), 1194–1209 (2011)
Malakuti, S., Akşit, M.: Event modules: modularizing domain-specific crosscutting RV concerns. In: Chiba, S., Tanter, É., Bodden, E., Maoz, S., Kienzle, J. (eds.) Transactions on AOSD XI. LNCS, vol. 8400, pp. 27–69. Springer, Heidelberg (2014). doi:10.1007/978-3-642-55099-7_2
Malakuti, S., Akşit, M.: Evolution of composition filters to event composition. In: SAC 2012, pp. 1850–1857 (2012)
Odersky, M., Zenger, M.: Scalable component abstractions. In: OOPSLA 2005, pp. 41–57 (2005)
Rajan, H., Leavens, G.T.: Ptolemy: a language with quantified, typed events. In: Vitek, J. (ed.) ECOOP 2008. LNCS, vol. 5142, pp. 155–179. Springer, Heidelberg (2008). doi:10.1007/978-3-540-70592-5_8
Salvaneschi, G., Ghezzi, C., Pradella, M.: ContextErlang: introducing context-oriented programming in theactor model. In: AOSD 2012 (2012)
Tanter, É., Gybels, K., Denker, M., Bergel, A.: Context-aware aspects. In: Löwe, W., Südholt, M. (eds.) SC 2006. LNCS, vol. 4089, pp. 227–242. Springer, Heidelberg (2006). doi:10.1007/11821946_15
Ungar, D., Smith, R.B.: Self: the power of simplicity. In: OOPSLA 1987, pp. 227–241 (1987)
von Löwis, M., Denker, M., Nierstrasz, O.: Context-oriented programming: beyond layers. In: ICDL 2007: Proceedings of the 2007 International Conference on Dynamic Languages, pp. 143–156 (2007)
Zhuang, Y.Y., Chiba, S.: Method slots: supporting methods, events, and advices by a singlelanguage construct. In: AOSD 2013, pp. 197–208 (2013)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2016 Springer International Publishing Switzerland
About this chapter
Cite this chapter
Kamina, T., Aotani, T., Masuhara, H. (2016). Generalized Layer Activation Mechanism for Context-Oriented Programming. In: Chiba, S., Südholt, M., Eugster, P., Ziarek, L., Leavens, G. (eds) Transactions on Modularity and Composition I. Lecture Notes in Computer Science(), vol 9800. Springer, Cham. https://doi.org/10.1007/978-3-319-46969-0_4
Download citation
DOI: https://doi.org/10.1007/978-3-319-46969-0_4
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-46968-3
Online ISBN: 978-3-319-46969-0
eBook Packages: Computer ScienceComputer Science (R0)