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
RepositoryConnectionis 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 classEndpointBase.ManagedRepositoryConnectionA wrapper for managedRepositoryConnections which makes sure thatEndpointBase.ManagedRepositoryConnection.close()is a no-op, i.e.
-
Field Summary
Fields Modifier and Type Field Description protected Stringendpointprotected EndpointClassificationendpointClassificationprotected EndpointConfigurationendpointConfigurationprotected booleaninitializedprotected static org.slf4j.Loggerlogprotected RepositoryInformationrepoInfoprotected TripleSourcetripleSourceprotected booleanwritable
-
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:
getTripleSourcein interfaceEndpoint- Returns:
- the
TripleSource
-
getEndpointClassification
public EndpointClassification getEndpointClassification()
- Specified by:
getEndpointClassificationin interfaceEndpoint- Returns:
- the
EndpointClassification
-
setEndpointClassification
public void setEndpointClassification(EndpointClassification endpointClassification)
-
isLocal
public boolean isLocal()
-
isWritable
public boolean isWritable()
- Specified by:
isWritablein 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:EndpointAdditional endpoint specific configuration.- Specified by:
getEndpointConfigurationin interfaceEndpoint- Returns:
- the endpointConfiguration
-
setEndpointConfiguration
public void setEndpointConfiguration(EndpointConfiguration endpointConfiguration)
- Parameters:
endpointConfiguration- the endpointConfiguration to set
-
getConnection
public RepositoryConnection getConnection()
Description copied from interface:EndpointReturn aRepositoryConnectionfor theRepositoryrepresented 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
RepositoryConnectionneeds to stay open outside the scope of a method (e.g. for streaming results), consider usingCloseDependentConnectionIteration.- Specified by:
getConnectionin interfaceEndpoint- Returns:
- the repository connection
-
getFreshConnection
protected RepositoryConnection getFreshConnection()
-
getId
public String getId()
-
getEndpoint
public String getEndpoint()
Description copied from interface:EndpointGet the endpoint location, e.g. for SPARQL endpoints the url- Specified by:
getEndpointin interfaceEndpoint- Returns:
- the endpoint location
-
getType
public EndpointType getType()
-
isInitialized
public boolean isInitialized()
- Specified by:
isInitializedin interfaceEndpoint- Returns:
- whether this Endpoint is initialized
-
size
public long size() throws RepositoryExceptionDescription copied from interface:EndpointReturns the size of the given repository, i.e. the number of triples.- Specified by:
sizein interfaceEndpoint- Returns:
- the size of the endpoint
- Throws:
RepositoryException
-
init
public void init(FederationContext federationContext) throws RepositoryException
Description copied from interface:EndpointInitialize thisEndpoint- Specified by:
initin interfaceEndpoint- Throws:
RepositoryException
-
useSingleConnection
protected boolean useSingleConnection()
Whether to reuse the sameRepositoryConnectionthroughout the lifetime of this Endpoint.Note that the
RepositoryConnectionis wrapped asEndpointBase.ManagedRepositoryConnection- Returns:
- indicator whether a single connection should be used
-
shutDown
public void shutDown() throws RepositoryExceptionDescription copied from interface:EndpointShutdown thisEndpoint- Specified by:
shutDownin interfaceEndpoint- Throws:
RepositoryException
-
-