|
Spring LDAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.ldap.control.AbstractRequestControlDirContextProcessor
org.springframework.ldap.control.AbstractFallbackRequestAndResponseControlDirContextProcessor
public abstract class AbstractFallbackRequestAndResponseControlDirContextProcessor
Convenient base class useful when implementing a standard DirContextProcessor which has a request control and a response control. It handles the loading of the control classes, using fallback implementations specified by the subclass if necessary. It handles the request control constructor invocation; it only needs the constructor arguments to be provided. It also handles most of the work in the post processing of the response control, only delegating to a template method for the actual value retrieval. In short, it makes it easy to implement a custom DirContextProcessor.
public class SortControlDirContextProcessor extends AbstractFallbackRequestAndResponseControlDirContextProcessor {
String sortKey;
private boolean sorted = false;
private int resultCode = -1;
public SortControlDirContextProcessor(String sortKey) {
this.sortKey = sortKey;
defaultRequestControl = "javax.naming.ldap.SortControl";
defaultResponseControl = "com.sun.jndi.ldap.ctl.SortControl";
fallbackRequestControl = "javax.naming.ldap.SortResponseControl";
fallbackResponseControl = "com.sun.jndi.ldap.ctl.SortResponseControl";
loadControlClasses();
}
public boolean isSorted() {
return sorted;
}
public int getResultCode() {
return resultCode;
}
public Control createRequestControl() {
return super.createRequestControl(new Class[] { String[].class, boolean.class }, new Object[] {
new String[] { sortKey }, Boolean.valueOf(critical) });
}
protected void handleResponse(Object control) {
Boolean result = (Boolean) invokeMethod("isSorted", responseControlClass, control);
this.sorted = result.booleanValue();
Integer code = (Integer) invokeMethod("getResultCode", responseControlClass, control);
resultCode = code.intValue();
}
}
| Field Summary | |
|---|---|
protected boolean |
critical
|
protected String |
defaultRequestControl
|
protected String |
defaultResponseControl
|
protected String |
fallbackRequestControl
|
protected String |
fallbackResponseControl
|
protected Class<?> |
requestControlClass
|
protected Class<?> |
responseControlClass
|
| Fields inherited from class org.springframework.ldap.control.AbstractRequestControlDirContextProcessor |
|---|
log |
| Constructor Summary | |
|---|---|
AbstractFallbackRequestAndResponseControlDirContextProcessor()
|
|
| Method Summary | |
|---|---|
Control |
createRequestControl(Class<?>[] paramTypes,
Object[] params)
Creates a request control using the constructor parameters given in params. |
protected abstract void |
handleResponse(Object control)
|
protected Object |
invokeMethod(String method,
Class<?> clazz,
Object control)
Utility method for invoking a method on a Control. |
protected void |
loadControlClasses()
|
void |
postProcess(DirContext ctx)
Perform post-processing on the supplied DirContext. |
void |
setCritical(boolean critical)
Set whether this control should be indicated as critical. |
void |
setRequestControlClass(Class<?> requestControlClass)
|
void |
setResponseControlClass(Class<?> responseControlClass)
Set the class of the expected ResponseControl for the sorted result response. |
| Methods inherited from class org.springframework.ldap.control.AbstractRequestControlDirContextProcessor |
|---|
createRequestControl, isReplaceSameControlEnabled, preProcess, setReplaceSameControlEnabled |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Class<?> responseControlClass
protected Class<?> requestControlClass
protected boolean critical
protected String defaultRequestControl
protected String defaultResponseControl
protected String fallbackRequestControl
protected String fallbackResponseControl
| Constructor Detail |
|---|
public AbstractFallbackRequestAndResponseControlDirContextProcessor()
| Method Detail |
|---|
protected void loadControlClasses()
public void setResponseControlClass(Class<?> responseControlClass)
responseControlClass - Class of the expected response control.public void setRequestControlClass(Class<?> requestControlClass)
protected Object invokeMethod(String method,
Class<?> clazz,
Object control)
method - name of method to invokeclazz - Class of the object that the method should be invoked oncontrol - Instance that the method should be invoked on
public Control createRequestControl(Class<?>[] paramTypes,
Object[] params)
params.
paramTypes - Types of the constructor parametersparams - Actual constructor parameters
public void postProcess(DirContext ctx)
throws NamingException
DirContextProcessorDirContext.
ctx - the DirContext instance.
NamingException - if thrown by the underlying operation.public void setCritical(boolean critical)
critical - whether the control is critical.protected abstract void handleResponse(Object control)
|
Spring LDAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||