use of org.apache.directory.api.ldap.codec.api.IntermediateResponseFactory in project directory-ldap-api by apache.
the class StandaloneLdapApiService method loadIntermediateResponse.
/**
* Loads an intermediate responses from its FQCN
*/
private void loadIntermediateResponse(String intermediateResponseFQCN) throws Exception {
if (getIntermediateResponseFactories().containsKey(intermediateResponseFQCN)) {
LOG.debug("Factory for Intermediate Response {} was already loaded", intermediateResponseFQCN);
return;
}
Class<?>[] types = new Class<?>[] { LdapApiService.class };
// note, trimming whitespace doesn't hurt as it is a class name and
// helps DI containers that use xml config as xml ignores whitespace
@SuppressWarnings("unchecked") Class<? extends IntermediateResponseFactory> clazz = (Class<? extends IntermediateResponseFactory>) Class.forName(intermediateResponseFQCN.trim());
Constructor<?> constructor = clazz.getConstructor(types);
IntermediateResponseFactory factory = (IntermediateResponseFactory) constructor.newInstance(this);
getIntermediateResponseFactories().put(factory.getOid(), factory);
LOG.info("Registered pre-bundled Intermediate Response factory: {}", factory.getOid());
}
use of org.apache.directory.api.ldap.codec.api.IntermediateResponseFactory in project directory-ldap-api by apache.
the class DefaultLdapCodecService method newIntermediateResponse.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public <I extends IntermediateResponse> I newIntermediateResponse(String responseName, int messageId, byte[] serializedResponse) throws DecoderException {
IntermediateResponseDecorator<IntermediateResponse> resp;
IntermediateResponseFactory intermediateResponseFactory = intermediateResponseFactories.get(responseName);
if (intermediateResponseFactory != null) {
resp = (IntermediateResponseDecorator<IntermediateResponse>) intermediateResponseFactory.newResponse(serializedResponse);
} else {
resp = new IntermediateResponseDecorator<IntermediateResponse>(this, new IntermediateResponseImpl(responseName));
resp.setResponseValue(serializedResponse);
resp.setResponseName(responseName);
}
resp.setMessageId(messageId);
return (I) resp;
}
Aggregations