Code Monkey home page Code Monkey logo

scribble-java's Introduction

Build Status Released Version

Java Tooling for Scribble

This project provides Java tooling/libraries for the Scribble multi-party protocol definition language.

Building from source

First step is to clone this git repository locally. Once available, run the following maven command to build the project:

mvn [clean] install

The distribution will be available from the folder scribble-dist/target. The contents of the zip is:

  • lib jars needed to run the scribble-java tool
  • scribblec.sh script for running the command line tool

Command line usage:

Assuming scribblec.sh has been extracted from the above zip:

List command line options.

./scribblec.sh --help

Assuming a Scribble module file Test.scr in the same directory:

Check well-formedness of global protocols in module Test.scr.

./scribblec.sh Test.scr

Note: try the -V command line flag to obtain full traces for errors (and other details).

Project local protocol for role "C" of protocol "Proto" in Test.scr

./scribblec.sh Test.scr -project Proto C

Print (a dot representation of) the Endpoint FSM for role "C" of protocol "Proto" in Test.scr

./scribblec.sh Test.scr -fsm Proto C

Generate Java Endpoint API for role "C" of protocol "Proto" in Test.scr

./scribblec.sh -d . Test.scr -api Proto C

Note: omitting the -d argument will print the output to stdout.

Examples:

To write a HelloWorld protocol in Test.scr (e.g., for the commands listed above):

echo 'module Test; global protocol Proto(role C, role S) { Hello() from C to S; }' > Test.scr

Further examples can be found in:

https://github.com/scribble/scribble-java/tree/master/scribble-demos/scrib

The distribution zip does not include these examples. They can be obtained as part of the source repository, or separately via the above link.

E.g. To generate the Java Endpoint API for role "C" in the "Adder" protocol from the Scribble-Java tutorial (http://www.scribble.org/docs/scribble-java.html#QUICK)

./scribblec.sh scribble-demos/scrib/tutorial/src/tutorial/adder/Adder.scr 
    -d scribble-demos/scrib/tutorial/src/ -api Adder C 

Alternative command line usage:

To run the Scribble tool directly via java, try

./scribblec.sh --verbose [args]

to see the underlying java command with main class, classpath and other args.

Or try (from Nick Ng):

mvn dependency:build-classpath -Dmdep.outputFile=classpath

java -cp $(cat dist/classpath) org.scribble.cli.CommandLine [args] MyModule.scr

Issue reporting

Bugs and issues can be reported via the github Issues facility.

Or email r.z.h.hu1234 [at] herts.ac.uk excluding the 1234.

scribble-java's People

Contributors

rhu1 avatar objectiser avatar fangyi-zhou avatar nickng avatar dependabot[bot] avatar

Stargazers

 avatar Hiroaki Inoue avatar Karuna Grewal avatar Stéphane Legrand avatar  avatar Ruijie Fang avatar Oleksandr Nikitin avatar Anson Miu avatar Rakhmad Azhari avatar Nos Doughty avatar Shafqat Ullah avatar Conrad Steenberg avatar Cheng Kuan avatar Anqur avatar Rajiv Abraham avatar Alessio Coltellacci avatar  avatar Marcin Kuthan avatar Sean Jensen-Grey avatar Stig Kleppe-Jørgensen avatar He-Pin(kerr) avatar Jun Liu avatar  avatar weekend bear avatar  avatar Dominic Orchard avatar  avatar  avatar Mahmoud Rusty Abdelkader avatar David Castro-Perez avatar  avatar Jonathan King avatar friendlywavingrobot avatar  avatar MATSUBARA Nobutada avatar Tristan NGUYEN avatar Masaki Hara avatar Jan de Muijnck-Hughes avatar Erik Anderson avatar  avatar Martin Ellis avatar Shane Pearman avatar Nat Ravenhill avatar  avatar Arun Udayashankar avatar Suminda Sirinath Salpitikorala Dharmasena avatar Simon Fowler avatar Mark Stillwell avatar bobwenx avatar Pierre-Malo Deniélou avatar  avatar  avatar  avatar HAYASHI, Tatsuya (aka. lef) avatar

Watchers

Stig Kleppe-Jørgensen avatar  avatar  avatar James Cloos avatar Pierre-Malo Deniélou avatar Erik Anderson avatar  avatar

scribble-java's Issues

Support module level projection

Currently the core requires the module file, protocol and role to be specified, which results in a local protocol being generated in a module named "".

Although this may be useful in situations where only the individual protocol is required - other situations (such as in tooling environments that operate on the module level), would be easier if the project could be done based on the module and role - resulting in a module named "_" and containing a project of all the protocols in the global module.

Add support for module path

In scribble 0.3 spec it introduces the concept of a module path, similar to the Java concept of a class path, to provide zero or more directories that can be searched to find a module.

Consider separating out CLI into own repository

Not sure yet whether this should be done, as the resulting repository will be very small. However it would also be targetted to producing a particular type of tool.

If we have already decided to separate out Eclipse and eventual Web App tooling, then having separate CLI repo makes sense - but there again it could be the default approach bundled with the core project.

Monitor/Simulate mechanism for validating a stream of events/actions against FSM

The initial requirement is to support simulation of a trace (series of sends/receives) against a set of FSMs - one per role (or service) being simulated.

However the more general case will be to manage a set of session instances, per role/service, over time - with the events being received in realtime. It is also possible that there will be multiple instances of the monitor (for load balancing/resilience purposes), so the session data needs to be persisted in a shared db/cache (should be pluggable to allow different implementations).

This means that the session needs a way to save the position within the FSM, for a particular session instance (and service/role), and then be able to recover it when a new event for an existing session instance is received.

So in the case of OpenTracing - the role will be determined by the service name, and the session instance by the trace id.

eclipse vs. mvn install target CL scripts

Consider separating CL scribblec scripts aimed at Scribble built by Eclipse vs mvn install.

Although the only difference (currently) between them would be the classpath entries for each. Perhaps factor out just that part, so that changes to other parts of the script do not need to be repeated for both.

Currrently, the single script looks for both Eclipse and mvn build outout on a single classpath, with higher priority for the Eclipse output. This works fine if one or the other is not actually present.

Eclipse plugin support for running traces

Have a launch configuration type (with Run As menu support) that can operate on .trace files.

Experiment with creating junit xml files (in a temp area?) and opening the editor on it to show the results.

Handle multicast/broadcast communications

Creating this issue as a placeholder for discussions about multicast and broadcast communications.

In scribble we can specify multiple 'to' roles which would enable different endpoints, representing different behaviours, to receive and use the same message.

However wondering whether we also need to cater for multiple (potentially unbounded) instances of a role(s) - I think we would need to find some real world examples to understand whether this is relevant.

If defining a global protocol, then would we have multiple recipients all behaving the same way - but doing something differently internally, to warrant it being considered equivalent from an externally observable behaviour perspective?

Running Adder Demo

I am an undergraduate CS student, as part of my honours thesis I have been studying MPST and trying to find use cases for Scribble. I've been trying to follow the tutorial at http://www.scribble.org/docs/scribble-java.html, and have been trying to execute the Adder implementations provided.

I apologize that I am still new to Java and maven so I'm probably just not doing something very simple. If anyone can help it would be appreciated.

When I try to compile, for instance, AdderS.java, I get the following error:

scribble-java-master\scribble-demos\scrib\tutorial\src\tutorial\adder\AdderS.java:16: error: package tutorial.adder.Adder.Adder does not exist
import static tutorial.adder.Adder.Adder.Adder.Add;
                                        ^

Which makes me think that I need to compile the file tutorial/adder/Adder/Adder/Adder.java

Attempting this gives the error

scribble-java-master\scribble-demos\scrib\tutorial\src\tutorial\adder\Adder\Adder\Adder.java:7: error: package org.scribble.core.type.name does not exist
import org.scribble.core.type.name.Role;
                                  ^

Am I going about this the wrong way? Have I missed some part of setting up the software? Or am I not supposed to try to compile these files this way? I am using Windows 10 and trying to run the software on the command line. I apologize again for my inexperience.

Is there updated documentation on this? attempting to use Scribble protocols

The wiki documentation does not seem to line up with the code.

https://github.com/scribble/scribble-java/wiki/SJDGProtocol references classes like org.scribble.parser.ProtocolParser pp=new org.scribble.parser.ProtocolParser(); which seem to no longer exist since v0.4.x

should we not be using this version 4? is there any documentation for v4 that describes how to parse scribble syntax as it seems to have been rewritten or at least heavily refactored from the from the current developer guides

running scribblec.sh from command line only opens a window which then closes immediately

I am trying to follow the tutorial at http://www.scribble.org/docs/scribble-java.html
I used eclipse to "Maven install" the project and extracted the resulting zip file.
On Windows, both scribblec.sh --help and scribblec.sh scribble-demos/scrib/tutorial/src/tutorial/adder/Adder.scr -api Adder C -d scribble-demos/scrib/tutorial/src/ have the same result: a black window with a caret opens and immediately closes. No endpoints were generated for the adder.
The window has the following title: "usr/bin/bash --login -i" followed by the path of scribblec.sh and the parameters (e.g. --help).

Handling redirects, retries and fallbacks

Microservices tend to use common infrastructure patterns to make the systems more resilient, for example circuit breakers to prevent services from being overloaded by returning a 'default' response, retry mechanisms, fallbacks, etc.

We need to examine how these are handled from a scribble protocol description and monitoring perspective.

Naming convensions for Scribble Protocols

I noticed that scribblec generates package paths with capitalized name if I use capitalized protocol names, i.e. if I name my global protocol "Sample" under module org.example with file name scribble, the Java package path will be inconsistent with Java naming convensions: org.example.scribble.Sample is the package name. But it seems like in Scribble doc, capitalized names are preferred as they are also used as part of class name, and the naming convention for Java classname is indeed Capitalized. Is there a way to generate API packages that are both compliant with Scribble and with Java conventions?

Mechanism for obtaining type from particular activities

Main example is message, where a parameter name or type alias could be used, which may also reference a type imported from another module.

Need some utility that can be given the context within a description, and also use cached modules (so not to continually reload on each request), to return the actual type being used.

`scribble-ast` classpath missing in `scribblec.sh` after mvn install?

When compiling using mvn clean && mvn install with JDK 12.0.1, the scribblec.sh file after unzipping scribble-dist/target/ does not load a classpath for scribble-ast, which results in the following Exception when executing:

Error: Unable to initialize main class org.scribble.cli.CommandLine
Caused by: java.lang.NoClassDefFoundError: org/scribble/ast/ProtoDecl

Manually adding scribble-ast classpath into scribblec.sh fixes this issue:

 99 ARGS=
100 
101 CLASSPATH=$DIR'/scribble-cli/target/classes/'
102 CLASSPATH=$CLASSPATH':'$DIR'/scribble-core/target/classes'
103 CLASSPATH=$CLASSPATH':'$DIR'/scribble-ast/target/classes'
104 CLASSPATH=$CLASSPATH':'$DIR'/scribble-lang/target/classes'
105 CLASSPATH=$CLASSPATH':'$DIR'/scribble-parser/target/classes'
106 CLASSPATH=$CLASSPATH':'$DIR'/scribble-codegen/target/classes'
107 CLASSPATH=$CLASSPATH':'$DIR'/scribble-main/target/classes'
108 CLASSPATH=$CLASSPATH':'$ANTLR
109 CLASSPATH=$CLASSPATH':'$DIR'/'$LIB'/antlr.jar'
110 CLASSPATH=$CLASSPATH':'$DIR'/'$LIB'/antlr-runtime.jar'
111 CLASSPATH=$CLASSPATH':'$DIR'/'$LIB'/commons-io.jar'
112 CLASSPATH=$CLASSPATH':'$DIR'/'$LIB'/scribble-core.jar'
113 CLASSPATH=$CLASSPATH':'$DIR'/'$LIB'/scribble-lang.jar'
114 CLASSPATH=$CLASSPATH':'$DIR'/'$LIB'/scribble-parser.jar'
115 CLASSPATH=$CLASSPATH':'$DIR'/'$LIB'/scribble-codegen.jar'
116 CLASSPATH=$CLASSPATH':'$DIR'/'$LIB'/scribble-main.jar'
117 CLASSPATH=$CLASSPATH':'$DIR'/'$LIB'/scribble-cli.jar'
118 CLASSPATH=$CLASSPATH':'$DIR'/'$LIB'/stringtemplate.jar'
119 CLASSPATH="'"`fixpath "$CLASSPATH"`"'"
120 
121 usage=0

Implement CLI and tests

Currently the CLI is not implemented - and the only test ignored.

Need to update to include support for command line usage.

Role problem on message transfer causes focus on message signature

Due to role not having positional information, updated error messages to be reported against GMessageTransfer - however if the role does not exist, the highlighted position is the message signature (-1).

Need to investigate how the positional information is assigned to the model objects.

Message transfer Role objects do not have positional information

MessageTransfer validation rule has been changed to associate errors with the complete element, until positional information is available on the role.

Currently the DefaultParserContext is only receiving these roles as a token, rather than ModelObject, so not applying the properties - need to investigate.

Move scribble artifacts out of modules folder

As raised by @rhu1 via email, it would be better for the artifact folder names to reflect the artifact id - and as the modules folder no longer has its own pom (as the artifacts are in the main org.scribble groupId), it would be better to locate them under the top level folder.

Therefore,the sub-folders in the existing modules folder should be moved up a level (removing the modules folder), and renamed to include prefix scribble-. The root pom.xml should then be update to reference the new location/names.

Support projection

Provide support for projecting a global model into local models per role.

Handling timeouts

Need to examine some concrete scenarios of how timeouts are handled in a microservices context.

Error notification API

Ray's code currently uses exceptions for reporting issues found in a Scribble definition.

However when integrating into Eclipse or other tooling (e.g. webapp) we will want to provide a list of errors and allow the user to navigate to the appropriate part of the scribble definition associated with the error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.