public class ContentSourceBean extends java.lang.Object implements ContentSource
This is a Java Bean compatible implementation of ContentSource intended for use in a JNDI
context or container where configuration must be done via setter methods.
Use of this class to directly instantiate a ContentSource is discouraged. If you wish to
programmatically create an instance use the primary factory class ContentSourceFactory
instead.
This class depends on a container-provided ObjectFactory implementation.
If you have the option of configuring a custom bean factory, you are encouraged to use
ContentSourceBeanFactory instead.
<Context path="/">
<Resource name="marklogic/ContentSource" auth="Container"
type="com.marklogic.xcc.jndi.ContentSourceBean"
factory="org.apache.naming.factory.BeanFactory"
host="somehost.mycorp.com" port="8003" user="fred" password="hush"
contentbase="productiondb"/>
<Context>
See ContentSourceBeanFactory for more details and an example of looking up a
ContentSource with JNDI. The lookup code will be identical for both configuration
approaches.
ContentSourceBeanFactory| Constructor and Description |
|---|
ContentSourceBean() |
| 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 databaseId)
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)
Attempts to establish a
Session with the default contentbase for this ContentSource
using the provided login credentials. |
Session |
newSession(java.lang.String userName,
java.lang.String password,
java.lang.String databaseId)
Attempts to establish a
Session with the specified contentbase on the server
represented by this ContentSource, using the provided user credentials. |
void |
setAuthenticationPreemptive(boolean value)
Sets whether basic authentication should be attempted preemptively, default is false.
|
void |
setContentBase(java.lang.String contentBase) |
void |
setDefaultLogger(java.util.logging.Logger logger)
Set the default java.util.Logger instance which will be inherited by new
Session
instances. |
void |
setHost(java.lang.String host) |
void |
setPassword(java.lang.String password) |
void |
setPort(int port) |
void |
setUrl(java.lang.String url) |
void |
setUser(java.lang.String user) |
java.lang.String |
toString() |
public Session newSession()
ContentSourceSession with the default contentbase for this ContentSource.
Login credentials are the defaults established when the instance was created or bound to the
JNDI service.newSession in interface ContentSourceSession instance.public Session newSession(java.lang.String databaseId)
ContentSourceSession with the specified contentbase on the server
represented by this ContentSource.newSession in interface ContentSourcedatabaseId - A contentbase name or numeric ID.Session instance.public Session newSession(java.lang.String userName, java.lang.String password)
ContentSourceSession with the default contentbase for this ContentSource
using the provided login credentials.newSession in interface ContentSourceuserName - The user name to connect as.password - The password associated with the user name.Session instance.public Session newSession(java.lang.String userName, java.lang.String password, java.lang.String databaseId)
ContentSourceSession with the specified contentbase on the server
represented by this ContentSource, using the provided user credentials.newSession in interface ContentSourceuserName - The user name to connect as.password - The password associated with the user name.databaseId - A contentbase name or numeric ID.Session instance.public java.util.logging.Logger getDefaultLogger()
ContentSource
Returns the current Logger to which log messages will be sent. If not overridden with
ContentSource.setDefaultLogger(Logger), an implementation default logger is returned. This Logger
will be inherited by Session instances created from this ContentSource. The
Logger for individual Sessions 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.
getDefaultLogger in interface ContentSourcepublic void setDefaultLogger(java.util.logging.Logger logger)
ContentSource
Set the default java.util.Logger instance which will be inherited by new Session
instances.
setDefaultLogger in interface ContentSourcelogger - An instance of java.util.logging.Loggerpublic ConnectionProvider getConnectionProvider()
getConnectionProvider in interface ContentSourcepublic UserCredentials getUserCredentials()
getUserCredentials in interface ContentSourcepublic java.lang.String toString()
toString in class java.lang.Objectpublic void setHost(java.lang.String host)
public void setPort(int port)
public void setUser(java.lang.String user)
public void setPassword(java.lang.String password)
public void setContentBase(java.lang.String contentBase)
public void setUrl(java.lang.String url)
throws java.net.URISyntaxException
java.net.URISyntaxExceptionpublic boolean isAuthenticationPreemptive()
isAuthenticationPreemptive in interface ContentSourcepublic void setAuthenticationPreemptive(boolean value)
ContentSourceSets 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.
setAuthenticationPreemptive in interface ContentSourcevalue - true if basic authentication should be attempted preemptively, false otherwise.public Session newSession(java.lang.String userName, char[] password)
ContentSourceSession with the default contentbase for this ContentSource
using the provided login credentials.newSession in interface ContentSourceuserName - The user name to connect as.password - The password associated with the user name.Session instance.public Session newSession(java.lang.String userName, char[] password, java.lang.String contentbaseId)
ContentSourceSession with the specified contentbase on the server
represented by this ContentSource, using the provided user credentials.newSession in interface ContentSourceuserName - The user name to connect as.password - The password associated with the user name.contentbaseId - A contentbase name or numeric ID.Session instance.Copyright © 2025 MarkLogic Corporation. All Rights Reserved.
Complete online documentation for MarkLogic Server, XQuery and related components may be found at developer.marklogic.com