{"id":20032688,"url":"https://github.com/lucko/scriptcontroller","last_synced_at":"2025-06-16T07:33:38.651Z","repository":{"id":57736638,"uuid":"121050145","full_name":"lucko/ScriptController","owner":"lucko","description":"Extended API for Java's Scripting Engine framework","archived":false,"fork":false,"pushed_at":"2021-09-06T20:28:20.000Z","size":53,"stargazers_count":12,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T17:08:57.676Z","etag":null,"topics":["javax-script","nashorn","script-loader"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lucko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-10T20:10:52.000Z","updated_at":"2024-07-24T09:02:23.000Z","dependencies_parsed_at":"2022-08-24T14:57:20.729Z","dependency_job_id":null,"html_url":"https://github.com/lucko/ScriptController","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucko%2FScriptController","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucko%2FScriptController/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucko%2FScriptController/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucko%2FScriptController/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucko","download_url":"https://codeload.github.com/lucko/ScriptController/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252445649,"owners_count":21749093,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["javax-script","nashorn","script-loader"],"created_at":"2024-11-13T09:38:45.414Z","updated_at":"2025-05-05T05:30:44.700Z","avatar_url":"https://github.com/lucko.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ScriptController\n\nExtended API for Java's [Scripting Engine framework](https://docs.oracle.com/javase/8/docs/api/javax/script/package-summary.html) (`javax.script`) with the Nashorn JavaScript engine.\n\n\nScriptController provides:\n\n* Automatic detection \u0026 reloading of script files\n* Global export registry system\n* Builder-style API for constructing new controllers and environments\n\n### Usage\n\nThe main entry point into the API is via `ScriptController`.\n\nThe following is a valid way to obtain an instance.\n\n```java\nScriptController controller = ScriptController.builder().build();\n```\n\nHowever, it's likely that you'll want to customize certain aspects of the controller.\n\n```java\nLogger logger = Logger.getLogger(\"my-logger\");\nSpecialObject mySpecialObject = new SpecialObject();\n\nEnvironmentSettings environmentSettings = EnvironmentSettings.builder()\n        .initScript(\"init.js\")\n        .withDefaultPackageImport(\"java.util\")\n        .withDefaultTypeImport(\"me.lucko.test.MyTestClass\")\n        .withDefaultTypeImport(\"com.example.RuntimeManager\")\n        .withBindings((script, accumulator) -\u003e {\n            accumulator.put(\"specialObject\", mySpecialObject);\n            accumulator.put(\"bootstrap\", this);\n        })\n        .build();\n\nScriptController controller = ScriptController.builder()\n        .logger(SystemLogger.usingJavaLogger(logger))\n        .withDirectory(Paths.get(\"scripts/\"))\n        .defaultEnvironmentSettings(environmentSettings)\n        .build();\n```\n\nThese are just a few examples of the available settings. ScriptController is designed with flexibility in mind.\n\n`ScriptController`s \"manage\" a number of `ScriptEnvironments`, which center around a root scripts directory.\n\nYou can define these environments when building the controller, using `.withDirectory(...)`, or after the controller has been constructed.\n\n```java\nScriptController controller = ScriptController.builder().build();\nScriptEnvironment env = controller.setupNewEnvironment(Paths.get(\"src\"), EnvironmentSettings.defaults());\n```\n\n`ScriptEnvironment` exposes further instances which make up the overall system.\n\n```java\nExportRegistry exports = env.getExportRegistry();\nEnvironmentScriptLoader loader = env.getLoader();\nScriptRegistry scriptRegistry = env.getScriptRegistry();\n```\n\n* `ExportRegistry` holds a shared set of \"exports\". This is effectively a namespace which is shared between scripts.\n* `EnvironmentScriptLoader` is responsible for loading/reloading/unloading scripts, and monitoring the source directory for changes.\n* `ScriptRegistry` holds all currently loaded scripts.\n\nThe library has extensive JavaDocs - all public classes, methods and fields have documentation. More detailed commentary and explanation on the purpose, behaviour and usage of methods and classes can be found there.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucko%2Fscriptcontroller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucko%2Fscriptcontroller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucko%2Fscriptcontroller/lists"}