XCC/J 6.0-3

com.marklogic.xcc.jndi
Class ContentSourceBean

java.lang.Object
  extended by com.marklogic.xcc.jndi.ContentSourceBean
All Implemented Interfaces:
ContentSource

public class ContentSourceBean
extends 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.

An example of configuring Tomcat to use this bean would look like this:

 <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.

See Also:
ContentSourceBeanFactory

Constructor Summary
ContentSourceBean()
           
 
Method Summary
 ConnectionProvider getConnectionProvider()
           
 Logger getDefaultLogger()
           Returns the current Logger to which log messages will be sent.
 boolean isAuthenticationPreemptive()
           
 Session newSession()
          Attempts to establish a Session with the default contentbase for this ContentSource.
 Session newSession(String databaseId)
          Attempts to establish a Session with the specified contentbase on the server represented by this ContentSource.
 Session newSession(String userName, String password)
          Attempts to establish a Session with the default contentbase for this ContentSource using the provided login credentials.
 Session newSession(String userName, String password, 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(String contentBase)
           
 void setDefaultLogger(Logger logger)
           Set the default java.util.Logger instance which will be inherited by new Session instances.
 void setHost(String host)
           
 void setPassword(String password)
           
 void setPort(int port)
           
 void setUrl(String url)
           
 void setUser(String user)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ContentSourceBean

public ContentSourceBean()
Method Detail

newSession

public Session newSession()
Description copied from interface: ContentSource
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.

Specified by:
newSession in interface ContentSource
Returns:
A Session instance.

newSession

public Session newSession(String databaseId)
Description copied from interface: ContentSource
Attempts to establish a Session with the specified contentbase on the server represented by this ContentSource.

Specified by:
newSession in interface ContentSource
Parameters:
databaseId - A contentbase name or numeric ID.
Returns:
A Session instance.

newSession

public Session newSession(String userName,
                          String password)
Description copied from interface: ContentSource
Attempts to establish a Session with the default contentbase for this ContentSource using the provided login credentials.

Specified by:
newSession in interface ContentSource
Parameters:
userName - The user name to connect as.
password - The password associated with the user name.
Returns:
A Session instance.

newSession

public Session newSession(String userName,
                          String password,
                          String databaseId)
Description copied from interface: ContentSource
Attempts to establish a Session with the specified contentbase on the server represented by this ContentSource, using the provided user credentials.

Specified by:
newSession in interface ContentSource
Parameters:
userName - The user name to connect as.
password - The password associated with the user name.
databaseId - A contentbase name or numeric ID.
Returns:
A Session instance.

getDefaultLogger

public Logger getDefaultLogger()
Description copied from interface: 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.

Default logging properties file in xcc.jar.

Specified by:
getDefaultLogger in interface ContentSource
Returns:
The currently set Logger instance, or a default created by the implementation.

setDefaultLogger

public void setDefaultLogger(Logger logger)
Description copied from interface: ContentSource

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

Specified by:
setDefaultLogger in interface ContentSource
Parameters:
logger - An instance of java.util.logging.Logger

getConnectionProvider

public ConnectionProvider getConnectionProvider()
Specified by:
getConnectionProvider in interface ContentSource
Returns:
The ConnectionProvider used to construct this ContentSource.

toString

public String toString()
Overrides:
toString in class Object

setHost

public void setHost(String host)

setPort

public void setPort(int port)

setUser

public void setUser(String user)

setPassword

public void setPassword(String password)

setContentBase

public void setContentBase(String contentBase)

setUrl

public void setUrl(String url)
            throws URISyntaxException
Throws:
URISyntaxException

isAuthenticationPreemptive

public boolean isAuthenticationPreemptive()
Specified by:
isAuthenticationPreemptive in interface ContentSource
Returns:
true if basic authentication will be attempted preemptively, false otherwise.

setAuthenticationPreemptive

public void setAuthenticationPreemptive(boolean value)
Description copied from interface: ContentSource

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.

Specified by:
setAuthenticationPreemptive in interface ContentSource
Parameters:
value - true if basic authentication should be attempted preemptively, false otherwise.

XCC/J 6.0-3

Copyright © 2013 MarkLogic Corporation. All Rights Reserved.

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