📄 broker.java
字号:
* <i>allready</i> in the request queue.<p>
* While it is not an error to register a listener multiple times,
* a listener will still only be notified once.
*/
public void addDataListener(DataListener l)
{
if (listeners.contains(l) == false)
{
listeners.add(l);
}
}
/**
* Removes a data listener from every DataQuery generated by this broker.
* @param l the listener to be notified when the data is ready.
*/
public void removeDataListener(DataListener l)
{
if (listeners.contains(l)==true)
{
listeners.remove(l);
}
}
// Abstract DataSource methods - must be extended
public abstract boolean isModifiable();
public abstract DirContext getDirContext();
public abstract boolean isActive();
public abstract SchemaOps getSchemaOps();
/**
* Sets the finish flag of a request and returns
* the query. Often overloaded by derived broker classes.
*/
protected DataQuery finish(DataQuery request)
{
if (debug) System.out.println("Thread: " + Thread.currentThread().getName() + " request " + request.id + " finished ");
request.finish();
return request;
}
// Methods for the stop monitor - return a list of outstanding tasks
/**
* Returns the DataQuery currently being processed (if any).
* @return the current DataQuery (may be null if there is none).
*/
public DataQuery getCurrent() { return current; }
/**
* Returns the vector of outstanding queries.
* @return a vector of (DataQuery).
*/
public synchronized Vector getRequestQueue()
{
return requestQueue;
}
// this one doesn't need to be abstract...
protected DataQuery doExtendedQuery(DataQuery request)
throws NamingException
{
request.doExtendedRequest(this);
return finish(request);
}
/**
* Method for the Broker interface - chains to
* dirOp.exists().
*/
protected DataQuery doExistsQuery(DataQuery request)
throws NamingException
{
unthreadedExists(request.requestDN());
request.setStatus(true);
return finish(request);
}
/**
* Method for the Broker interface - chains to
* list().
*/
protected DataQuery doListQuery(DataQuery request)
throws NamingException
{
request.setEnum(unthreadedList(request.requestDN()));
return finish(request);
}
/**
* Method for the Broker interface - chains to
* dirOp.read().
*/
protected DataQuery doEntryQuery(DataQuery request)
throws NamingException
{
request.setEntry(unthreadedReadEntry(request.requestDN(), null));
return finish(request);
}
/**
* Method for the Broker interface - chains to
* search().
*/
protected DataQuery doSearchQuery(DataQuery request)
throws NamingException
{
DXNamingEnumeration en = unthreadedSearch(request.requestDN(), request.filter(), request.searchLevel(), request.returnAttributes());
request.setEnum(en);
return finish(request);
}
/**
* Method for the Broker interface - chains to
* modifyEntry().
*/
protected DataQuery doModifyQuery(DataQuery request)
throws NamingException
{
unthreadedModify(request.oldEntry(), request.newEntry());
request.setStatus(true);
return finish(request);
}
/**
* Method for the Broker interface - chains to
* copyTree().
*/
protected DataQuery doCopyQuery(DataQuery request)
throws NamingException
{
unthreadedCopy(request.oldDN(), request.requestDN());
request.setStatus(true);
return finish(request);
}
/**
* Method for the Broker interface - chains to
* unthreadedGetRecOCs.
*/
protected DataQuery doGetRecOCsQuery(DataQuery request)
throws NamingException
{
request.setArrayList(unthreadedGetRecOCs(request.requestDN()));
return finish(request);
}
/**
* Method for the Broker interface - chains to
* getObjectClasses().
*/
/*
protected DataQuery doGetAllOCsQuery(DataQuery request)
{
request.setVector(unthreadedGetAllOCs());
return finish(request);
}
*/
/**
* returns the next level of a directory tree, returning
* a Enumeration of the results
*
* @param searchbase the node in the tree to expand
* @return list of results (NameClassPair); the next layer of the tree...
*/
public abstract DXNamingEnumeration unthreadedList(DN searchbase) throws NamingException;
/**
* Performs a directory search.
*
* @param dn the domain name (relative to initial context in ldap) to seach from.
* @param filter the non-null filter to use for the search
* @param search_level whether to search the base object, the next level or the whole subtree.
* @param returnAttributes a vector of string names of attributes to return in the search.
* (null means 'return all entries', a zero length array means 'return no attributes'.)
* @return list of results ('SearchResult's); the next layer of the tree...
*/
public abstract DXNamingEnumeration unthreadedSearch(DN dn, String filter, int search_level, String[] returnAttributes) throws NamingException;
/**
* Copies a DN representing a subtree to a new subtree, including
* copying all subordinate entries.
*
* @param oldNodeDN the original DN of the sub tree root
* to be copied (may be a single entry).
* @param newNodeDN the target DN for the tree to be moved to.
*/
public abstract void unthreadedCopy(DN oldNodeDN, DN newNodeDN) throws NamingException;
/**
* Checks the existance of a given entry.
*/
public abstract boolean unthreadedExists(DN checkMe) throws NamingException;
/**
* Returns a complete list of all known object classes.
*/
//public abstract Vector unthreadedGetAllOCs();
/**
* Reads an entry with all its attributes from
* the directory.
* @param entryDN the DN of the object to read.
* @param returnAttributes a vector of string names of attributes to return in the search.
* (null means 'return all entries', a zero length array means 'return no attributes'.)
*/
public abstract DXEntry unthreadedReadEntry(DN entryDN, String[] returnAttributes) throws NamingException;
/**
* Update an entry with the designated DN.
* @param oldEntry oldSet the old set of attributes of the object.
* @param newEntry newSet the replacement set of attributes..
*/
public abstract void unthreadedModify(DXEntry oldEntry, DXEntry newEntry) throws NamingException;
/**
* Gets a list of the object classes most likely
* to be used for the next Level of the DN...
* @param dn the dn of the parent to determine likely
* child object classes for
* @return list of recommended object classes...
*/
public abstract ArrayList unthreadedGetRecOCs(DN dn) throws NamingException;
/**
* Utility method for extended queries - returns whether
* a 'masked' exception has occured.
* @return the exception, or null if there is none.
*/
public Exception getException()
{
return null;
}
/**
* Utility method for extended queries - allows
* a 'masked' exception to be cleared.
*/
public void clearException()
{
}
/**
* As a way to directly access the directory broker, a DataSource
* MAY choose to publish the directory broker.
* @return the Broker - may be null.
*/
public Broker getBroker() { return this; }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -