Class SPARQLRepository
- java.lang.Object
-
- org.eclipse.rdf4j.repository.base.AbstractRepository
-
- org.eclipse.rdf4j.repository.sparql.SPARQLRepository
-
- All Implemented Interfaces:
HttpClientDependent,SessionManagerDependent,Repository
public class SPARQLRepository extends AbstractRepository implements HttpClientDependent, SessionManagerDependent
A proxy class to access any SPARQL 1.1 endpoint.- Author:
- James Leigh
-
-
Field Summary
-
Fields inherited from class org.eclipse.rdf4j.repository.base.AbstractRepository
logger
-
-
Constructor Summary
Constructors Constructor Description SPARQLRepository(String endpointUrl)Create a new SPARQLRepository using the supplied endpoint URL for queries and updates.SPARQLRepository(String queryEndpointUrl, String updateEndpointUrl)Create a new SPARQLRepository using the supplied query endpoint URL for queries, and the supplied update endpoint URL for updates.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected SPARQLProtocolSessioncreateHTTPClient()Deprecated.usecreateSPARQLProtocolSession()insteadprotected SPARQLProtocolSessioncreateSPARQLProtocolSession()Creates a newSPARQLProtocolSessionobject.voidenableQuadMode(boolean flag)Activate quad mode for thisSPARQLRepository, i.e.Map<String,String>getAdditionalHttpHeaders()Get the additional HTTP headers which will be usedRepositoryConnectiongetConnection()FilegetDataDir()org.apache.http.client.HttpClientgetHttpClient()HttpClientSessionManagergetHttpClientSessionManager()BooleangetPassThroughEnabled()Retrieve the passThroughEnabled setting to be used for any newly createdRepositoryConnections.org.eclipse.rdf4j.model.ValueFactorygetValueFactory()protected voidinitializeInternal()booleanisWritable()voidsetAdditionalHttpHeaders(Map<String,String> additionalHttpHeaders)Set additional HTTP headers to be included in every request to the server, which may be required for certain unusual server configurations.voidsetDataDir(File dataDir)voidsetHttpClient(org.apache.http.client.HttpClient httpClient)voidsetHttpClientSessionManager(HttpClientSessionManager client)voidsetPassThroughEnabled(Boolean passThroughEnabled)Set the passThroughEnabled configuration.voidsetUsernameAndPassword(String username, String password)Set the username and password to use for authenticating with the remote repository.protected voidshutDownInternal()StringtoString()-
Methods inherited from class org.eclipse.rdf4j.repository.base.AbstractRepository
init, isInitialized, shutDown
-
-
-
-
Constructor Detail
-
SPARQLRepository
public SPARQLRepository(String endpointUrl)
Create a new SPARQLRepository using the supplied endpoint URL for queries and updates.- Parameters:
endpointUrl- a SPARQL endpoint URL. May not be null.
-
SPARQLRepository
public SPARQLRepository(String queryEndpointUrl, String updateEndpointUrl)
Create a new SPARQLRepository using the supplied query endpoint URL for queries, and the supplied update endpoint URL for updates.- Parameters:
queryEndpointUrl- a SPARQL endpoint URL for queries. May not be null.updateEndpointUrl- a SPARQL endpoint URL for updates. May not be null.- Throws:
IllegalArgumentException- if one of the supplied endpoint URLs is null.
-
-
Method Detail
-
getHttpClientSessionManager
public HttpClientSessionManager getHttpClientSessionManager()
- Specified by:
getHttpClientSessionManagerin interfaceSessionManagerDependent
-
setHttpClientSessionManager
public void setHttpClientSessionManager(HttpClientSessionManager client)
- Specified by:
setHttpClientSessionManagerin interfaceSessionManagerDependent
-
getHttpClient
public final org.apache.http.client.HttpClient getHttpClient()
- Specified by:
getHttpClientin interfaceHttpClientDependent
-
setHttpClient
public void setHttpClient(org.apache.http.client.HttpClient httpClient)
- Specified by:
setHttpClientin interfaceHttpClientDependent
-
createSPARQLProtocolSession
protected SPARQLProtocolSession createSPARQLProtocolSession()
Creates a newSPARQLProtocolSessionobject. The life-cycle of this is per-connection.- Returns:
- a SPARQLProtocolSession object.
-
createHTTPClient
@Deprecated protected SPARQLProtocolSession createHTTPClient()
Deprecated.usecreateSPARQLProtocolSession()instead
-
getConnection
public RepositoryConnection getConnection() throws RepositoryException
- Specified by:
getConnectionin interfaceRepository- Throws:
RepositoryException
-
getDataDir
public File getDataDir()
- Specified by:
getDataDirin interfaceRepository
-
getValueFactory
public org.eclipse.rdf4j.model.ValueFactory getValueFactory()
- Specified by:
getValueFactoryin interfaceRepository
-
initializeInternal
protected void initializeInternal() throws RepositoryException- Specified by:
initializeInternalin classAbstractRepository- Throws:
RepositoryException
-
isWritable
public boolean isWritable() throws RepositoryException- Specified by:
isWritablein interfaceRepository- Throws:
RepositoryException
-
setDataDir
public void setDataDir(File dataDir)
- Specified by:
setDataDirin interfaceRepository
-
setUsernameAndPassword
public void setUsernameAndPassword(String username, String password)
Set the username and password to use for authenticating with the remote repository.- Parameters:
username- the username. Setting this to null will disable authentication.password- the password. Setting this to null will disable authentication.
-
shutDownInternal
protected void shutDownInternal() throws RepositoryException- Specified by:
shutDownInternalin classAbstractRepository- Throws:
RepositoryException
-
getAdditionalHttpHeaders
public Map<String,String> getAdditionalHttpHeaders()
Get the additional HTTP headers which will be used- Returns:
- a read-only view of the additional HTTP headers which will be included in every request to the server.
-
setAdditionalHttpHeaders
public void setAdditionalHttpHeaders(Map<String,String> additionalHttpHeaders)
Set additional HTTP headers to be included in every request to the server, which may be required for certain unusual server configurations. This will only take effect on connections subsequently returned bygetConnection().- Parameters:
additionalHttpHeaders- a map containing pairs of header names and values. May be null
-
enableQuadMode
public void enableQuadMode(boolean flag)
Activate quad mode for thisSPARQLRepository, i.e. for retrieval of statements also retrieve the graph.Note: the setting is only applied in newly created
SPARQLConnections as the setting is an immutable configuration of a connection instance.- Parameters:
flag- flag to enable or disable the quad mode- See Also:
SPARQLConnection#getStatements(org.eclipse.rdf4j.model.Resource, org.eclipse.rdf4j.model.URI, org.eclipse.rdf4j.model.Value, boolean, org.eclipse.rdf4j.model.Resource...)
-
getPassThroughEnabled
public Boolean getPassThroughEnabled()
Retrieve the passThroughEnabled setting to be used for any newly createdRepositoryConnections.- Returns:
- the passThroughEnabled setting. May be
nullif not explicitly configured. - See Also:
SPARQLProtocolSession.isPassThroughEnabled()
-
setPassThroughEnabled
public void setPassThroughEnabled(Boolean passThroughEnabled)
Set the passThroughEnabled configuration. Changing this will influence behavior of any newRepositoryConnections, but not of existing ones.- Parameters:
passThroughEnabled- the passThroughEnabled to set- See Also:
SPARQLProtocolSession#setPassThroughEnabled()
-
-