@@ -0,0 +1,2684 @@
+/*%0A * Copyright (c) %22Neo4j%22%0A * Neo4j Sweden AB %5Bhttp://neo4j.com%5D%0A *%0A * This file is part of Neo4j.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.neo4j.driver.internal.svm;%0A%0Aimport com.oracle.svm.core.annotate.Substitute;%0Aimport com.oracle.svm.core.annotate.TargetClass;%0A%0Aimport org.neo4j.driver.Config;%0Aimport org.neo4j.driver.MetricsAdapter;%0Aimport org.neo4j.driver.internal.DriverFactory;%0Aimport org.neo4j.driver.internal.metrics.DevNullMetricsProvider;%0Aimport org.neo4j.driver.internal.metrics.InternalMetricsProvider;%0Aimport org.neo4j.driver.internal.metrics.MetricsProvider;%0Aimport org.neo4j.driver.internal.metrics.MicrometerMetricsProvider;%0Aimport org.neo4j.driver.internal.util.Clock;%0A%0A@TargetClass( DriverFactory.class )%0Afinal class Target_org_neo4j_driver_internal_DriverFactory%0A%7B%0A%0A    /**%0A     * Substitutes metrics adatper in such a way that it falls back to off when Micrometer is not available.%0A     *%0A     * @param config Drivers config%0A     * @param clock Clock to use%0A     * @return A metrics provider, never null%0A     */%0A    @Substitute%0A    protected static MetricsProvider getOrCreateMetricsProvider( Config config, Clock clock )%0A    %7B%0A        MetricsAdapter metricsAdapter = config.metricsAdapter();%0A        if ( metricsAdapter == null )%0A        %7B%0A            metricsAdapter = config.isMetricsEnabled() ? MetricsAdapter.DEFAULT : MetricsAdapter.DEV_NULL;%0A        %7D%0A        switch ( metricsAdapter )%0A        %7B%0A        case DEV_NULL:%0A            return DevNullMetricsProvider.INSTANCE;%0A        case DEFAULT:%0A            return new InternalMetricsProvider( clock, config.logging() );%0A        case MICROMETER:%0A            try%0A            %7B%0A                @SuppressWarnings( %22unused%22 ) Class%3C?%3E metricsClass = Class.forName( %22io.micrometer.core.instrument.Metrics%22 );%0A                return MicrometerMetricsProvider.forGlobalRegistry();%0A            %7D%0A            catch ( ClassNotFoundException e )%0A            %7B%0A                return DevNullMetricsProvider.INSTANCE;%0A            %7D%0A        %7D%0A        throw new IllegalStateException( %22Unknown or unsupported MetricsAdapter: %22 + metricsAdapter );%0A    %7D%0A%7D%0A%0Aclass MicrometerSubstitutions%0A%7B%0A%7D%0A

Add substitutions for DriverFactory#getOrCreateMetricsProvider. (#1183) (#1189)