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.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Default port when running in Java viaFusekiServer....build()
. -
Method Summary
Modifier and TypeMethodDescriptionstatic FusekiServer
Construct a Fuseki server from command line arguments.static FusekiServer.Builder
create()
Return a builder, with the default choices of actions available.static FusekiServer.Builder
create
(org.apache.jena.fuseki.server.OperationRegistry serviceDispatchRegistry) Return a builder, with a custom set of operation-action mappings.datasetURL
(String dsName) Return the URL for a local dataset.org.apache.jena.fuseki.server.DataAccessPointRegistry
Get theDataAccessPointRegistry
.int
Get the HTTP port.int
Get the HTTPS port.org.eclipse.jetty.server.Server
Get the underlying Jetty server which has also been set up.Return the list ofFusekiModule
s for this server.org.apache.jena.fuseki.server.OperationRegistry
Get theOperationRegistry
.int
getPort()
Return the port being used.jakarta.servlet.ServletContext
Get theServletContext
used for Fuseki processing.Return the filename to the static content area.void
join()
Wait for the server to exit.static FusekiServer
Construct a Fuseki server for one dataset.Calculate the server URL for "localhost".start()
Start the server - the server continues to run after this call returns.void
stop()
Stop the server.
-
Field Details
-
DefaultServerPort
public static final int DefaultServerPortDefault port when running in Java viaFusekiServer....build()
. The server will be http://localhost:3330. This is not the command line port (3030) which the command line programme sets. SeeFusekiMain.defaultPort
andFusekiMain.defaultHttpsPort
.- See Also:
-
-
Method Details
-
construct
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
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 operationcreate()
. -
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 UsegetHttpsPort()
. -
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
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
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 theServletContext
used for Fuseki processing. Adding new servlets is possible with care. -
getDataAccessPointRegistry
public org.apache.jena.fuseki.server.DataAccessPointRegistry getDataAccessPointRegistry()Get theDataAccessPointRegistry
. This method is intended for inspecting the registry. -
getOperationRegistry
public org.apache.jena.fuseki.server.OperationRegistry getOperationRegistry()Get theOperationRegistry
. This method is intended for inspecting the registry. -
getStaticContentDir
Return the filename to the static content area. Returns null if there is no such area. -
getModules
Return the list ofFusekiModule
s for this server. -
start
Start the server - the server continues to run after this call returns. To synchronise with the server stopping, calljoin()
. -
stop
public void stop()Stop the server. -
join
public void join()Wait for the server to exit. This call is blocking.
-