You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by pl...@apache.org on 2016/09/15 17:26:27 UTC
[10/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/TamayaConfigAdminImpl.java
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/TamayaConfigAdminImpl.java b/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/TamayaConfigAdminImpl.java
deleted file mode 100644
index 7bf4da7..0000000
--- a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/TamayaConfigAdminImpl.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.tamaya.integration.osgi;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceFactory;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.cm.ManagedService;
-import org.osgi.service.cm.ManagedServiceFactory;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * Tamaya based implementation of an OSGI {@link ConfigurationAdmin}.
- */
-public class TamayaConfigAdminImpl implements ConfigurationAdmin {
- /** the logger. */
- private static final Logger LOG = Logger.getLogger(TamayaConfigAdminImpl.class.getName());
-
- /** The OSGI context. */
- private final BundleContext context;
- /** THe optional OSGI parent service. */
- private ConfigurationAdmin parent;
- /** The cached configurations. */
- private Map<String,Configuration> configs = new ConcurrentHashMap<>();
- /** The configuration section mapper. */
- private OSGIConfigRootMapper configRootMapper;
-
- /**
- * Create a new config.
- * @param context the OSGI context
- */
- TamayaConfigAdminImpl(BundleContext context) {
- this.context = context;
- this.configRootMapper = loadConfigRootMapper();
- ServiceReference<ConfigurationAdmin> ref = context.getServiceReference(ConfigurationAdmin.class);
- this.parent = ref!=null?context.getService(ref):null;
- ServiceTracker<ManagedService, ManagedService> serviceTracker = new ServiceTracker<ManagedService,
- ManagedService>(context, ManagedService.class, null) {
- @Override
- public ManagedService addingService(ServiceReference<ManagedService> reference) {
- ManagedService service = context.getService(reference);
- Object pidObj = reference.getProperty(Constants.SERVICE_PID);
- if (pidObj instanceof String) {
- String pid = (String) pidObj;
- try {
- Configuration config = getConfiguration(pid);
- if(config==null){
- service.updated(null);
- } else{
- service.updated(config.getProperties());
- }
- } catch (Exception e) {
- LOG.log(Level.WARNING, "Error configuring ManagedService: " + service, e);
- }
- } else {
- LOG.log(Level.SEVERE, "Unsupported pid: " + pidObj);
- }
- return service;
- }
-
- @Override
- public void removedService(ServiceReference<ManagedService> reference, ManagedService service) {
- context.ungetService(reference);
- }
- };
- serviceTracker.open();
-
- ServiceTracker<ServiceFactory, ServiceFactory> factoryTracker
- = new ServiceTracker<ServiceFactory, ServiceFactory>(context, ServiceFactory.class, null) {
- @Override
- public ServiceFactory addingService(ServiceReference<ServiceFactory> reference) {
- ServiceFactory factory = context.getService(reference);
- if(factory instanceof ManagedServiceFactory) {
- Object pidObj = reference.getProperty(Constants.SERVICE_PID);
- if (pidObj instanceof String) {
- String pid = (String) pidObj;
- try {
- Configuration config = getConfiguration(pid);
- if (config != null) {
- ((ManagedServiceFactory) factory).updated(config.getFactoryPid(), config.getProperties());
- }
- } catch (Exception e) {
- LOG.log(Level.WARNING, "Error configuring ManagedServiceFactory: " + factory, e);
- }
- } else {
- LOG.log(Level.SEVERE, "Unsupported pid: " + pidObj);
- }
- }
- return factory;
- }
-
- @Override
- public void removedService(ServiceReference<ServiceFactory> reference, ServiceFactory service) {
- super.removedService(reference, service);
- }
- };
- factoryTracker.open();
- }
-
- @Override
- public Configuration createFactoryConfiguration(String factoryPid) throws IOException {
- return createFactoryConfiguration(factoryPid, null);
- }
-
- @Override
- public Configuration createFactoryConfiguration(String factoryPid, String location) throws IOException {
- return new TamayaConfigurationImpl(factoryPid, null, configRootMapper, this.parent);
- }
-
- @Override
- public Configuration getConfiguration(String pid, String location) throws IOException {
- return getConfiguration(pid);
- }
-
- @Override
- public Configuration getConfiguration(String pid) throws IOException {
- return new TamayaConfigurationImpl(pid, null, configRootMapper, this.parent);
- }
-
- @Override
- public Configuration[] listConfigurations(String filter) throws IOException, InvalidSyntaxException {
- Collection<Configuration> result;
- if (filter == null) {
- result = this.configs.values();
- } else {
- result = new ArrayList<>();
- Filter flt = context.createFilter(filter);
- for (Configuration config : this.configs.values()) {
- if (flt.match(config.getProperties())) {
- result.add(config);
- }
- }
- }
- return result.isEmpty() ? null : result.toArray(new Configuration[configs.size()]);
- }
-
- /**
- * Loads the configuration toor mapper using the OSGIConfigRootMapper OSGI service resolving mechanism. If no
- * such service is available it loads the default mapper.
- * @return the mapper to be used, bever null.
- */
- private OSGIConfigRootMapper loadConfigRootMapper() {
- OSGIConfigRootMapper mapper = null;
- ServiceReference<OSGIConfigRootMapper> ref = context.getServiceReference(OSGIConfigRootMapper.class);
- if(ref!=null){
- mapper = context.getService(ref);
- }
- if(mapper==null){
- mapper = new OSGIConfigRootMapper() {
- @Override
- public String getTamayaConfigRoot(String pid, String factoryPid) {
- if(pid!=null) {
- return "[bundle:" + pid +']';
- } else{
- return "[bundle:" + factoryPid +']';
- }
- }
- @Override
- public String toString(){
- return "Default OSGIConfigRootMapper(pid -> [bundle:pid], factoryPid -> [bundle:factoryPid]";
- }
- };
- }
- return mapper;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/TamayaConfigurationImpl.java
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/TamayaConfigurationImpl.java b/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/TamayaConfigurationImpl.java
deleted file mode 100644
index c7b0864..0000000
--- a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/TamayaConfigurationImpl.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.tamaya.integration.osgi;
-
-import java.io.IOException;
-import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.functions.PropertyMatcher;
-import org.apache.tamaya.functions.ConfigurationFunctions;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-
-/**
- * Tamaya based implementation of an OSGI {@link Configuration}.
- */
-public class TamayaConfigurationImpl implements Configuration {
- private static final Logger LOG = Logger.getLogger(TamayaConfigurationImpl.class.getName());
- private final String pid;
- private final String factoryPid;
- private Map<String, String> properties = new HashMap<>();
- private org.apache.tamaya.Configuration config;
-
- /**
- * Constructor.
- * @param confPid the OSGI pid
- * @param factoryPid the factory pid
- * @param configRootMapper the mapper that maps the pids to a tamaya root section.
- * @param parent the (optional delegating parent, used as default).
- */
- TamayaConfigurationImpl(String confPid, String factoryPid, OSGIConfigRootMapper configRootMapper,
- ConfigurationAdmin parent) {
- this.pid = confPid;
- this.factoryPid = factoryPid;
- if(parent!=null){
- try {
- Dictionary<String, Object> conf = parent.getConfiguration(confPid, factoryPid).getProperties();
- if(conf!=null) {
- LOG.info("Configuration: Adding default parameters from parent: " + parent.getClass().getName());
- Enumeration<String> keys = conf.keys();
- while (keys.hasMoreElements()) {
- String key = keys.nextElement();
- this.properties.put(key, conf.get(key).toString());
- }
- }
- } catch (IOException e) {
- LOG.log(Level.WARNING, "Error reading parent OSGI config.", e);
- }
- }
- this.config = ConfigurationProvider.getConfiguration();
- final String rootKey = configRootMapper.getTamayaConfigRoot(pid, factoryPid);
- LOG.info("Configuration: Evaluating Tamaya configuration for '" + rootKey + "'.");
- this.properties.putAll(
- config.with(ConfigurationFunctions.section(rootKey, true)).getProperties());
- }
-
- @Override
- public String getPid() {
- return pid;
- }
-
- @Override
- public Dictionary<String, Object> getProperties() {
- return new Hashtable<String, Object>(properties);
- }
-
- @Override
- public void update(Dictionary<String, ?> properties) throws IOException {
- throw new UnsupportedOperationException("Nuatability not yet supported.");
- // ConfigChangeProvider.createChangeRequest(this.config)
- }
-
- @Override
- public void delete() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getFactoryPid() {
- return factoryPid;
- }
-
- @Override
- public void update() throws IOException {
- this.config = ConfigurationProvider.getConfiguration();
- this.properties = config.with(ConfigurationFunctions.filter(new PropertyMatcher() {
- @Override
- public boolean test(String key, String value) {
-// TODO define name space / SPI
- return false;
- }
- })).getProperties();
- }
-
- @Override
- public void setBundleLocation(String location) {
- }
-
- @Override
- public String getBundleLocation() {
- return null;
- }
-
- @Override
- public long getChangeCount() {
- return 0;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/osgi/src/test/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/src/test/resources/META-INF/javaconfiguration.properties b/modules/integration/osgi/src/test/resources/META-INF/javaconfiguration.properties
deleted file mode 100644
index 0f09ce9..0000000
--- a/modules/integration/osgi/src/test/resources/META-INF/javaconfiguration.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you 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.
-#
-[bundle:tamaya]my.testProperty=success!
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/osgi/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/src/test/resources/arquillian.xml b/modules/integration/osgi/src/test/resources/arquillian.xml
deleted file mode 100644
index a4c885a..0000000
--- a/modules/integration/osgi/src/test/resources/arquillian.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you 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 current 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.
--->
-<arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
-
- <container qualifier="osgi" default="true">
- <configuration>
- <property name="frameworkProperties">src/test/resources/felix.properties</property>
- </configuration>
- </container>
-</arquillian>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/osgi/src/test/resources/felix.properties
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/src/test/resources/felix.properties b/modules/integration/osgi/src/test/resources/felix.properties
deleted file mode 100644
index de50401..0000000
--- a/modules/integration/osgi/src/test/resources/felix.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you 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.
-#
-# org.osgi.service.cm;org.apache.felix.cm;org.apache.tamaya;org.apache.tamaya.spi;
-org.osgi.framework.bootdelegation=org.apache.tamaya,org.apache.tamaya.integration.osgi,org.apache.tamaya.integration.osgi.test
-felix.log.level=4 #debug logging
-# felix.auto.deploy.dir=../test-bundles
-org.osgi.framework.storage=target/felix-cache
-felix.fileinstall.dir=./test-bundles
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/pom.xml
----------------------------------------------------------------------
diff --git a/modules/integration/pom.xml b/modules/integration/pom.xml
deleted file mode 100644
index df4775d..0000000
--- a/modules/integration/pom.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you 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 current 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- </parent>
-
- <packaging>pom</packaging>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>tamaya-integration</artifactId>
- <name>Apache Tamaya Integration - all</name>
-
- <modules>
- <module>spring</module>
- <module>cdi-se</module>
- <module>cdi</module>
- <module>osgi</module>
- <module>camel</module>
- <module>etcd</module>
- <module>consul</module>
- </modules>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/pom.xml
----------------------------------------------------------------------
diff --git a/modules/integration/spring/pom.xml b/modules/integration/spring/pom.xml
deleted file mode 100644
index ee1628c..0000000
--- a/modules/integration/spring/pom.xml
+++ /dev/null
@@ -1,116 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you 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 current 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-integration</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- </parent>
-
- <artifactId>tamaya-spring</artifactId>
- <name>Apache Tamaya Integration - Spring</name>
- <packaging>bundle</packaging>
-
- <properties>
- <spring.version>4.2.1.RELEASE</spring.version>
- <spring.boot.version>1.2.6.RELEASE</spring.boot.version>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>prepare-agent</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.integration.spring
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-injection</artifactId>
- <version>${project.version}</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <version>${spring.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>${spring.version}</version>
- <scope>provided</scope>
- </dependency>
- <!-- Test -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <version>${spring.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/SpringConfigInjectionPostProcessor.java
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/SpringConfigInjectionPostProcessor.java b/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/SpringConfigInjectionPostProcessor.java
deleted file mode 100644
index e25b230..0000000
--- a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/SpringConfigInjectionPostProcessor.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.tamaya.integration.spring;
-
-import org.apache.tamaya.inject.ConfigurationInjection;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.config.BeanPostProcessor;
-import org.springframework.stereotype.Component;
-
-/**
- * PostProcessor that performs injection of configured values using Tamaya {@link ConfigurationInjection}.
- */
-@Component
-public class SpringConfigInjectionPostProcessor implements BeanPostProcessor{
-
- @Override
- public Object postProcessBeforeInitialization(Object o, String s) throws BeansException {
- ConfigurationInjection.getConfigurationInjector().configure(o);
- return o;
- }
-
- @Override
- public Object postProcessAfterInitialization(Object o, String s) throws BeansException {
- return o;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaEnvironment.java
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaEnvironment.java b/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaEnvironment.java
deleted file mode 100644
index 7f1000e..0000000
--- a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaEnvironment.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.tamaya.integration.spring;
-
-import org.springframework.core.env.MutablePropertySources;
-import org.springframework.core.env.StandardEnvironment;
-
-/**
- * Tamaya specific environment for Spring.
- */
-public class TamayaEnvironment extends StandardEnvironment{
-
- protected void customizePropertySources(MutablePropertySources propertySources) {
- super.customizePropertySources(propertySources);
- propertySources.addLast(new TamayaSpringPropertySource());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaSpringConfig.java
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaSpringConfig.java b/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaSpringConfig.java
deleted file mode 100644
index cacab20..0000000
--- a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaSpringConfig.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.tamaya.integration.spring;
-
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
-import org.springframework.core.env.ConfigurableEnvironment;
-import org.springframework.core.env.MutablePropertySources;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.PostConstruct;
-
-/**
- * Spring Configuration Bean adding {@link TamayaSpringPropertySource} to the current
- * {@link org.springframework.core.env.Environment}.
- */
-@Component
-@Configuration
-public class TamayaSpringConfig {
-
- @Autowired
- private ConfigurableEnvironment env;
-
- @PostConstruct
- public void init() {
- env.getPropertySources().addFirst(new TamayaSpringPropertySource());
- }
-
- @Bean
- public static PropertySourcesPlaceholderConfigurer placeHolderConfigurer() {
- PropertySourcesPlaceholderConfigurer cfgBean = new PropertySourcesPlaceholderConfigurer();
- MutablePropertySources sources = new MutablePropertySources();
- sources.addFirst(new TamayaSpringPropertySource());
- cfgBean.setPropertySources(sources);
- return cfgBean;
- }
- }
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaSpringPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaSpringPropertySource.java b/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaSpringPropertySource.java
deleted file mode 100644
index 2e8ac1c..0000000
--- a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaSpringPropertySource.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.tamaya.integration.spring;
-
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.springframework.core.env.PropertySource;
-
-/**
- * Spring PropertySource bridging to Tamaya {@link org.apache.tamaya.Configuration}.
- */
-public class TamayaSpringPropertySource extends PropertySource<String> {
-
- public TamayaSpringPropertySource() {
- super("ApacheTamayaConfig");
- }
-
- @Override
- public String getProperty(String name) {
- return ConfigurationProvider.getConfiguration().get(name);
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/main/resources/spring-config.xml
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/main/resources/spring-config.xml b/modules/integration/spring/src/main/resources/spring-config.xml
deleted file mode 100644
index c1d6eda..0000000
--- a/modules/integration/spring/src/main/resources/spring-config.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you 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 current 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
- <context:annotation-config />
- <context:component-scan base-package="org.apache.tamaya.integration.spring"/>
-
- <!-- Our dependencies -->
- <bean id="tamayaInjectionProcessor" name="tamayaInjectionProcessor" class="org.apache.tamaya.integration.spring.SpringConfigInjectionPostProcessor"/>
- <bean id="tamayaConfigProvider" name="tamayaConfigProvider" class="org.apache.tamaya.integration.spring.TamayaSpringConfig"/>
-
-</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/ConfiguredSpringBean.java
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/ConfiguredSpringBean.java b/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/ConfiguredSpringBean.java
deleted file mode 100644
index c43dde0..0000000
--- a/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/ConfiguredSpringBean.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.tamaya.integration.spring;
-
-import org.apache.tamaya.inject.api.Config;
-import org.apache.tamaya.inject.api.ConfigDefaultSections;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.env.Environment;
-
-/**
- * Created by Anatole on 25.09.2015.
- */
-@ConfigDefaultSections
-public class ConfiguredSpringBean {
-
- private String message;
-
- @Autowired
- private Environment env;
-
- @Config("java.version")
- private String javaVersion;
-
- @Config(defaultValue = "23")
- private int testNumber;
-
- public String getJavaVersion(){
- return javaVersion;
- }
-
- public int getTestNumber(){
- return testNumber;
- }
-
- public Environment getEnv(){
- return env;
- }
-
- public void setMessage(String message){
- this.message = message;
- }
-
- public String getMessage() {
- return message;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/SpringConfigTest.java
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/SpringConfigTest.java b/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/SpringConfigTest.java
deleted file mode 100644
index 1f28816..0000000
--- a/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/SpringConfigTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.tamaya.integration.spring;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Created by Anatole on 25.09.2015.
- */
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration("classpath:spring-config.xml")
-public class SpringConfigTest {
-
- @Autowired
- private ConfiguredSpringBean configuredBean;
-
- @Test
- public void assertBeanNotNull(){
- assertNotNull(configuredBean);
- }
-
- @Test
- public void assert_JavaVersion_Injected(){
- assertNotNull(configuredBean.getJavaVersion());
- assertEquals(System.getProperty("java.version"), configuredBean.getJavaVersion());
- }
-
- @Test
- public void assert_Number_Injected(){
- assertEquals(configuredBean.getTestNumber(), 23);
- }
-
- @Test
- public void assert_Number_From_Environment(){
- assertEquals("value11", configuredBean.getEnv().getProperty("myConfiguredValue"));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/SpringConfigTest2.java
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/SpringConfigTest2.java b/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/SpringConfigTest2.java
deleted file mode 100644
index 6eab61d..0000000
--- a/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/SpringConfigTest2.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.tamaya.integration.spring;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Test using standard Spring setup.
- */
-public class SpringConfigTest2 {
-
- @Test
- public void assertDefaultSetup(){
- ApplicationContext context = new ClassPathXmlApplicationContext("classpath:spring-config-scanOnly.xml");
- ConfiguredSpringBean configuredBean = context.getBean(ConfiguredSpringBean.class);
- assertNotNull(configuredBean.getJavaVersion());
- assertEquals(System.getProperty("java.version"), configuredBean.getJavaVersion());
- assertNotNull(configuredBean.getMessage());
- assertEquals("value2", configuredBean.getMessage());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/test/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/test/resources/META-INF/javaconfiguration.properties b/modules/integration/spring/src/test/resources/META-INF/javaconfiguration.properties
deleted file mode 100644
index 3366128..0000000
--- a/modules/integration/spring/src/test/resources/META-INF/javaconfiguration.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you 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 current 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.
-#
-myConfiguredValue=value11
-propertyValue=value2
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/test/resources/spring-config-scanOnly.xml
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/test/resources/spring-config-scanOnly.xml b/modules/integration/spring/src/test/resources/spring-config-scanOnly.xml
deleted file mode 100644
index 6e98d80..0000000
--- a/modules/integration/spring/src/test/resources/spring-config-scanOnly.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you 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 current 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
- <context:annotation-config />
- <context:component-scan base-package="org.apache.tamaya.integration.spring"/>
-
- <!-- Our dependencies -->
- <!--<bean id="tamayaInjectionProcessor" name="tamayaInjectionProcessor" class="org.apache.tamaya.integration.spring.SpringConfigInjectionPostProcessor"/>-->
- <!--<bean id="tamayaConfigProvider" name="tamayaConfigProvider" class="org.apache.tamaya.integration.spring.TamayaSpringConfig"/>-->
- <bean id="configuredBean" name="configuredBean" class="org.apache.tamaya.integration.spring.ConfiguredSpringBean">
- <property name="message" value="${propertyValue}"/>
- </bean>
-
-</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/test/resources/spring-config.xml
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/test/resources/spring-config.xml b/modules/integration/spring/src/test/resources/spring-config.xml
deleted file mode 100644
index fc3f9d8..0000000
--- a/modules/integration/spring/src/test/resources/spring-config.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you 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 current 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
-
- <!-- Our dependencies -->
- <bean id="tamayaInjectionProcessor" name="tamayaInjectionProcessor" class="org.apache.tamaya.integration.spring.SpringConfigInjectionPostProcessor"/>
- <bean id="tamayaConfigProvider" name="tamayaConfigProvider" class="org.apache.tamaya.integration.spring.TamayaSpringConfig"/>
- <bean id="configuredBean" name="configuredBean" class="org.apache.tamaya.integration.spring.ConfiguredSpringBean"/>
-
-</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/pom.xml
----------------------------------------------------------------------
diff --git a/modules/json/pom.xml b/modules/json/pom.xml
deleted file mode 100644
index 49f4629..0000000
--- a/modules/json/pom.xml
+++ /dev/null
@@ -1,147 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>tamaya-json</artifactId>
- <name>Apache Tamaya Modules - JSON Support</name>
- <packaging>bundle</packaging>
- <inceptionYear>2015</inceptionYear>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-formats</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-json_1.0_spec</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.johnzon</groupId>
- <artifactId>johnzon-core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.daemon</groupId>
- <artifactId>arquillian-daemon-container-managed</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.daemon</groupId>
- <artifactId>arquillian-daemon-container-common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.daemon</groupId>
- <artifactId>arquillian-daemon-main</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.daemon</groupId>
- <artifactId>arquillian-daemon-protocol-arquillian</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.daemon</groupId>
- <artifactId>arquillian-daemon-protocol-wire</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.daemon</groupId>
- <artifactId>arquillian-daemon-server</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.junit</groupId>
- <artifactId>arquillian-junit-container</artifactId>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copyMain</id>
- <phase>process-test-sources</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <outputDirectory>${project.build.directory}</outputDirectory>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>false</overWriteSnapshots>
- <overWriteIfNewer>true</overWriteIfNewer>
- <stripVersion>true</stripVersion>
- <artifactItems>
- <artifactItem>
- <groupId>org.jboss.arquillian.daemon</groupId>
- <artifactId>arquillian-daemon-main</artifactId>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.json
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/main/java/org/apache/tamaya/json/JSONFormat.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/tamaya/json/JSONFormat.java b/modules/json/src/main/java/org/apache/tamaya/json/JSONFormat.java
deleted file mode 100644
index 8bdd414..0000000
--- a/modules/json/src/main/java/org/apache/tamaya/json/JSONFormat.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.tamaya.json;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.format.ConfigurationData;
-import org.apache.tamaya.format.ConfigurationDataBuilder;
-import org.apache.tamaya.format.ConfigurationFormat;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.nio.charset.Charset;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-import javax.json.Json;
-import javax.json.JsonException;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import javax.json.JsonReaderFactory;
-
-/**
- * Implementation of the {@link org.apache.tamaya.format.ConfigurationFormat}
- * able to read configuration properties represented in JSON
- *
- * @see <a href="http://www.json.org">JSON format specification</a>
- */
-public class JSONFormat implements ConfigurationFormat {
- /** Property that make Johnzon accept commentc. */
- public static final String JOHNZON_SUPPORTS_COMMENTS_PROP = "org.apache.johnzon.supports-comments";
- /** The reader factory used. */
- private final JsonReaderFactory readerFactory;
-
- /**
- * Constructor, itniaitlizing zhe JSON reader factory.
- */
- public JSONFormat(){
- Map<String, Object> config = new HashMap<>();
- config.put(JOHNZON_SUPPORTS_COMMENTS_PROP, true);
- this.readerFactory = Json.createReaderFactory(config);
- }
-
- @Override
- public String getName() {
- return "json";
- }
-
- @Override
- public boolean accepts(URL url) {
- return Objects.requireNonNull(url).getPath().endsWith(".json");
- }
-
- @Override
- public ConfigurationData readConfiguration(String resource, InputStream inputStream) {
-
- try {
- final JsonReader reader = this.readerFactory.createReader(inputStream, Charset.forName("UTF-8"));
- JsonObject root = reader.readObject();
- HashMap<String, String> values = new HashMap<>();
- JSONVisitor visitor = new JSONVisitor(root, values);
- visitor.run();
- return ConfigurationDataBuilder.of(resource, this).addProperties(values)
- .build();
- } catch (JsonException e) {
- throw new ConfigException("Failed to read data from " + resource, e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java b/modules/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java
deleted file mode 100644
index 43cfa73..0000000
--- a/modules/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.tamaya.json;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.nio.charset.Charset;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.json.Json;
-import javax.json.JsonObject;
-import javax.json.JsonReaderFactory;
-import javax.json.JsonStructure;
-
-import static java.lang.String.format;
-
-/**
- * Property source based on a JSON file.
- */
-public class JSONPropertySource implements PropertySource {
- /** Constant for enabling comments in Johnzon. */
- public static final String JOHNZON_SUPPORTS_COMMENTS_PROP = "org.apache.johnzon.supports-comments";
-
- /** The underlying resource. */
- private final URL urlResource;
- /** The values read. */
- private final Map<String, String> values;
- /** The evaluated ordinal. */
- private int ordinal;
- /** The JSON reader factory used. */
- private JsonReaderFactory readerFactory = initReaderFactory();
-
- /** Initializes the factory to be used for creating readers. */
- private JsonReaderFactory initReaderFactory() {
- Map<String, Object> config = new HashMap<>();
- config.put(JOHNZON_SUPPORTS_COMMENTS_PROP, true);
- return Json.createReaderFactory(config);
- }
-
- /**
- * Constructor, hereby using 0 as the default ordinal.
- * @param resource the resource modelled as URL, not null.
- */
- public JSONPropertySource(URL resource) {
- this(resource, 0);
- }
-
- /**
- * Constructor.
- * @param resource the resource modelled as URL, not null.
- * @param defaultOrdinal the defaultOrdinal to be used.
- */
- public JSONPropertySource(URL resource, int defaultOrdinal) {
- urlResource = Objects.requireNonNull(resource);
- this.ordinal = defaultOrdinal; // may be overriden by read...
- this.values = readConfig(urlResource);
- if (this.values.containsKey(TAMAYA_ORDINAL)) {
- this.ordinal = Integer.parseInt(this.values.get(TAMAYA_ORDINAL));
- }
- Map<String, Object> config = new HashMap<>();
- config.put(JOHNZON_SUPPORTS_COMMENTS_PROP, true);
- this.readerFactory = Json.createReaderFactory(config);
- }
-
-
- @Override
- public int getOrdinal() {
- PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL);
- if(configuredOrdinal!=null){
- try{
- return Integer.parseInt(configuredOrdinal.getValue());
- } catch(Exception e){
- Logger.getLogger(getClass().getName()).log(Level.WARNING,
- "Configured Ordinal is not an int number: " + configuredOrdinal, e);
- }
- }
- return ordinal;
- }
-
- @Override
- public String getName() {
- return urlResource.toExternalForm();
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, getProperties().get(key), getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return Collections.unmodifiableMap(values);
- }
-
- /**
- * Reads the configuration.
- * @param urlResource soure of the configuration.
- * @return the configuration read from the given resource URL.
- * @throws ConfigException if resource URL cannot be read.
- */
- protected Map<String, String> readConfig(URL urlResource) {
- try (InputStream is = urlResource.openStream()) {
- JsonStructure root = this.readerFactory.createReader(is, Charset.forName("UTF-8")).read();
-
- // Test added. H. Saly, 15. Aug. 2015
- if (!(root instanceof JsonObject)) {
- throw new ConfigException("Currently only JSON objects are supported");
- }
-
- Map<String, String> values = new HashMap<>();
- JSONVisitor visitor = new JSONVisitor((JsonObject)root, values);
- visitor.run();
- return values;
- }
- catch (Throwable t) {
- throw new ConfigException(format("Failed to read properties from %s", urlResource.toExternalForm()), t);
- }
- }
-
- @Override
- public boolean isScannable() {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/main/java/org/apache/tamaya/json/JSONVisitor.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/tamaya/json/JSONVisitor.java b/modules/json/src/main/java/org/apache/tamaya/json/JSONVisitor.java
deleted file mode 100644
index 2135ec5..0000000
--- a/modules/json/src/main/java/org/apache/tamaya/json/JSONVisitor.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.tamaya.json;
-
-import org.apache.tamaya.ConfigException;
-
-import java.util.*;
-
-import javax.json.JsonArray;
-import javax.json.JsonObject;
-import javax.json.JsonString;
-import javax.json.JsonStructure;
-import javax.json.JsonValue;
-
-/**
- * Visitor implementation to read a JSON formatted input source.
- */
-class JSONVisitor {
- private final JsonObject rootNode;
- private final Map<String, String> targetStore;
-
- JSONVisitor(JsonObject startNode, Map<String, String> target) {
- rootNode = startNode;
- targetStore = target;
- }
-
- public void run() {
- Deque<VisitingContext> stack = new ArrayDeque<>();
-
- stack.add(new VisitingContext(rootNode));
- boolean goOn = stack.peek().hasNext();
-
- if (goOn) {
- do {
- Map.Entry<String, JsonValue> current = stack.peek().nextElement();
-
- if (!(current.getValue() instanceof JsonStructure)) {
- String key = stack.peek().getNSPrefix() + current.getKey();
- String value;
- JsonValue jsonValue = current.getValue();
- switch(jsonValue.getValueType()) {
- case NULL: value = null; break;
- case FALSE: value = Boolean.FALSE.toString(); break;
- case TRUE: value = Boolean.TRUE.toString(); break;
- case NUMBER: value = jsonValue.toString(); break;
- case STRING: value = ((JsonString) jsonValue).getString(); break;
- default:
- throw new ConfigException("Internal failure while processing JSON document.");
- }
-
- targetStore.put(key, value);
- } else if (current.getValue() instanceof JsonObject) {
- String key = stack.peek().getNSPrefix() + current.getKey();
- JsonObject node = (JsonObject) current.getValue();
- stack.push(new VisitingContext(node, key));
- } else if (current.getValue() instanceof JsonArray) {
- throw new ConfigException("Arrays are not supported at the moment.");
- } else {
- throw new ConfigException("Internal failure while processing JSON document.");
- }
-
- goOn = stack.peek().hasNext();
-
- while (!goOn && stack.size() > 0) {
- stack.remove();
- goOn = (stack.size() > 0) && stack.peek().hasNext();
- }
- } while (goOn);
- }
- }
-
- /**
- * Context for a sub context visited.
- */
- private static class VisitingContext {
- private final String namespace;
- private final JsonObject node;
- private final Iterator<Map.Entry<String, JsonValue>> elements;
-
- public VisitingContext(JsonObject node) {
- this(node, "");
- }
-
- public VisitingContext(JsonObject rootNode, String currentNamespace) {
- namespace = currentNamespace;
- node = rootNode;
- elements = node.entrySet().iterator();
- }
-
- public Map.Entry<String, JsonValue> nextElement() {
- return elements.next();
- }
-
-
- public boolean hasNext() {
- return elements.hasNext();
- }
-
- public String getNSPrefix() {
- return namespace.isEmpty() ? namespace : namespace + ".";
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat
----------------------------------------------------------------------
diff --git a/modules/json/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat b/modules/json/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat
deleted file mode 100644
index a843cbe..0000000
--- a/modules/json/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you 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 current 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.
-#
-org.apache.tamaya.json.JSONFormat
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/test/java/org/apache/tamaya/json/CommonJSONTestCaseCollection.java
----------------------------------------------------------------------
diff --git a/modules/json/src/test/java/org/apache/tamaya/json/CommonJSONTestCaseCollection.java b/modules/json/src/test/java/org/apache/tamaya/json/CommonJSONTestCaseCollection.java
deleted file mode 100644
index 946878c..0000000
--- a/modules/json/src/test/java/org/apache/tamaya/json/CommonJSONTestCaseCollection.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.tamaya.json;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.hamcrest.CoreMatchers;
-import org.hamcrest.Matchers;
-import org.junit.Test;
-
-import java.net.URL;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.hasSize;
-
-/**
- * Class with a collection of common test cases each JSON processing
- * class must be able to pass.
- */
-public abstract class CommonJSONTestCaseCollection {
-
- abstract PropertySource getPropertiesFrom(URL source) throws Exception;
-
- @Test
- public void canReadNonLatinCharacters() throws Exception {
- URL configURL = JSONPropertySourceTest.class
- .getResource("/configs/valid/cyrillic.json");
-
- assertThat(configURL, Matchers.notNullValue());
-
- PropertySource propertySource = getPropertiesFrom(configURL);
-
- assertThat(propertySource.get("name"), Matchers.notNullValue());
- assertThat(propertySource.get("name").getValue(), equalTo("\u041e\u043b\u0438\u0432\u0435\u0440"));
- assertThat(propertySource.get("\u0444\u0430\u043c\u0438\u043b\u0438\u044f"), Matchers.notNullValue());
- assertThat(propertySource.get("\u0444\u0430\u043c\u0438\u043b\u0438\u044f").getValue(), Matchers.equalTo("Fischer"));
- }
-
- @Test
- public void canReadNestedStringOnlyJSONConfigFile() throws Exception {
- URL configURL = JSONPropertySourceTest.class
- .getResource("/configs/valid/simple-nested-string-only-config-1.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- PropertySource properties = getPropertiesFrom(configURL);
-
- assertThat(properties.getProperties().keySet(), hasSize(5));
-
- PropertyValue keyB = properties.get("b");
- PropertyValue keyDO = properties.get("d.o");
- PropertyValue keyDP = properties.get("d.p");
-
- assertThat(keyB, notNullValue());
- assertThat(keyB.getValue(), equalTo("B"));
- assertThat(keyDO, notNullValue());
- assertThat(keyDO.getValue(), equalTo("O"));
- assertThat(keyDP, Matchers.notNullValue());
- assertThat(keyDP.getValue(), is("P"));
- }
-
- @Test
- public void canReadNestedStringOnlyJSONConfigFileWithObjectInTheMiddle()
- throws Exception {
- URL configURL = JSONPropertySourceTest.class
- .getResource("/configs/valid/simple-nested-string-only-config-2.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- PropertySource properties = getPropertiesFrom(configURL);
-
- assertThat(properties.getProperties().keySet(), hasSize(4));
-
- PropertyValue keyA = properties.get("a");
- PropertyValue keyDO = properties.get("b.o");
- PropertyValue keyDP = properties.get("b.p");
- PropertyValue keyC = properties.get("c");
-
- assertThat(keyA, notNullValue());
- assertThat(keyA.getValue(), is("A"));
- assertThat(keyC, notNullValue());
- assertThat(keyC.getValue(), equalTo("C"));
- assertThat(keyDO, notNullValue());
- assertThat(keyDO.getValue(), equalTo("O"));
- assertThat(keyDP, notNullValue());
- assertThat(keyDP.getValue(), is("P"));
- }
-
- @Test(expected = ConfigException.class)
- public void canHandleIllegalJSONFileWhichContainsAnArray() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/with-array.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- getPropertiesFrom(configURL).getProperties();
- }
-
- @Test(expected = ConfigException.class)
- public void canHandleIllegalJSONFileConsistingOfOneOpeningBracket() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/only-opening-bracket.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- getPropertiesFrom(configURL).getProperties();
- }
-
- @Test(expected = ConfigException.class)
- public void canHandleIllegalJSONFileWhichIsEmpty() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/empty-file.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- getPropertiesFrom(configURL).getProperties();
- }
-
- @Test
- public void priorityInConfigFileOverwriteExplicitlyGivenPriority() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/valid/with-explicit-priority.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- PropertySource properties = getPropertiesFrom(configURL);
-
- assertThat(properties.getOrdinal(), is(16784));
- }
-
- @Test
- public void canReadFlatStringOnlyJSONConfigFile() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/valid/simple-flat-string-only-config.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- PropertySource properties = getPropertiesFrom(configURL);
-
- assertThat(properties.getProperties().keySet(), hasSize(3));
-
- PropertyValue keyA = properties.get("a");
- PropertyValue keyB = properties.get("b");
- PropertyValue keyC = properties.get("c");
-
- assertThat(keyA, notNullValue());
- assertThat(keyA.getValue(), equalTo("A"));
- assertThat(keyB, notNullValue());
- assertThat(keyB.getValue(), is("B"));
- assertThat(keyC, notNullValue());
- assertThat(keyC.getValue(), is("C"));
- }
-
- @Test(expected = ConfigException.class)
- public void emptyJSONFileResultsInConfigException() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/empty-file.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- PropertySource properties = getPropertiesFrom(configURL);
-
- properties.getProperties();
- }
-
- @Test
- public void canHandleEmptyJSONObject() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/valid/empty-object-config.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- PropertySource properties = getPropertiesFrom(configURL);
-
- assertThat(properties.getProperties().keySet(), hasSize(0));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatIT.java
----------------------------------------------------------------------
diff --git a/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatIT.java b/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatIT.java
deleted file mode 100644
index 851655e..0000000
--- a/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatIT.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.tamaya.json;
-
-import org.apache.tamaya.format.ConfigurationFormat;
-import org.apache.tamaya.spi.ServiceContextManager;
-import org.junit.Test;
-
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Integration tests for {@link JSONFormat}.
- */
-public class JSONFormatIT {
- @Test
- public void jsonFormatCanBeFoundViaServiceLoader() throws Exception {
- List<ConfigurationFormat> formats = ServiceContextManager.getServiceContext()
- .getServices(ConfigurationFormat.class);
-
- ConfigurationFormat format = null;
- for (ConfigurationFormat f : formats) {
- if (f instanceof JSONFormat) {
- format = f;
- break;
- }
- }
- assertThat(format, notNullValue());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatTest.java
----------------------------------------------------------------------
diff --git a/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatTest.java b/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatTest.java
deleted file mode 100644
index 9218046..0000000
--- a/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.tamaya.json;
-
-
-import org.apache.tamaya.format.ConfigurationData;
-import org.apache.tamaya.format.FlattenedDefaultPropertySource;
-import org.apache.tamaya.spi.PropertySource;
-import org.junit.Test;
-
-import java.io.InputStream;
-import java.net.URL;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-
-public class JSONFormatTest extends CommonJSONTestCaseCollection {
- private final JSONFormat format = new JSONFormat();
-
- @Test(expected = NullPointerException.class)
- public void acceptsNeedsNonNullParameter() throws Exception {
- format.accepts(null);
- }
-
- @Test
- public void aNonJSONFileBasedURLIsNotAccepted() throws Exception {
- URL url = new URL("file:///etc/service/conf.conf");
-
- assertThat(format.accepts(url), is(false));
- }
-
- @Test
- public void aJSONFileBasedURLIsAccepted() throws Exception {
- URL url = new URL("file:///etc/service/conf.json");
-
- assertThat(format.accepts(url), is(true));
- }
-
- @Test
- public void aHTTPBasedURLIsNotAccepted() throws Exception {
- URL url = new URL("http://nowhere.somewhere/conf.json");
- assertThat(format.accepts(url), is(true));
- }
-
- @Test
- public void aFTPBasedURLIsNotAccepted() throws Exception {
- URL url = new URL("ftp://nowhere.somewhere/a/b/c/d/conf.json");
-
- assertThat(format.accepts(url), is(true));
- }
-
- @Override
- PropertySource getPropertiesFrom(URL source) throws Exception {
- try (InputStream is = source.openStream()) {
- ConfigurationData data = format.readConfiguration(source.toString(), is);
- return new FlattenedDefaultPropertySource(data);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/test/java/org/apache/tamaya/json/JSONPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/json/src/test/java/org/apache/tamaya/json/JSONPropertySourceTest.java b/modules/json/src/test/java/org/apache/tamaya/json/JSONPropertySourceTest.java
deleted file mode 100644
index 9892446..0000000
--- a/modules/json/src/test/java/org/apache/tamaya/json/JSONPropertySourceTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.tamaya.json;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.spi.PropertySource;
-import org.hamcrest.CoreMatchers;
-import org.junit.Test;
-
-import java.net.URL;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-
-public class JSONPropertySourceTest extends CommonJSONTestCaseCollection {
-
- @Test
- public void tamayaOrdinalKeywordIsNotPropagatedAsNormalProperty() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/valid/with-explicit-priority.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- JSONPropertySource source = new JSONPropertySource(configURL, 4);
- assertEquals(source.get(PropertySource.TAMAYA_ORDINAL).getValue(), "16784");
- }
-
- @Test(expected=ConfigException.class)
- public void testDoNotAcceptJsonArrays() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/array.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- new JSONPropertySource(configURL);
- }
-
- @Override
- PropertySource getPropertiesFrom(URL source) throws Exception {
- return new JSONPropertySource(source);
- }
-}