Search in sources :

Example 1 with NoopSchemaChangeListener

use of com.datastax.oss.driver.internal.core.metadata.schema.NoopSchemaChangeListener in project java-driver by datastax.

the class DefaultDriverContext method buildSchemaChangeListener.

protected SchemaChangeListener buildSchemaChangeListener(SchemaChangeListener schemaChangeListenerFromBuilder) {
    List<SchemaChangeListener> listeners = new ArrayList<>();
    if (schemaChangeListenerFromBuilder != null) {
        listeners.add(schemaChangeListenerFromBuilder);
    }
    DefaultDriverOption newOption = DefaultDriverOption.METADATA_SCHEMA_CHANGE_LISTENER_CLASSES;
    @SuppressWarnings("deprecation") DefaultDriverOption legacyOption = DefaultDriverOption.METADATA_SCHEMA_CHANGE_LISTENER_CLASS;
    DriverExecutionProfile profile = config.getDefaultProfile();
    if (profile.isDefined(newOption)) {
        listeners.addAll(Reflection.buildFromConfigList(this, newOption, SchemaChangeListener.class, "com.datastax.oss.driver.internal.core.metadata.schema"));
    }
    if (profile.isDefined(legacyOption)) {
        LOG.warn("Option {} has been deprecated and will be removed in a future release; please use option {} instead.", legacyOption, newOption);
        Reflection.buildFromConfig(this, legacyOption, SchemaChangeListener.class, "com.datastax.oss.driver.internal.core.metadata.schema").ifPresent(listeners::add);
    }
    if (listeners.isEmpty()) {
        return new NoopSchemaChangeListener(this);
    } else if (listeners.size() == 1) {
        return listeners.get(0);
    } else {
        return new MultiplexingSchemaChangeListener(listeners);
    }
}
Also used : NoopSchemaChangeListener(com.datastax.oss.driver.internal.core.metadata.schema.NoopSchemaChangeListener) NoopSchemaChangeListener(com.datastax.oss.driver.internal.core.metadata.schema.NoopSchemaChangeListener) MultiplexingSchemaChangeListener(com.datastax.oss.driver.internal.core.metadata.schema.MultiplexingSchemaChangeListener) SchemaChangeListener(com.datastax.oss.driver.api.core.metadata.schema.SchemaChangeListener) DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) MultiplexingSchemaChangeListener(com.datastax.oss.driver.internal.core.metadata.schema.MultiplexingSchemaChangeListener) DefaultDriverOption(com.datastax.oss.driver.api.core.config.DefaultDriverOption) ArrayList(java.util.ArrayList)

Aggregations

DefaultDriverOption (com.datastax.oss.driver.api.core.config.DefaultDriverOption)1 DriverExecutionProfile (com.datastax.oss.driver.api.core.config.DriverExecutionProfile)1 SchemaChangeListener (com.datastax.oss.driver.api.core.metadata.schema.SchemaChangeListener)1 MultiplexingSchemaChangeListener (com.datastax.oss.driver.internal.core.metadata.schema.MultiplexingSchemaChangeListener)1 NoopSchemaChangeListener (com.datastax.oss.driver.internal.core.metadata.schema.NoopSchemaChangeListener)1 ArrayList (java.util.ArrayList)1