All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.undefinedlabs.scope.rules.sql.provider.ConnectionInfoProviderRegistry Maven / Gradle / Ivy

Go to download

Scope is a APM for tests to give engineering teams unprecedented visibility into their CI process to quickly identify, troubleshoot and fix failed builds. This artifact contains the classes to instrument the Java SQL package.

There is a newer version: 0.15.1-beta.2
Show newest version
package com.undefinedlabs.scope.rules.sql.provider;

import com.undefinedlabs.scope.rules.sql.provider.internal.NoopConnectionInfoProvider;
import com.undefinedlabs.scope.rules.sql.provider.internal.h2.H2JdbcConnectionInfoProvider;
import com.undefinedlabs.scope.rules.sql.provider.internal.mysql.MySqlConnectionImplInfoProvider;
import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;

public enum ConnectionInfoProviderRegistry {
  INSTANCE;

  private static final ConnectionInfoProvider NOOP_PROVIDER = new NoopConnectionInfoProvider();
  private static final Map PROVIDERS = new HashMap<>();

  static {
    PROVIDERS.put(
        H2JdbcConnectionInfoProvider.JDBC_CONNECTION_CLASS_NAME,
        new H2JdbcConnectionInfoProvider());
    PROVIDERS.put(
        MySqlConnectionImplInfoProvider.JDBC_CONNECTION_CLASS_NAME,
        new MySqlConnectionImplInfoProvider());
  }

  public ConnectionInfoProvider getProvider(final Connection connection) {
    return connection != null ? getProvider(connection.getClass().getName()) : NOOP_PROVIDER;
  }

  ConnectionInfoProvider getProvider(final String connectionClassName) {
    return PROVIDERS.get(connectionClassName) != null
        ? PROVIDERS.get(connectionClassName)
        : NOOP_PROVIDER;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy