edu.vt.middleware.ldap
Class LdapSearch

java.lang.Object
  extended by edu.vt.middleware.ldap.LdapSearch
Direct Known Subclasses:
DsmlSearch, LdifSearch

public class LdapSearch
extends Object

LdapSearch queries an LDAP and returns the result. Each instance of LdapSearch maintains it's own pool of LDAP connections.

Version:
$Revision: 1330 $ $Date: 2010-05-23 18:10:53 -0400 (Sun, 23 May 2010) $
Author:
Middleware Services

Field Summary
protected  LdapBeanFactory beanFactory
          Ldap bean factory.
protected  org.apache.commons.logging.Log logger
          Log for this class.
protected  LdapPool<Ldap> pool
          Ldap object to use for searching.
 
Constructor Summary
LdapSearch(LdapPool<Ldap> pool)
          This creates a new LdapSearch with the supplied pool.
 
Method Summary
 void close()
          Empties the underlying ldap pool, closing all connections.
protected  void finalize()
          Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
 LdapBeanFactory getLdapBeanFactory()
          Returns the factory for creating ldap beans.
 Iterator<SearchResult> search(String query, String[] attrs)
          This will perform an LDAP search with the supplied query and return attributes.
 void search(String query, String[] attrs, Writer writer)
          This will perform an LDAP search with the supplied query and return attributes.
 void setLdapBeanFactory(LdapBeanFactory lbf)
          Sets the factory for creating ldap beans.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Log for this class.


pool

protected LdapPool<Ldap> pool
Ldap object to use for searching.


beanFactory

protected LdapBeanFactory beanFactory
Ldap bean factory.

Constructor Detail

LdapSearch

public LdapSearch(LdapPool<Ldap> pool)
This creates a new LdapSearch with the supplied pool.

Parameters:
pool - LdapPool
Method Detail

getLdapBeanFactory

public LdapBeanFactory getLdapBeanFactory()
Returns the factory for creating ldap beans.

Returns:
LdapBeanFactory

setLdapBeanFactory

public void setLdapBeanFactory(LdapBeanFactory lbf)
Sets the factory for creating ldap beans.

Parameters:
lbf - LdapBeanFactory

search

public Iterator<SearchResult> search(String query,
                                     String[] attrs)
                              throws NamingException
This will perform an LDAP search with the supplied query and return attributes.

Parameters:
query - String to search for
attrs - String[] to return
Returns:
Iterator of search results
Throws:
NamingException - if an error occurs while searching

search

public void search(String query,
                   String[] attrs,
                   Writer writer)
            throws NamingException,
                   IOException
This will perform an LDAP search with the supplied query and return attributes. The results will be written to the supplied Writer.

Parameters:
query - String to search for
attrs - String[] to return
writer - Writer to write to
Throws:
NamingException - if an error occurs while searching
IOException - if an error occurs while writing search results

close

public void close()
Empties the underlying ldap pool, closing all connections. See LdapPool.close().


finalize

protected void finalize()
                 throws Throwable
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

Overrides:
finalize in class Object
Throws:
Throwable - if an exception is thrown by this method


Copyright © 2003-2010 Virginia Tech. All Rights Reserved.