class ElasticsearchAuditEventHandlerFactory implements AuditEventHandlerFactory {

    @Override
    public AuditEventHandler create(AuditEventHandlerConfiguration configuration) throws AuditException {
        final ElasticsearchAuditEventHandlerConfiguration esHandlerConfiguration = new
                ElasticsearchAuditEventHandlerConfiguration();

        Map<String, Set<String>> attributes = configuration.getAttributes();

        esHandlerConfiguration.setName(configuration.getHandlerName());
        esHandlerConfiguration.setEnabled(getBooleanMapAttr(attributes, "enabled", false));
        esHandlerConfiguration.setTopics(attributes.get("topics"));
        esHandlerConfiguration.setIndexMapping(getIndexMapping(attributes));
        esHandlerConfiguration.setBuffering(getBufferingConfiguration(attributes));
        esHandlerConfiguration.setConnection(getConnection(attributes));

        final Client client = createClient();

        return new ElasticsearchAuditEventHandler(esHandlerConfiguration, configuration.getEventTopicsMetaData(),
                client);
    }

}