Sistema de Nombrado en Java (JNDI) [Parte I]

La lecci�n Operaciones de Directorio mostr� c�mo usar los distintos m�todos DirContext.search().

Cuando realizamos una b�squeda usando un par�metro SearchControls, podemos controlar qu� se obtiene en cada SearchResult.

Espec�ficamente, si llamamos a SearchControls.setReturningObjFlag() con true y pasamos esto a search(), entonces cada entrada en el SearchResult contendr� el correspondiente objeto Java.

El siguiente ejemplo busca el contexto usado para unir los distintos objetos de la lecci�n Almacenar Objetos en el Directorio e imprime cada objeto resultado (nombre de la clase y referencia al objeto).

SearchControls ctls = new SearchControls();
ctls.setReturningObjFlag(true);

// Specify the search filter to match any object
String filter = "(objectclass=*)";

// Search for objects by using the filter
NamingEnumeration answer = ctx.search("", filter, ctls);

Aqu� tenemos la salida de este ejemplo.

# java -Djava.security.manager -Djava.security.policy=.policy Search
ou=Groups: com.sun.jndi.ldap.LdapCtx: com.sun.jndi.ldap.LdapCtx@723fdc9a
ou=People: com.sun.jndi.ldap.LdapCtx: com.sun.jndi.ldap.LdapCtx@642fdc9a
cn=Fruits: com.sun.jndi.ldap.LdapCtx: com.sun.jndi.ldap.LdapCtx@63afdc9a
cn=Button: java.awt.Button: java.awt.Button[button0,0,0,0x0,invalid,label=Push me]
cn=Flower: Flower: pink rose
cn=favorite: Fruit: orange
cn=favDrink: Drink: water
cn=CorbaHello: com.sun.CORBA.idl.CORBAObjectImpl: com.sun.CORBA.idl.CORBAObjectImpl:com.sun.CORBA.idl.
								GenericCORBAClientSC@8a9e173a
cn=RemoteHello: HelloImpl_Stub: HelloImpl_Stub[RemoteStub [ref: [endpoint:[129.111.111.111:46547](remote),
								objID:[75de816d:d98468df8c:-8000, 0]]]]
cn=RefHello: HelloImpl_Stub: HelloImpl_Stub[RemoteStub [ref: [endpoint:[129.111.111.111:46550](remote),objID.
								[272f25a1:d9846946ca:-8000, 0]]]]
cn=Custom: com.sun.jndi.ldap.LdapCtx: com.sun.jndi.ldap.LdapCtx@db7a1739
cn=John Smith: Person: My name is Smith, John Smith.
cn=RmiiiopHello: com.sun.CORBA.idl.CORBAObjectImpl: com.sun.CORBA.idl.CORBAObjectImpl:com.sun.CORBA.idl.
								GenericCORBAClientSC@ac6b5dd2

COMPARTE ESTE ARTÍCULO

COMPARTIR EN FACEBOOK
COMPARTIR EN TWITTER
COMPARTIR EN LINKEDIN
COMPARTIR EN WHATSAPP
SIGUIENTE ARTÍCULO