XCC/J 3.2-9

com.marklogic.xcc.spi
Interface ConnectionProvider


public interface ConnectionProvider

This interface defines a provider of Sockets for a ContentSource. Policies such as load balancing or failover can be implemented by supplying a custom ConnectionProvider.


Method Summary
 ServerConnection obtainConnection(Session session, Logger logger)
          Provide a ServerConnection) that is open and ready to communicate with the server.
 void returnConnection(ServerConnection connection, Logger logger)
          Return a ServerConnection object (obtained from a previous call to obtainConnection(com.marklogic.xcc.Session,java.util.logging.Logger)) to the provider, possibly to be pooled and re-used.
 ConnectionErrorAction returnErrorConnection(ServerConnection connection, Throwable exception, Logger logger)
          Return a connection that experienced an error.
 void shutdown(Logger logger)
          Tell the provider to shutdown and release any resources being used.
 

Method Detail

obtainConnection

public ServerConnection obtainConnection(Session session,
                                         Logger logger)
                                  throws IOException
Provide a ServerConnection) that is open and ready to communicate with the server.

Parameters:
session - The Session requesting a connection.
logger - A Logger instance to use.
Returns:
An open, ready to use ServerConnection object.
Throws:
IOException - If an underlying connection cannot be created.

returnConnection

public void returnConnection(ServerConnection connection,
                             Logger logger)
Return a ServerConnection object (obtained from a previous call to obtainConnection(com.marklogic.xcc.Session,java.util.logging.Logger)) to the provider, possibly to be pooled and re-used. If the connection has a non-zero timeout value set (ServerConnection.setTimeoutMillis(long)), that value will inform the provider to discard the object after that amount of time has elapsed.

Parameters:
connection - A previously obtained ServerConnection instance.
logger - A Logger instance to use.

returnErrorConnection

public ConnectionErrorAction returnErrorConnection(ServerConnection connection,
                                                   Throwable exception,
                                                   Logger logger)
Return a connection that experienced an error. The provider will indicate the action the client should take.

Parameters:
connection - A previously obtained ServerConnection instance.
exception - The (possibly null) exception that occurred. The provider may wish to decide which action to recommend depending on the type of exception.
logger - A Logger instance to use.
Returns:
An instance of ConnectionErrorAction instance that advises the client which action to take.

shutdown

public void shutdown(Logger logger)
Tell the provider to shutdown and release any resources being used. It's possible this method may never be called.

Parameters:
logger - A Logger instance to use.

XCC/J 3.2-9

Copyright © 2003-2008 Mark Logic Corporation, All Rights Reserved.

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