Class FusekiServer

java.lang.Object
org.apache.jena.fuseki.main.FusekiServer

public class FusekiServer extends Object
Fuseki server.

This is a Fuseki server running with a pre-configured set of datasets and services.

To create a embedded sever, use FusekiServer (make(int, java.lang.String, org.apache.jena.sparql.core.DatasetGraph) is a packaging of a call to FusekiServer for the case of one dataset, responding to localhost only).

The application calls start() to run the server (it will run in the background : see join()).

Example:

      DatasetGraph dsg = ...;
      FusekiServer server = FusekiServer.create()
          .port(1234)
          .add("/ds", dsg)
          .build();
       server.start();
 

Supplying a port number of 0, causes the server to allocate a free port and use that. The actual port can be found with getPort().

The following compact form builds a server that only responds to localhost traffic:

    FusekiServer.make(1234, "/ds", dsg).start();
 
which may be useful for a test server.
  • Field Details

  • Method Details

    • construct

      public static FusekiServer construct(String... args)
      Construct a Fuseki server from command line arguments. The return server has not been started.
    • make

      public static FusekiServer make(int port, String name, org.apache.jena.sparql.core.DatasetGraph dsg)
      Construct a Fuseki server for one dataset. It only responds to localhost. The returned server has not been started.
    • create

      public static FusekiServer.Builder create()
      Return a builder, with the default choices of actions available.
    • create

      public static FusekiServer.Builder create(org.apache.jena.fuseki.server.OperationRegistry serviceDispatchRegistry)
      Return a builder, with a custom set of operation-action mappings. An endpoint must still be created for the server to be able to provide the action. An endpoint dispatches to an operation, and an operation maps to an implementation. This is a specialised operation - normal use is the operation create().
    • getPort

      public int getPort()
      Return the port being used.

      This will be the server port, which defaults to 3330 for embedded use, and to 3030 for command line use, or one actually allocated if the port was 0 ("choose a free port").

      If https is in-use, this is the HTTPS port.

      If http and https are in-use, this is the HTTPS port.

      If there multiple ports of the same schema, return any one port in use.

      See also getHttpPort() or Use getHttpsPort().

    • getHttpPort

      public int getHttpPort()
      Get the HTTP port.

      Returns -1 for no HTTP port.

      If there are multiple HTTP ports configured, returns one of them.

    • getHttpsPort

      public int getHttpsPort()
      Get the HTTPS port.

      Returns -1 for no HTTPS port.

      If there are multiple HTTPS ports configured, returns one of them.

    • serverURL

      public String serverURL()
      Calculate the server URL for "localhost".

      Example: http://localhost:3330/. The URL ends in "/". The host name is "localhost". If both HTTP and HTTPS are available, then reply with an HTTPS URL.

      This operation is useful when using Fuseki as an embedded test server.

    • datasetURL

      public String datasetURL(String dsName)
      Return the URL for a local dataset.

      Example: http://localhost:3330/dataset. The host name is "localhost". If both HTTP and HTTPS are available, then reply with an HTTPS URL.

      This operation is useful when using Fuseki as an embedded test server.

    • getJettyServer

      public org.eclipse.jetty.server.Server getJettyServer()
      Get the underlying Jetty server which has also been set up.
    • getServletContext

      public jakarta.servlet.ServletContext getServletContext()
      Get the ServletContext used for Fuseki processing. Adding new servlets is possible with care.
    • getDataAccessPointRegistry

      public org.apache.jena.fuseki.server.DataAccessPointRegistry getDataAccessPointRegistry()
      Get the DataAccessPointRegistry. This method is intended for inspecting the registry.
    • getOperationRegistry

      public org.apache.jena.fuseki.server.OperationRegistry getOperationRegistry()
      Get the OperationRegistry. This method is intended for inspecting the registry.
    • getStaticContentDir

      public String getStaticContentDir()
      Return the filename to the static content area. Returns null if there is no such area.
    • getModules

      public FusekiModules getModules()
      Return the list of FusekiModules for this server.
    • start

      public FusekiServer start()
      Start the server - the server continues to run after this call returns. To synchronise with the server stopping, call join().
    • stop

      public void stop()
      Stop the server.
    • join

      public void join()
      Wait for the server to exit. This call is blocking.