Class FusekiServer.Builder

java.lang.Object
org.apache.jena.fuseki.main.FusekiServer.Builder
Enclosing class:
FusekiServer

public static class FusekiServer.Builder extends Object
FusekiServer.Builder
  • Method Details

    • port

      public FusekiServer.Builder port(int port)
      Set the HTTP port to run on.

      If set to 0, a random free port will be used.

    • contextPath

      public FusekiServer.Builder contextPath(String path)
      Context path to Fuseki. If it's "/" then Fuseki URL look like "http://host:port/dataset/query" else "http://host:port/path/dataset/query" The default is "/".
    • loopback

      public FusekiServer.Builder loopback(boolean loopback)
      Restrict the server to only responding to the localhost interface.
    • staticFileBase

      public FusekiServer.Builder staticFileBase(String directory)
      Set the location (filing system directory) to serve static files from.
    • staticFileBase

      public String staticFileBase()
      Get the location (if any has been set) to serve static files from. Return null if unset.
    • securityHandler

      public FusekiServer.Builder securityHandler(org.eclipse.jetty.security.SecurityHandler securityHandler)
      Set a Jetty SecurityHandler.

      This is an alternative to using the Fuseki Main built-in security configuration.

    • verbose

      public FusekiServer.Builder verbose(boolean verbose)
      Set verbose logging
    • enableCors

      public FusekiServer.Builder enableCors(boolean withCORS)
      Enable or disable a Cross Origin (CORS) filter with default settings.
      See Also:
      • CrossOriginFilter
    • enableCors

      public FusekiServer.Builder enableCors(boolean withCORS, String corsConfigFile)
      Enable a Cross Origin (CORS) filter with a specific configuration, or disable CORS processing.
      See Also:
      • CrossOriginFilter
    • enablePing

      public FusekiServer.Builder enablePing(boolean withPing)
      Add the "/$/ping" servlet that responds to HTTP very efficiently. This is useful for testing whether a server is alive, for example, from a load balancer.
    • enableStats

      public FusekiServer.Builder enableStats(boolean withStats)
      Add the "/$/stats" servlet that responds with stats about the server, including counts of all calls made.
    • enableMetrics

      public FusekiServer.Builder enableMetrics(boolean withMetrics)
      Add the "/$/metrics" servlet that responds with Prometheus metrics about the server.
    • enableCompact

      public FusekiServer.Builder enableCompact(boolean withCompact)
      Add the "/$/compact/*" servlet that triggers compaction for specified dataset. Also adds the "/$/tasks/*" servlet if compact is enabled (but if compact is disabled, then tasks is not automatically disabled).
    • enableTasks

      public FusekiServer.Builder enableTasks(boolean withTasks)
      Add the "/$/tasks" servlet that responds with info about tasks run on the server
    • getDataServiceBuilder

      public org.apache.jena.fuseki.server.DataService.Builder getDataServiceBuilder(String name)
      Get the DataService.Builder, if any, in this builder for the given service name.

      Returns the DataService.Builder or null.

      This operation does not return the FusekiServer builder.

    • getDataset

      public org.apache.jena.sparql.core.DatasetGraph getDataset(String name)
      Get the DatasetGraph, if any, being built for a service in this builder.

      Returns the DatasetGraph or null.

      This operation does not return the FusekiServer builder.

    • remove

      public org.apache.jena.sparql.core.DatasetGraph remove(String name)
      Remove the dataset from being built.

      Returns the DatasetGraph or null.

      This operation does not return the builder.

    • add

      public FusekiServer.Builder add(String name, org.apache.jena.query.Dataset dataset)
      Add the dataset with given name and a default set of services including update. This is equivalent to add(name, dataset, true).
    • add

      public FusekiServer.Builder add(String name, org.apache.jena.sparql.core.DatasetGraph dataset)
      Add the dataset with given name and a default set of services including update
    • add

      public FusekiServer.Builder add(String name, org.apache.jena.query.Dataset dataset, boolean allowUpdate)
      Add the dataset with given name and a default set of services and enabling update if allowUpdate=true.
    • add

      public FusekiServer.Builder add(String name, org.apache.jena.sparql.core.DatasetGraph dataset, boolean allowUpdate)
      Add the dataset with given name and a default set of services and enabling update if allowUpdate=true.
    • addDataset

      public FusekiServer.Builder addDataset(String name, org.apache.jena.sparql.core.DatasetGraph dataset)
      Add a dataset, do not configure it in this call. Subsequent calls of addEndpoint and addOperation will be needed to give this dataset some functionality.

      This operation replaces any previous dataset and configuration with the same canonical name.

      DataService.Builder. for building the DataService separately.

    • add

      public FusekiServer.Builder add(String name, org.apache.jena.fuseki.server.DataService.Builder dataServiceBuilder)
    • add

      public FusekiServer.Builder add(String name, org.apache.jena.fuseki.server.DataService dataService)
      Add a data service that includes dataset and service names. A DataService allows for choices of the various endpoint names. A DataService added with this operation cannot be modified further with other builder calls.
    • parseConfigFile

      public FusekiServer.Builder parseConfigFile(String filename)
      Configure using a Fuseki services/datasets assembler file.

      The application is responsible for ensuring a correct classpath. For example, including a dependency on jena-text if the configuration file includes a text index.

    • parseConfig

      public FusekiServer.Builder parseConfig(org.apache.jena.rdf.model.Model model)
      Configure using a Fuseki services/datasets assembler model.

      The application is responsible for ensuring a correct classpath. For example, including a dependency on jena-text if the configuration file includes a text index.

    • parseConfig

      public FusekiServer.Builder parseConfig(org.apache.jena.graph.Graph graph)
      Configure using a Fuseki services/datasets assembler in a Graph.

      The application is responsible for ensuring a correct classpath. For example, including a dependency on jena-text if the configuration file includes a text index.

    • jettyServerConfig

      public FusekiServer.Builder jettyServerConfig(String filename)
      Build the server using a Jetty configuration file. See Jetty/Reference/jetty.xml_syntax This is instead of any other HTTP server settings such as port and HTTPs.
    • auth

      public FusekiServer.Builder auth(org.apache.jena.atlas.web.AuthScheme authScheme)
      Choose the HTTP authentication scheme.
    • serverAuthPolicy

      public FusekiServer.Builder serverAuthPolicy(org.apache.jena.fuseki.auth.AuthPolicy authPolicy)
      Set the server-wide server authorization AuthPolicy. Defaults to "logged in users" if a password file provided but no other policy. To allow any one to access the server, use Auth.ANY_ANON.
    • realm

      public FusekiServer.Builder realm(String realm)
      Set the realm used for HTTP digest authentication.
    • passwordFile

      public FusekiServer.Builder passwordFile(String passwordFile)
      Set the password file. This will be used to build a security handler if one is not supplied. Setting null clears any previous entry. The file should be in the format of Eclipse jetty password file.
    • https

      public FusekiServer.Builder https(int httpsPort, String certStore, String certStorePasswd)
      Set the HTTPs port and provide the certificate store and password.
      Pass -1 for the httpsPort to clear the settings.
      Pass port 0 to get an allocated free port on startup.
    • https

      public FusekiServer.Builder https(int httpsPort, String certificate)
      Set the HTTPs port and read the certificate store location and password from a file. The file can be secured by the host OS. This means the password for the certificate is not in the application code.

      The file format is a JSON object:

       {
           "keystore" : "mykey.jks" ,
           "passwd"   : "certificate password"
       }
       
      Pass -1 for the httpsPort to clear the settings.
      Pass port 0 to get an allocated free port on startup.
    • addProcessor

      public FusekiServer.Builder addProcessor(String pathSpec, org.apache.jena.fuseki.servlets.ActionProcessor processor)
      Add an ActionProcessor as a servlet. ActionProcessor are the implementation of servlet handling that operate within the Fuseki logging and execution framework.
    • addProcessor

      public FusekiServer.Builder addProcessor(String pathSpec, org.apache.jena.fuseki.servlets.ActionProcessor processor, org.slf4j.Logger log)
      Add an ActionProcessor as a servlet. ActionProcessor are the implementation of servlet handling that operate within the Fuseki logging and execution framework.
    • addServlet

      public FusekiServer.Builder addServlet(String pathSpec, jakarta.servlet.http.HttpServlet servlet)
      Add the given servlet with the pathSpec. These servlets are added so that they are checked after the Fuseki filter for datasets and before the static content handler (which is the last servlet) used for staticFileBase(String).
    • addServletAttribute

      public FusekiServer.Builder addServletAttribute(String attrName, Object value)
      Add a servlet attribute. Pass a value of null to remove any existing binding.
    • getServletAttribute

      public Object getServletAttribute(String attrName)
      Read a servlet attribute that has been set during building this server.
    • addFilter

      public FusekiServer.Builder addFilter(String pathSpec, jakarta.servlet.Filter filter)
      Add a filter with the pathSpec. Note that Fuseki dispatch uses a servlet filter which is the last in the filter chain.
    • fusekiModules

      public FusekiServer.Builder fusekiModules(FusekiModules modules)
      Set the Fuseki Module for a server. If no modules are added to a builder, then the system-wide default set (found by loading FusekiModule via Java's ServiceLoader mechanism) is used.

      Pass null to switch back the system-wide default set.

      See Also:
    • fusekiModules

      public FusekiModules fusekiModules()
      Return the current list of Fuseki modules in the builder.
    • registerOperation

      public FusekiServer.Builder registerOperation(org.apache.jena.fuseki.server.Operation operation, org.apache.jena.fuseki.servlets.ActionService handler)
      Add an operation and handler to the server. This does not enable it for any dataset.

      To associate an operation with a dataset, call addEndpoint(java.lang.String, java.lang.String, org.apache.jena.fuseki.server.Operation) after adding the dataset.

      See Also:
    • registerOperation

      public FusekiServer.Builder registerOperation(org.apache.jena.fuseki.server.Operation operation, String contentType, org.apache.jena.fuseki.servlets.ActionService handler)
      Add an operation to the server, together with its triggering Content-Type (which may be null) and servlet handler.

      To associate an operation with a dataset, call addEndpoint(java.lang.String, java.lang.String, org.apache.jena.fuseki.server.Operation) after adding the dataset.

      See Also:
    • addEndpoint

      public FusekiServer.Builder addEndpoint(String datasetName, String endpointName, org.apache.jena.fuseki.server.Operation operation)
      Create an endpoint on the dataset. The operation must already be registered with the builder.
      See Also:
    • addEndpoint

      public FusekiServer.Builder addEndpoint(String datasetName, String endpointName, org.apache.jena.fuseki.server.Operation operation, org.apache.jena.fuseki.auth.AuthPolicy authPolicy)
      Create an endpoint as a service of the dataset (i.e. /dataset/endpointName). The operation must already be registered with the builder.
      See Also:
    • addOperation

      public FusekiServer.Builder addOperation(String datasetName, org.apache.jena.fuseki.server.Operation operation)
      Create an endpoint on the dataset i.e. /dataset/ for an operation that has other query parameters or a Content-Type that distinguishes it. The operation must already be registered with the builder.
      See Also:
    • addOperation

      public FusekiServer.Builder addOperation(String datasetName, org.apache.jena.fuseki.server.Operation operation, org.apache.jena.fuseki.auth.AuthPolicy authPolicy)
      Create an endpoint on the dataset i.e. /dataset/ for an operation that has other query parameters or a Content-Type that distinguishes it. Use addEndpoint(String, String, Operation) when the functionality is invoked by presence of a name in the URL after the dataset name. The operation must already be registered with the builder.
      See Also:
    • numServerThreads

      public FusekiServer.Builder numServerThreads(int minThreads, int maxThreads)
      Set the number threads used by Jetty. This uses a QueuedThreadPool provided by Jetty.

      Argument order is (minThreads, maxThreads).

      • Use (-1,-1) for Jetty "default". The Jetty 9.4 defaults are (min=8,max=200).
      • If (min != -1, max is -1) then the default max is 20.
      • If (min is -1, max != -1) then the default min is 2.
    • maxServerThreads

      public FusekiServer.Builder maxServerThreads(int maxThreads)
      Set the maximum number threads used by Jetty. This is equivalent to numServerThreads(-1, maxThreads) and overrides any previous setting of the maximum number of threads. In development or in embedded use, limiting the maximum threads can be useful.
    • start

      public FusekiServer start()
      Shortcut: build, then start the server.
    • build

      public FusekiServer build()
      Build a server according to the current description.