Search in sources :

Example 1 with IntermediateResponseFactory

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());
}
Also used : LdapApiService(org.apache.directory.api.ldap.codec.api.LdapApiService) IntermediateResponseFactory(org.apache.directory.api.ldap.codec.api.IntermediateResponseFactory)

Example 2 with IntermediateResponseFactory

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;
}
Also used : IntermediateResponse(org.apache.directory.api.ldap.model.message.IntermediateResponse) IntermediateResponseFactory(org.apache.directory.api.ldap.codec.api.IntermediateResponseFactory) IntermediateResponseImpl(org.apache.directory.api.ldap.model.message.IntermediateResponseImpl)

Aggregations

IntermediateResponseFactory (org.apache.directory.api.ldap.codec.api.IntermediateResponseFactory)2 LdapApiService (org.apache.directory.api.ldap.codec.api.LdapApiService)1 IntermediateResponse (org.apache.directory.api.ldap.model.message.IntermediateResponse)1 IntermediateResponseImpl (org.apache.directory.api.ldap.model.message.IntermediateResponseImpl)1