io.smallrye.config.SmallRyeConfigProviderResolver Java Examples

The following examples show how to use io.smallrye.config.SmallRyeConfigProviderResolver. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArchiveProcessor.java    From smallrye-metrics with Apache License 2.0 7 votes vote down vote up
@Override
public void process(TestDeployment testDeployment, Archive<?> protocolArchive) {
    WebArchive war = (WebArchive) protocolArchive;
    war.addAsWebInfResource("WEB-INF/jboss-web.xml", "jboss-web.xml");
    String[] deps = {
            "io.smallrye:smallrye-config",
            "io.smallrye:smallrye-metrics",
            "io.smallrye:smallrye-metrics-testsuite-common",
            "org.eclipse.microprofile.metrics:microprofile-metrics-api",
            "org.jboss.weld.servlet:weld-servlet-core"
    };

    File[] dependencies = Maven.resolver().loadPomFromFile(new File("pom.xml")).resolve(deps).withTransitivity().asFile();

    war.addAsLibraries(dependencies);

    war.addClass(SmallRyeBeanArchiveHandler.class);
    war.addClass(MetricsHttpServlet.class);
    war.addClass(MetricsInitializer.class);
    war.addAsResource("io/smallrye/metrics/base-metrics.properties", "/io/smallrye/metrics/base-metrics.properties");
    war.addAsServiceProvider(BeanArchiveHandler.class, SmallRyeBeanArchiveHandler.class);
    war.addAsServiceProvider(Extension.class, ConfigExtension.class);
    war.addAsServiceProvider(ConfigProviderResolver.class, SmallRyeConfigProviderResolver.class);
}
 
Example #2
Source File: ConfigBuildSteps.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@BuildStep
void nativeServiceProviders(
        final BuildProducer<ServiceProviderBuildItem> providerProducer) throws IOException {
    providerProducer.produce(new ServiceProviderBuildItem(ConfigProviderResolver.class.getName(),
            SmallRyeConfigProviderResolver.class.getName()));
    final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    classLoader.getResources(SERVICES_PREFIX + ConfigSourceProvider.class.getName());
    for (Class<?> serviceClass : Arrays.asList(
            ConfigSource.class,
            ConfigSourceProvider.class,
            Converter.class)) {
        final String serviceName = serviceClass.getName();
        final Set<String> names = ServiceUtil.classNamesNamedIn(classLoader, SERVICES_PREFIX + serviceName);
        final List<String> list = names.stream()
                // todo: see https://github.com/quarkusio/quarkus/issues/5492
                .filter(s -> !s.startsWith("org.jboss.resteasy.microprofile.config.")).collect(Collectors.toList());
        if (!list.isEmpty()) {
            providerProducer.produce(new ServiceProviderBuildItem(serviceName, list));
        }
    }
}
 
Example #3
Source File: AmqpSourceTest.java    From smallrye-reactive-messaging with Apache License 2.0 6 votes vote down vote up
@After
public void cleanup() {
    if (provider != null) {
        provider.terminate(null);
    }

    if (container != null) {
        container.shutdown();
    }

    MapBasedConfig.clear();
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());

    System.clearProperty("mp-config");
    System.clearProperty("client-options-name");
    System.clearProperty("amqp-client-options-name");
}
 
Example #4
Source File: KafkaSourceTest.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void cleanup() {
    if (container != null) {
        container.close();
    }
    // Release the config objects
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
}
 
Example #5
Source File: SecureMqttTestBase.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() {
    System.clearProperty("mqtt-host");
    System.clearProperty("mqtt-port");
    System.clearProperty("mqtt-user");
    System.clearProperty("mqtt-pwd");
    vertx.closeAndAwait();
    usage.close();

    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig(this.getClass().getClassLoader()));
}
 
Example #6
Source File: JmsTestBase.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Before
public void initializeWeld() {
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
    if (withConnectionFactory()) {
        initWeldWithConnectionFactory();
    } else {
        initWithoutConnectionFactory();
    }
}
 
Example #7
Source File: MetadataPropagationTest.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void cleanup() {
    if (container != null) {
        container.close();
    }
    // Release the config objects
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
}
 
Example #8
Source File: DefaultConfigTest.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void cleanup() {
    if (container != null) {
        container.close();
    }
    // Release the config objects
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
}
 
Example #9
Source File: KafkaSinkTest.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void cleanup() {
    if (container != null) {
        container.close();
    }
    // Release the config objects
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
}
 
Example #10
Source File: NoKafkaTest.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() {
    if (container != null) {
        container.shutdown();
    }
    KafkaTestBase.stopKafkaBroker();
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
}
 
Example #11
Source File: MissingBackPressureTest.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void stop() {
    if (container != null) {
        container.shutdown();
    }
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
}
 
Example #12
Source File: HeaderPropagationTest.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void close() {
    jms.close();
    factory.close();
    // Release the config objects
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
}
 
Example #13
Source File: KafkaFailureHandlerTest.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void cleanup() {
    if (container != null) {
        container.close();
    }
    // Release the config objects
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
}
 
Example #14
Source File: KafkaNackPropagationTest.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void cleanup() {
    if (container != null) {
        container.close();
    }
    // Release the config objects
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
}
 
Example #15
Source File: ChannelNameConflictTest.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void cleanup() {
    if (container != null) {
        container.close();
    }
    // Release the config objects
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
}
 
Example #16
Source File: InjectionTestConfigFactory.java    From smallrye-config with Apache License 2.0 5 votes vote down vote up
@Override
public SmallRyeConfig getConfigFor(
        final SmallRyeConfigProviderResolver configProviderResolver, final ClassLoader classLoader) {
    return configProviderResolver.getBuilder().forClassLoader(classLoader)
            .addDefaultSources()
            .withSources(new PropertiesConfigSource(new HashMap<String, String>() {
                {
                    put("testkey", "testvalue");
                }
            }, "memory", 0))
            .addDefaultInterceptors()
            .build();
}
 
Example #17
Source File: InjectionTestConfigFactory.java    From smallrye-config with Apache License 2.0 5 votes vote down vote up
@Override
public SmallRyeConfig getConfigFor(
        final SmallRyeConfigProviderResolver configProviderResolver, final ClassLoader classLoader) {
    return configProviderResolver.getBuilder().forClassLoader(classLoader)
            .addDefaultSources()
            .addDefaultInterceptors()
            .withSources(KeyValuesConfigSource.config("my.prop", "1234", "expansion", "${my.prop}", "secret", "12345678"))
            .withSources(new ConfigSource() {
                int counter = 1;

                @Override
                public Map<String, String> getProperties() {
                    return new HashMap<>();
                }

                @Override
                public String getValue(final String propertyName) {
                    return "my.counter".equals(propertyName) ? "" + counter++ : null;
                }

                @Override
                public String getName() {
                    return this.getClass().getName();
                }
            })
            .withSources(KeyValuesConfigSource.config("optional.int.value", "1", "optional.long.value", "2",
                    "optional.double.value", "3.3"))
            .withSecretKeys("secret")
            .build();
}
 
Example #18
Source File: QuarkusConfigFactory.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public SmallRyeConfig getConfigFor(final SmallRyeConfigProviderResolver configProviderResolver,
        final ClassLoader classLoader) {
    if (config == null) {
        //TODO: this code path is only hit when start fails in dev mode very early in the process
        //the recovery code will fail without this as it cannot read any properties such as
        //the HTTP port or logging info
        return configProviderResolver.getBuilder().forClassLoader(classLoader)
                .addDefaultSources()
                .addDiscoveredSources()
                .addDiscoveredConverters()
                .build();
    }
    return config;
}
 
Example #19
Source File: MqttTestBase.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() {
    System.clearProperty("mqtt-host");
    System.clearProperty("mqtt-port");
    System.clearProperty("mqtt-user");
    System.clearProperty("mqtt-pwd");

    vertx.closeAndAwait();
    usage.close();

    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig(this.getClass().getClassLoader()));
}
 
Example #20
Source File: FailureHandlerTest.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void cleanup() {
    if (container != null) {
        container.close();
    }
    // Release the config objects
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
}
 
Example #21
Source File: HeaderPropagationAmqpToAppToAmqpTest.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void cleanup() {
    if (container != null) {
        container.close();
    }
    // Release the config objects
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
}
 
Example #22
Source File: AmqpSinkTest.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void cleanup() {
    if (provider != null) {
        provider.terminate(null);
    }

    if (container != null) {
        container.shutdown();
    }

    MapBasedConfig.clear();
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
}
 
Example #23
Source File: FailureHandlerTest.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void cleanup() {
    if (container != null) {
        container.close();
    }
    // Release the config objects
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
}
 
Example #24
Source File: ObjectExchangeTest.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void cleanup() {
    if (container != null) {
        container.close();
    }
    // Release the config objects
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
}
 
Example #25
Source File: AmqpTestBase.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() {
    System.clearProperty("amqp-host");
    System.clearProperty("amqp-port");

    usage.close();
    executionHolder.terminate(null);
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
    MapBasedConfig.clear();
}
 
Example #26
Source File: AmqpTestBase.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    executionHolder = new ExecutionHolder(Vertx.vertx());
    host = artemis.getContainerIpAddress();
    port = artemis.getMappedPort(5672);
    System.setProperty("amqp-host", host);
    System.setProperty("amqp-port", Integer.toString(port));
    System.setProperty("amqp-user", username);
    System.setProperty("amqp-pwd", password);
    usage = new AmqpUsage(executionHolder.vertx(), host, port);
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
    MapBasedConfig.clear();
}
 
Example #27
Source File: AmqpFailureHandlerTest.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void cleanup() {
    if (container != null) {
        container.close();
    }
    // Release the config objects
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
}
 
Example #28
Source File: HeaderPropagationAmqpToAmqpTest.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void cleanup() {
    if (container != null) {
        container.close();
    }
    // Release the config objects
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
}
 
Example #29
Source File: AmqpLinkTest.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@After
public void cleanup() {
    if (container != null) {
        container.shutdown();
    }

    MapBasedConfig.clear();
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
}
 
Example #30
Source File: HttpTestBase.java    From smallrye-reactive-messaging with Apache License 2.0 4 votes vote down vote up
@After
public void cleanUp() {
    weld.shutdown();
    SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig());
}