Skip to content

bThink-BGU/COBPjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

COBPjs: A Context-Oriented Behavioral Programming Environment based on BPjs

This repository contains a javascript-based Context-Oriented Behavioral Programming (COBP) library.

License

  • 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.

Getting COBPjs

Creating a new Maven project

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>

Start from a template project

Clone SampleBPProject and change to the COBP branch.

git clone -b COBP https://github.com/achiyae/SampleBPProject.git

Writing COBP Programs

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

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.

Documentation & Relevant links


Citation

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}},
}