|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--org.globus.mds.MDS
The interface to the Monitoring and Discovery Service.
USING THE MDS CLASS
The intention of the MDS class is to simplify the connection to the Monitoring and Discovery Service (MDS). This includes:The main motivation for this class is to have an intermediate Application Layer which can be easily adapted to different LDAP client libraries (JNDI, Netscape SDK, Microsoft SDK). To adapt to the differnt API's only a limited number of routines have to be ported. The current release is based on JNDI.
- establishing a conection to an MDS Server,
- quering for contents in the MDS,
- printing the result of a query, and
- disconecting from the MDS Server.
Connecting
The first step in using the class is to establish a connection, which is done in the following way:MDS mds = new MDS("www.globus.org", "389", "o=Globus, c=US");The parameters to the mds class are simply the DNS name of the MDS server and the port number for the connection. The default values for the connection to the MDS are set to ldap://mds.globus.org:389, which are used in case no parameters are specified:MDS mds = new MDS();
Searching
Searching the MDS is done with LDAP queries in respect to a base directory specified by a distingished name (DN). The top level of a globus related seraches is:o=Globus, c=USA search is invoked in the following way:NamingEnumeration result;The search result is stored in a NamingEnumeration as provided by JNDI.
result = mds.search("o=Globus, c=US", "(objectclass=*)", MDS.ONELEVEL_SCOPE);
Printing
A result from a search can be modified by the appropiate JNDI functions. A simple print function is provided which is intended to simplify debugging and programming development:mds.print(result, false);
Example
The following example shows a program which connets to the MDS, and prints all ComputeResources located at Argonne National Laboratory:MDS mds = new MDS("mds.globus.org", "389");
try {
mds.connect();
String bindDN =
"o=Argonne National Laboratory, o=Globus,c=US";
Vector result;
result = mds.search(bindDN,
"(objectclass=GlobusComputeResource)", MDS.ONELEVEL_SCOPE);
System.out.println(results);
mds.disconnect();
} catch(MDSException e) {
System.err.println( "Error:"+ e.getLdapMessage() );
}
| Field Summary | |
protected javax.naming.ldap.LdapContext |
ctx
|
protected static java.lang.String |
DEFAULT_CTX
|
protected java.util.Properties |
env
|
protected int |
limit
|
static int |
OBJECT_SCOPE
|
static int |
ONELEVEL_SCOPE
|
static int |
SUBTREE_SCOPE
|
protected int |
timeout
|
protected int |
version
|
| Constructor Summary | |
MDS()
initilaizes a connetion to the MDS database with its default values |
|
MDS(GlobusURL spec)
initilaizes a connetion to the MDS database using the specified LDAP URL |
|
MDS(java.lang.String hostname,
java.lang.String port)
initilaizes a connetion to the MDS database to the speified host and port |
|
MDS(java.lang.String hostname,
java.lang.String port,
java.lang.String baseDN)
initilaizes a connetion to the MDS database to the speified host and port |
|
| Method Summary | |
void |
addAttribute(java.lang.String dn,
MDSResult at)
adds attributes to an entry. |
void |
addEntry(java.lang.String dn,
MDSResult at)
adds attributes specified in a Attributes to an Object. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener l)
|
void |
connect()
connects to the specified server |
void |
connect(java.lang.String managerDN,
java.lang.String password)
connects and authenticates to the specified server |
protected javax.naming.directory.SearchControls |
createConstraints(int scope,
java.lang.String[] attrToReturn)
|
void |
deleteAttribute(java.lang.String dn,
java.lang.String attr)
deletes a specific attribute of an entry. |
void |
deleteEntry(java.lang.String dn)
deletes a specific object specified by the dn. |
void |
deleteTree(java.lang.String dn,
boolean deleteItSelf)
deletes a subtree starting from dn |
void |
deleteValues(java.lang.String dn,
MDSResult at)
deletes attributes of an entry. |
void |
disconnect()
disconnects from the MDS server |
MDSResult |
getAttributes(java.lang.String dn)
This methods returns that attributes of the specified distinguished name. |
MDSResult |
getAttributes(java.lang.String dn,
java.lang.String[] attributes)
This methods returns that attributes of the specified distinguished name. |
java.lang.String |
getBaseDN()
returns the baseDN currently used |
java.lang.String |
getHostname()
gets the hostname |
int |
getLdapVersion()
gets ldap protocol version |
java.lang.String |
getPort()
gets the port |
int |
getSearchLimit()
gets search limit |
int |
getSearchTimeout()
returns search timeout |
java.lang.String |
getURL()
gets the URL |
java.util.Hashtable |
list(java.lang.String baseDN)
Lists the objects bound to the argument. |
void |
reconnect()
reconnects to the server. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener l)
|
void |
renameEntry(java.lang.String oldDN,
java.lang.String newDN)
renames an object in an LDAP database. |
void |
renameEntry(java.lang.String oldDN,
java.lang.String newDN,
boolean deleteOldDN)
renames an object in an LDAP database. |
java.util.Hashtable |
search(java.lang.String filter,
int searchScope)
issues a specified search to the MDS. |
java.util.Hashtable |
search(java.lang.String filter,
java.lang.String[] attrToReturn,
int searchScope)
issues a specified search to the MDS starting from the base DN. |
java.util.Hashtable |
search(java.lang.String baseDN,
java.lang.String filter,
int searchScope)
issues a specified search to the MDS starting from the base DN. |
java.util.Hashtable |
search(java.lang.String baseDN,
java.lang.String filter,
java.lang.String[] attrToReturn,
int searchScope)
issues a specified search to the MDS starting from the base DN. |
javax.naming.NamingEnumeration |
searchl(java.lang.String baseDN,
java.lang.String filter,
java.lang.String[] attrToReturn,
int searchScope)
Issues a search starting from the basDN. |
void |
setBaseDN(java.lang.String baseDN)
sets the baseDN to the specified value |
void |
setHostname(java.lang.String hostname)
sets the hostname to the specified value |
void |
setLdapVersion(int newVersion)
sets ldap protocol version |
void |
setPort(java.lang.String port)
Sets the port to the specified value |
void |
setSearchLimit(int newLimit)
sets search limit - number of returned entries |
void |
setSearchTimeout(int newTimeout)
sets search timeout |
void |
updateAttribute(java.lang.String dn,
MDSResult at)
updates attributes of an entry. |
void |
updateEntry(java.lang.String dn,
MDSResult at)
updates specifed dn with attributes |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected int limit
protected int timeout
protected int version
public static final int SUBTREE_SCOPE
public static final int ONELEVEL_SCOPE
public static final int OBJECT_SCOPE
protected static final java.lang.String DEFAULT_CTX
protected javax.naming.ldap.LdapContext ctx
protected java.util.Properties env
| Constructor Detail |
public MDS()
public MDS(java.lang.String hostname,
java.lang.String port)
hostname - specifies the hostname to which to connectport - is the port on which the conection is established
public MDS(java.lang.String hostname,
java.lang.String port,
java.lang.String baseDN)
hostname - specifies the hostname to which to connectport - is the port on which the conection is establishedbaseDN - is the base DN from which searches are rootedpublic MDS(GlobusURL spec)
spec - the LDAP URL spec from which connection information is
derived| Method Detail |
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
public void setBaseDN(java.lang.String baseDN)
baseDN - public java.lang.String getBaseDN()
public void setPort(java.lang.String port)
port - public java.lang.String getPort()
public void setHostname(java.lang.String hostname)
hostname - public java.lang.String getHostname()
public java.lang.String getURL()
public void setSearchTimeout(int newTimeout)
newTimeout - public int getSearchTimeout()
public void setSearchLimit(int newLimit)
newLimit - public int getSearchLimit()
public void setLdapVersion(int newVersion)
newVersion - public int getLdapVersion()
public void connect()
throws MDSException
an - MDSexception if unable to connectMDSException -
public void connect(java.lang.String managerDN,
java.lang.String password)
throws MDSException
managerDN - specifies the distingushed name of the directory manager
or userpassword - specifies the password of the directory manager or useran - MDSexception if unable to connectMDSException -
public void disconnect()
throws MDSException
an - MDSexception if failed to disconnect
public void reconnect()
throws MDSException
an - MDSexception if unable to reconnect
public java.util.Hashtable search(java.lang.String filter,
int searchScope)
throws MDSException
filter - a common LDAP filtersearchScope - sets the scope of the searchan - MDSexception if something goes bad
public java.util.Hashtable search(java.lang.String filter,
java.lang.String[] attrToReturn,
int searchScope)
throws MDSException
filter - a common LDAP filterattrToReturn - searchScope - sets the scope of the searchan - MDSexception if something goes bad
public java.util.Hashtable search(java.lang.String baseDN,
java.lang.String filter,
int searchScope)
throws MDSException
baseDN - filter - a common LDAP filtersearchScope - sets the scope of the searchan - MDSexception if something goes bad
public java.util.Hashtable search(java.lang.String baseDN,
java.lang.String filter,
java.lang.String[] attrToReturn,
int searchScope)
throws MDSException
baseDN - the base DN from which thefilter - a common LDAP filterattrToReturn - an array of attributes to be returnedsearchScope - sets the scope of the searchan - MDSexception if something goes badMDSException -
public javax.naming.NamingEnumeration searchl(java.lang.String baseDN,
java.lang.String filter,
java.lang.String[] attrToReturn,
int searchScope)
throws javax.naming.NamingException
baseDN - the base dn from which the search is startedfilter - the filter for the searchattrToReturn - an array of attributes to returnsearchScope - The search scopejavax.naming.NamingException - when an LDAP error occurs.
public java.util.Hashtable list(java.lang.String baseDN)
throws MDSException
baseDN - an - MDSexception if something goes bad
public MDSResult getAttributes(java.lang.String dn)
throws MDSException
dn - an - MDSexception if something goes bad
public MDSResult getAttributes(java.lang.String dn,
java.lang.String[] attributes)
throws MDSException
dn - attributes - an - MDSexception if something goes bad
protected javax.naming.directory.SearchControls createConstraints(int scope,
java.lang.String[] attrToReturn)
public void deleteEntry(java.lang.String dn)
throws MDSException
dn - the distinguished name of the object to be deleted.an - MDSexception if something goes bad
public void renameEntry(java.lang.String oldDN,
java.lang.String newDN)
throws MDSException
oldDN - newDN - an - MDSexception if something goes bad
public void renameEntry(java.lang.String oldDN,
java.lang.String newDN,
boolean deleteOldDN)
throws MDSException
oldDN - newDN - deleteOldDN - deletes old dn from the entry
public void updateEntry(java.lang.String dn,
MDSResult at)
throws MDSException
dn - the distinguished name of the object.at - an - MDSexception if something goes bad
public void addEntry(java.lang.String dn,
MDSResult at)
throws MDSException
dn - the distinguished name of the object.at - an - MDSexception if something goes bad
public void deleteAttribute(java.lang.String dn,
java.lang.String attr)
throws MDSException
dn - the distinguished name of the entryattr - the attribute name of the attribute to be deleted.an - MDSexception if something goes bad
public void deleteValues(java.lang.String dn,
MDSResult at)
throws MDSException
dn - the distinguished name of the entry.at - a set of attributes to deletean - MDSexception if something goes bad
public void updateAttribute(java.lang.String dn,
MDSResult at)
throws MDSException
dn - the distinguished name of the entry.at - a set of attributes to replace or addan - MDSexception if something goes bad
public void addAttribute(java.lang.String dn,
MDSResult at)
throws MDSException
dn - the distinguished name of the object.at - an - MDSexception if something goes bad
public void deleteTree(java.lang.String dn,
boolean deleteItSelf)
throws MDSException
dn - the distinguished name of the object.deleteItSelf - if set to true, it also deletes the dnan - MDSexception if something goes bad
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||