com.marklogic.xcc

## Interface ContentSource

- All Known Implementing Classes:
    ContentSourceBean

      public interface ContentSource

  A ContentSource object describes a content source (MarkLogic Server instance) and serves as a factory that creates `Session` objects. Instances of ContentSource may be obtained from a JNDI lookup service or from one of the static factory methods on the `ContentSourceFactory` class.

  See the `getDefaultLogger()` method for information about configuring logging behavior.

  See Also:
    `getDefaultLogger()`, `ContentSourceFactory`, `Session`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `ConnectionProvider` | `getConnectionProvider()`
    `java.util.logging.Logger` | `getDefaultLogger()` Returns the current Logger to which log messages will be sent.
    `UserCredentials` | `getUserCredentials()`
    `boolean` | `isAuthenticationPreemptive()`
    `Session` | `newSession()` Attempts to establish a `Session` with the default contentbase for this ContentSource.
    `Session` | `newSession(java.lang.String contentbaseId)` Attempts to establish a `Session` with the specified contentbase on the server represented by this ContentSource.
    `Session` | `newSession(java.lang.String userName, char[] password)` Attempts to establish a `Session` with the default contentbase for this ContentSource using the provided login credentials.
    `Session` | `newSession(java.lang.String userName, char[] password, java.lang.String contentbaseId)` Attempts to establish a `Session` with the specified contentbase on the server represented by this ContentSource, using the provided user credentials.
    `Session` | `newSession(java.lang.String userName, java.lang.String password)` Deprecated.
    `Session` | `newSession(java.lang.String userName, java.lang.String password, java.lang.String contentbaseId)` Deprecated.
    `void` | `setAuthenticationPreemptive(boolean value)` Sets whether basic authentication should be attempted preemptively, default is false.
    `void` | `setDefaultLogger(java.util.logging.Logger logger)` Set the default java.util.Logger instance which will be inherited by new `Session` instances.

- - ### Method Detail

    - #### newSession

          Session newSession()

      Attempts to establish a `Session` with the default contentbase for this ContentSource. Login credentials are the defaults established when the instance was created or bound to the JNDI service.
      Returns:
        A `Session` instance.
      Throws:
        `java.lang.IllegalStateException` - If this ContentSource was created without specifying user/password credentials.

    - #### newSession

          Session newSession(java.lang.String contentbaseId)

      Attempts to establish a `Session` with the specified contentbase on the server represented by this ContentSource.
      Parameters:
        `contentbaseId` - A contentbase name or numeric ID.
      Returns:
        A `Session` instance.
      Throws:
        `java.lang.IllegalStateException` - If this ContentSource was created without specifying default user credentials.

    - #### newSession

          @Deprecated
          Session newSession(java.lang.String userName,
                                         java.lang.String password)

      Deprecated.
      Attempts to establish a `Session` with the default contentbase for this ContentSource using the provided login credentials.
      Parameters:
        `userName` - The user name to connect as.
        `password` - The password associated with the user name.
      Returns:
        A `Session` instance.

    - #### newSession

          Session newSession(java.lang.String userName,
                             char[] password)

      Attempts to establish a `Session` with the default contentbase for this ContentSource using the provided login credentials.
      Parameters:
        `userName` - The user name to connect as.
        `password` - The password associated with the user name.
      Returns:
        A `Session` instance.

    - #### newSession

          Session newSession(java.lang.String userName,
                             char[] password,
                             java.lang.String contentbaseId)

      Attempts to establish a `Session` with the specified contentbase on the server represented by this ContentSource, using the provided user credentials.
      Parameters:
        `userName` - The user name to connect as.
        `password` - The password associated with the user name.
        `contentbaseId` - A contentbase name or numeric ID.
      Returns:
        A `Session` instance.

    - #### newSession

          @Deprecated
          Session newSession(java.lang.String userName,
                                         java.lang.String password,
                                         java.lang.String contentbaseId)

      Deprecated.
      Attempts to establish a `Session` with the specified contentbase on the server represented by this ContentSource, using the provided user credentials.
      Parameters:
        `userName` - The user name to connect as.
        `password` - The password associated with the user name.
        `contentbaseId` - A contentbase name or numeric ID.
      Returns:
        A `Session` instance.

    - #### getDefaultLogger

          java.util.logging.Logger getDefaultLogger()

      Returns the current Logger to which log messages will be sent. If not overridden with `setDefaultLogger(Logger)`, an implementation default logger is returned. This Logger will be inherited by `Session` instances created from this ContentSource. The `Logger` for individual `Session`s can be overridden with the `Session.setLogger(java.util.logging.Logger)` method.

      The name of the implementation default logger is `com.marklogic.xcc`. This is the name which should be used in a logging properties file (see `LogManager`) to customize the logger.

      XCC includes a bundled properties file that augments the default JVM logging properties. This file, xcc.logging.properties, is read from the classpath when the first ContentSource instance is created. The properties file in xcc.jar looks like this. If you wish to customize these logging properties, place a copy of this file in your classpath ahead of xcc.jar.

      Default logging properties file in xcc.jar.

      Returns:
        The currently set Logger instance, or a default created by the implementation.

    - #### setDefaultLogger

          void setDefaultLogger(java.util.logging.Logger logger)

      Set the default java.util.Logger instance which will be inherited by new `Session` instances.

      Parameters:
        `logger` - An instance of java.util.logging.Logger

    - #### isAuthenticationPreemptive

          boolean isAuthenticationPreemptive()

      Returns:
        true if basic authentication will be attempted preemptively, false otherwise.

    - #### setAuthenticationPreemptive

          void setAuthenticationPreemptive(boolean value)

      Sets whether basic authentication should be attempted preemptively, default is false.

      Preemptive authentication can reduce the overhead of making connections to servers that accept basic authentication by eliminating the challenge-response interaction otherwise required.

      Note that misuse of preemptive authentication entails potential security risks, and under most circumstances the credentials used to authenticate will be cached after the first connection. To avoid creating the illusion that credentials are protected, connections to a server requiring digest authentication will not be retried if this flag is set.

      Parameters:
        `value` - true if basic authentication should be attempted preemptively, false otherwise.

    - #### getConnectionProvider

          ConnectionProvider getConnectionProvider()

      Returns:
        The ConnectionProvider used to construct this ContentSource.

    - #### getUserCredentials

          UserCredentials getUserCredentials()

      Returns:
        The UserCredentials used to construct this ContentSource.

Copyright © 2025 MarkLogic Corporation. All Rights Reserved.

Complete online documentation for MarkLogic Server, XQuery and related components may be found at developer.marklogic.com