Package org.eclipse.rdf4j.federated.endpoint

## Class EndpointFactory

- java.lang.Object
- - org.eclipse.rdf4j.federated.endpoint.EndpointFactory

-     public class EndpointFactory
      extends Object

  Utility class providing various methods to create Endpoints to be used as federation members.
  Author:
    Andreas Schwarte

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `protected static class` | `EndpointFactory.DefaultRDFHandler` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `EndpointFactory()` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static String` | `getId​(String endpointID, String type)` | Construct a unique id for the provided SPARQL Endpoint, e.g http://dbpedia.org/ => %type%_dbpedia.org
    `static Endpoint` | `loadEndpoint​(String id, Repository repository)` | Load an `Endpoint` for a given (configured) Repository.
    `static List<Endpoint>` | `loadFederationMembers​(File dataConfig, File fedXBaseDir)` | Utility function to load federation members from a data configuration file.
    `static List<Endpoint>` | `loadFederationMembers​(Model members, File baseDir)` | Utility function to load federation members from a model.
    `static Endpoint` | `loadNativeEndpoint​(File location)` | Construct a `NativeStore` endpoint using the provided information and the file location as name.
    `static Endpoint` | `loadNativeEndpoint​(String name, File location)` | Construct a NativeStore endpoint using the provided information.
    `static Endpoint` | `loadRemoteRepository​(String repositoryServer, String repositoryName)` |
    `static Endpoint` | `loadRemoteRepository​(String repositoryServer, String repositoryName, boolean writable)` |
    `static Endpoint` | `loadResolvableRepository​(String repositoryId)` | Load a `ResolvableEndpoint`
    `static Endpoint` | `loadResolvableRepository​(String repositoryId, boolean writable)` | Load a `ResolvableEndpoint`
    `static Endpoint` | `loadSPARQLEndpoint​(String endpoint)` | Construct a SPARQL endpoint using the the provided information and the host of the url as name.
    `static Endpoint` | `loadSPARQLEndpoint​(String name, String endpoint)` | Construct a SPARQL endpoint using the the provided information.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### EndpointFactory

          public EndpointFactory()

  - ### Method Detail

    - #### loadSPARQLEndpoint

          public static Endpoint loadSPARQLEndpoint​(String name,
                                                    String endpoint)
                                             throws FedXException

      Construct a SPARQL endpoint using the the provided information.
      Parameters:
        `name` - a descriptive name, e.g. http://dbpedia
        `endpoint` - the URL of the SPARQL endpoint, e.g. http://dbpedia.org/sparql
      Returns:
        an initialized `EndpointBase` containing the repository
      Throws:
        `FedXException`

    - #### loadSPARQLEndpoint

          public static Endpoint loadSPARQLEndpoint​(String endpoint)
                                             throws FedXException

      Construct a SPARQL endpoint using the the provided information and the host of the url as name.
      Parameters:
        `endpoint` - the URL of the SPARQL endpoint, e.g. http://dbpedia.org/sparql
      Returns:
        an initialized `EndpointBase` containing the repository
      Throws:
        `FedXException`

    - #### loadRemoteRepository

          public static Endpoint loadRemoteRepository​(String repositoryServer,
                                                      String repositoryName)
                                               throws FedXException

      Throws:
        `FedXException`

    - #### loadRemoteRepository

          public static Endpoint loadRemoteRepository​(String repositoryServer,
                                                      String repositoryName,
                                                      boolean writable)
                                               throws FedXException

      Throws:
        `FedXException`

    - #### loadResolvableRepository

          public static Endpoint loadResolvableRepository​(String repositoryId)

      Load a `ResolvableEndpoint`

      The federation must be initialized with a `RepositoryResolver` ( see `FedXFactory.withRepositoryResolver(RepositoryResolver)`) and this resolver must offer a Repository with the id provided by `Endpoint.getId()`

      Note that the name is set to "http://" + repositoryId

      Parameters:
        `repositoryId` - the repository identifier
      Returns:
        the configured `Endpoint`
      See Also:
        `ResolvableRepositoryProvider`, `ResolvableRepositoryInformation`

    - #### loadResolvableRepository

          public static Endpoint loadResolvableRepository​(String repositoryId,
                                                          boolean writable)

      Load a `ResolvableEndpoint`

      The federation must be initialized with a `RepositoryResolver` ( see `FedXFactory.withRepositoryResolver(RepositoryResolver)`) and this resolver must offer a Repository with the id provided by `Endpoint.getId()`

      Note that the name is set to "http://" + repositoryId

      Parameters:
        `repositoryId` - the repository identifier
        `writable` - whether to configure the endpoint as writable.
      Returns:
        the configured `Endpoint`
      See Also:
        `ResolvableRepositoryProvider`, `ResolvableRepositoryInformation`

    - #### loadEndpoint

          public static Endpoint loadEndpoint​(String id,
                                              Repository repository)
                                       throws FedXException

      Load an `Endpoint` for a given (configured) Repository.

      Note that `EndpointType` is set to `EndpointType.Other`

      If the repository is already initialized, it is assumed that the lifecycle is managed externally. Otherwise, FedX will make sure to take care for the lifecycle of the repository, i.e. initialize and shutdown.

      Parameters:
        `id` - the identifier, e.g. "myRepository"
        `repository` - the constructed repository
      Returns:
        the initialized endpoint
      Throws:
        `FedXException`

    - #### loadNativeEndpoint

          public static Endpoint loadNativeEndpoint​(String name,
                                                    File location)
                                             throws FedXException

      Construct a NativeStore endpoint using the provided information.

      If the repository location denotes an absolute path, the native store directory must already exist. If a relative path is used, the repository is created on the fly (if necessary).

      Parameters:
        `name` - a descriptive name, e.g. http://dbpedia
        `location` - the location of the data store, either absolute or relative in a "repositories" subfolder `SailRepository.getDataDir()`
      Returns:
        an initialized endpoint containing the repository
      Throws:
        `FedXException`

    - #### loadNativeEndpoint

          public static Endpoint loadNativeEndpoint​(File location)
                                             throws FedXException

      Construct a `NativeStore` endpoint using the provided information and the file location as name.

      If the repository location denotes an absolute path, the native store directory must already exist. If a relative path is used, the repository is created on the fly (if necessary).

      Parameters:
        `location` - the location of the data store
      Returns:
        an initialized endpoint containing the repository
      Throws:
        `FedXException`

    - #### loadFederationMembers

          public static List<Endpoint> loadFederationMembers​(File dataConfig,
                                                             File fedXBaseDir)
                                                      throws FedXException

      Utility function to load federation members from a data configuration file.

      A data configuration file provides information about federation members in form of turtle. Currently the types NativeStore, ResolvableEndpoint and SPARQLEndpoint are supported. For details please refer to the documentation in `NativeRepositoryInformation`, `ResolvableRepositoryInformation` and `SPARQLRepositoryInformation`.

      Parameters:
        `dataConfig` -
      Returns:
        a list of initialized endpoints, i.e. the federation members
      Throws:
        `FedXException`

    - #### loadFederationMembers

          public static List<Endpoint> loadFederationMembers​(Model members,
                                                             File baseDir)
                                                      throws FedXException

      Utility function to load federation members from a model.

      Currently the types NativeStore, ResolvableEndpoint and SPARQLEndpoint are supported. For details please refer to the documentation in `NativeRepositoryInformation`, `ResolvableRepositoryInformation` and `SPARQLRepositoryInformation`.

      Parameters:
        `members` -
        `baseDir` -
      Returns:
        list of endpoints
      Throws:
        `FedXException`

    - #### getId

          public static String getId​(String endpointID,
                                     String type)

      Construct a unique id for the provided SPARQL Endpoint, e.g http://dbpedia.org/ => %type%_dbpedia.org
      Parameters:
        `endpointID` -
        `type` - the repository type, e.g. native, sparql, etc
      Returns:
        the ID for the SPARQL endpoint