Skip to main content
Top

2016 | OriginalPaper | Chapter

Generalized Layer Activation Mechanism for Context-Oriented Programming

Authors : Tetsuo Kamina, Tomoyuki Aotani, Hidehiko Masuhara

Published in: Transactions on Modularity and Composition I

Publisher: Springer International Publishing

Activate our intelligent search to find suitable subject content or patents.

search-config
loading …

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.

Dont have a licence yet? Then find out more about our products and how to get one now:

Springer Professional "Wirtschaft+Technik"

Online-Abonnement

Mit Springer Professional "Wirtschaft+Technik" erhalten Sie Zugriff auf:

  • über 102.000 Bücher
  • über 537 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Maschinenbau + Werkstoffe
  • Versicherung + Risiko

Jetzt Wissensvorsprung sichern!

Springer Professional "Technik"

Online-Abonnement

Mit Springer Professional "Technik" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 390 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Maschinenbau + Werkstoffe




 

Jetzt Wissensvorsprung sichern!

Springer Professional "Wirtschaft"

Online-Abonnement

Mit Springer Professional "Wirtschaft" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 340 Zeitschriften

aus folgenden Fachgebieten:

  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Versicherung + Risiko




Jetzt Wissensvorsprung sichern!

Footnotes
1
We use the term “context” to indicate the temporal context.
 
2
As illustrated in Sect. 3.2, we believe that this ordering is preferable in many cases. However, we also acknowledge that it is preferable for programmers to configure the ordering policy in particular cases. This configuration mechanism is discussed in Sect. 7.
 
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.
 
Literature
1.
go back to reference 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: 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)
2.
go back to reference 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) 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)
3.
go back to reference 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.: Featherweight EventCJ: a core calculus for a context-oriented language with event-based per-instance layer transition. In: COP 2011 (2011)
4.
go back to reference 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) 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)
5.
go back to reference 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., Lincke, J., Perscheid, M.: A comparison of context-oriented programming languages. In: COP 2009, pp. 1–6 (2009)
6.
go back to reference 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., Haupt, M., Masuhara, H.: ContextJ: context-oriented programming with Java. Comput. Softw. 28(1), 272–292 (2011)
7.
go back to reference 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.: Improving the development of context-dependent Java application with ContextJ. In: COP 2009 (2009)
8.
go back to reference 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 CrossRef 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 CrossRef
9.
go back to reference 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 CrossRef 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 CrossRef
10.
go back to reference 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) 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)
11.
go back to reference 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) 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)
12.
go back to reference Costanza, P., Hirschfeld, R.: Language constructs for context-oriented programming - an overview of ContextL. In: Dynamic Language Symposium (DLS) 2005, pp. 1–10 (2005) Costanza, P., Hirschfeld, R.: Language constructs for context-oriented programming - an overview of ContextL. In: Dynamic Language Symposium (DLS) 2005, pp. 1–10 (2005)
14.
go back to reference 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 CrossRef 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 CrossRef
15.
go back to reference 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., Cádiz, A.: Context-oriented programming with the ambient object systems. J. Univ. Comput. Sci. 14(20), 3307–3332 (2008)
16.
go back to reference 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) 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)
17.
go back to reference Hirschfeld, R., Costanza, P., Nierstrasz, O.: Context-oriented programming. J. Object Technol. 7(3), 125–151 (2008)CrossRef Hirschfeld, R., Costanza, P., Nierstrasz, O.: Context-oriented programming. J. Object Technol. 7(3), 125–151 (2008)CrossRef
18.
go back to reference Hirschfeld, R., Igarashi, A., Masuhara, H.: ContextFJ: a minimal core calculus for context-orientedprogramming. In: FOAL 2011, pp. 19–23 (2011) Hirschfeld, R., Igarashi, A., Masuhara, H.: ContextFJ: a minimal core calculus for context-orientedprogramming. In: FOAL 2011, pp. 19–23 (2011)
19.
go back to reference Igarashi, A., Hirschfeld, R., Masuhara, H.: A type system for dynamic layer composition. In: FOOL 2012 (2012) Igarashi, A., Hirschfeld, R., Masuhara, H.: A type system for dynamic layer composition. In: FOOL 2012 (2012)
20.
go back to reference Igarashi, A., Pierce, B., Wadler, P.: Featherweight Java: a minimal core calculus for Java and GJ. ACM TOPLAS 23(3), 396–450 (2001)CrossRef Igarashi, A., Pierce, B., Wadler, P.: Featherweight Java: a minimal core calculus for Java and GJ. ACM TOPLAS 23(3), 396–450 (2001)CrossRef
21.
go back to reference 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.: EventCJ: a context-oriented programming language with declarative event-based context transition. In: AOSD 2011, pp. 253–264 (2011)
22.
go back to reference Kamina, T., Aotani, T., Masuhara, H.: Introducing composite layers in EventCJ. IPSJ Trans. Program. 6(1), 1–8 (2013)CrossRef Kamina, T., Aotani, T., Masuhara, H.: Introducing composite layers in EventCJ. IPSJ Trans. Program. 6(1), 1–8 (2013)CrossRef
23.
go back to reference 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 CrossRef 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 CrossRef
24.
go back to reference 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)CrossRef 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)CrossRef
25.
go back to reference 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 CrossRef 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 CrossRef
26.
go back to reference Malakuti, S., Akşit, M.: Evolution of composition filters to event composition. In: SAC 2012, pp. 1850–1857 (2012) Malakuti, S., Akşit, M.: Evolution of composition filters to event composition. In: SAC 2012, pp. 1850–1857 (2012)
27.
go back to reference Odersky, M., Zenger, M.: Scalable component abstractions. In: OOPSLA 2005, pp. 41–57 (2005) Odersky, M., Zenger, M.: Scalable component abstractions. In: OOPSLA 2005, pp. 41–57 (2005)
29.
go back to reference Salvaneschi, G., Ghezzi, C., Pradella, M.: ContextErlang: introducing context-oriented programming in theactor model. In: AOSD 2012 (2012) Salvaneschi, G., Ghezzi, C., Pradella, M.: ContextErlang: introducing context-oriented programming in theactor model. In: AOSD 2012 (2012)
30.
go back to reference 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 CrossRef 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 CrossRef
31.
go back to reference Ungar, D., Smith, R.B.: Self: the power of simplicity. In: OOPSLA 1987, pp. 227–241 (1987) Ungar, D., Smith, R.B.: Self: the power of simplicity. In: OOPSLA 1987, pp. 227–241 (1987)
32.
go back to reference 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) 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)
33.
go back to reference Zhuang, Y.Y., Chiba, S.: Method slots: supporting methods, events, and advices by a singlelanguage construct. In: AOSD 2013, pp. 197–208 (2013) Zhuang, Y.Y., Chiba, S.: Method slots: supporting methods, events, and advices by a singlelanguage construct. In: AOSD 2013, pp. 197–208 (2013)
Metadata
Title
Generalized Layer Activation Mechanism for Context-Oriented Programming
Authors
Tetsuo Kamina
Tomoyuki Aotani
Hidehiko Masuhara
Copyright Year
2016
DOI
https://doi.org/10.1007/978-3-319-46969-0_4

Premium Partner