This repository contains a javascript-based Context-Oriented Behavioral Programming (COBP) library.
- COBPjs is open sourced under the MIT license. If you use it in a system, please provide a link to this page somewhere in the documentation/system about section.
- COBPjs uses the BPjs. Project page and source code can be found here.
- COBPjs uses the Mozilla Rhino JavaScript engine. Project page and source code can be found here.
Add JitPack repository:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Also add COBPjs dependency. Note that the version number changes....
<dependencies>
<dependency>
<groupId>com.github.bThink-BGU</groupId>
<artifactId>COBPjs</artifactId>
<version>0.6.12</version>
</dependency>
</dependencies>
Clone SampleBPProject and change to the COBP branch.
git clone -b COBP https://github.com/achiyae/SampleBPProject.git
This section assumes that you are already familiar with the COBP paradigm. If this is not the case, you should start by reading the COBP Paper.
A COBP program usually includes at least two files:
- dal.js: The specification of the context schema, the effect functions, the queries, and the initial contextual data.
- bl.js: The specification of the context-dependent behaviors.
Examples for such programs are in the src/test directory.
Important
You must not use bp.sync
and bp.registerBThread
. Instead, use sync
and bthread
.
If you wish to bind a bthread to a context, use ctx.bthread
.
Running a COBP program is similar to the execution of a BP program:
BProgram bprog = new ContextBProgram("dal.js", "bl.js"); //you can change the files names...
BProgramRunner rnr = new BProgramRunner(bprog);
There is a full example for a main file - here.
- COBP Paper introducing COBP, COLSC, and COBPjs.
- A presentation at MORSE18 introduces COLSC and the paper "A Context-Based Behavioral Language for IoT".
- COLSC paper introduces the LCS implementation for COBP.
- SampleProgram sample usage of many language idioms.
- Tic-Tac-Toe introduces a COBP implementation of the game.
- Hot-Cold introduces a COBP implementation of an extended hot cold example.
- BPjs documentation and tutorials - a great starting point for BP.
- Behavioral Programming - introduces behavioral programming.
- BPjs Google group
To cite the paper on COBP:
@article{cobp,
title = {Context-Oriented Behavioral Programming},
journal = {Information and Software Technology},
volume = {133},
pages = {106504},
year = {2021},
issn = {0950-5849},
doi = {https://doi.org/10.1016/j.infsof.2020.106504},
url = {https://www.sciencedirect.com/science/article/pii/S095058492030094X},
author = {Achiya Elyasaf},
keywords = {Behavioral programming, Scenario-based programming, Programming paradigm, Context awareness, Context-oriented programming, Context-Oriented Behavioral Programming}
}
To cite this repository in publications:
@misc{cobpjs,
author = {Achiya Elyasaf},
title = {COBPjs: Context-oriented behavioral programming in JavaScript},
year = {2021},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/bThink-BGU/COBPjs}},
}