You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "OyvindLGjesdal (via GitHub)" <gi...@apache.org> on 2023/06/07 21:37:37 UTC

[GitHub] [jena-site] OyvindLGjesdal commented on a diff in pull request #159: Update Fuseki Module documentation

OyvindLGjesdal commented on code in PR #159:
URL: https://github.com/apache/jena-site/pull/159#discussion_r1222201864


##########
source/documentation/fuseki2/fuseki-modules.md:
##########
@@ -4,53 +4,80 @@ title: Fuseki Modules
 
 <em>Fuseki modules</em> are a mechanism to include extension code into a Fuseki
 server. Modules are invoked during the process of building a [Fuseki
-Main](./fuseki-main.html) server. The module can modify the server
+Main](./fuseki-main.html) server. A module can modify the server
 configuration, add new functionality, or react to a server being built and
 started.
 
-This feature was added in Jena version 4.3.0. They are an expeirmental feature
+This feature was added in Jena version 4.3.0. It is an expeirmental feature
 that will evolve based on experineace and use cases.
 
-Fuseki Modules are loaded use the JDK
-[ServiceLoader](https://www.baeldung.com/java-spi) by being placing a jar file on the classpath,
+FusekiModules can be provided in two ways:
+
+* Loaded from additional jars on the classpath
+* Programmatically controlling the setup of the `FusekiServer` server.
+
+### Automatically loaded
+
+Fuseki Modules can be loaded use the JDK
+[ServiceLoader](https://www.baeldung.com/java-spi) by being placing
+a jar file on the classpath,
 together with any additional dependencies. The service loader looks for files
 `META-INF/services/org.apache.jena.fuseki.main.sys.FusekiModule` in the jar
 file.
+
 This is often done by placing the file in the development code in
 `src/main/resources/META-INF/services/`).
 The file containing a line with the implementation full class name. If
 [repacking](../notes/jena-repack.html) Fuseki with the maven-shade-plugin, make
 sure the `ServicesResourceTransformer` is used. The module must have a no
 argument constructor.
 
+The method `start` is called when the module is loaded. Custom operations can
+be globally registered at this point (see the [Fuseki
+examples](https://github.com/apache/jena/tree/main/jena-fuseki2/jena-fuseki-main/src/test/java/org/apache/jena/fuseki/main/examples) directory).
+
+### Programmaticaly configuring a server
+
 If using Fuseki as an [embedded server](./fuseki-embedded.html), the module is
 added in code as:
 
 ```
-    FusekiModule module = new MyModule();
-    FusekiModules.add(module);
+    FusekiModule myModule = new MyModule();
+    FusekiModules fmods = FusekiModules.create(myModule);
+    FusekiServer server = FusekiServer.create()
+        ...
+        .fusekiModules(fmods)
+        ...
+        .build();  
 ```
 
-The method `start` is called when the module is loaded. Custom operations can
-be globally registered at this point (see the [Fuseki
-examples](https://github.com/apache/jena/tree/main/jena-fuseki2/jena-fuseki-main/src/test/java/org/apache/jena/fuseki/main/examples) directory).
+`FusekiModule.start()` is not automatically called.
+
+### Fuseki Module operations
 
 The module lifecycle during creating a Fuseki server is:
 
-* `configuration` - access and modify the setup. 
-  This is called after the server has been configured, just before the server is built.
-* `server` - access the built server
-* `serverBeforeStarting` - about to call "server.start()"
-* `serverAfterStarting` - just after calling "server.start()"
-* `serverStopped` - called as the server stop 
+* `prepare` - called at the start of the server
+   build steps before setting up the datasets.
+* `configured` - access and modify the setup. 
+   This is called after the server has been configured, before the server is built.
+   It defaults to calls to `configDataAccessPoint` for dataset being hosted by the server.
+* `server` - called after the built, beforee the return of `FusekiServerBuilder.build()`
+
+and the Fuseki start up sequence is:
+
+* `serverBeforeStarting` - called at the start of `server.start()`
+* `serverAfterStarting` - called at the end of `server.start()`
+* `serverStopped` - called as just after the server
+    has stopped in the `server.stop()` call.
   (note, this is not always called because a server can simply exit the JVM).
 
-A Fuseki module does not need to implement all these steps, the default for all
+A Fuseki module does not need to implement all these steps. The default for all
 of them is "do nothing". Usually, an extension will only be interested in
 certain stpes, like the configuration and registry information of

Review Comment:
   stpes -> steps?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org