Class EndpointBase
- java.lang.Object
-
- org.eclipse.rdf4j.federated.endpoint.EndpointBase
-
- All Implemented Interfaces:
Endpoint
- Direct Known Subclasses:
RepositoryEndpoint
,ResolvableEndpoint
public abstract class EndpointBase extends Object implements Endpoint
Base implementation for anEndpoint
.Provides implementation for the common behavior as well as connection management. Typically a fresh
RepositoryConnection
is returned when invokinggetConnection()
, however, it is configurable that a managed (singleton) connection can be used.- Author:
- Andreas Schwarte
- See Also:
EndpointManager
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EndpointBase.ManagedRepositoryConnection
A wrapper for managedRepositoryConnection
s which makes sure thatEndpointBase.ManagedRepositoryConnection.close()
is a no-op, i.e.
-
Field Summary
Fields Modifier and Type Field Description protected String
endpoint
protected EndpointClassification
endpointClassification
protected EndpointConfiguration
endpointConfiguration
protected boolean
initialized
protected static org.slf4j.Logger
log
protected RepositoryInformation
repoInfo
protected TripleSource
tripleSource
protected boolean
writable
-
Constructor Summary
Constructors Constructor Description EndpointBase(RepositoryInformation repoInfo, String endpoint, EndpointClassification endpointClassification)
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.rdf4j.federated.endpoint.Endpoint
getRepository
-
-
-
-
Field Detail
-
log
protected static final org.slf4j.Logger log
-
repoInfo
protected final RepositoryInformation repoInfo
-
endpoint
protected final String endpoint
-
endpointClassification
protected EndpointClassification endpointClassification
-
writable
protected boolean writable
-
initialized
protected boolean initialized
-
tripleSource
protected TripleSource tripleSource
-
endpointConfiguration
protected EndpointConfiguration endpointConfiguration
-
-
Constructor Detail
-
EndpointBase
public EndpointBase(RepositoryInformation repoInfo, String endpoint, EndpointClassification endpointClassification)
-
-
Method Detail
-
getName
public String getName()
-
getTripleSource
public TripleSource getTripleSource()
- Specified by:
getTripleSource
in interfaceEndpoint
- Returns:
- the
TripleSource
-
getEndpointClassification
public EndpointClassification getEndpointClassification()
- Specified by:
getEndpointClassification
in interfaceEndpoint
- Returns:
- the
EndpointClassification
-
setEndpointClassification
public void setEndpointClassification(EndpointClassification endpointClassification)
-
isLocal
public boolean isLocal()
-
isWritable
public boolean isWritable()
- Specified by:
isWritable
in interfaceEndpoint
- Returns:
- whether this endpoint is writable
-
getRepoInfo
public RepositoryInformation getRepoInfo()
-
setWritable
public void setWritable(boolean writable)
- Parameters:
writable
- the writable to set
-
getEndpointConfiguration
public EndpointConfiguration getEndpointConfiguration()
Description copied from interface:Endpoint
Additional endpoint specific configuration.- Specified by:
getEndpointConfiguration
in interfaceEndpoint
- Returns:
- the endpointConfiguration
-
setEndpointConfiguration
public void setEndpointConfiguration(EndpointConfiguration endpointConfiguration)
- Parameters:
endpointConfiguration
- the endpointConfiguration to set
-
getConnection
public RepositoryConnection getConnection()
Description copied from interface:Endpoint
Return aRepositoryConnection
for theRepository
represented by this endpoint.Callers of this method need to ensure to close the connection after use.
Typical pattern:
try (RepositoryConnection conn = endpoint.getConnection()) { // do something with the connection }
If the
RepositoryConnection
needs to stay open outside the scope of a method (e.g. for streaming results), consider usingCloseDependentConnectionIteration
.- Specified by:
getConnection
in interfaceEndpoint
- Returns:
- the repository connection
-
getFreshConnection
protected RepositoryConnection getFreshConnection()
-
getId
public String getId()
-
getEndpoint
public String getEndpoint()
Description copied from interface:Endpoint
Get the endpoint location, e.g. for SPARQL endpoints the url- Specified by:
getEndpoint
in interfaceEndpoint
- Returns:
- the endpoint location
-
getType
public EndpointType getType()
-
isInitialized
public boolean isInitialized()
- Specified by:
isInitialized
in interfaceEndpoint
- Returns:
- whether this Endpoint is initialized
-
size
public long size() throws RepositoryException
Description copied from interface:Endpoint
Returns the size of the given repository, i.e. the number of triples.- Specified by:
size
in interfaceEndpoint
- Returns:
- the size of the endpoint
- Throws:
RepositoryException
-
init
public void init(FederationContext federationContext) throws RepositoryException
Description copied from interface:Endpoint
Initialize thisEndpoint
- Specified by:
init
in interfaceEndpoint
- Throws:
RepositoryException
-
useSingleConnection
protected boolean useSingleConnection()
Whether to reuse the sameRepositoryConnection
throughout the lifetime of this Endpoint.Note that the
RepositoryConnection
is wrapped asEndpointBase.ManagedRepositoryConnection
- Returns:
- indicator whether a single connection should be used
-
shutDown
public void shutDown() throws RepositoryException
Description copied from interface:Endpoint
Shutdown thisEndpoint
- Specified by:
shutDown
in interfaceEndpoint
- Throws:
RepositoryException
-
-