{"id":45151103,"url":"https://github.com/jaccomoc/jactl-vertx","last_synced_at":"2026-03-06T12:07:16.005Z","repository":{"id":151146397,"uuid":"618136965","full_name":"jaccomoc/jactl-vertx","owner":"jaccomoc","description":"Jacsal integration with Vert.x","archived":false,"fork":false,"pushed_at":"2025-07-25T04:14:02.000Z","size":162,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-25T09:25:39.602Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jaccomoc.png","metadata":{"files":{"readme":"docs/README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-03-23T20:38:03.000Z","updated_at":"2025-07-25T04:12:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"9cf1c081-a26a-4af7-ac16-60a4adf662d5","html_url":"https://github.com/jaccomoc/jactl-vertx","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/jaccomoc/jactl-vertx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaccomoc%2Fjactl-vertx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaccomoc%2Fjactl-vertx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaccomoc%2Fjactl-vertx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaccomoc%2Fjactl-vertx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaccomoc","download_url":"https://codeload.github.com/jaccomoc/jactl-vertx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaccomoc%2Fjactl-vertx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29639809,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T22:32:43.237Z","status":"online","status_checked_at":"2026-02-20T02:00:07.535Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-02-20T03:03:50.845Z","updated_at":"2026-02-20T03:03:52.117Z","avatar_url":"https://github.com/jaccomoc.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jactl-Vertx\n\nThe Jactl-Vertx project is a project that adds a [Vert.x](https://vertx.io/) based execution environment\nto the [Jactl](https://jactl.io) scripting language along with some additional methods\nand an example function that shows how to extend Jactl with your own application specific functions/methods.\n\n## Dependency\n\nTo use this library you will need to add a dependency on the `jactl-vertx` library.\n\n### Gradle\n\nIn the `dependencies` section of your `build.gradle` file:\n```groovy\nimplementation group: 'io.jactl', name: 'jactl-vertx', version: '2.3.0'\n```\n\nIf you want to use the example `sendReceiveJson()` function then also include a dependency on the `tests` jar (you\nwill need to have built the `tests` jar locally as this is not published in Maven Central):\n```groovy\nimplementation group:'io.jactl', name:'jactl-vertx', version:'2.3.0', classifier:'tests'\n```\n\n### Maven\n\nIn the `dependencies` section of your `pom.xml`:\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.jactl\u003c/groupId\u003e\n  \u003cartifactId\u003ejactl-vertx\u003c/artifactId\u003e\n  \u003cversion\u003e2.3.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nIf you have built the `tests` jar locally and want to use it in a test application then add this (the `tests` jar is\nnot published in Maven Central):\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.jactl\u003c/groupId\u003e\n  \u003cartifactId\u003ejactl-vertx\u003c/artifactId\u003e\n  \u003cversion\u003e2.3.0\u003c/version\u003e\n  \u003cclassifier\u003etests\u003c/classifier\u003e\n\u003c/dependency\u003e\n```\n\n# Building\n\n## Requirements\n\n* Java 11+\n* Jactl 2.3.0\n* Gradle 8.0.2\n* Vert.x 4.4.6\n\n## Build\n\nDownload a zip file of the source from GitHub or use `git` to clone the repository:\n\n```shell\ngit clone https://github.com/jaccomoc/jactl-vertx.git\ncd jactl-vertx\n./gradlew build testJar\n```\n\nThat will build `jactl-vertx-${VERSION}.jar` and `jactl-vertx-${VERSION}-tests.jar` under the `build/libs` directory\nwhere `${VERSION}` is the current version or the version of the tag/branch you have checked out.\n\nTo push the `jactl-vertx` jar to your local Maven repository you can use `publishToMavenLocal`:\n```shell\n./gradlew build testJar publishToMavenLocal\n```\n\n# Integration\n\n## Jactl Environment Class\n\nThe `io.jactl.vertx.JactlVertxEnv` class provides a bridge between the Jactl runtime and the Vert.x runtime\nenvironment to allow Jactl to run on Vert.x event-loop threads and schedule blocking work on Vert.x blocking worker\nthreads.\n\nIt should be constructed by passing a `Vertx` instance and the `JactlVertxEnv` should be set on the `JactlContext`\nobject that you create using the `JactlContext.environment()` method.\nSee next section for an example.\n\n## Application Integration\n\nTo add the additional functions/methods from the `jactl-vertx` library to your Jactl based application you will need\nto make sure that the functions/methods are registered with the Jactl runtime by invoking\n`io.jactl.vertx.JsonFunctions.registerFunctions()` (for the JSON methods) and, if you want to use the example\n`sendReceiveJson()` function, invoking `example.io.jactl.vertx.VertxFunctions.registerFunctions()`.\n\nBoth these methods should be passed the instance of the `io.jactl.vertx.JactlVertxEnv` class that is also passed to\nthe `JactlContext.environment()` method when constructing your `JactlContext` object.\n\nFor example, here we construct the `JactlVertxEnv` object and pass it to the `registerFunctions()` calls as well\nas setting it on our `JactlContext` object:\n```java\nclass MyVertxApp {\n  Vertx vertx;\n  public void init() {\n    this.vertx         = Vertx.vertx();\n    JactlVertxEnv env = new JactlVertxEnv(vertx);\n    \n    // Register functions/methods\n    JsonFunctions.registerFunctions(env);\n    VertxFunctions.registerFunctions(env);   // If using example sendReceiveJson() method\n    \n    JactlContext context = JactlContext.create()\n                                         .environment(env)\n                                         .build();\n    ...\n  }\n}\n```\n\n## Jactl REPL and Jactl Commandline Integration\n\nTo include these methods/functions in your Jactl REPL or Jactl commandline scripts you can set your `~/.jactlrc`\nconfiguration file to include something like the following:\n\n```groovy\ndef VERS = '2.3.0'                                                  // The jactl-vertx version to use\ndef LIBS = \"~/.m2/repository/io/jactl/jactl-vertx/${VERS}\"         // Location of the jars\n\n// Specify the Vertx based environment class to use\nenvironmentClass = 'io.jactl.vertx.JactlVertxEnv'\n\n// List the extra jactl-vertx jars\nextraJars        = [ \"$LIBS/jactl-vertx-${VERS}.jar\",\n                     \"$LIBS/jactl-vertx-${VERS}-tests.jar\" ]\n\n// List the function registration classes\nfunctionClasses  = [ 'io.jactl.vertx.JsonFunctions',\n                     'example.io.jactl.vertx.VertxFunctions' ]\n```\n\n\u003e **Note**\u003cbr/\u003e\n\u003e The `jactl-vertx` test jar is built as a \"fat\" jar and includes the dependencies it needs (including the\n\u003e Vert.x libraries) so we don't need to separately list the Vert.x jars as well.\n\n## Functions\n\nAn example of a Jactl global function called `sendReceiveJson()` is provided in the `tests` jar.\n\n### sendReceiveJson(String url, def request)\n\nThe `sendReceiveJson()` function is an example function provided to show how to extend Jactl with your own\nglobal functions and methods.\nIt will send a JSON encoded request to a remote URL and wait for the response.\nIt does a `POST` and passes the JSON as the request body to the remote server and then decodes the JSON response\nthat comes back.\n\nThe return value of the function is a Map that contains a field called `statusCode` with the HTTP status code\nand then either:\n* a field called `response` with the decoded JSON body if the status code is 2xx, or\n* a field called `errorMsg` with the error message if a non-2xx status is received.\n\nFor example:\n```groovy\n\u003e sendReceiveJson('http://localhost:58476/wordCount', [text:'here are some words to count'])\n[response:6, statusCode:200]\n```\n\nAnd an example with named args:\n```groovy\n\u003e sendReceiveJson(url:'http://localhost:58476/wordCount', request:[text:'here are some more words to be counted'])\n[response:8, statusCode:200]\n```\n\nHere are some examples where an error occurrs:\n```groovy\n\u003e sendReceiveJson('http://localhost:58476/bad', [arg:'abc'])\n[errorMsg:'java.nio.file.NoSuchFileException: scripts/bad.jactl', statusCode:404]\n\u003e sendReceiveJson(url:'http://localhost:58476/wordCount', request:[bad:'here are some more words to be counted'])\n[errorMsg:'jactl.runtime.DieError: Missing value for text field', statusCode:400]\n```\n\n# Example Application\n\nIn the `tests` jar is an example application showing how to integrate a simple Vert.x based web server with Jactl\nscripting.\n\nThe server listens for JSON requests and looks for the URI portion of the URL to work out what script to\nrun to handle the request.\nFor example, if the incoming URL is 'http://localhost:8080/doSomething' then it will look for a Jactl script\nunder the directory from where it is running called `scripts/doSomething.jactl`.\nIf the script exists it will compile it and invoke it with a global variable called `request` containing the\nbody of the request (already decoded).\n\nThe application will cache the compiled script so that it doesn't need to recompile it each time, but it\nmonitors the source code for any changes (every 5 seconds), and if it has changed it will recompile it\nif another request for that script comes in.\n\nTo run the example application, create a subdirectory called `scripts` under the location where you are\ngoing to run from and then add the `jactl-vertx` jar and `jactl-vertx` `tests` jar to the java classpath\nand invoke `io.jactl.vertx.example.ExampleWebServer`.\nBy default, it will listen on a random port:\n```shell\n$ java -cp jactl-vertx-2.3.0-tests.jar:jactl-vertx-2.3.0.jar io.jactl.vertx.example.ExampleWebServer\nListening on localhost:52178\n```\n\nIf you pass in a port number on the command line it will use that instead:\n```shell\n$ java -cp jactl-vertx-2.3.0-tests.jar:jactl-vertx-2.3.0.jar io.jactl.vertx.example.ExampleWebServer 8080\nListening on localhost:8080\n```\n\nYou can specify the host address to listen on by using `hostname:port`:\n```shell\n$ java -cp jactl-vertx-2.3.0-tests.jar:jactl-vertx-2.3.0.jar io.jactl.vertx.example.ExampleWebServer 8080\nListening on localhost:8080\n```\n\nIf the `hostname` portion is blank (i.e. you pass it `:port`) then it will bind to all local addresses\nand listen on the port.\n\nIf the `port` is blank (i.e. has the form `hostname:`) then it will bind to that address with a random\nport.\n\nAssume we run it on port 8080:\n```shell\n$ java -cp jactl-vertx-2.3.0-tests.jar:jactl-vertx-2.3.0.jar io.jactl.vertx.example.ExampleWebServer 8080\nListening on localhost:8080\n```\n\nNow assume we have created a Jactl script for counting words and put it in under `scripts/wordCount.jactl`:\n```groovy\n// Validate request. Should be of form: [text:'some text to be word counted']\ndie 'Missing value for text field' unless request instanceof Map \u0026\u0026 request.text\ndef badFields = request.filter{ k,v -\u003e k != 'text' }.map{ k,v -\u003e k }\ndie \"Unknown field${badFields.size() \u003e 1 ? 's' : ''}: ${badFields.join(', ')}\" if badFields\n\nrequest.text.split(/\\s+/)         // split on whitespace\n            .filter{ /^\\w+$/r }   // filter for things that only contain word characters\n            .size()               // return the count\n```\n\nWe can then invoke the script from the Jactl REPL like this using the `sendReceiveJson()` example function\ndescribed previously:\n```groovy\n\u003e sendReceiveJson(url:'http://localhost:8080/wordCount', request:[text:'here are some more words to be counted'])\n[response:8, statusCode:200]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaccomoc%2Fjactl-vertx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaccomoc%2Fjactl-vertx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaccomoc%2Fjactl-vertx/lists"}