You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2017/08/13 23:38:26 UTC
incubator-tamaya-sandbox git commit: TAMAYA-260: Fixed Boolean
conversion to comply with MP TCK.
Repository: incubator-tamaya-sandbox
Updated Branches:
refs/heads/java8 4a63a4a4f -> b2c69a1b7
TAMAYA-260: Fixed Boolean conversion to comply with MP TCK.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/commit/b2c69a1b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/b2c69a1b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/b2c69a1b
Branch: refs/heads/java8
Commit: b2c69a1b71b73e8c0546bf46e5e290a583b38381
Parents: 4a63a4a
Author: anatole <an...@apache.org>
Authored: Mon Aug 14 01:38:20 2017 +0200
Committer: anatole <an...@apache.org>
Committed: Mon Aug 14 01:38:20 2017 +0200
----------------------------------------------------------------------
microprofile/pom.xml | 5 +++++
.../tamaya/microprofile/MicroprofileConfig.java | 20 +++++++++++++++++++-
.../microprofile/cdi/BridgingConfigBean.java | 10 ----------
.../converter/BooleanAsIntegerConverterFix.java | 13 +++++++------
.../tck/TamayaConfigArchiveProcessor.java | 5 +++--
5 files changed, 34 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/b2c69a1b/microprofile/pom.xml
----------------------------------------------------------------------
diff --git a/microprofile/pom.xml b/microprofile/pom.xml
index ff893b8..37bbb2b 100644
--- a/microprofile/pom.xml
+++ b/microprofile/pom.xml
@@ -77,6 +77,11 @@ under the License.
<version>${tamaya-version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-events</artifactId>
+ <version>${tamaya-version}</version>
+ </dependency>
+ <dependency>
<groupId>org.eclipse.microprofile.config</groupId>
<artifactId>microprofile-config-api</artifactId>
<version>1.0</version>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/b2c69a1b/microprofile/src/main/java/org/apache/tamaya/microprofile/MicroprofileConfig.java
----------------------------------------------------------------------
diff --git a/microprofile/src/main/java/org/apache/tamaya/microprofile/MicroprofileConfig.java b/microprofile/src/main/java/org/apache/tamaya/microprofile/MicroprofileConfig.java
index 3dc4b34..61c3cdc 100644
--- a/microprofile/src/main/java/org/apache/tamaya/microprofile/MicroprofileConfig.java
+++ b/microprofile/src/main/java/org/apache/tamaya/microprofile/MicroprofileConfig.java
@@ -20,16 +20,21 @@ package org.apache.tamaya.microprofile;
import org.apache.tamaya.ConfigException;
import org.apache.tamaya.Configuration;
+import org.apache.tamaya.events.FrozenConfiguration;
import org.apache.tamaya.spi.PropertySource;
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.spi.ConfigSource;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
import java.util.*;
/**
* Microprofile {@link ConfigSource} implementation that wraps a {@link PropertySource} instance.
*/
-public class MicroprofileConfig implements Config {
+public class MicroprofileConfig implements Config, Serializable {
private Configuration delegate;
@@ -79,4 +84,17 @@ public class MicroprofileConfig implements Config {
"delegate=" + delegate +
'}';
}
+
+ private void writeObject(ObjectOutputStream out) throws IOException{
+ if(!(this.delegate instanceof Serializable)){
+ out.writeObject(FrozenConfiguration.of(this.delegate));
+ }else {
+ out.writeObject(this.delegate);
+ }
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException{
+ this.delegate = (Configuration)in.readObject();
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/b2c69a1b/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/BridgingConfigBean.java
----------------------------------------------------------------------
diff --git a/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/BridgingConfigBean.java b/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/BridgingConfigBean.java
index deb2496..a08f76f 100644
--- a/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/BridgingConfigBean.java
+++ b/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/BridgingConfigBean.java
@@ -85,16 +85,6 @@ final class BridgingConfigBean implements Bean<Object> {
@Override
public Object create(CreationalContext<Object> creationalContext) {
-// Set<InjectionPoint> injectionPoints = delegate.getInjectionPoints();
-// for(InjectionPoint injectionPoint:injectionPoints){
-// final ConfigProperty annotation = injectionPoint.getAnnotated().getAnnotation(ConfigProperty.class);
-// String key = annotation.name();
-// ConversionContext context =
-// MicroprofileConfigurationProducer.createConversionContext(key, injectionPoint);
-// Object result = MicroprofileConfigurationProducer.resolveValue(annotation.defaultValue(), context, injectionPoint);
-// creationalContext.push(result);
-// return result;
-// }
return this.delegate.create(creationalContext);
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/b2c69a1b/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/BooleanAsIntegerConverterFix.java
----------------------------------------------------------------------
diff --git a/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/BooleanAsIntegerConverterFix.java b/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/BooleanAsIntegerConverterFix.java
index debf6c7..1debc71 100644
--- a/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/BooleanAsIntegerConverterFix.java
+++ b/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/BooleanAsIntegerConverterFix.java
@@ -21,30 +21,31 @@ package org.apache.tamaya.microprofile.converter;
import org.apache.tamaya.spi.ConversionContext;
import org.apache.tamaya.spi.PropertyConverter;
+import javax.annotation.Priority;
import java.util.Locale;
import java.util.Objects;
import java.util.logging.Logger;
/**
- * Converter, converting from String to Boolean for zerpo = false, otherwise true.
+ * Converter, converting from String to Boolean for 1 = true, otherwise false.
*/
+@Priority(-1)
public class BooleanAsIntegerConverterFix implements PropertyConverter<Boolean> {
private final Logger LOG = Logger.getLogger(getClass().getName());
@Override
public Boolean convert(String value, ConversionContext context) {
- context.addSupportedFormats(getClass(), "int != 0 (true)", "0 (false)");
+ context.addSupportedFormats(getClass(), "'1' (true), otherwise false.");
try{
int val = Integer.parseInt(Objects.requireNonNull(value).trim());
- if(val!=0) {
+ if(val==1) {
return Boolean.TRUE;
- }else {
- return Boolean.FALSE;
}
+ return Boolean.FALSE;
}catch(Exception e){
// OK
- return null;
+ return Boolean.FALSE;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/b2c69a1b/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigArchiveProcessor.java
----------------------------------------------------------------------
diff --git a/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigArchiveProcessor.java b/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigArchiveProcessor.java
index 059f715..27c6013 100644
--- a/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigArchiveProcessor.java
+++ b/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigArchiveProcessor.java
@@ -21,6 +21,7 @@ package org.apache.tamaya.microprofile.tck;
import org.apache.tamaya.microprofile.MicroprofileAdapter;
import org.apache.tamaya.microprofile.MicroprofileConfigProviderResolver;
import org.apache.tamaya.microprofile.cdi.MicroprofileCDIExtension;
+import org.apache.tamaya.microprofile.converter.BooleanAsIntegerConverterFix;
import org.apache.tamaya.spi.PropertyConverter;
import org.eclipse.microprofile.config.spi.ConfigProviderResolver;
import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor;
@@ -61,10 +62,10 @@ public class TamayaConfigArchiveProcessor implements ApplicationArchiveProcessor
.create(JavaArchive.class, "tamaya-config-impl.jar")
.addPackage(MicroprofileAdapter.class.getPackage())
.addPackage(MicroprofileCDIExtension.class.getPackage())
-// .addPackage(ProviderConverter.class.getPackage())
+ .addPackage(BooleanAsIntegerConverterFix.class.getPackage())
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsServiceProvider(ConfigProviderResolver.class, MicroprofileConfigProviderResolver.class)
-// .addAsServiceProvider(PropertyConverter.class, ProviderConverter.class)
+ .addAsServiceProvider(PropertyConverter.class, BooleanAsIntegerConverterFix.class)
.addAsServiceProvider(Extension.class, MicroprofileCDIExtension.class);
((WebArchive) applicationArchive).addAsLibraries(
configJar)