diff --git a/docs/plugins/deploy.adoc b/docs/plugins/deploy.adoc index 9a37f690..650ac971 100644 --- a/docs/plugins/deploy.adoc +++ b/docs/plugins/deploy.adoc @@ -10,13 +10,37 @@ This section provides information on how to package and deploy plugins. NOTE: To quick start a new Java plugin, you can clone the link:https://github.com/SoftInstigate/restheart-plugin-skeleton[plugin skeleton repository]. It contains a basic skeleton for a plugin and an helper script that allows to build, deploy the plugin. -== Java Plugins +== Deploying Java Plugins in RESTHeart -Java and Kotlin plugins must be packaged as jar files. +Java (and Kotlin, Scala, etc.) plugins must be packaged as JAR files. Deploying a plugin is straightforward: **just copy its JAR file into the `./plugins` directory of RESTHeart**. -To deploy a plugin, *just copy its jar file into the directory `./plugins` of RESTHeart*. +**IMPORTANT:** After deploying a JAR plugin, you must restart RESTHeart. -IMPORTANT: After deploying a jar plugin, you must restart RESTHeart. +You can also nest your JARs into the `./plugins` directory up to two levels deep. This is particularly useful when developing a custom plugin. In this scenario, your Java project directory structure might look like this: + +[source] +---- +. +├── LICENSE +├── README.md +├── pom.xml +├── src +│ ├── main +│ └── test +└── target + ├── classes + ├── lib + │ ├── lib1.jar + │ └── lib2.jar + ├── plugin.jar +---- + +In this case, you need to deploy `plugin.jar` along with the dependency libraries `lib1.jar` and `lib2.jar`. + +To deploy, you can simply copy the entire `target` directory into the `./plugins` directory. If you are using Docker, you can mount the `target` directory under `/opt/restheart/plugins/custom` with the following command: + +[source,bash] +$ docker run --name restheart --rm -p "8080:8080" -v ./target:/opt/restheart/plugins/custom softinstigate/restheart === Example diff --git a/docs/plugins/overview.adoc b/docs/plugins/overview.adoc index 9d925e8d..7b51933f 100644 --- a/docs/plugins/overview.adoc +++ b/docs/plugins/overview.adoc @@ -40,11 +40,9 @@ To quick start a new plugin, you can clone the link:https://github.com/SoftInsti [source,bash] ---- $ git clone --depth 1 git@github.com:SoftInstigate/restheart-plugin-skeleton.git && cd restheart-plugin-skeleton -$ ./bin/rh.sh build -o "-s" +$ ./mvnw clean package && docker run --name restheart --rm -p "8080:8080" -v ./target:/opt/restheart/plugins/custom softinstigate/restheart -s ---- -The script `./bin/rh.sh` automatically builds, deploys the plugin and restart RESTHeart to apply changes. At first run, it also automatically downloads the latest version of RESTHeart. - The project skeleton defines a dummy Service bound at `/srv`: [source] @@ -198,7 +196,7 @@ Available providers allow to inject the following objects: - `@Inject("registry")` - injects the `PluginsRegistry` singleton that allows a plugin to get the reference of other plugins. - `@Inject("mclient")` - injects the `MongoClient` object that has been already initialized and connected to MongoDB by the `mongo-client-provider`. - `@Inject("mclient-reactive")` - injects the reactive `MongoClient` object that has been already initialized and connected to MongoDB by the `mongo-client-provider`. -- `@Inject("acl-registru")` - injects the ACL registry to define permission programmatically +- `@Inject("acl-registry")` - injects the ACL registry to define permission programmatically [source,java] ----