diff --git a/cdi/pom.xml b/cdi/pom.xml new file mode 100644 index 000000000..8d99e9d1f --- /dev/null +++ b/cdi/pom.xml @@ -0,0 +1,116 @@ + + + + + + 4.0.0 + + + io.smallrye.config + smallrye-config-parent + 1.9.0-SNAPSHOT + + + smallrye-config + + SmallRye: MicroProfile Config CDI Implementation + + + + io.smallrye.config + smallrye-config-core + + + jakarta.enterprise + jakarta.enterprise.cdi-api + + + org.jboss.logging + jboss-logging + + + org.jboss.logging + jboss-logging-annotations + + + org.jboss.logging + jboss-logging-processor + + + + + org.junit.jupiter + junit-jupiter + + + org.jboss.weld + weld-junit5 + test + + + javax.enterprise + cdi-api + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + 1234 + + true + true + -Xmx512m + once + false + + + + + + + + coverage + + @{jacocoArgLine} + + + + + org.jacoco + jacoco-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + @{jacocoArgLine} -Xmx512m + + + + + + + + diff --git a/implementation/src/main/java/io/smallrye/config/inject/ConfigException.java b/cdi/src/main/java/io/smallrye/config/inject/ConfigException.java similarity index 99% rename from implementation/src/main/java/io/smallrye/config/inject/ConfigException.java rename to cdi/src/main/java/io/smallrye/config/inject/ConfigException.java index 10ab2b310..9f923d680 100644 --- a/implementation/src/main/java/io/smallrye/config/inject/ConfigException.java +++ b/cdi/src/main/java/io/smallrye/config/inject/ConfigException.java @@ -42,4 +42,4 @@ public String getConfigPropertyName() { return configPropertyName; } -} \ No newline at end of file +} diff --git a/implementation/src/main/java/io/smallrye/config/inject/ConfigExtension.java b/cdi/src/main/java/io/smallrye/config/inject/ConfigExtension.java similarity index 100% rename from implementation/src/main/java/io/smallrye/config/inject/ConfigExtension.java rename to cdi/src/main/java/io/smallrye/config/inject/ConfigExtension.java diff --git a/implementation/src/main/java/io/smallrye/config/inject/ConfigInjectionBean.java b/cdi/src/main/java/io/smallrye/config/inject/ConfigInjectionBean.java similarity index 100% rename from implementation/src/main/java/io/smallrye/config/inject/ConfigInjectionBean.java rename to cdi/src/main/java/io/smallrye/config/inject/ConfigInjectionBean.java diff --git a/implementation/src/main/java/io/smallrye/config/inject/ConfigProducer.java b/cdi/src/main/java/io/smallrye/config/inject/ConfigProducer.java similarity index 100% rename from implementation/src/main/java/io/smallrye/config/inject/ConfigProducer.java rename to cdi/src/main/java/io/smallrye/config/inject/ConfigProducer.java diff --git a/implementation/src/main/java/io/smallrye/config/inject/ConfigProducerUtil.java b/cdi/src/main/java/io/smallrye/config/inject/ConfigProducerUtil.java similarity index 100% rename from implementation/src/main/java/io/smallrye/config/inject/ConfigProducerUtil.java rename to cdi/src/main/java/io/smallrye/config/inject/ConfigProducerUtil.java diff --git a/implementation/src/main/java/io/smallrye/config/inject/InjectionMessages.java b/cdi/src/main/java/io/smallrye/config/inject/InjectionMessages.java similarity index 100% rename from implementation/src/main/java/io/smallrye/config/inject/InjectionMessages.java rename to cdi/src/main/java/io/smallrye/config/inject/InjectionMessages.java diff --git a/implementation/src/main/java/io/smallrye/config/inject/SecuritySupport.java b/cdi/src/main/java/io/smallrye/config/inject/SecuritySupport.java similarity index 100% rename from implementation/src/main/java/io/smallrye/config/inject/SecuritySupport.java rename to cdi/src/main/java/io/smallrye/config/inject/SecuritySupport.java diff --git a/implementation/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension b/cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension similarity index 100% rename from implementation/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension rename to cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension diff --git a/implementation/src/test/java/io/smallrye/config/inject/ConfigInjectionTest.java b/cdi/src/test/java/io/smallrye/config/inject/ConfigInjectionTest.java similarity index 100% rename from implementation/src/test/java/io/smallrye/config/inject/ConfigInjectionTest.java rename to cdi/src/test/java/io/smallrye/config/inject/ConfigInjectionTest.java diff --git a/implementation/src/test/java/io/smallrye/config/inject/InjectionTest.java b/cdi/src/test/java/io/smallrye/config/inject/InjectionTest.java similarity index 90% rename from implementation/src/test/java/io/smallrye/config/inject/InjectionTest.java rename to cdi/src/test/java/io/smallrye/config/inject/InjectionTest.java index 8c9b75138..9f5d10a1b 100644 --- a/implementation/src/test/java/io/smallrye/config/inject/InjectionTest.java +++ b/cdi/src/test/java/io/smallrye/config/inject/InjectionTest.java @@ -16,9 +16,7 @@ public abstract class InjectionTest { public static void beforeClass() throws Exception { final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); final URLClassLoader urlClassLoader = new URLClassLoader(new URL[] { - new URL("memory", null, 0, "/", - new InMemoryStreamHandler( - "io.smallrye.config.inject.InjectionTestConfigFactory")) + new URL("memory", null, 0, "/", new InMemoryStreamHandler(InjectionTestConfigFactory.class.getName())) }, contextClassLoader); Thread.currentThread().setContextClassLoader(urlClassLoader); } diff --git a/implementation/src/test/java/io/smallrye/config/inject/InjectionTestConfigFactory.java b/cdi/src/test/java/io/smallrye/config/inject/InjectionTestConfigFactory.java similarity index 97% rename from implementation/src/test/java/io/smallrye/config/inject/InjectionTestConfigFactory.java rename to cdi/src/test/java/io/smallrye/config/inject/InjectionTestConfigFactory.java index dbac8b7b2..e924b233d 100644 --- a/implementation/src/test/java/io/smallrye/config/inject/InjectionTestConfigFactory.java +++ b/cdi/src/test/java/io/smallrye/config/inject/InjectionTestConfigFactory.java @@ -5,7 +5,6 @@ import org.eclipse.microprofile.config.spi.ConfigSource; -import io.smallrye.config.KeyValuesConfigSource; import io.smallrye.config.SmallRyeConfig; import io.smallrye.config.SmallRyeConfigFactory; import io.smallrye.config.SmallRyeConfigProviderResolver; diff --git a/cdi/src/test/java/io/smallrye/config/inject/KeyValuesConfigSource.java b/cdi/src/test/java/io/smallrye/config/inject/KeyValuesConfigSource.java new file mode 100644 index 000000000..690780526 --- /dev/null +++ b/cdi/src/test/java/io/smallrye/config/inject/KeyValuesConfigSource.java @@ -0,0 +1,59 @@ +/* + * Copyright 2017 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.smallrye.config.inject; + +import java.io.Serializable; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.microprofile.config.spi.ConfigSource; + +public class KeyValuesConfigSource implements ConfigSource, Serializable { + + private final Map properties = new HashMap<>(); + + private KeyValuesConfigSource(Map properties) { + this.properties.putAll(properties); + } + + @Override + public Map getProperties() { + return Collections.unmodifiableMap(properties); + } + + @Override + public String getValue(String propertyName) { + return properties.get(propertyName); + } + + @Override + public String getName() { + return "KeyValuesConfigSource"; + } + + public static ConfigSource config(String... keyValues) { + if (keyValues.length % 2 != 0) { + throw new IllegalArgumentException("keyValues array must be a multiple of 2"); + } + + Map props = new HashMap<>(); + for (int i = 0; i < keyValues.length; i += 2) { + props.put(keyValues[i], keyValues[i + 1]); + } + return new KeyValuesConfigSource(props); + } +} diff --git a/implementation/src/test/java/io/smallrye/config/inject/OptionalInjectionTest.java b/cdi/src/test/java/io/smallrye/config/inject/OptionalInjectionTest.java similarity index 100% rename from implementation/src/test/java/io/smallrye/config/inject/OptionalInjectionTest.java rename to cdi/src/test/java/io/smallrye/config/inject/OptionalInjectionTest.java diff --git a/implementation/src/test/java/io/smallrye/config/inject/SupplierInjectionTest.java b/cdi/src/test/java/io/smallrye/config/inject/SupplierInjectionTest.java similarity index 100% rename from implementation/src/test/java/io/smallrye/config/inject/SupplierInjectionTest.java rename to cdi/src/test/java/io/smallrye/config/inject/SupplierInjectionTest.java diff --git a/implementation/pom.xml b/implementation/pom.xml index 154ddf3ce..6cc928122 100644 --- a/implementation/pom.xml +++ b/implementation/pom.xml @@ -25,9 +25,9 @@ 1.9.0-SNAPSHOT - smallrye-config + smallrye-config-core - SmallRye: MicroProfile Config Implementation + SmallRye: MicroProfile Config Core Implementation @@ -35,11 +35,6 @@ microprofile-config-api provided - - jakarta.enterprise - jakarta.enterprise.cdi-api - provided - jakarta.annotation jakarta.annotation-api @@ -79,17 +74,6 @@ org.junit.jupiter junit-jupiter - - org.jboss.weld - weld-junit5 - test - - - javax.enterprise - cdi-api - - - diff --git a/pom.xml b/pom.xml index 806a3cd3c..831bfb51e 100644 --- a/pom.xml +++ b/pom.xml @@ -67,6 +67,7 @@ common implementation + cdi sources/hocon sources/file-system sources/yaml @@ -139,6 +140,11 @@ smallrye-config-common ${project.version} + + io.smallrye.config + smallrye-config-core + ${project.version} + io.smallrye.config smallrye-config