Package com.netscape.cmscore.ldapconn
Class LdapAnonConnFactory
java.lang.Object
com.netscape.certsrv.ldap.LdapConnFactory
com.netscape.cmscore.ldapconn.LdapAnonConnFactory
Factory for getting LDAP Connections to a LDAP server
each connection is a seperate thread that can be bound to a different
authentication dn and password.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
used to keep track of connections from this factory. -
Field Summary
Fields inherited from class com.netscape.certsrv.ldap.LdapConnFactory
approvalCallback, auditor, config, id, logger, mConnInfo, mDefErrorIfDown, mErrorIfDown, mMaxConns, mMaxResults, mMinConns, mNumConns, mTotal, PROP_ERROR_IF_DOWN, PROP_MAXCONNS, PROP_MAXRESULTS, PROP_MINCONNS, socketListener
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor for initializing from the config store.LdapAnonConnFactory
(String id, boolean defErrorIfDown) LdapAnonConnFactory
(String id, int minConns, int maxConns, int maxResults, LdapConnInfo connInfo) Constructor for LdapAnonConnFactoryLdapAnonConnFactory
(String id, int minConns, int maxConns, LdapConnInfo connInfo) Constructor for LdapAnonConnFactory -
Method Summary
Modifier and TypeMethodDescriptionnetscape.ldap.LDAPConnection
getConn()
Gets connection from this factory.netscape.ldap.LDAPConnection
getConn
(boolean waitForConn) Returns a LDAP connection - a clone of the master connection.protected void
init()
initialize routine from parameters.void
init
(PKISocketConfig config) void
init
(PKISocketConfig config, LDAPConfig dbConfig) protected void
makeMinimum
(boolean errorIfDown) make the mininum configured connectionsvoid
reset()
resets this factory - if no connections outstanding, disconnections all connections and resets everything to 0 as if no connections were ever made.void
returnConn
(netscape.ldap.LDAPConnection conn) Returns a connection to the factory for recycling.Methods inherited from class com.netscape.certsrv.ldap.LdapConnFactory
finalize, freeConn, getApprovalCallback, getAuditor, getConnInfo, getSocketListener, maxConn, setApprovalCallback, setAuditor, setSocketListener, totalConn
-
Constructor Details
-
LdapAnonConnFactory
Constructor for initializing from the config store. must be followed by init(ConfigStore) -
LdapAnonConnFactory
-
LdapAnonConnFactory
public LdapAnonConnFactory(String id, int minConns, int maxConns, LdapConnInfo connInfo) throws ELdapException Constructor for LdapAnonConnFactory- Parameters:
minConns
- minimum number of connections to have availablemaxConns
- max number of connections to have available. This is the maximum number of clones of this connection one wants to allow.connInfo
- server connection info - host, port, etc.- Throws:
ELdapException
-
LdapAnonConnFactory
public LdapAnonConnFactory(String id, int minConns, int maxConns, int maxResults, LdapConnInfo connInfo) throws ELdapException Constructor for LdapAnonConnFactory- Parameters:
minConns
- minimum number of connections to have availablemaxConns
- max number of connections to have available. This is the maximum number of clones of this connection one wants to allow.maxResults
- max number of results to return per queryconnInfo
- server connection info - host, port, etc.- Throws:
ELdapException
-
-
Method Details
-
init
- Throws:
ELdapException
-
init
- Throws:
EBaseException
ELdapException
-
init
initialize routine from parameters.- Throws:
ELdapException
-
makeMinimum
make the mininum configured connections- Throws:
ELdapException
-
getConn
Gets connection from this factory. All connections gotten from this factory must be returned. If not the max number of connections may be reached prematurely. The best thing to put returnConn in a finally clause so it always gets called. For example,LDAPConnection c = null; try { c = factory.getConn(); myclass.do_something_with_c(c); } catch (ELdapException e) { handle_error_here(); } finally { factory.returnConn(c); }
- Specified by:
getConn
in classLdapConnFactory
- Returns:
- Ldap connection object. connection is not available
- Throws:
ELdapException
- if any error occurs, such as a
-
getConn
Returns a LDAP connection - a clone of the master connection. All connections should be returned to the factory using returnConn() to recycle connection objects. If not returned the limited max number is affected but if that number is large not much harm is done. Returns null if maximum number of connections reached.The best thing to put returnConn in a finally clause so it always gets called. For example,
LDAPConnection c = null; try { c = factory.getConn(); myclass.do_something_with_c(c); } catch (ELdapException e) { handle_error_here(); } finally { factory.returnConn(c); }
- Throws:
ELdapException
-
returnConn
public void returnConn(netscape.ldap.LDAPConnection conn) Returns a connection to the factory for recycling. All connections gotten from this factory must be returned. If not the max number of connections may be reached prematurely.The best thing to put returnConn in a finally clause so it always gets called. For example,
LDAPConnection c = null; try { c = factory.getConn(); myclass.do_something_with_c(c); } catch (ELdapException e) { handle_error_here(); } finally { factory.returnConn(c); }
- Specified by:
returnConn
in classLdapConnFactory
- Parameters:
conn
- Ldap connection object to be returned to the free list of the pool.
-
reset
resets this factory - if no connections outstanding, disconnections all connections and resets everything to 0 as if no connections were ever made. intended to be called just before shutdown or exit to disconnection and cleanup connections.- Specified by:
reset
in classLdapConnFactory
- Throws:
ELdapException
-