Interface MarkLogicOperations

  • All Known Implementing Classes:
    MarkLogicTemplate

    public interface MarkLogicOperations
    The central interface between you and the MarkLogic database. Helper methods have been created for basic CRUD operations as well as for building some common query constructs. Additional methods allow you direct access to the different query and document managers, as well as direct access to the database client, so that you can write logic against the database using the full power of the MarkLogic Java Client Library. The main implementation of this is MarkLogicTemplate, so you will create an instance of that in order to use this interface.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void configure​(org.springframework.core.io.Resource configuration)
      Configures the connected database using the specified JSON information.
      long count​(com.marklogic.client.query.StructuredQueryDefinition query)
      Gives a count of the number of documents that would match the specified query.
      <T> long count​(com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)
      Count the number of entities that would match the specified query.
      <T> long count​(Class<T> entityClass)
      Count the number of the specified entity that exist in the database.
      long count​(String... collections)
      Count the number of documents that exist in the database under the specified collections.
      <T> void delete​(com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)
      Delete entities of the specified type that match the specified query.
      <T> void delete​(List<T> entities)
      Delete the specified entities from the database.
      <T> void deleteById​(Object id, Class<T> entityClass)
      Deletes the entity with the specified ID.
      <T> void deleteByIds​(List<?> ids, Class<T> entityClass)
      Deletes the entities which have one of the specified IDs.
      void deleteByUri​(String... uris)
      Delete a document from the database that is stored under the specified uris
      void deleteByUris​(List<String> uris)
      Delete a set of documents from the database that are stored under one of the specified URIs
      <T> void dropCollection​(Class<T> entityClass)
      Deletes all the entities of the specified type.
      <T> void dropCollections​(Class<T>... entityClasses)
      Deletes all the entities of the specified types.
      void dropCollections​(String... collections)
      Delete documents that are under the specified collection URIs.
      <T> T execute​(DocumentCallback<T> action)
      Executes the specified action using a GenericDocumentManager interface.
      <T> T executeQuery​(QueryCallback<T> action)
      Executes the specified action using a QueryManager.
      <T> T executeWithClient​(ClientCallback<T> action)
      Executes the specified action using the full DatabaseClient.
      <T> boolean exists​(com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)
      Check for existence of entities matching the specified structured query.
      <T> boolean exists​(Object id, Class<T> entityClass)
      Check for existence of an entity in the database by using it's ID.
      boolean exists​(String uri)
      Check for existence of a document by using the full URI under which the document is stored.
      <T> FacetedPage<T> facetedSearch​(com.marklogic.client.query.StructuredQueryDefinition query, long start, int limit, Class<T> entityClass)
      Similar to a normal paged query, except also includes facets for the matched results.
      <T> FacetedPage<T> facetedSearch​(com.marklogic.client.query.StructuredQueryDefinition query, long start, Class<T> entityClass)  
      <T> FacetedPage<T> facetedSearch​(com.marklogic.client.query.StructuredQueryDefinition query, org.springframework.data.domain.Pageable pageable, Class<T> entityClass)
      Same as faceted search with int bounds, but allows paging/sorting based off Spring Pageable.
      MarkLogicConverter getConverter()
      Get the entity converter that is used to convert Java POJOs into a form with which they can be stored in the database.
      QueryConversionService getQueryConversionService()
      Get the query object convert service that is used to convert various Java types into their "correct" form for querying in MarkLogic.
      QueryMapper getQueryMapper()
      The query mapper is responsible for interpreting entity/query annotations and applying the information to a query before it is executed in MarkLogicTemplate.
      <T> com.marklogic.client.pojo.PojoQueryBuilder<T> qb​(Class<T> entityClass)
      Get an instance of a PojoQueryBuilder for the specified entity class.
      <T> T read​(Object id, Class<T> entityClass)
      Read a document with the specified ID from the database.
      List<com.marklogic.client.document.DocumentRecord> read​(List<?> uris)
      Reads a list of documents from the database by their URIs instead of ids.
      <T> List<T> read​(List<?> ids, Class<T> entityClass)
      Reads a set of documents that have the specified IDs.
      List<com.marklogic.client.document.DocumentRecord> search​(com.marklogic.client.query.StructuredQueryDefinition query)
      Query for a list of documents using the specified structured query.
      com.marklogic.client.document.DocumentPage search​(com.marklogic.client.query.StructuredQueryDefinition query, long start)
      Query for a page of documents using the specified structured query, starting at the specified item in the result set.
      com.marklogic.client.document.DocumentPage search​(com.marklogic.client.query.StructuredQueryDefinition query, long start, int length)
      Query for a page of documents using the specified structured query.
      <T> org.springframework.data.domain.Page<T> search​(com.marklogic.client.query.StructuredQueryDefinition query, long start, int limit, Class<T> entityClass)
      Queries for a page of documents of the specified type, using the specified structured query to constrain which documents are returned.
      <T> org.springframework.data.domain.Page<T> search​(com.marklogic.client.query.StructuredQueryDefinition query, long start, Class<T> entityClass)
      Query for a page of of documents of the specified type using the specified structured query.
      <T> List<T> search​(com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)
      Query for a list of of documents of the specified type using the specified structured query.
      com.marklogic.client.document.DocumentPage search​(com.marklogic.client.query.StructuredQueryDefinition query, org.springframework.data.domain.Pageable pageable)
      Same as search with int bounds, but allows paging/sorting based off Spring Pageable.
      <T> org.springframework.data.domain.Page<T> search​(com.marklogic.client.query.StructuredQueryDefinition query, org.springframework.data.domain.Pageable pageable, Class<T> entityClass)
      Same as search with int bounds, but allows paging/sorting based off Spring Pageable.
      <T> List<T> search​(Class<T> entityClass)
      Query for a list of of documents of the specified type using the specified structured query.
      <T> T searchOne​(com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)
      Query for a single entity using the specified structured query.
      com.marklogic.client.query.StructuredQueryDefinition sortQuery​(org.springframework.data.domain.Sort sort, com.marklogic.client.query.StructuredQueryDefinition query)
      Adds sorting configuration to the specified query.
      <T> com.marklogic.client.query.StructuredQueryDefinition sortQuery​(org.springframework.data.domain.Sort sort, com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)
      Add sorting configuration to the specified query.
      InputStream stream​(com.marklogic.client.query.StructuredQueryDefinition query)  
      InputStream stream​(com.marklogic.client.query.StructuredQueryDefinition query, long start)  
      InputStream stream​(com.marklogic.client.query.StructuredQueryDefinition query, long start, int length)  
      <T> InputStream stream​(com.marklogic.client.query.StructuredQueryDefinition query, long start, int length, Class<T> entityClass)
      Queries just like the search(StructuredQueryDefinition, long, int, Class) method does, but instead of a page/list of documents it returns an input stream straight from the results of the REST call against the database.
      <T> InputStream stream​(com.marklogic.client.query.StructuredQueryDefinition query, long start, Class<T> entityClass)  
      <T> InputStream stream​(com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)  
      InputStream stream​(com.marklogic.client.query.StructuredQueryDefinition query, org.springframework.data.domain.Pageable pageable)
      Same as method taking int bounds, but allows use of Pagable for paging/sorting.
      <T> InputStream stream​(com.marklogic.client.query.StructuredQueryDefinition query, org.springframework.data.domain.Pageable pageable, Class<T> entityClass)
      Same as method taking int bounds, but allows use of Pagable for paging/sorting.
      com.marklogic.client.query.StructuredQueryDefinition termQuery​(String term, com.marklogic.client.query.StructuredQueryDefinition query)
      Add a search term to the specified query.
      <T> List<T> write​(List<T> entities)
      Write the specified entities to the database into the default entity collection, without any transforms
      <T> List<T> write​(List<T> entities, com.marklogic.client.document.ServerTransform transform)
      Write the specified entities to the database into the default entity collection using the specified transform.
      <T> List<T> write​(List<T> entities, com.marklogic.client.document.ServerTransform transform, String... collections)
      Write the specified list of entities to the database.
      <T> List<T> write​(List<T> entities, String... collections)
      Write the specified entities to the database into the specified collections, without any transforms.
      <T> T write​(T entity)
      Write a single entity to the database into the default entity collection without any transforms.
      <T> T write​(T entity, com.marklogic.client.document.ServerTransform transform)
      Write the specified entity to the database into the default entity collection using the specified transform.
      <T> T write​(T entity, com.marklogic.client.document.ServerTransform transform, String... collections)
      Write the specified entity to the database into the specified collections with the specified transform.
      <T> T write​(T entity, String... collections)
      Write a single entity to the database into the specified collections, without any transforms.
    • Method Detail

      • qb

        <T> com.marklogic.client.pojo.PojoQueryBuilder<T> qb​(Class<T> entityClass)
        Get an instance of a PojoQueryBuilder for the specified entity class. This is a simplified interface for building structured queries against JSON objects in the database. For full control of all query options use the StructuredQueryBuilder instead.
        Type Parameters:
        T - The type of the entity.
        Parameters:
        entityClass - Type of Java entity being stored in the database.
        Returns:
      • sortQuery

        com.marklogic.client.query.StructuredQueryDefinition sortQuery​(org.springframework.data.domain.Sort sort,
                                                                       com.marklogic.client.query.StructuredQueryDefinition query)
        Adds sorting configuration to the specified query.
        See Also:
        sortQuery(Sort, StructuredQueryDefinition, Class)
      • sortQuery

        <T> com.marklogic.client.query.StructuredQueryDefinition sortQuery​(org.springframework.data.domain.Sort sort,
                                                                           com.marklogic.client.query.StructuredQueryDefinition query,
                                                                           Class<T> entityClass)
        Add sorting configuration to the specified query. The default sort algorithm will expect to use a path range index with specified sort properties, i.e. if sorting on "name" then a path index of "/name" should exist. Through use of the Indexed annotation you can indicate use of a different type of range index for the property sorting, or specify the full path that should be used in creation of the sort options. This requires that the entity type is specified.
        Parameters:
        sort - Sort information for the query, i.e. which properties and which orders.
        query - The structured query to "enhance".
        entityClass - The entity type.
        Returns:
        The "enhanced" query definition for use in continued building.
      • termQuery

        com.marklogic.client.query.StructuredQueryDefinition termQuery​(String term,
                                                                       com.marklogic.client.query.StructuredQueryDefinition query)
        Add a search term to the specified query. This is used for word searches across your entire document. For more fine-grained control use StructuredQueryBuilder.word(StructuredQueryBuilder.TextIndex, String...) to specify specific properties or fields into which to scope the word search.
        Parameters:
        term - A search phrase.
        query - The structured query to "enhance".
        Returns:
        The "enhanced" query definition for use in continued building.
      • configure

        void configure​(org.springframework.core.io.Resource configuration)
                throws IOException
        Configures the connected database using the specified JSON information. The format of the JSON is outlined at http://docs.marklogic.com/REST/PUT/manage/v2/databases/[id-or-name]/properties. This requires that the client was created with a user that has "admin" privileges.
        Parameters:
        configuration - Resource pointing to a JSON document containing database configuration information.
        Throws:
        IOException
      • execute

        <T> T execute​(DocumentCallback<T> action)
        Executes the specified action using a GenericDocumentManager interface. For all the basic operations this is sufficient.
        Type Parameters:
        T - The result type of the function.
        Parameters:
        action - A function to execute using the document manager. The active transaction is also provided so that the function can add additional operations to it.
        Returns:
        The results of the document manager interactions (results of a query, etc.).
      • executeWithClient

        <T> T executeWithClient​(ClientCallback<T> action)
        Executes the specified action using the full DatabaseClient. This gives you full control of your interactions with the database with the full power of the MarkLogic Java Client Library, but it also requires you to do a lot of the busy work yourself. Should mainly be used for operations not supported currently in this template interface either through the helper methods, a GenericDocumentManager, or a QueryManager.
        Type Parameters:
        T - The result type of the function.
        Parameters:
        action - A function to execute using the database client and active transaction.
        Returns:
        The results of the function.
      • executeQuery

        <T> T executeQuery​(QueryCallback<T> action)
        Executes the specified action using a QueryManager.
        Type Parameters:
        T - The result type of the function.
        Parameters:
        action - A function to execute using the query manager and active transaction.
        Returns:
        The results from the query manager.
      • write

        <T> T write​(T entity,
                    com.marklogic.client.document.ServerTransform transform)
        Write the specified entity to the database into the default entity collection using the specified transform.
        See Also:
        write(List, ServerTransform, String...)
      • write

        <T> T write​(T entity,
                    com.marklogic.client.document.ServerTransform transform,
                    String... collections)
        Write the specified entity to the database into the specified collections with the specified transform.
        See Also:
        write(List, ServerTransform, String...)
      • write

        <T> List<T> write​(List<T> entities,
                          com.marklogic.client.document.ServerTransform transform)
        Write the specified entities to the database into the default entity collection using the specified transform.
        See Also:
        write(List, ServerTransform, String...)
      • write

        <T> List<T> write​(List<T> entities,
                          com.marklogic.client.document.ServerTransform transform,
                          String... collections)
        Write the specified list of entities to the database. Using the Document annotation you can specify some information as to how it is persisted (i.e. whether or not to store it in a "type" collection, what path, etc.). If a transform is specified then before the entity is saved into the database they transform will be run against each entity. For more information see http://docs.marklogic.com/guide/java/transforms.
        Type Parameters:
        T - The type of entity
        Parameters:
        entities - A list of POJO entities you wish to save into the database.
        transform - The transform to use before finally persisting to the database.
        collections - Additional collections to which you want the document to be a part of inside the database.
        Returns:
        The list of entities that were saved to the database. This is mainly for convenience as they are not modified through this process.
      • read

        List<com.marklogic.client.document.DocumentRecord> read​(List<?> uris)
        Reads a list of documents from the database by their URIs instead of ids. Since type information is not know a "raw" DocumentRecord is returned, and can be handled as desired.
        Parameters:
        uris - A list of database URIs of documents.
        Returns:
        A list of DocumentRecord objects from the database.
      • read

        <T> T read​(Object id,
                   Class<T> entityClass)
        Read a document with the specified ID from the database.
        See Also:
        read(List, Class)
      • read

        <T> List<T> read​(List<?> ids,
                         Class<T> entityClass)
        Reads a set of documents that have the specified IDs. The documents must match the specified type or they will not be included in the result set.
        Type Parameters:
        T - The type of the entity.
        Parameters:
        ids - A list of IDs of entities.
        entityClass - The Java type of the entity.
        Returns:
        A list of all the entities that matched the specified IDs.
      • search

        List<com.marklogic.client.document.DocumentRecord> search​(com.marklogic.client.query.StructuredQueryDefinition query)
        Query for a list of documents using the specified structured query.
        See Also:
        search(StructuredQueryDefinition, long, int)
      • search

        com.marklogic.client.document.DocumentPage search​(com.marklogic.client.query.StructuredQueryDefinition query,
                                                          long start)
        Query for a page of documents using the specified structured query, starting at the specified item in the result set.
        See Also:
        search(StructuredQueryDefinition, long, int)
      • search

        com.marklogic.client.document.DocumentPage search​(com.marklogic.client.query.StructuredQueryDefinition query,
                                                          long start,
                                                          int length)
        Query for a page of documents using the specified structured query. Specify a start and length to get different "chunks" of data in the result set from the database. You seldom want to return all results, as this could be a very large number and will degrade the performance of your application. You instead should query out "pages" of data as needed.
        Parameters:
        query - A structured query defining the constraints to use to match the desired documents.
        start - The start index within the result set that acts as the start of the "page".
        length - The number of items to include in the "page"
        Returns:
        A DocumentPage containing the records for this "chunk" of the result set.
      • search

        com.marklogic.client.document.DocumentPage search​(com.marklogic.client.query.StructuredQueryDefinition query,
                                                          org.springframework.data.domain.Pageable pageable)
        Same as search with int bounds, but allows paging/sorting based off Spring Pageable.
        See Also:
        search(StructuredQueryDefinition, long, int, Class)
      • searchOne

        <T> T searchOne​(com.marklogic.client.query.StructuredQueryDefinition query,
                        Class<T> entityClass)
        Query for a single entity using the specified structured query. If for some reason multiple results are matched then only the first is returned. This is a convenience method to get a single item when you "know" that is all there is.
        See Also:
        search(StructuredQueryDefinition, long, int, Class)
      • search

        <T> List<T> search​(com.marklogic.client.query.StructuredQueryDefinition query,
                           Class<T> entityClass)
        Query for a list of of documents of the specified type using the specified structured query. Only the first DocumentManagerImpl.DEFAULT_PAGE_LENGTH documents are returned.
        See Also:
        search(StructuredQueryDefinition, long, int, Class)
      • search

        <T> org.springframework.data.domain.Page<T> search​(com.marklogic.client.query.StructuredQueryDefinition query,
                                                           long start,
                                                           Class<T> entityClass)
        Query for a page of of documents of the specified type using the specified structured query. Only a page of documents is returned, starting from the specified start index and containing DocumentManagerImpl.DEFAULT_PAGE_LENGTH entities.
        See Also:
        search(StructuredQueryDefinition, long, int, Class)
      • search

        <T> org.springframework.data.domain.Page<T> search​(com.marklogic.client.query.StructuredQueryDefinition query,
                                                           long start,
                                                           int limit,
                                                           Class<T> entityClass)
        Queries for a page of documents of the specified type, using the specified structured query to constrain which documents are returned. Only a page is returned, starting from the specified index and containing the specified number of entries.
        Type Parameters:
        T - The type of entity.
        Parameters:
        query - The structured query to use to match documents in the database.
        start - The starting index within the result set of matches.
        limit - The number of documents to return.
        entityClass - The entity type class.
        Returns:
        A page of documents matching the specified parameters.
      • search

        <T> org.springframework.data.domain.Page<T> search​(com.marklogic.client.query.StructuredQueryDefinition query,
                                                           org.springframework.data.domain.Pageable pageable,
                                                           Class<T> entityClass)
        Same as search with int bounds, but allows paging/sorting based off Spring Pageable.
        See Also:
        search(StructuredQueryDefinition, long, int, Class)
      • facetedSearch

        <T> FacetedPage<T> facetedSearch​(com.marklogic.client.query.StructuredQueryDefinition query,
                                         long start,
                                         int limit,
                                         Class<T> entityClass)
        Similar to a normal paged query, except also includes facets for the matched results. In order for the facets to be generated you need to ensure the specified query has the name of persisted options that describe the facets, or the query is a CombinedQueryDefinition that includes the ad-hoc options definitions for them.
        Type Parameters:
        T - The type of entity.
        Parameters:
        query - The structured query to use to match documents in the database.
        start - The starting index within the result set of matches.
        limit - The number of documents to return.
        entityClass - The entity type class.
        Returns:
        A page of documents matching the specified parameters with the included facets.
      • facetedSearch

        <T> FacetedPage<T> facetedSearch​(com.marklogic.client.query.StructuredQueryDefinition query,
                                         org.springframework.data.domain.Pageable pageable,
                                         Class<T> entityClass)
        Same as faceted search with int bounds, but allows paging/sorting based off Spring Pageable.
        See Also:
        search(StructuredQueryDefinition, long, int, Class)
      • stream

        <T> InputStream stream​(com.marklogic.client.query.StructuredQueryDefinition query,
                               long start,
                               int length,
                               Class<T> entityClass)
        Queries just like the search(StructuredQueryDefinition, long, int, Class) method does, but instead of a page/list of documents it returns an input stream straight from the results of the REST call against the database. The purpose of these methods is to skip the serialization/deserialization process of your application layer and just return raw data. If you don't need to access any parts of the document and just need to return the raw JSON/XML then it is easier/faster to just copy the stream from the database into the HTTP response directly. Extractions or server-side transforms can still be used to change how the data is returned in cases where there are properties you don't want returned through a public API, etc.
        Returns:
        An input stream of all the documents that matched the specified parameters.
      • exists

        boolean exists​(String uri)
        Check for existence of a document by using the full URI under which the document is stored.
        Parameters:
        uri - The full URI of the document, i.e. "/Person/my-id.json"
        Returns:
        True if a document with the specified URI exists.
      • exists

        <T> boolean exists​(Object id,
                           Class<T> entityClass)
        Check for existence of an entity in the database by using it's ID.
        Type Parameters:
        T - The type of an entity.
        Parameters:
        id - The ID value of an entity.
        entityClass - The type class of an entity.
        Returns:
        True if an entity with the specified ID exists.
      • exists

        <T> boolean exists​(com.marklogic.client.query.StructuredQueryDefinition query,
                           Class<T> entityClass)
        Check for existence of entities matching the specified structured query. This will not show which ones match, but is a way to do a quick estimate on whether or not any exist in the first place.
        Type Parameters:
        T - The type of an entity.
        Parameters:
        query - The structured query to use to match documents in the database.
        entityClass - The type class of an entity.
        Returns:
        True if there are any entities that match the query.
      • count

        long count​(String... collections)
        Count the number of documents that exist in the database under the specified collections.
        Parameters:
        collections - Collection URIs to which to scope the count.
        Returns:
        The number of documents contained under the specified collections.
      • count

        <T> long count​(Class<T> entityClass)
        Count the number of the specified entity that exist in the database.
        Type Parameters:
        T - The type of an entity.
        Parameters:
        entityClass - The type class of an entity.
        Returns:
        The number of the specified entity contained in the database.
      • count

        long count​(com.marklogic.client.query.StructuredQueryDefinition query)
        Gives a count of the number of documents that would match the specified query.
        See Also:
        count(StructuredQueryDefinition, Class)
      • count

        <T> long count​(com.marklogic.client.query.StructuredQueryDefinition query,
                       Class<T> entityClass)
        Count the number of entities that would match the specified query.
        Type Parameters:
        T - The type of an entity.
        Parameters:
        query - The structured query to use to match documents in the database.
        entityClass - The type class of an entity.
        Returns:
        The count of entities that are in the database.
      • deleteByUri

        void deleteByUri​(String... uris)
        Delete a document from the database that is stored under the specified uris
        Parameters:
        uris - The uris to delete, i.e. "/Person/my-id.json"
      • deleteByUris

        void deleteByUris​(List<String> uris)
        Delete a set of documents from the database that are stored under one of the specified URIs
        Parameters:
        uris - A list of uris to delete.
      • deleteByIds

        <T> void deleteByIds​(List<?> ids,
                             Class<T> entityClass)
        Deletes the entities which have one of the specified IDs.
        Type Parameters:
        T - The type of an entity.
        Parameters:
        ids - A list of entity IDs.
        entityClass - The type class of an entity.
      • dropCollection

        <T> void dropCollection​(Class<T> entityClass)
        Deletes all the entities of the specified type.
        Type Parameters:
        T - The type of an entity.
        Parameters:
        entityClass - The type class of an entity.
      • dropCollections

        <T> void dropCollections​(Class<T>... entityClasses)
        Deletes all the entities of the specified types.
        Type Parameters:
        T - The type of an entity.
        Parameters:
        entityClasses - The type classes of entities.
      • dropCollections

        void dropCollections​(String... collections)
        Delete documents that are under the specified collection URIs.
        Parameters:
        collections - Collection URIs containing documents to delete.
      • delete

        <T> void delete​(List<T> entities)
        Delete the specified entities from the database.
        Type Parameters:
        T - The type of an entity.
        Parameters:
        entities - A list of entities.
      • delete

        <T> void delete​(com.marklogic.client.query.StructuredQueryDefinition query,
                        Class<T> entityClass)
        Delete entities of the specified type that match the specified query.
        Type Parameters:
        T - The type of an entity.
        Parameters:
        query - The structured query to use to match documents in the database.
        entityClass - The type class of an entity.
      • getConverter

        MarkLogicConverter getConverter()
        Get the entity converter that is used to convert Java POJOs into a form with which they can be stored in the database.
        Returns:
        The converter object.
      • getQueryMapper

        QueryMapper getQueryMapper()
        The query mapper is responsible for interpreting entity/query annotations and applying the information to a query before it is executed in MarkLogicTemplate. It also handles converting Query By Example objects into a MarkLogic query. The query mapper can be used when it is necessary to use the "execute" methods but you still want to take advantage of the annotations and other logic that is part of this framework.
      • getQueryConversionService

        QueryConversionService getQueryConversionService()
        Get the query object convert service that is used to convert various Java types into their "correct" form for querying in MarkLogic.
        Returns:
        The service object.