Skip to content

Commit

Permalink
📝 Clarify plugin deployment on nested dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
ujibang committed Jun 13, 2024
1 parent 6635d70 commit 6a22e7b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
32 changes: 28 additions & 4 deletions docs/plugins/deploy.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 2 additions & 4 deletions docs/plugins/overview.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]: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]
Expand Down Expand Up @@ -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]
----
Expand Down

0 comments on commit 6a22e7b

Please sign in to comment.