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/06 17:45:20 UTC
[1/3] incubator-tamaya-sandbox git commit: Simplified the sandbox
structure.
Repository: incubator-tamaya-sandbox
Updated Branches:
refs/heads/master 194a48b27 -> 07b101310
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/src/main/java/org/apache/tamaya/dsl/MetaConfiguration.java
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/main/java/org/apache/tamaya/dsl/MetaConfiguration.java b/metamodels/staged/src/main/java/org/apache/tamaya/dsl/MetaConfiguration.java
deleted file mode 100644
index a16bfa8..0000000
--- a/metamodels/staged/src/main/java/org/apache/tamaya/dsl/MetaConfiguration.java
+++ /dev/null
@@ -1,144 +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.dsl;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.format.ConfigurationData;
-import org.apache.tamaya.format.ConfigurationFormat;
-import org.apache.tamaya.format.ConfigurationFormats;
-import org.apache.tamaya.json.YAMLFormat;
-import org.apache.tamaya.resource.ConfigResources;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
-import org.apache.tamaya.spisupport.DefaultConfiguration;
-import org.apache.tamaya.spisupport.MapPropertySource;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Meta environment configuration builder and accessor. Normally this class shoulds never be accessed
- * by client code. But it could be useful for extensions that extend the meta-configuration capabilities
- * of tamaya having access to the meta-configuration, so they can read their own meta-entries to
- * setup whatever features they implement.
- */
-public final class MetaConfiguration {
-
- private static final Logger LOGGER = Logger.getLogger(MetaConfiguration.class.getName());
- private static MetaConfiguration INSTANCE = new MetaConfiguration();
-
- private Configuration config;
- private String resourceExpression;
- private String[] formatNames;
-
- /**
- * Initializes the metaconfiguration.
- * @param resourceExpression the resource expression that defines the resources to load.
- * @param formatNames the format names to be used.
- */
- private void init(String resourceExpression, String... formatNames){
- if(this.config!=null){
- LOGGER.warning(">>> Reset of Meta-Configuration resource : " + resourceExpression);
- LOGGER.warning(">>> Reset of Meta-Configuration formats : " + Arrays.toString(formatNames));
- }
- if(resourceExpression==null){
- resourceExpression = "tamaya-config.*";
- }
- LOGGER.info(">>> Meta-Configuration resource : " + resourceExpression);
- ConfigurationFormat[] formats = loadFormats(formatNames);
- ConfigurationContextBuilder builder = ConfigurationProvider.getConfigurationContextBuilder();
- for(URL url:ConfigResources.getResourceResolver().getResources(resourceExpression)) {
- for(ConfigurationFormat format:formats) {
- if(format.accepts(url)){
- try(InputStream is = url.openStream()){
- ConfigurationData data = format.readConfiguration(url.toString(), is);
- builder.addPropertySources(new MapPropertySource(
- url.toString(), data.getCombinedProperties()));
- }catch(Exception e){
- LOGGER.log(Level.INFO, "Failed to read " + url + " with format " + format, e);
- }
- }
- }
- }
- this.config = new DefaultConfiguration(builder.build());
- LOGGER.info("Meta-Configuration read: " + this.config.getProperties().size() + " entries.");
- }
-
- private ConfigurationFormat[] loadFormats(String... formatNames) {
- List<ConfigurationFormat> formats = new ArrayList<>();
- if(formatNames.length==0) {
- String metaFormats = System.getProperty("tamaya.meta-formats");
- if (metaFormats != null) {
- formatNames = metaFormats.split(",");
- }
- }
- for (String formatName : formatNames) {
- formats.addAll(ConfigurationFormats.getFormats(formatName));
- }
- if(formats.isEmpty()){
- formats.addAll(ConfigurationFormats.getFormats("yaml"));
- }
- if(formats.isEmpty()){
- formats.add(new YAMLFormat());
- }
- LOGGER.info(">>> Meta-Configuration formats : " + formats);
- return formats.toArray(new ConfigurationFormat[formats.size()]);
- }
-
- /**
- * Access the system's meta-configuration, initialize if necessary. Normally this class shoulds never be accessed
- * by client code. But it could be useful for extensions that extend the meta-configuration capabilities
- * of tamaya having access to the meta-configuration, so they can read their own meta-entries to
- * setup whatever features they implement.
- * @return the meta-configuration instance used for setting up the Tamaya's application configuration
- * model.
- */
- public static Configuration getConfiguration(){
- if(INSTANCE.config==null) {
- INSTANCE.init(null);
- }
- return INSTANCE.config;
- }
-
- /**
- * Access the system's meta-configuration, initialize if necessary. Normally this class shoulds never be accessed
- * by client code. But it could be useful for extensions that extend the meta-configuration capabilities
- * of tamaya having access to the meta-configuration, so they can read their own meta-entries to
- * setup whatever features they implement.
- *
- * @param resourceExpression the resource expression that defines where the metaconfiguration
- * files/resources are located.
- * @param formatNames the formats supported, if null all formats found are tried for each resource(=URL).
- * @return the meta-configuration instance used for setting up the Tamaya's application configuration
- * model.
- */
- public static Configuration getConfiguration(String resourceExpression,
- String... formatNames){
- if(INSTANCE.config==null) {
- INSTANCE.init(resourceExpression, formatNames);
- }
- return INSTANCE.config;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/src/main/java/org/apache/tamaya/dsl/ProfileManager.java
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/main/java/org/apache/tamaya/dsl/ProfileManager.java b/metamodels/staged/src/main/java/org/apache/tamaya/dsl/ProfileManager.java
deleted file mode 100644
index 70211ca..0000000
--- a/metamodels/staged/src/main/java/org/apache/tamaya/dsl/ProfileManager.java
+++ /dev/null
@@ -1,213 +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.dsl;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.functions.ConfigurationFunctions;
-import org.apache.tamaya.resolver.Resolver;
-import org.apache.tamaya.resolver.spi.ExpressionResolver;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Component that manages the current setup profiles for this environment/runtime. The profile manager
- * reads the profile meta configuration that looks as follows:
- * <pre>
- * TAMAYA:
- * PROFILES-DEF:
- * - profiles: DEFAULTS,DEV,TEST,PTA,PROD
- * - defaults: DEFAULTS
- * - default-active: DEV
- * - evaluation: ${sys:ENV}, ${env:ENV}
- * </pre>
- * Hereby:
- * <ul>
- * <li><b>profiles</b> defines the available profiles, including implicit default profiles.</li>
- * <li><b>defaults</b> defines the profiles that are loaded implicitly first as defaults.</li>
- * <li><b>default-active</b> defines the profile(s) activated by default, when no profile setting could be evaluated.
- * <li><b>evaluation</b> defines the resolution expressions to be used to evaluate the current profiles active.
- * By default {@code ${sys:ENV}, ${env:ENV}} is used, which tries to evaluate {@code ENV} using system and
- * environment properties. Refere to the {@code tamaya-resolver} module for further details on resolvers and
- * expressions and see {@link Resolver#evaluateExpression(String, boolean)}.
- * </ul>
- */
-public final class ProfileManager {
-
- private static final Logger LOG = Logger.getLogger(ProfileManager.class.getName());
- private static final ProfileManager INSTANCE = new ProfileManager();
-
- /** The currently active profiles, in order of precedence, the most significant are the last ones. */
- private List<String> activeProfiles = new ArrayList<>();
- /** A set of all defined profiles. */
- private Set<String> profiles = new HashSet<>();
- /** The current used default profiles, loaded initially, before all other profiles are loaded. */
- private List<String> defaultProfiles = new ArrayList<>();
-
-
- /**
- * Get the current instance.
- * @return the current profile manager, never null.
- */
- public static ProfileManager getInstance(){
- return INSTANCE;
- }
-
- private ProfileManager(){
- Configuration metaConfig = MetaConfiguration.getConfiguration();
- Configuration profileConfig = metaConfig.with(
- ConfigurationFunctions.section("TAMAYA.PROFILES-DEF"));
- String[] selectables = profileConfig.getOrDefault("profiles","DEFAULT,DEV,TEST,PROD").split(",");
- for(String sel:selectables){
- sel = sel.trim();
- if(sel.isEmpty()){
- continue;
- }
- this.profiles.add(sel);
- }
- String[] defaults = profileConfig.getOrDefault("defaults","DEFAULT").split(",");
- for(String def:defaults){
- def = def.trim();
- if(def.isEmpty()){
- continue;
- }
- if(!isProfileDefined(def)){
- throw new ConfigException("Invalid profile encountered: " +def + ", valid are: " + profiles);
- }
- this.defaultProfiles.add(def);
- }
- String[] expressions = profileConfig.getOrDefault("evaluation","${sys:ENV}, ${env:ENV}").split(",");
- String currentEnvironment = null;
- for(String exp:expressions){
- exp = exp.trim();
- if(exp.isEmpty()){
- continue;
- }
- currentEnvironment = evaluateExpression(exp);
- if(currentEnvironment!=null){
- currentEnvironment = currentEnvironment.trim();
- if(!currentEnvironment.isEmpty()){
- break;
- }
- }
- }
- if(currentEnvironment==null|| currentEnvironment.isEmpty()){
- currentEnvironment = profileConfig.getOrDefault("default-active", "DEV");
- }
- this.activeProfiles.addAll(defaultProfiles);
- String[] profilesActive = currentEnvironment.split(",");
- for(String prof:profilesActive){
- prof = prof.trim();
- if(prof.isEmpty()){
- continue;
- }
- if(!isProfileDefined(prof)){
- throw new ConfigException("Invalid profile encountered: " +prof + ", valid are: " + profiles);
- }
- this.activeProfiles.add(prof);
- }
- }
-
- /**
- * Evaluates the expressions to evaluate the current profile.
- * Currently the following expressions are supported
- * <pre>
- * sys-property:xxx
- * env-property:xxx
- * </pre>
- * {@code xxx} is the corresponding key.
- * @param currentProfileExpression the profile expression.
- * @return the evaluated String, or null.
- */
- private String evaluateExpression(String currentProfileExpression){
- currentProfileExpression = currentProfileExpression.trim();
- List<ExpressionResolver> resolvers = new ArrayList<>();
- for(ExpressionResolver res: ServiceContextManager.getServiceContext().getServices(ExpressionResolver.class)){
- resolvers.add(res);
- }
- for(ExpressionResolver res:resolvers){
- if(currentProfileExpression.startsWith(res.getResolverPrefix())){
- try{
- return res.evaluate(currentProfileExpression.substring(res.getResolverPrefix().length()));
- }catch(Exception e){
- LOG.log(Level.FINEST, "Error evaluating resolver: " + res, e);
- }
- }
- }
- return null;
- }
-
- /**
- * Allows to check if a profile is currently active.
- * @param profileName the profile name, not null.
- * @return true, if the profile is active.
- */
- public boolean isProfileActive(String profileName){
- return this.activeProfiles.contains(profileName);
- }
-
- /**
- * Allows to check if a profile is currently defined.
- * @param profileName the profile name, not null.
- * @return true, if the profile is defined.
- */
- public boolean isProfileDefined(String profileName){
- return this.profiles.contains(profileName);
- }
-
- /**
- * Allows to check if a profile is a default profile.
- * @param profileName the profile name, not null.
- * @return true, if the profile is a default profile.
- */
- public boolean isProfileDefault(String profileName){
- return this.defaultProfiles.contains(profileName);
- }
-
- /**
- * Get the list of currently active profiles.
- * @return the list of currently active profiles, in order of precedence, the most significant
- * are the last ones, never null.
- */
- public List<String> getActiveProfiles(){
- return Collections.unmodifiableList(activeProfiles);
- }
-
- /**
- * Get the list of currently active profiles.
- * @return the list of currently active profiles, in order of precedence, the most significant
- * are the last ones, never null.
- */
- public List<String> getDefaultProfiles(){
- return Collections.unmodifiableList(defaultProfiles);
- }
-
- /**
- * Get the list of currently active profiles.
- * @return the list of currently active profiles, in order of precedence, the most significant
- * are the last ones, never null.
- */
- public Set<String> getAllProfiles(){
- return Collections.unmodifiableSet(profiles);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/src/main/java/org/apache/tamaya/dsl/TamayaConfigurator.java
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/main/java/org/apache/tamaya/dsl/TamayaConfigurator.java b/metamodels/staged/src/main/java/org/apache/tamaya/dsl/TamayaConfigurator.java
deleted file mode 100644
index c7c62b5..0000000
--- a/metamodels/staged/src/main/java/org/apache/tamaya/dsl/TamayaConfigurator.java
+++ /dev/null
@@ -1,234 +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.dsl;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.functions.ConfigurationFunctions;
-import org.apache.tamaya.spi.*;
-import org.apache.tamaya.staged.spi.DSLPropertySourceProvider;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Logger;
-
-/**
- * Configuration class setting up the Tamaya runtime model.
- */
-public final class TamayaConfigurator {
-
- private static final Logger LOGGER = Logger.getLogger(MetaConfiguration.class.getName());
- private static final Comparator<WrappedPropertySource> ORDINAL_COMPARATOR =
- new Comparator<WrappedPropertySource>(){
- @Override
- public int compare(WrappedPropertySource o1, WrappedPropertySource o2) {
- return o1.getOrdinal() - o2.getOrdinal();
- }
- };
-
- private static final TamayaConfigurator INSTANCE = new TamayaConfigurator();
-
- private ConfigurationContext configurationContext;
- private Set<String> formats = new HashSet<>();
- private Set<String> suffixes = new HashSet<>();
- private Map<String,DSLPropertySourceProvider> dslResolvers = new HashMap<>();
-
-
- private TamayaConfigurator(){
- configure(null);
- }
-
- /**
- * Get the singleton instance.
- * @return the instance, never null.
- */
- public static TamayaConfigurator getInstance(){
- return INSTANCE;
- }
-
- /**
- * Configures the Tamaya runtime using the metamodel configuration found at the default
- * location.
- * @see MetaConfiguration
- */
- public void configure(){
- configure(null);
- }
-
- /**
- * Configures the Tamaya runtime using the given resource location expression and (optionally)
- * formats to be used for evaluating the metamodel configuration.
- * @param resourceExpression resource expression for resolving the location of the
- * meta configuration.
- * @param formats the format names to be used, optional, but not null.
- * @see MetaConfiguration
- */
- public void configure(String resourceExpression, String... formats){
- loadDSLSourceResolvers();
- Configuration metaConfig = MetaConfiguration.getConfiguration(resourceExpression, formats);
- Configuration profilesConfig = metaConfig.with(
- ConfigurationFunctions.section("TAMAYA.PROFILES.", true));
- Configuration metaProfile = profilesConfig.with(
- ConfigurationFunctions.section("<COMMON>.", true));
- System.out.println(metaProfile.getProperties().keySet());
- String[] values = metaProfile.getOrDefault("formats","yaml, properties, xml-properties").split(",");
- for(String fmt:values){
- fmt = fmt.trim();
- if(fmt.isEmpty()){
- continue;
- }
- this.formats.add(fmt);
- }
- values = metaProfile.getOrDefault("suffixes", "yml, yaml, properties, xml").split(",");
- for(String sfx:values){
- sfx = sfx.trim();
- if(sfx.isEmpty()){
- continue;
- }
- this.suffixes.add(sfx);
- }
- ConfigurationContextBuilder builder = ConfigurationProvider.getConfigurationContextBuilder();
- Map<String, PropertySource> loadedPropertySources = loadDefaultPropertySources();
- int defaultOrdinal = loadSources(builder, "<COMMON>", metaProfile, loadedPropertySources, 0) + 20;
- // Load current profiles
- for(String profile:ProfileManager.getInstance().getActiveProfiles()){
- metaProfile = profilesConfig.with(
- ConfigurationFunctions.section(profile, true));
- defaultOrdinal = loadSources(builder, profile, metaProfile, loadedPropertySources, defaultOrdinal) + 20;
- }
- // formats: yaml, properties, xml-properties
- // - SUFFIX: yaml, yml, properties, xml
- // - sources:
- // - "named:env-properties" # provider name, or class name
- // - "named:main-args"
- // - "named:sys-properties"
- // - "resource:classpath:META-INF/config/**/*.SUFFIX"
-
- }
-
- /**
- * Loads all default registered property sources and providers.
- * @return the default property sources available on the system.
- */
- private Map<String, PropertySource> loadDefaultPropertySources() {
- Map<String, PropertySource> loadedPropertySources = new HashMap<>();
- for(PropertySource ps: ServiceContextManager.getServiceContext().getServices(PropertySource.class)){
- loadedPropertySources.put(ps.getName(), ps);
- }
- for(PropertySourceProvider prov: ServiceContextManager.getServiceContext().getServices(PropertySourceProvider.class)){
- for(PropertySource ps: prov.getPropertySources()){
- loadedPropertySources.put(ps.getName(), ps);
- }
- }
- return loadedPropertySources;
- }
-
- private int loadSources(ConfigurationContextBuilder builder, String profileId, Configuration metaProfile, Map<String,
- PropertySource> defaultPropertySources, int nextOrdinal) {
- String[] values;
- List<PropertySource> propertySourcesLoaded = new ArrayList<>();
- values = metaProfile.getOrDefault("sources","<default>").split(",");
- if(values.length==1 && "<default>".equals(values[0])){
- // load default property sources and providers from config as default.
- // additional providers may be added depending on the active profile...
- LOGGER.info("Using default configuration setup for "+profileId);
- nextOrdinal = addAndGetNextOrdinal(builder, defaultPropertySources.values(),
- propertySourcesLoaded, nextOrdinal);
- }else {
- LOGGER.info("Loading DSL based "+profileId+" configuration context...");
- int count = 0;
- for (String source : values) {
- source = source.trim();
- if (source.isEmpty()) {
- continue;
- }
- String sourceKey = getSourceKey(source);
- LOGGER.info("Loading "+profileId+" configuration source: " + source);
- // evaluate DSLSourceResolver and resolve PropertySources, register thm into context
- // apply newMaxOrdinal...
- DSLPropertySourceProvider resolver = dslResolvers.get(sourceKey);
- if(resolver==null){
- LOGGER.warning("DSL error: unresolvable source expression: "+ source);
- continue;
- }
- List<PropertySource> sources = resolver.resolve(source.substring(sourceKey.length()),
- defaultPropertySources);
- nextOrdinal = addAndGetNextOrdinal(builder, sources, propertySourcesLoaded, nextOrdinal);
- }
- LOGGER.info("Loaded "+count+" DSL based "+profileId+" configuration contexts.");
- }
- return nextOrdinal;
- }
-
- private int addAndGetNextOrdinal(ConfigurationContextBuilder builder, Collection<PropertySource> sourcesToAdd,
- List<PropertySource> allPropertySources, int nextOrdinal) {
- allPropertySources.addAll(wrapOrdinals(nextOrdinal, sourcesToAdd));
- nextOrdinal = Math.max(calculateHighestOrdinal(allPropertySources)+1, nextOrdinal+1);
- builder.addPropertySources(allPropertySources);
- return nextOrdinal;
- }
-
- private List<WrappedPropertySource> wrapOrdinals(int nextOrdinal, Collection<PropertySource> propertySources) {
- List<WrappedPropertySource> result = new ArrayList<>();
- for(PropertySource ps: propertySources){
- result.add(WrappedPropertySource.of(ps));
- }
- Collections.sort(result, ORDINAL_COMPARATOR);
- for(WrappedPropertySource ps: result){
- ps.setOrdinal(nextOrdinal++);
- }
- Collections.sort(result, ORDINAL_COMPARATOR);
- return result;
- }
-
- private int calculateHighestOrdinal(Collection<PropertySource> sources) {
- int maxOrdinal = 0;
- for (PropertySource ps : sources) {
- if (ps.getOrdinal() > maxOrdinal) {
- maxOrdinal = ps.getOrdinal();
- }
- }
- return maxOrdinal;
- }
-
- private String getSourceKey(String source) {
- int index = source.indexOf(':');
- if(index>0){
- return source.substring(0,index);
- }
- return source;
- }
-
- private void loadDSLSourceResolvers() {
- // Load the ConfigurationDSLSourceResolvers on the system
- for(DSLPropertySourceProvider res:
- ServiceContextManager.getServiceContext().getServices(
- DSLPropertySourceProvider.class)){
- this.dslResolvers.put(res.getKey(), res);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/src/main/java/org/apache/tamaya/dsl/WrappedPropertySource.java
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/main/java/org/apache/tamaya/dsl/WrappedPropertySource.java b/metamodels/staged/src/main/java/org/apache/tamaya/dsl/WrappedPropertySource.java
deleted file mode 100644
index 15e6089..0000000
--- a/metamodels/staged/src/main/java/org/apache/tamaya/dsl/WrappedPropertySource.java
+++ /dev/null
@@ -1,100 +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.dsl;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * Wrapped property source that allows dynamically reassigning the property source's
- * ordinal value. This is needed for reordering the property sources to
- * match the DSL configured ordering.
- */
-final class WrappedPropertySource implements PropertySource {
-
- private Integer ordinalAssigned;
- private PropertySource wrapped;
-
- private WrappedPropertySource(PropertySource wrapped){
- this.wrapped = Objects.requireNonNull(wrapped);
- }
-
- /**
- * Wraps a given property source.
- * @param propertySource the property source to be wrapped.
- * @return a wrapped property source.
- */
- public static WrappedPropertySource of(PropertySource propertySource){
- if(propertySource instanceof WrappedPropertySource){
- return (WrappedPropertySource)propertySource;
- }
- return new WrappedPropertySource(propertySource);
- }
-
- @Override
- public int getOrdinal() {
- return ordinalAssigned!=null?ordinalAssigned.intValue():wrapped.getOrdinal();
- }
-
- /**
- * Applies the given ordinal to the instance.
- * @param ordinal the new ordinal.
- */
- public void setOrdinal(int ordinal){
- this.ordinalAssigned = ordinal;
- }
-
- /**
- * Resetting the ordinal to the one of the wrapped property source.
- */
- public void resetOrdinal(){
- this.ordinalAssigned = null;
- }
-
- @Override
- public String getName() {
- return wrapped.getName();
- }
-
- @Override
- public PropertyValue get(String key) {
- return wrapped.get(key);
- }
-
- @Override
- public Map<String, String> getProperties() {
- return wrapped.getProperties();
- }
-
- @Override
- public boolean isScannable() {
- return wrapped.isScannable();
- }
-
- @Override
- public String toString() {
- return "WrappedPropertySource{" +
- "ordinalAssigned=" + ordinalAssigned +
- ", wrapped=" + wrapped +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/src/main/java/org/apache/tamaya/dsl/internal/DSLLoadingConfigurationProviderSpi.java
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/main/java/org/apache/tamaya/dsl/internal/DSLLoadingConfigurationProviderSpi.java b/metamodels/staged/src/main/java/org/apache/tamaya/dsl/internal/DSLLoadingConfigurationProviderSpi.java
deleted file mode 100644
index 8538609..0000000
--- a/metamodels/staged/src/main/java/org/apache/tamaya/dsl/internal/DSLLoadingConfigurationProviderSpi.java
+++ /dev/null
@@ -1,82 +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.dsl.internal;
-
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.dsl.TamayaConfigurator;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
-import org.apache.tamaya.spi.ConfigurationProviderSpi;
-import org.apache.tamaya.spi.ServiceContextManager;
-import org.apache.tamaya.spisupport.DefaultConfiguration;
-import org.apache.tamaya.spisupport.DefaultConfigurationContext;
-
-import javax.annotation.Priority;
-
-/**
- * ConfigurationContext that uses {@link TamayaConfigurator} to configure the
- * Tamaya runtime context.
- */
-@Priority(10)
-public class DSLLoadingConfigurationProviderSpi implements ConfigurationProviderSpi{
-
- private boolean configured;
-
- private ConfigurationContext context = new DefaultConfigurationContext();
- private Configuration config = new DefaultConfiguration(context);
-
-
- @Override
- public ConfigurationContextBuilder getConfigurationContextBuilder() {
- return ServiceContextManager.getServiceContext().getService(ConfigurationContextBuilder.class);
- }
-
- @Override
- public void setConfigurationContext(ConfigurationContext context){
- // TODO think on a SPI or move event part into API...
- this.config = new DefaultConfiguration(context);
- this.context = context;
- }
-
- @Override
- public boolean isConfigurationContextSettable() {
- return true;
- }
-
- @Override
- public Configuration getConfiguration() {
- checkInitialized();
- return config;
- }
-
- @Override
- public ConfigurationContext getConfigurationContext() {
- checkInitialized();
- return context;
- }
-
- private void checkInitialized() {
- if(!configured){
- synchronized (context) {
- TamayaConfigurator.getInstance().configure();
- configured = true;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/src/main/java/org/apache/tamaya/dsl/internal/NamedDSLPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/main/java/org/apache/tamaya/dsl/internal/NamedDSLPropertySourceProvider.java b/metamodels/staged/src/main/java/org/apache/tamaya/dsl/internal/NamedDSLPropertySourceProvider.java
deleted file mode 100644
index 0bc71da..0000000
--- a/metamodels/staged/src/main/java/org/apache/tamaya/dsl/internal/NamedDSLPropertySourceProvider.java
+++ /dev/null
@@ -1,53 +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.dsl.internal;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.staged.spi.DSLPropertySourceProvider;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Logger;
-
-/**
- * DSL provider implementation that allows to use registered {@link PropertySource} instances
- * by matching {@link PropertySource#getName()} with the configured value and overriding the
- * {@link PropertySource#getOrdinal()} method.
- */
-public class NamedDSLPropertySourceProvider implements DSLPropertySourceProvider{
-
- private static final Logger LOG = Logger.getLogger(NamedDSLPropertySourceProvider.class.getName());
-
- @Override
- public List<PropertySource> resolve(String sourceExpression, Map<String, PropertySource> defaultPropertySources) {
- List<PropertySource> result = new ArrayList<>();
- PropertySource ps = defaultPropertySources.get(sourceExpression);
- if(ps==null){
- LOG.warning("No such property source provider found: " + sourceExpression);
- }
- result.add(ps);
- return result;
- }
-
- @Override
- public String getKey() {
- return "named:";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/src/main/java/org/apache/tamaya/dsl/internal/ResourceDSLPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/main/java/org/apache/tamaya/dsl/internal/ResourceDSLPropertySourceProvider.java b/metamodels/staged/src/main/java/org/apache/tamaya/dsl/internal/ResourceDSLPropertySourceProvider.java
deleted file mode 100644
index 394562d..0000000
--- a/metamodels/staged/src/main/java/org/apache/tamaya/dsl/internal/ResourceDSLPropertySourceProvider.java
+++ /dev/null
@@ -1,82 +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.dsl.internal;
-
-import org.apache.tamaya.dsl.DSLFormatManager;
-import org.apache.tamaya.format.ConfigurationData;
-import org.apache.tamaya.format.ConfigurationFormat;
-import org.apache.tamaya.resource.ConfigResources;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spisupport.MapPropertySource;
-import org.apache.tamaya.staged.spi.DSLPropertySourceProvider;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * DSL provider implementation that allows to use registered {@link PropertySource} instances
- * by matching {@link PropertySource#getName()} with the configured value and overriding the
- * {@link PropertySource#getOrdinal()} method.
- */
-public class ResourceDSLPropertySourceProvider implements DSLPropertySourceProvider{
-
- private static final Logger LOG = Logger.getLogger(ResourceDSLPropertySourceProvider.class.getName());
-
- @Override
- public List<PropertySource> resolve(String sourceExpression, Map<String, PropertySource> defaultPropertySources) {
- List<PropertySource> result = new ArrayList<>();
- List<URL> resources = new ArrayList<>();
- if(sourceExpression.contains("SUFFIX")) {
- for (String suffix : DSLFormatManager.getInstance().getSuffixes()) {
- Collection<URL> locations = ConfigResources.getResourceResolver().getResources(getClass().getClassLoader(),
- sourceExpression.replace("SUFFIX", suffix));
- loadPropertySources(locations, result);
- }
- }else {
- Collection<URL> locations = ConfigResources.getResourceResolver().getResources(getClass().getClassLoader(),
- sourceExpression);
- loadPropertySources(locations, result);
- }
- return result;
- }
-
- private void loadPropertySources(Collection<URL> locations, List<PropertySource> result) {
- for(URL url:locations){
- for(ConfigurationFormat format: DSLFormatManager.getInstance().getFormats()) {
- try(InputStream is = url.openStream()){
- ConfigurationData data = format.readConfiguration(url.toString(),is);
- result.add(new MapPropertySource(url.toString(), data.getCombinedProperties()));
- }catch(Exception e){
- LOG.log(Level.FINEST, "Format failed: " + format.getName() + " for " + url, e);
- }
- }
- }
- }
-
- @Override
- public String getKey() {
- return "resource:";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/src/main/java/org/apache/tamaya/dsl/package-info.java
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/main/java/org/apache/tamaya/dsl/package-info.java b/metamodels/staged/src/main/java/org/apache/tamaya/dsl/package-info.java
deleted file mode 100644
index 0b89d0d..0000000
--- a/metamodels/staged/src/main/java/org/apache/tamaya/dsl/package-info.java
+++ /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.
- */
-/**
- * Main package of the DSL module. Normally client code does not need access this package.
- * But extensions also relying on the meta-data configuration mechanism may use it.
- */
-package org.apache.tamaya.dsl;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/BaseStagedPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/BaseStagedPropertySourceProvider.java b/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/BaseStagedPropertySourceProvider.java
deleted file mode 100644
index 04a7359..0000000
--- a/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/BaseStagedPropertySourceProvider.java
+++ /dev/null
@@ -1,121 +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.staged.spi;
-//
-//
-//import org.apache.tamaya.ConfigException;
-//import org.apache.tamaya.spi.PropertySource;
-//import org.apache.tamaya.spi.PropertySourceProvider;
-//
-//import java.util.ArrayList;
-//import java.util.Arrays;
-//import java.util.Collection;
-//import java.util.List;
-//import java.util.logging.Logger;
-//
-///**
-// * Implements a base property source provider that defines a multilayered
-// * stage setup.
-// */
-//public abstract class BaseStagedPropertySourceProvider implements PropertySourceProvider {
-//
-// /** The logger used. */
-// private static final Logger LOGGER = Logger.getLogger(BaseStagedPropertySourceProvider.class.getName());
-//
-// /** the current environment stages in order of precedence (weakest first). */
-// private List<String> contextIds = new ArrayList<>();
-//
-// /** Optional root context of the environment in the config tree. All entries loaded will be mapped into
-// * this root conztext.
-// */
-// private String rootContext;
-//
-// /** List of PropertySources evaluated and returned to the current ConfigurationContext on load. */
-// private List<PropertySource> propertySources = new ArrayList<>();
-//
-//
-// /**
-// * Creates a new Environment provider, hereby using 10 for basePriority and priorityIncrease.
-// * @param rootContext the environment target root context, e.g. ENV. or null
-// * for not remapping the environment properties.
-// * @param contextIds the context ids, that build up the environment.
-// */
-// public BaseStagedPropertySourceProvider(String rootContext,
-// String... contextIds) {
-// this(rootContext, 10,10, contextIds);
-// }
-// /**
-// * Creates a new Environment provider.
-// * @param rootContext the environment target root context, e.g. ENV. or null
-// * for not remapping the environment properties.
-// * @param basePriority the base priority used for the weakest environment properties set.
-// * @param priorityIncrease the value the property source's priority should be increased with each
-// * environment context level added.
-// * @param contextIds the context ids, that build up the environment.
-// */
-// public BaseStagedPropertySourceProvider(String rootContext, int basePriority, int priorityIncrease,
-// String... contextIds) {
-// if (contextIds.length == 0) {
-// throw new ConfigException("At least one environment context id must be defined.");
-// }
-// if (rootContext == null) {
-// LOGGER.finest("No environment mapping is applied.");
-// }
-// this.rootContext = rootContext;
-// this.contextIds.addAll(Arrays.asList(contextIds));
-// int priority = basePriority;
-// for (String contextId : contextIds) {
-// propertySources.addAll(loadStageProperties(rootContext, contextId, priority));
-// priority += priorityIncrease;
-// }
-// }
-//
-// /**
-// * Method that loads the environment properties for the given contextId.
-// * @param rootContext the root context, where entries read should be mapped to.
-// * @param contextId the contextId.
-// * @param priority the target priority the created PropertySource should have. This priority is
-// * important, since it reflects the order as defined
-// * when configuring this class. Therefore it should not be overridden normally.
-// * @return the corresponding PrioritySources to be added, never null.
-// */
-// protected abstract Collection<PropertySource> loadStageProperties(
-// String rootContext, String contextId, int priority);
-//
-// /**
-// * Get the environment context ids that define how this environment configuration
-// * is setup, in order of their increasing priority.
-// * @return the ordered list of context ids.
-// */
-// public List<String> getContextIds() {
-// return contextIds;
-// }
-//
-// @Override
-// public String toString() {
-// return "EnvironmentPropertySourceProvider{" +
-// "contextIds=" + contextIds +
-// ", rootContext='" + rootContext + '\'' +
-// '}';
-// }
-//
-// @Override
-// public Collection<PropertySource> getPropertySources() {
-// return propertySources;
-// }
-//
-//}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/DSLPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/DSLPropertySourceProvider.java b/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/DSLPropertySourceProvider.java
deleted file mode 100644
index 4482a5e..0000000
--- a/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/DSLPropertySourceProvider.java
+++ /dev/null
@@ -1,51 +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.staged.spi;
-
-import org.apache.tamaya.spi.PropertySource;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Resolver to resolve/map DSL related source expressions into PropertySources
- * loadable by a ConfigurationContext. Hereby the ordering of loaded property sources must be
- * honored if possible by implicitly adapting/Overriding the default ordinal for the sources
- * added.
- */
-public interface DSLPropertySourceProvider {
-
- /**
- * Resolve the given expression (without the key part).
- * @param sourceExpression the source expression, not null.
- * @param defaultPropertySources the default property sources that can be used as defined by the functionality by
- * a resolver.
- * @return the list of loaded Property sources, never null.
- */
- List<PropertySource> resolve(String sourceExpression,
- Map<String, PropertySource> defaultPropertySources);
-
- /**
- * Get the resolver key, which identifiesan expression to be resolved by a resolver instance.
- * As an example {@code "named:"} is the key for an expression {@code "named:sys-properties"}.
- * The method {@link #resolve(String, Map)} will onyl receive the secoind part of the expression.
- * @return identifying key.
- */
- String getKey();
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/StagedConfigPropertiesProvider.java
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/StagedConfigPropertiesProvider.java b/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/StagedConfigPropertiesProvider.java
deleted file mode 100644
index 722d0d0..0000000
--- a/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/StagedConfigPropertiesProvider.java
+++ /dev/null
@@ -1,137 +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.staged.spi;
-//
-//
-//import org.apache.tamaya.spisupport.MapPropertySource;
-//import org.apache.tamaya.spisupport.PropertiesResourcePropertySource;
-//import org.apache.tamaya.resource.ConfigResources;
-//import org.apache.tamaya.spi.PropertySource;
-//
-//import java.net.URL;
-//import java.util.ArrayList;
-//import java.util.Collection;
-//import java.util.List;
-//import java.util.logging.Logger;
-//
-///**
-// * Configuration provider that resolves to a location in the classpath.
-// * Hereby the following system properties can be set to configure the provider
-// * (all entries are optional):
-// * <pre>
-// * env.STAGE : ordered list of configs to be loaded, e.g. sys-env,GLOBAL,TEST,DEV
-// * </pre>
-// * Adding {@code sys-env} as stage maps the current environment properties using
-// * the priority to be aliged with the context ordering, defined by {@code env.STAGE}.
-// * Similarly the same thing can be done by passing {@code sys-props} as context id for
-// * adding the current System properties to the configuration tree.
-// *
-// * The rootContext can be used to remap the whole property space to an alternate subtree in
-// * the configuration tree overall. This is very handy, if multiple instances of this class
-// * are registered into the same configuration, but with different location setups. Remapping
-// * configuration allows to separate these entries clearly.<br/>
-// * Finally the resource location can be adapted by overriding {@link #getBaseResourcePath()}.
-// * Different formats and loading mechanisms can be implemented by overriding
-// * {@link #loadProperties(String, String, int, List)}.
-// */
-//public class StagedConfigPropertiesProvider extends BaseStagedPropertySourceProvider {
-//
-// /** The system property to define the stages used. */
-// private static final String STAGE_PROP = "env.STAGE";
-// /** The logger used. */
-//
-// private static final Logger LOGGER = Logger.getLogger(StagedConfigPropertiesProvider.class.getName());
-//
-// /** The context id for adding the system's environment properties. */
-// private static final String DEFAULT_ENV = "sys-env";
-//
-// /** The context id for adding the system's properties. */
-// private static final String DEFAULT_SYSPROPS = "sys-props";
-//
-// /**
-// * Creates a new instance.
-// * @param rootContext the (optional) root context, can be null.
-// * @param stages the comma separated list of stages.
-// */
-// public StagedConfigPropertiesProvider(String rootContext, String... stages){
-// super(rootContext, evaluateStages(stages));
-// }
-//
-// /**
-// * Creates a default instance. the stages are read from the {@code env.STAGE} system�propertx
-// * or a default is applied.
-// */
-// public StagedConfigPropertiesProvider(){
-// super(null, evaluateStages(null));
-// }
-//
-// /**
-// * Evaluates the stages or returns the default STAGE entry.
-// * @return the stages to be used, never null.
-// */
-// private static String[] evaluateStages(String[] stages) {
-// if(stages!=null && stages.length>0){
-// return stages.clone();
-// }
-// String value = System.getProperty(STAGE_PROP);
-// if(value==null) {
-// value = System.getenv(STAGE_PROP);
-// }
-// if(value==null){
-// value = "sys-env,GLOBAL,DEVELOPMENT,sys-props";
-// }
-// return value.split(",");
-// }
-//
-// @Override
-// protected Collection<PropertySource> loadStageProperties(
-// String rootContext, String contextId, int priority) {
-// List<PropertySource> result = new ArrayList<>();
-// if (DEFAULT_ENV.equals(contextId)){
-// result.add(new MapPropertySource(DEFAULT_ENV, System.getenv(),
-// rootContext, priority));
-// }else if (DEFAULT_SYSPROPS.equals(contextId)){
-// result.add(new MapPropertySource(DEFAULT_SYSPROPS, System.getProperties(),
-// rootContext, priority));
-// }
-// else{
-// loadProperties(rootContext, contextId, priority, result);
-// }
-// return result;
-// }
-//
-// private void loadProperties(String rootContext, String contextId, int priority,
-// List<PropertySource> result) {
-// String cpExp = getBaseResourcePath()+'/' +contextId+".properties";
-// if(cpExp.startsWith("/")){
-// cpExp = cpExp.substring(1);
-// }
-// for(URL url: ConfigResources.getResourceResolver().getResources(cpExp)){
-// result.add(new PropertiesResourcePropertySource(rootContext, url, priority));
-// }
-// }
-//
-// /**
-// * Get the basic resource path used for lookup of properties files.
-// * @return the basic resource path, never null.
-// */
-// protected String getBaseResourcePath() {
-// return "";
-// }
-//
-//
-//}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/package-info.java
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/package-info.java b/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/package-info.java
deleted file mode 100644
index 9037c2b..0000000
--- a/metamodels/staged/src/main/java/org/apache/tamaya/staged/spi/package-info.java
+++ /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.
- */
-/**
- * Main API of the environment module, containing the base class for implementing adapted
- * environment parts in your configuration.
- */
-package org.apache.tamaya.environment.spi;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationProviderSpi
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationProviderSpi b/metamodels/staged/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationProviderSpi
deleted file mode 100644
index 8ef0643..0000000
--- a/metamodels/staged/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationProviderSpi
+++ /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.dsl.internal.DSLLoadingConfigurationProviderSpi
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/src/main/resources/META-INF/services/org.apache.tamaya.staged.spi.DSLPropertySourceProvider
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/main/resources/META-INF/services/org.apache.tamaya.staged.spi.DSLPropertySourceProvider b/metamodels/staged/src/main/resources/META-INF/services/org.apache.tamaya.staged.spi.DSLPropertySourceProvider
deleted file mode 100644
index e80367e..0000000
--- a/metamodels/staged/src/main/resources/META-INF/services/org.apache.tamaya.staged.spi.DSLPropertySourceProvider
+++ /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.
-#
-org.apache.tamaya.dsl.internal.NamedDSLPropertySourceProvider
-org.apache.tamaya.dsl.internal.ResourceDSLPropertySourceProvider
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/src/test/java/org/apache/tamaya/dsl/ProfileManagerTest.java
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/test/java/org/apache/tamaya/dsl/ProfileManagerTest.java b/metamodels/staged/src/test/java/org/apache/tamaya/dsl/ProfileManagerTest.java
deleted file mode 100644
index 9692d47..0000000
--- a/metamodels/staged/src/test/java/org/apache/tamaya/dsl/ProfileManagerTest.java
+++ /dev/null
@@ -1,78 +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.dsl;
-
-import java.util.List;
-import java.util.Set;
-
-import static org.junit.Assert.*;
-
-/**
- * Created by atsticks on 05.05.16.
- */
-public class ProfileManagerTest {
-
- private ProfileManager profileManager = ProfileManager.getInstance();
-
- @org.junit.Test
- public void isProfileActive() throws Exception {
- assertTrue(profileManager.isProfileActive("DEV"));
- assertTrue(profileManager.isProfileActive("DEFAULT"));
- assertFalse(profileManager.isProfileActive("PROD"));
- }
-
- @org.junit.Test
- public void isProfileDefined() throws Exception {
- assertTrue(profileManager.isProfileDefined("DEV"));
- assertTrue(profileManager.isProfileDefined("DEFAULT"));
- assertFalse(profileManager.isProfileDefined("foo"));
- }
-
- @org.junit.Test
- public void isProfileDefault() throws Exception {
- assertFalse(profileManager.isProfileDefault("DEV"));
- assertTrue(profileManager.isProfileDefault("DEFAULT"));
- }
-
- @org.junit.Test
- public void getActiveProfiles() throws Exception {
- List<String> profiles = profileManager.getActiveProfiles();
- assertTrue(profiles.contains("DEV"));
- assertTrue(profiles.contains("DEFAULT"));
- assertFalse(profiles.contains("TEST"));
- assertFalse(profiles.contains("PROD"));
- }
-
- @org.junit.Test
- public void getDefaultProfiles() throws Exception {
- List<String> profiles = profileManager.getDefaultProfiles();
- assertTrue(profiles.contains("DEFAULT"));
- assertFalse(profiles.contains("TEST"));
- }
-
- @org.junit.Test
- public void getAllProfiles() throws Exception {
- Set<String> profiles = profileManager.getAllProfiles();
- assertTrue(profiles.contains("DEFAULT"));
- assertTrue(profiles.contains("DEV"));
- assertTrue(profiles.contains("TEST"));
- assertTrue(profiles.contains("PROD"));
- assertFalse(profiles.contains("foo"));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/src/test/resources/GLOBAL.properties
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/test/resources/GLOBAL.properties b/metamodels/staged/src/test/resources/GLOBAL.properties
deleted file mode 100644
index 9f39f75..0000000
--- a/metamodels/staged/src/test/resources/GLOBAL.properties
+++ /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.
-#
-aKey=aValue.GLOBAL
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/src/test/resources/TEST.properties
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/test/resources/TEST.properties b/metamodels/staged/src/test/resources/TEST.properties
deleted file mode 100644
index 2b31cb3..0000000
--- a/metamodels/staged/src/test/resources/TEST.properties
+++ /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.
-#
-aKey=aValue.TEST
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/src/test/resources/tamaya-TEST.yaml
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/test/resources/tamaya-TEST.yaml b/metamodels/staged/src/test/resources/tamaya-TEST.yaml
deleted file mode 100644
index 3e56656..0000000
--- a/metamodels/staged/src/test/resources/tamaya-TEST.yaml
+++ /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.
-#
-tamaya-configuration:
- includes:
- tamaya-DEFAULT.yaml
-
- property-sources:
- - class: org.apache.tamaya.resources.ResourceProvider
- resource: classpath:META-INF/config/test/**/*.*"
- - class: org.apache.tamaya.resources.ResourceProvider
- resource: classpath://META-INF/config/test/**/*.*"
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/src/test/resources/tamaya-config.yaml
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/test/resources/tamaya-config.yaml b/metamodels/staged/src/test/resources/tamaya-config.yaml
deleted file mode 100644
index a2980f6..0000000
--- a/metamodels/staged/src/test/resources/tamaya-config.yaml
+++ /dev/null
@@ -1,37 +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.
-#
-tamaya-config:
- source-selectors:
- - DEFAULT:
- source: tamaya-DEFAULT.yml
- labels: env=TEST env=PTA env=PROD
- - TEST:
- source: tamaya-TEST.yml
- labels: env=TEST
- - PTA:
- source: tamaya-PTA.yml
- labels: env=PTA
- - PROD:
- source: tamaya-PROD.yml
- labels: env=PROD
-
- default-labels: env=DEV
-
- expressions:
- - env: ${sys-property:ENV}, ${env-property:ENV}, "DEV"
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/store-file/src/main/java/org/apache/tamaya/store/internal/FileProprtyStoreProviderSpi.java
----------------------------------------------------------------------
diff --git a/store-file/src/main/java/org/apache/tamaya/store/internal/FileProprtyStoreProviderSpi.java b/store-file/src/main/java/org/apache/tamaya/store/internal/FileProprtyStoreProviderSpi.java
new file mode 100644
index 0000000..3ea768a
--- /dev/null
+++ b/store-file/src/main/java/org/apache/tamaya/store/internal/FileProprtyStoreProviderSpi.java
@@ -0,0 +1,85 @@
+/*
+ * 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.store.internal;
+
+import com.hazelcast.config.Config;
+import com.hazelcast.config.GroupConfig;
+import com.hazelcast.core.Hazelcast;
+import com.hazelcast.core.HazelcastInstance;
+import org.apache.tamaya.spi.ServiceContextManager;
+import org.apache.tamaya.store.PropertyStore;
+import org.apache.tamaya.store.spi.PropertyStoreProviderSpi;
+
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * SPI implmentation for a providing Hazelcast based PropertyStores.
+ */
+public class FileProprtyStoreProviderSpi implements PropertyStoreProviderSpi {
+ private static final String CONFIG_CLASS_SYS_PROP = "tamaya.store.file.configClass";
+ private static final String CONFIG_GROUP_SYS_PROP = "tamaya.store.file.groupName";
+
+ private static final Logger LOG = Logger.getLogger(HazelcastProprtyStoreProviderSpi.class.getName());
+
+ private File file;
+ private Map<String,HazelcastProprtyStore> stores = new ConcurrentHashMap<>();
+
+ public HazelcastProprtyStoreProviderSpi() {
+ String customConfig = System.getProperty(CONFIG_CLASS_SYS_PROP);
+ Config config = null;
+ if(customConfig!=null){
+ try {
+ config = (Config)Class.forName(customConfig).newInstance();
+ LOG.info("Successfully created custom store config for HazelCast store: " + customConfig);
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, "Failed to instantiate custom store config for HazelCast store: " + customConfig, e);
+ }
+ }
+ if(config==null){
+ config = ServiceContextManager.getServiceContext().getService(Config.class);
+ }
+ if(config==null) {
+ config = new Config();
+ GroupConfig gc = new GroupConfig();
+ String groupName = System.getProperty(CONFIG_GROUP_SYS_PROP, "Tamaya");
+ gc.setName(groupName);
+ config.setGroupConfig(gc);
+ }
+ LOG.info("Starting HazelCast storage with config: " + config);
+ store = Hazelcast.getOrCreateHazelcastInstance(config);
+ }
+
+ @Override
+ public PropertyStore getPropertyStore(String storeId) {
+ HazelcastProprtyStore propertyStore = stores.get(storeId);
+ if(propertyStore==null){
+ LOG.info("Creating new distributed configuration map in HazelCast store for " + storeId + "...");
+ propertyStore = new HazelcastProprtyStore(store, storeId);
+ this.stores.put(storeId, propertyStore);
+ }
+ return propertyStore;
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/store-file/src/main/resources/META-INF/services/org.apache.tamaya.store.spi.PropertyStoreProviderSpi
----------------------------------------------------------------------
diff --git a/store-file/src/main/resources/META-INF/services/org.apache.tamaya.store.spi.PropertyStoreProviderSpi b/store-file/src/main/resources/META-INF/services/org.apache.tamaya.store.spi.PropertyStoreProviderSpi
new file mode 100644
index 0000000..f3199f2
--- /dev/null
+++ b/store-file/src/main/resources/META-INF/services/org.apache.tamaya.store.spi.PropertyStoreProviderSpi
@@ -0,0 +1,18 @@
+#
+# 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.
+#
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/store-hazelcast/src/main/java/org/apache/tamaya/store/internal/HazelcastProprtyStoreProviderSpi.java
----------------------------------------------------------------------
diff --git a/store-hazelcast/src/main/java/org/apache/tamaya/store/internal/HazelcastProprtyStoreProviderSpi.java b/store-hazelcast/src/main/java/org/apache/tamaya/store/internal/HazelcastProprtyStoreProviderSpi.java
new file mode 100644
index 0000000..db567ac
--- /dev/null
+++ b/store-hazelcast/src/main/java/org/apache/tamaya/store/internal/HazelcastProprtyStoreProviderSpi.java
@@ -0,0 +1,87 @@
+/*
+ * 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.store.internal;
+
+import com.hazelcast.config.Config;
+import com.hazelcast.config.GroupConfig;
+import com.hazelcast.core.Hazelcast;
+import com.hazelcast.core.HazelcastInstance;
+import org.apache.tamaya.spi.ServiceContextManager;
+import org.apache.tamaya.store.PropertyStore;
+import org.apache.tamaya.store.spi.PropertyStoreProviderSpi;
+
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * SPI implmentation for a providing Hazelcast based PropertyStores.
+ */
+public class HazelcastProprtyStoreProviderSpi implements PropertyStoreProviderSpi {
+ private static final String CONFIG_CLASS_SYS_PROP = "tamaya.store.hazelcast.configClass";
+ private static final String CONFIG_GROUP_SYS_PROP = "tamaya.store.hazelcast.groupName";
+
+
+
+ private static final Logger LOG = Logger.getLogger(HazelcastProprtyStoreProviderSpi.class.getName());
+
+ private HazelcastInstance store;
+ private Map<String,HazelcastProprtyStore> stores = new ConcurrentHashMap<>();
+
+ public HazelcastProprtyStoreProviderSpi() {
+ String customConfig = System.getProperty(CONFIG_CLASS_SYS_PROP);
+ Config config = null;
+ if(customConfig!=null){
+ try {
+ config = (Config)Class.forName(customConfig).newInstance();
+ LOG.info("Successfully created custom store config for HazelCast store: " + customConfig);
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, "Failed to instantiate custom store config for HazelCast store: " + customConfig, e);
+ }
+ }
+ if(config==null){
+ config = ServiceContextManager.getServiceContext().getService(Config.class);
+ }
+ if(config==null) {
+ config = new Config();
+ GroupConfig gc = new GroupConfig();
+ String groupName = System.getProperty(CONFIG_GROUP_SYS_PROP, "Tamaya");
+ gc.setName(groupName);
+ config.setGroupConfig(gc);
+ }
+ LOG.info("Starting HazelCast storage with config: " + config);
+ store = Hazelcast.getOrCreateHazelcastInstance(config);
+ }
+
+ @Override
+ public PropertyStore getPropertyStore(String storeId) {
+ HazelcastProprtyStore propertyStore = stores.get(storeId);
+ if(propertyStore==null){
+ LOG.info("Creating new distributed configuration map in HazelCast store for " + storeId + "...");
+ propertyStore = new HazelcastProprtyStore(store, storeId);
+ this.stores.put(storeId, propertyStore);
+ }
+ return propertyStore;
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/store-ignite/src/main/resources/META-INF/services/org.apache.tamaya.store.PropertyStore
----------------------------------------------------------------------
diff --git a/store-ignite/src/main/resources/META-INF/services/org.apache.tamaya.store.PropertyStore b/store-ignite/src/main/resources/META-INF/services/org.apache.tamaya.store.PropertyStore
new file mode 100644
index 0000000..0833eac
--- /dev/null
+++ b/store-ignite/src/main/resources/META-INF/services/org.apache.tamaya.store.PropertyStore
@@ -0,0 +1,19 @@
+#
+# 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.store.internal.IgniteProprtyStore
\ No newline at end of file
[2/3] incubator-tamaya-sandbox git commit: Simplified the sandbox
structure.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/src/main/java/org/apache/tamaya/dsl/TamayaConfigurator.java
----------------------------------------------------------------------
diff --git a/metamodel-staged/src/main/java/org/apache/tamaya/dsl/TamayaConfigurator.java b/metamodel-staged/src/main/java/org/apache/tamaya/dsl/TamayaConfigurator.java
new file mode 100644
index 0000000..c7c62b5
--- /dev/null
+++ b/metamodel-staged/src/main/java/org/apache/tamaya/dsl/TamayaConfigurator.java
@@ -0,0 +1,234 @@
+/*
+ * 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.dsl;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.functions.ConfigurationFunctions;
+import org.apache.tamaya.spi.*;
+import org.apache.tamaya.staged.spi.DSLPropertySourceProvider;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+
+/**
+ * Configuration class setting up the Tamaya runtime model.
+ */
+public final class TamayaConfigurator {
+
+ private static final Logger LOGGER = Logger.getLogger(MetaConfiguration.class.getName());
+ private static final Comparator<WrappedPropertySource> ORDINAL_COMPARATOR =
+ new Comparator<WrappedPropertySource>(){
+ @Override
+ public int compare(WrappedPropertySource o1, WrappedPropertySource o2) {
+ return o1.getOrdinal() - o2.getOrdinal();
+ }
+ };
+
+ private static final TamayaConfigurator INSTANCE = new TamayaConfigurator();
+
+ private ConfigurationContext configurationContext;
+ private Set<String> formats = new HashSet<>();
+ private Set<String> suffixes = new HashSet<>();
+ private Map<String,DSLPropertySourceProvider> dslResolvers = new HashMap<>();
+
+
+ private TamayaConfigurator(){
+ configure(null);
+ }
+
+ /**
+ * Get the singleton instance.
+ * @return the instance, never null.
+ */
+ public static TamayaConfigurator getInstance(){
+ return INSTANCE;
+ }
+
+ /**
+ * Configures the Tamaya runtime using the metamodel configuration found at the default
+ * location.
+ * @see MetaConfiguration
+ */
+ public void configure(){
+ configure(null);
+ }
+
+ /**
+ * Configures the Tamaya runtime using the given resource location expression and (optionally)
+ * formats to be used for evaluating the metamodel configuration.
+ * @param resourceExpression resource expression for resolving the location of the
+ * meta configuration.
+ * @param formats the format names to be used, optional, but not null.
+ * @see MetaConfiguration
+ */
+ public void configure(String resourceExpression, String... formats){
+ loadDSLSourceResolvers();
+ Configuration metaConfig = MetaConfiguration.getConfiguration(resourceExpression, formats);
+ Configuration profilesConfig = metaConfig.with(
+ ConfigurationFunctions.section("TAMAYA.PROFILES.", true));
+ Configuration metaProfile = profilesConfig.with(
+ ConfigurationFunctions.section("<COMMON>.", true));
+ System.out.println(metaProfile.getProperties().keySet());
+ String[] values = metaProfile.getOrDefault("formats","yaml, properties, xml-properties").split(",");
+ for(String fmt:values){
+ fmt = fmt.trim();
+ if(fmt.isEmpty()){
+ continue;
+ }
+ this.formats.add(fmt);
+ }
+ values = metaProfile.getOrDefault("suffixes", "yml, yaml, properties, xml").split(",");
+ for(String sfx:values){
+ sfx = sfx.trim();
+ if(sfx.isEmpty()){
+ continue;
+ }
+ this.suffixes.add(sfx);
+ }
+ ConfigurationContextBuilder builder = ConfigurationProvider.getConfigurationContextBuilder();
+ Map<String, PropertySource> loadedPropertySources = loadDefaultPropertySources();
+ int defaultOrdinal = loadSources(builder, "<COMMON>", metaProfile, loadedPropertySources, 0) + 20;
+ // Load current profiles
+ for(String profile:ProfileManager.getInstance().getActiveProfiles()){
+ metaProfile = profilesConfig.with(
+ ConfigurationFunctions.section(profile, true));
+ defaultOrdinal = loadSources(builder, profile, metaProfile, loadedPropertySources, defaultOrdinal) + 20;
+ }
+ // formats: yaml, properties, xml-properties
+ // - SUFFIX: yaml, yml, properties, xml
+ // - sources:
+ // - "named:env-properties" # provider name, or class name
+ // - "named:main-args"
+ // - "named:sys-properties"
+ // - "resource:classpath:META-INF/config/**/*.SUFFIX"
+
+ }
+
+ /**
+ * Loads all default registered property sources and providers.
+ * @return the default property sources available on the system.
+ */
+ private Map<String, PropertySource> loadDefaultPropertySources() {
+ Map<String, PropertySource> loadedPropertySources = new HashMap<>();
+ for(PropertySource ps: ServiceContextManager.getServiceContext().getServices(PropertySource.class)){
+ loadedPropertySources.put(ps.getName(), ps);
+ }
+ for(PropertySourceProvider prov: ServiceContextManager.getServiceContext().getServices(PropertySourceProvider.class)){
+ for(PropertySource ps: prov.getPropertySources()){
+ loadedPropertySources.put(ps.getName(), ps);
+ }
+ }
+ return loadedPropertySources;
+ }
+
+ private int loadSources(ConfigurationContextBuilder builder, String profileId, Configuration metaProfile, Map<String,
+ PropertySource> defaultPropertySources, int nextOrdinal) {
+ String[] values;
+ List<PropertySource> propertySourcesLoaded = new ArrayList<>();
+ values = metaProfile.getOrDefault("sources","<default>").split(",");
+ if(values.length==1 && "<default>".equals(values[0])){
+ // load default property sources and providers from config as default.
+ // additional providers may be added depending on the active profile...
+ LOGGER.info("Using default configuration setup for "+profileId);
+ nextOrdinal = addAndGetNextOrdinal(builder, defaultPropertySources.values(),
+ propertySourcesLoaded, nextOrdinal);
+ }else {
+ LOGGER.info("Loading DSL based "+profileId+" configuration context...");
+ int count = 0;
+ for (String source : values) {
+ source = source.trim();
+ if (source.isEmpty()) {
+ continue;
+ }
+ String sourceKey = getSourceKey(source);
+ LOGGER.info("Loading "+profileId+" configuration source: " + source);
+ // evaluate DSLSourceResolver and resolve PropertySources, register thm into context
+ // apply newMaxOrdinal...
+ DSLPropertySourceProvider resolver = dslResolvers.get(sourceKey);
+ if(resolver==null){
+ LOGGER.warning("DSL error: unresolvable source expression: "+ source);
+ continue;
+ }
+ List<PropertySource> sources = resolver.resolve(source.substring(sourceKey.length()),
+ defaultPropertySources);
+ nextOrdinal = addAndGetNextOrdinal(builder, sources, propertySourcesLoaded, nextOrdinal);
+ }
+ LOGGER.info("Loaded "+count+" DSL based "+profileId+" configuration contexts.");
+ }
+ return nextOrdinal;
+ }
+
+ private int addAndGetNextOrdinal(ConfigurationContextBuilder builder, Collection<PropertySource> sourcesToAdd,
+ List<PropertySource> allPropertySources, int nextOrdinal) {
+ allPropertySources.addAll(wrapOrdinals(nextOrdinal, sourcesToAdd));
+ nextOrdinal = Math.max(calculateHighestOrdinal(allPropertySources)+1, nextOrdinal+1);
+ builder.addPropertySources(allPropertySources);
+ return nextOrdinal;
+ }
+
+ private List<WrappedPropertySource> wrapOrdinals(int nextOrdinal, Collection<PropertySource> propertySources) {
+ List<WrappedPropertySource> result = new ArrayList<>();
+ for(PropertySource ps: propertySources){
+ result.add(WrappedPropertySource.of(ps));
+ }
+ Collections.sort(result, ORDINAL_COMPARATOR);
+ for(WrappedPropertySource ps: result){
+ ps.setOrdinal(nextOrdinal++);
+ }
+ Collections.sort(result, ORDINAL_COMPARATOR);
+ return result;
+ }
+
+ private int calculateHighestOrdinal(Collection<PropertySource> sources) {
+ int maxOrdinal = 0;
+ for (PropertySource ps : sources) {
+ if (ps.getOrdinal() > maxOrdinal) {
+ maxOrdinal = ps.getOrdinal();
+ }
+ }
+ return maxOrdinal;
+ }
+
+ private String getSourceKey(String source) {
+ int index = source.indexOf(':');
+ if(index>0){
+ return source.substring(0,index);
+ }
+ return source;
+ }
+
+ private void loadDSLSourceResolvers() {
+ // Load the ConfigurationDSLSourceResolvers on the system
+ for(DSLPropertySourceProvider res:
+ ServiceContextManager.getServiceContext().getServices(
+ DSLPropertySourceProvider.class)){
+ this.dslResolvers.put(res.getKey(), res);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/src/main/java/org/apache/tamaya/dsl/WrappedPropertySource.java
----------------------------------------------------------------------
diff --git a/metamodel-staged/src/main/java/org/apache/tamaya/dsl/WrappedPropertySource.java b/metamodel-staged/src/main/java/org/apache/tamaya/dsl/WrappedPropertySource.java
new file mode 100644
index 0000000..15e6089
--- /dev/null
+++ b/metamodel-staged/src/main/java/org/apache/tamaya/dsl/WrappedPropertySource.java
@@ -0,0 +1,100 @@
+/*
+ * 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.dsl;
+
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Wrapped property source that allows dynamically reassigning the property source's
+ * ordinal value. This is needed for reordering the property sources to
+ * match the DSL configured ordering.
+ */
+final class WrappedPropertySource implements PropertySource {
+
+ private Integer ordinalAssigned;
+ private PropertySource wrapped;
+
+ private WrappedPropertySource(PropertySource wrapped){
+ this.wrapped = Objects.requireNonNull(wrapped);
+ }
+
+ /**
+ * Wraps a given property source.
+ * @param propertySource the property source to be wrapped.
+ * @return a wrapped property source.
+ */
+ public static WrappedPropertySource of(PropertySource propertySource){
+ if(propertySource instanceof WrappedPropertySource){
+ return (WrappedPropertySource)propertySource;
+ }
+ return new WrappedPropertySource(propertySource);
+ }
+
+ @Override
+ public int getOrdinal() {
+ return ordinalAssigned!=null?ordinalAssigned.intValue():wrapped.getOrdinal();
+ }
+
+ /**
+ * Applies the given ordinal to the instance.
+ * @param ordinal the new ordinal.
+ */
+ public void setOrdinal(int ordinal){
+ this.ordinalAssigned = ordinal;
+ }
+
+ /**
+ * Resetting the ordinal to the one of the wrapped property source.
+ */
+ public void resetOrdinal(){
+ this.ordinalAssigned = null;
+ }
+
+ @Override
+ public String getName() {
+ return wrapped.getName();
+ }
+
+ @Override
+ public PropertyValue get(String key) {
+ return wrapped.get(key);
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ return wrapped.getProperties();
+ }
+
+ @Override
+ public boolean isScannable() {
+ return wrapped.isScannable();
+ }
+
+ @Override
+ public String toString() {
+ return "WrappedPropertySource{" +
+ "ordinalAssigned=" + ordinalAssigned +
+ ", wrapped=" + wrapped +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/src/main/java/org/apache/tamaya/dsl/internal/DSLLoadingConfigurationProviderSpi.java
----------------------------------------------------------------------
diff --git a/metamodel-staged/src/main/java/org/apache/tamaya/dsl/internal/DSLLoadingConfigurationProviderSpi.java b/metamodel-staged/src/main/java/org/apache/tamaya/dsl/internal/DSLLoadingConfigurationProviderSpi.java
new file mode 100644
index 0000000..8538609
--- /dev/null
+++ b/metamodel-staged/src/main/java/org/apache/tamaya/dsl/internal/DSLLoadingConfigurationProviderSpi.java
@@ -0,0 +1,82 @@
+/*
+ * 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.dsl.internal;
+
+import org.apache.tamaya.spi.ConfigurationContext;
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.dsl.TamayaConfigurator;
+import org.apache.tamaya.spi.ConfigurationContextBuilder;
+import org.apache.tamaya.spi.ConfigurationProviderSpi;
+import org.apache.tamaya.spi.ServiceContextManager;
+import org.apache.tamaya.spisupport.DefaultConfiguration;
+import org.apache.tamaya.spisupport.DefaultConfigurationContext;
+
+import javax.annotation.Priority;
+
+/**
+ * ConfigurationContext that uses {@link TamayaConfigurator} to configure the
+ * Tamaya runtime context.
+ */
+@Priority(10)
+public class DSLLoadingConfigurationProviderSpi implements ConfigurationProviderSpi{
+
+ private boolean configured;
+
+ private ConfigurationContext context = new DefaultConfigurationContext();
+ private Configuration config = new DefaultConfiguration(context);
+
+
+ @Override
+ public ConfigurationContextBuilder getConfigurationContextBuilder() {
+ return ServiceContextManager.getServiceContext().getService(ConfigurationContextBuilder.class);
+ }
+
+ @Override
+ public void setConfigurationContext(ConfigurationContext context){
+ // TODO think on a SPI or move event part into API...
+ this.config = new DefaultConfiguration(context);
+ this.context = context;
+ }
+
+ @Override
+ public boolean isConfigurationContextSettable() {
+ return true;
+ }
+
+ @Override
+ public Configuration getConfiguration() {
+ checkInitialized();
+ return config;
+ }
+
+ @Override
+ public ConfigurationContext getConfigurationContext() {
+ checkInitialized();
+ return context;
+ }
+
+ private void checkInitialized() {
+ if(!configured){
+ synchronized (context) {
+ TamayaConfigurator.getInstance().configure();
+ configured = true;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/src/main/java/org/apache/tamaya/dsl/internal/NamedDSLPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/metamodel-staged/src/main/java/org/apache/tamaya/dsl/internal/NamedDSLPropertySourceProvider.java b/metamodel-staged/src/main/java/org/apache/tamaya/dsl/internal/NamedDSLPropertySourceProvider.java
new file mode 100644
index 0000000..0bc71da
--- /dev/null
+++ b/metamodel-staged/src/main/java/org/apache/tamaya/dsl/internal/NamedDSLPropertySourceProvider.java
@@ -0,0 +1,53 @@
+/*
+ * 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.dsl.internal;
+
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.staged.spi.DSLPropertySourceProvider;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+/**
+ * DSL provider implementation that allows to use registered {@link PropertySource} instances
+ * by matching {@link PropertySource#getName()} with the configured value and overriding the
+ * {@link PropertySource#getOrdinal()} method.
+ */
+public class NamedDSLPropertySourceProvider implements DSLPropertySourceProvider{
+
+ private static final Logger LOG = Logger.getLogger(NamedDSLPropertySourceProvider.class.getName());
+
+ @Override
+ public List<PropertySource> resolve(String sourceExpression, Map<String, PropertySource> defaultPropertySources) {
+ List<PropertySource> result = new ArrayList<>();
+ PropertySource ps = defaultPropertySources.get(sourceExpression);
+ if(ps==null){
+ LOG.warning("No such property source provider found: " + sourceExpression);
+ }
+ result.add(ps);
+ return result;
+ }
+
+ @Override
+ public String getKey() {
+ return "named:";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/src/main/java/org/apache/tamaya/dsl/internal/ResourceDSLPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/metamodel-staged/src/main/java/org/apache/tamaya/dsl/internal/ResourceDSLPropertySourceProvider.java b/metamodel-staged/src/main/java/org/apache/tamaya/dsl/internal/ResourceDSLPropertySourceProvider.java
new file mode 100644
index 0000000..394562d
--- /dev/null
+++ b/metamodel-staged/src/main/java/org/apache/tamaya/dsl/internal/ResourceDSLPropertySourceProvider.java
@@ -0,0 +1,82 @@
+/*
+ * 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.dsl.internal;
+
+import org.apache.tamaya.dsl.DSLFormatManager;
+import org.apache.tamaya.format.ConfigurationData;
+import org.apache.tamaya.format.ConfigurationFormat;
+import org.apache.tamaya.resource.ConfigResources;
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spisupport.MapPropertySource;
+import org.apache.tamaya.staged.spi.DSLPropertySourceProvider;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * DSL provider implementation that allows to use registered {@link PropertySource} instances
+ * by matching {@link PropertySource#getName()} with the configured value and overriding the
+ * {@link PropertySource#getOrdinal()} method.
+ */
+public class ResourceDSLPropertySourceProvider implements DSLPropertySourceProvider{
+
+ private static final Logger LOG = Logger.getLogger(ResourceDSLPropertySourceProvider.class.getName());
+
+ @Override
+ public List<PropertySource> resolve(String sourceExpression, Map<String, PropertySource> defaultPropertySources) {
+ List<PropertySource> result = new ArrayList<>();
+ List<URL> resources = new ArrayList<>();
+ if(sourceExpression.contains("SUFFIX")) {
+ for (String suffix : DSLFormatManager.getInstance().getSuffixes()) {
+ Collection<URL> locations = ConfigResources.getResourceResolver().getResources(getClass().getClassLoader(),
+ sourceExpression.replace("SUFFIX", suffix));
+ loadPropertySources(locations, result);
+ }
+ }else {
+ Collection<URL> locations = ConfigResources.getResourceResolver().getResources(getClass().getClassLoader(),
+ sourceExpression);
+ loadPropertySources(locations, result);
+ }
+ return result;
+ }
+
+ private void loadPropertySources(Collection<URL> locations, List<PropertySource> result) {
+ for(URL url:locations){
+ for(ConfigurationFormat format: DSLFormatManager.getInstance().getFormats()) {
+ try(InputStream is = url.openStream()){
+ ConfigurationData data = format.readConfiguration(url.toString(),is);
+ result.add(new MapPropertySource(url.toString(), data.getCombinedProperties()));
+ }catch(Exception e){
+ LOG.log(Level.FINEST, "Format failed: " + format.getName() + " for " + url, e);
+ }
+ }
+ }
+ }
+
+ @Override
+ public String getKey() {
+ return "resource:";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/src/main/java/org/apache/tamaya/dsl/package-info.java
----------------------------------------------------------------------
diff --git a/metamodel-staged/src/main/java/org/apache/tamaya/dsl/package-info.java b/metamodel-staged/src/main/java/org/apache/tamaya/dsl/package-info.java
new file mode 100644
index 0000000..0b89d0d
--- /dev/null
+++ b/metamodel-staged/src/main/java/org/apache/tamaya/dsl/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+/**
+ * Main package of the DSL module. Normally client code does not need access this package.
+ * But extensions also relying on the meta-data configuration mechanism may use it.
+ */
+package org.apache.tamaya.dsl;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/src/main/java/org/apache/tamaya/staged/spi/BaseStagedPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/metamodel-staged/src/main/java/org/apache/tamaya/staged/spi/BaseStagedPropertySourceProvider.java b/metamodel-staged/src/main/java/org/apache/tamaya/staged/spi/BaseStagedPropertySourceProvider.java
new file mode 100644
index 0000000..04a7359
--- /dev/null
+++ b/metamodel-staged/src/main/java/org/apache/tamaya/staged/spi/BaseStagedPropertySourceProvider.java
@@ -0,0 +1,121 @@
+///*
+// * 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.staged.spi;
+//
+//
+//import org.apache.tamaya.ConfigException;
+//import org.apache.tamaya.spi.PropertySource;
+//import org.apache.tamaya.spi.PropertySourceProvider;
+//
+//import java.util.ArrayList;
+//import java.util.Arrays;
+//import java.util.Collection;
+//import java.util.List;
+//import java.util.logging.Logger;
+//
+///**
+// * Implements a base property source provider that defines a multilayered
+// * stage setup.
+// */
+//public abstract class BaseStagedPropertySourceProvider implements PropertySourceProvider {
+//
+// /** The logger used. */
+// private static final Logger LOGGER = Logger.getLogger(BaseStagedPropertySourceProvider.class.getName());
+//
+// /** the current environment stages in order of precedence (weakest first). */
+// private List<String> contextIds = new ArrayList<>();
+//
+// /** Optional root context of the environment in the config tree. All entries loaded will be mapped into
+// * this root conztext.
+// */
+// private String rootContext;
+//
+// /** List of PropertySources evaluated and returned to the current ConfigurationContext on load. */
+// private List<PropertySource> propertySources = new ArrayList<>();
+//
+//
+// /**
+// * Creates a new Environment provider, hereby using 10 for basePriority and priorityIncrease.
+// * @param rootContext the environment target root context, e.g. ENV. or null
+// * for not remapping the environment properties.
+// * @param contextIds the context ids, that build up the environment.
+// */
+// public BaseStagedPropertySourceProvider(String rootContext,
+// String... contextIds) {
+// this(rootContext, 10,10, contextIds);
+// }
+// /**
+// * Creates a new Environment provider.
+// * @param rootContext the environment target root context, e.g. ENV. or null
+// * for not remapping the environment properties.
+// * @param basePriority the base priority used for the weakest environment properties set.
+// * @param priorityIncrease the value the property source's priority should be increased with each
+// * environment context level added.
+// * @param contextIds the context ids, that build up the environment.
+// */
+// public BaseStagedPropertySourceProvider(String rootContext, int basePriority, int priorityIncrease,
+// String... contextIds) {
+// if (contextIds.length == 0) {
+// throw new ConfigException("At least one environment context id must be defined.");
+// }
+// if (rootContext == null) {
+// LOGGER.finest("No environment mapping is applied.");
+// }
+// this.rootContext = rootContext;
+// this.contextIds.addAll(Arrays.asList(contextIds));
+// int priority = basePriority;
+// for (String contextId : contextIds) {
+// propertySources.addAll(loadStageProperties(rootContext, contextId, priority));
+// priority += priorityIncrease;
+// }
+// }
+//
+// /**
+// * Method that loads the environment properties for the given contextId.
+// * @param rootContext the root context, where entries read should be mapped to.
+// * @param contextId the contextId.
+// * @param priority the target priority the created PropertySource should have. This priority is
+// * important, since it reflects the order as defined
+// * when configuring this class. Therefore it should not be overridden normally.
+// * @return the corresponding PrioritySources to be added, never null.
+// */
+// protected abstract Collection<PropertySource> loadStageProperties(
+// String rootContext, String contextId, int priority);
+//
+// /**
+// * Get the environment context ids that define how this environment configuration
+// * is setup, in order of their increasing priority.
+// * @return the ordered list of context ids.
+// */
+// public List<String> getContextIds() {
+// return contextIds;
+// }
+//
+// @Override
+// public String toString() {
+// return "EnvironmentPropertySourceProvider{" +
+// "contextIds=" + contextIds +
+// ", rootContext='" + rootContext + '\'' +
+// '}';
+// }
+//
+// @Override
+// public Collection<PropertySource> getPropertySources() {
+// return propertySources;
+// }
+//
+//}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/src/main/java/org/apache/tamaya/staged/spi/DSLPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/metamodel-staged/src/main/java/org/apache/tamaya/staged/spi/DSLPropertySourceProvider.java b/metamodel-staged/src/main/java/org/apache/tamaya/staged/spi/DSLPropertySourceProvider.java
new file mode 100644
index 0000000..4482a5e
--- /dev/null
+++ b/metamodel-staged/src/main/java/org/apache/tamaya/staged/spi/DSLPropertySourceProvider.java
@@ -0,0 +1,51 @@
+/*
+ * 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.staged.spi;
+
+import org.apache.tamaya.spi.PropertySource;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Resolver to resolve/map DSL related source expressions into PropertySources
+ * loadable by a ConfigurationContext. Hereby the ordering of loaded property sources must be
+ * honored if possible by implicitly adapting/Overriding the default ordinal for the sources
+ * added.
+ */
+public interface DSLPropertySourceProvider {
+
+ /**
+ * Resolve the given expression (without the key part).
+ * @param sourceExpression the source expression, not null.
+ * @param defaultPropertySources the default property sources that can be used as defined by the functionality by
+ * a resolver.
+ * @return the list of loaded Property sources, never null.
+ */
+ List<PropertySource> resolve(String sourceExpression,
+ Map<String, PropertySource> defaultPropertySources);
+
+ /**
+ * Get the resolver key, which identifiesan expression to be resolved by a resolver instance.
+ * As an example {@code "named:"} is the key for an expression {@code "named:sys-properties"}.
+ * The method {@link #resolve(String, Map)} will onyl receive the secoind part of the expression.
+ * @return identifying key.
+ */
+ String getKey();
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/src/main/java/org/apache/tamaya/staged/spi/StagedConfigPropertiesProvider.java
----------------------------------------------------------------------
diff --git a/metamodel-staged/src/main/java/org/apache/tamaya/staged/spi/StagedConfigPropertiesProvider.java b/metamodel-staged/src/main/java/org/apache/tamaya/staged/spi/StagedConfigPropertiesProvider.java
new file mode 100644
index 0000000..722d0d0
--- /dev/null
+++ b/metamodel-staged/src/main/java/org/apache/tamaya/staged/spi/StagedConfigPropertiesProvider.java
@@ -0,0 +1,137 @@
+///*
+// * 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.staged.spi;
+//
+//
+//import org.apache.tamaya.spisupport.MapPropertySource;
+//import org.apache.tamaya.spisupport.PropertiesResourcePropertySource;
+//import org.apache.tamaya.resource.ConfigResources;
+//import org.apache.tamaya.spi.PropertySource;
+//
+//import java.net.URL;
+//import java.util.ArrayList;
+//import java.util.Collection;
+//import java.util.List;
+//import java.util.logging.Logger;
+//
+///**
+// * Configuration provider that resolves to a location in the classpath.
+// * Hereby the following system properties can be set to configure the provider
+// * (all entries are optional):
+// * <pre>
+// * env.STAGE : ordered list of configs to be loaded, e.g. sys-env,GLOBAL,TEST,DEV
+// * </pre>
+// * Adding {@code sys-env} as stage maps the current environment properties using
+// * the priority to be aliged with the context ordering, defined by {@code env.STAGE}.
+// * Similarly the same thing can be done by passing {@code sys-props} as context id for
+// * adding the current System properties to the configuration tree.
+// *
+// * The rootContext can be used to remap the whole property space to an alternate subtree in
+// * the configuration tree overall. This is very handy, if multiple instances of this class
+// * are registered into the same configuration, but with different location setups. Remapping
+// * configuration allows to separate these entries clearly.<br/>
+// * Finally the resource location can be adapted by overriding {@link #getBaseResourcePath()}.
+// * Different formats and loading mechanisms can be implemented by overriding
+// * {@link #loadProperties(String, String, int, List)}.
+// */
+//public class StagedConfigPropertiesProvider extends BaseStagedPropertySourceProvider {
+//
+// /** The system property to define the stages used. */
+// private static final String STAGE_PROP = "env.STAGE";
+// /** The logger used. */
+//
+// private static final Logger LOGGER = Logger.getLogger(StagedConfigPropertiesProvider.class.getName());
+//
+// /** The context id for adding the system's environment properties. */
+// private static final String DEFAULT_ENV = "sys-env";
+//
+// /** The context id for adding the system's properties. */
+// private static final String DEFAULT_SYSPROPS = "sys-props";
+//
+// /**
+// * Creates a new instance.
+// * @param rootContext the (optional) root context, can be null.
+// * @param stages the comma separated list of stages.
+// */
+// public StagedConfigPropertiesProvider(String rootContext, String... stages){
+// super(rootContext, evaluateStages(stages));
+// }
+//
+// /**
+// * Creates a default instance. the stages are read from the {@code env.STAGE} system�propertx
+// * or a default is applied.
+// */
+// public StagedConfigPropertiesProvider(){
+// super(null, evaluateStages(null));
+// }
+//
+// /**
+// * Evaluates the stages or returns the default STAGE entry.
+// * @return the stages to be used, never null.
+// */
+// private static String[] evaluateStages(String[] stages) {
+// if(stages!=null && stages.length>0){
+// return stages.clone();
+// }
+// String value = System.getProperty(STAGE_PROP);
+// if(value==null) {
+// value = System.getenv(STAGE_PROP);
+// }
+// if(value==null){
+// value = "sys-env,GLOBAL,DEVELOPMENT,sys-props";
+// }
+// return value.split(",");
+// }
+//
+// @Override
+// protected Collection<PropertySource> loadStageProperties(
+// String rootContext, String contextId, int priority) {
+// List<PropertySource> result = new ArrayList<>();
+// if (DEFAULT_ENV.equals(contextId)){
+// result.add(new MapPropertySource(DEFAULT_ENV, System.getenv(),
+// rootContext, priority));
+// }else if (DEFAULT_SYSPROPS.equals(contextId)){
+// result.add(new MapPropertySource(DEFAULT_SYSPROPS, System.getProperties(),
+// rootContext, priority));
+// }
+// else{
+// loadProperties(rootContext, contextId, priority, result);
+// }
+// return result;
+// }
+//
+// private void loadProperties(String rootContext, String contextId, int priority,
+// List<PropertySource> result) {
+// String cpExp = getBaseResourcePath()+'/' +contextId+".properties";
+// if(cpExp.startsWith("/")){
+// cpExp = cpExp.substring(1);
+// }
+// for(URL url: ConfigResources.getResourceResolver().getResources(cpExp)){
+// result.add(new PropertiesResourcePropertySource(rootContext, url, priority));
+// }
+// }
+//
+// /**
+// * Get the basic resource path used for lookup of properties files.
+// * @return the basic resource path, never null.
+// */
+// protected String getBaseResourcePath() {
+// return "";
+// }
+//
+//
+//}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/src/main/java/org/apache/tamaya/staged/spi/package-info.java
----------------------------------------------------------------------
diff --git a/metamodel-staged/src/main/java/org/apache/tamaya/staged/spi/package-info.java b/metamodel-staged/src/main/java/org/apache/tamaya/staged/spi/package-info.java
new file mode 100644
index 0000000..9037c2b
--- /dev/null
+++ b/metamodel-staged/src/main/java/org/apache/tamaya/staged/spi/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+/**
+ * Main API of the environment module, containing the base class for implementing adapted
+ * environment parts in your configuration.
+ */
+package org.apache.tamaya.environment.spi;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationProviderSpi
----------------------------------------------------------------------
diff --git a/metamodel-staged/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationProviderSpi b/metamodel-staged/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationProviderSpi
new file mode 100644
index 0000000..8ef0643
--- /dev/null
+++ b/metamodel-staged/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationProviderSpi
@@ -0,0 +1,19 @@
+#
+# 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.dsl.internal.DSLLoadingConfigurationProviderSpi
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/src/main/resources/META-INF/services/org.apache.tamaya.staged.spi.DSLPropertySourceProvider
----------------------------------------------------------------------
diff --git a/metamodel-staged/src/main/resources/META-INF/services/org.apache.tamaya.staged.spi.DSLPropertySourceProvider b/metamodel-staged/src/main/resources/META-INF/services/org.apache.tamaya.staged.spi.DSLPropertySourceProvider
new file mode 100644
index 0000000..e80367e
--- /dev/null
+++ b/metamodel-staged/src/main/resources/META-INF/services/org.apache.tamaya.staged.spi.DSLPropertySourceProvider
@@ -0,0 +1,20 @@
+#
+# 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.dsl.internal.NamedDSLPropertySourceProvider
+org.apache.tamaya.dsl.internal.ResourceDSLPropertySourceProvider
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/src/test/java/org/apache/tamaya/dsl/ProfileManagerTest.java
----------------------------------------------------------------------
diff --git a/metamodel-staged/src/test/java/org/apache/tamaya/dsl/ProfileManagerTest.java b/metamodel-staged/src/test/java/org/apache/tamaya/dsl/ProfileManagerTest.java
new file mode 100644
index 0000000..9692d47
--- /dev/null
+++ b/metamodel-staged/src/test/java/org/apache/tamaya/dsl/ProfileManagerTest.java
@@ -0,0 +1,78 @@
+/*
+ * 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.dsl;
+
+import java.util.List;
+import java.util.Set;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by atsticks on 05.05.16.
+ */
+public class ProfileManagerTest {
+
+ private ProfileManager profileManager = ProfileManager.getInstance();
+
+ @org.junit.Test
+ public void isProfileActive() throws Exception {
+ assertTrue(profileManager.isProfileActive("DEV"));
+ assertTrue(profileManager.isProfileActive("DEFAULT"));
+ assertFalse(profileManager.isProfileActive("PROD"));
+ }
+
+ @org.junit.Test
+ public void isProfileDefined() throws Exception {
+ assertTrue(profileManager.isProfileDefined("DEV"));
+ assertTrue(profileManager.isProfileDefined("DEFAULT"));
+ assertFalse(profileManager.isProfileDefined("foo"));
+ }
+
+ @org.junit.Test
+ public void isProfileDefault() throws Exception {
+ assertFalse(profileManager.isProfileDefault("DEV"));
+ assertTrue(profileManager.isProfileDefault("DEFAULT"));
+ }
+
+ @org.junit.Test
+ public void getActiveProfiles() throws Exception {
+ List<String> profiles = profileManager.getActiveProfiles();
+ assertTrue(profiles.contains("DEV"));
+ assertTrue(profiles.contains("DEFAULT"));
+ assertFalse(profiles.contains("TEST"));
+ assertFalse(profiles.contains("PROD"));
+ }
+
+ @org.junit.Test
+ public void getDefaultProfiles() throws Exception {
+ List<String> profiles = profileManager.getDefaultProfiles();
+ assertTrue(profiles.contains("DEFAULT"));
+ assertFalse(profiles.contains("TEST"));
+ }
+
+ @org.junit.Test
+ public void getAllProfiles() throws Exception {
+ Set<String> profiles = profileManager.getAllProfiles();
+ assertTrue(profiles.contains("DEFAULT"));
+ assertTrue(profiles.contains("DEV"));
+ assertTrue(profiles.contains("TEST"));
+ assertTrue(profiles.contains("PROD"));
+ assertFalse(profiles.contains("foo"));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/src/test/resources/GLOBAL.properties
----------------------------------------------------------------------
diff --git a/metamodel-staged/src/test/resources/GLOBAL.properties b/metamodel-staged/src/test/resources/GLOBAL.properties
new file mode 100644
index 0000000..9f39f75
--- /dev/null
+++ b/metamodel-staged/src/test/resources/GLOBAL.properties
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+aKey=aValue.GLOBAL
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/src/test/resources/TEST.properties
----------------------------------------------------------------------
diff --git a/metamodel-staged/src/test/resources/TEST.properties b/metamodel-staged/src/test/resources/TEST.properties
new file mode 100644
index 0000000..2b31cb3
--- /dev/null
+++ b/metamodel-staged/src/test/resources/TEST.properties
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+aKey=aValue.TEST
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/src/test/resources/tamaya-TEST.yaml
----------------------------------------------------------------------
diff --git a/metamodel-staged/src/test/resources/tamaya-TEST.yaml b/metamodel-staged/src/test/resources/tamaya-TEST.yaml
new file mode 100644
index 0000000..3e56656
--- /dev/null
+++ b/metamodel-staged/src/test/resources/tamaya-TEST.yaml
@@ -0,0 +1,27 @@
+#
+# 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.
+#
+tamaya-configuration:
+ includes:
+ tamaya-DEFAULT.yaml
+
+ property-sources:
+ - class: org.apache.tamaya.resources.ResourceProvider
+ resource: classpath:META-INF/config/test/**/*.*"
+ - class: org.apache.tamaya.resources.ResourceProvider
+ resource: classpath://META-INF/config/test/**/*.*"
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/src/test/resources/tamaya-config.yaml
----------------------------------------------------------------------
diff --git a/metamodel-staged/src/test/resources/tamaya-config.yaml b/metamodel-staged/src/test/resources/tamaya-config.yaml
new file mode 100644
index 0000000..a2980f6
--- /dev/null
+++ b/metamodel-staged/src/test/resources/tamaya-config.yaml
@@ -0,0 +1,37 @@
+#
+# 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.
+#
+tamaya-config:
+ source-selectors:
+ - DEFAULT:
+ source: tamaya-DEFAULT.yml
+ labels: env=TEST env=PTA env=PROD
+ - TEST:
+ source: tamaya-TEST.yml
+ labels: env=TEST
+ - PTA:
+ source: tamaya-PTA.yml
+ labels: env=PTA
+ - PROD:
+ source: tamaya-PROD.yml
+ labels: env=PROD
+
+ default-labels: env=DEV
+
+ expressions:
+ - env: ${sys-property:ENV}, ${env-property:ENV}, "DEV"
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/pom.xml
----------------------------------------------------------------------
diff --git a/metamodels/pom.xml b/metamodels/pom.xml
deleted file mode 100644
index 9304deb..0000000
--- a/metamodels/pom.xml
+++ /dev/null
@@ -1,40 +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-sandbox</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <groupId>org.apache.tamaya.ext.metamodels</groupId>
- <artifactId>tamaya-metamodels</artifactId>
- <name>Apache Tamaya Modules - Metamodels</name>
- <packaging>pom</packaging>
-
- <modules>
- <module>simple</module>
- <module>staged</module>
- </modules>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/simple/config/README.txt
----------------------------------------------------------------------
diff --git a/metamodels/simple/config/README.txt b/metamodels/simple/config/README.txt
deleted file mode 100644
index 3dd71f5..0000000
--- a/metamodels/simple/config/README.txt
+++ /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.
-#
-This folder is for testing only. It contains some config files that are to be included by the
-ConfigDirPropertySourceProvider config provider.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/simple/config/test3.properties
----------------------------------------------------------------------
diff --git a/metamodels/simple/config/test3.properties b/metamodels/simple/config/test3.properties
deleted file mode 100644
index 9ddef76..0000000
--- a/metamodels/simple/config/test3.properties
+++ /dev/null
@@ -1,21 +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.
-#
-tamaya.ordinal=100000
-test3=3-overridden
-test5=value5
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/simple/pom.xml
----------------------------------------------------------------------
diff --git a/metamodels/simple/pom.xml b/metamodels/simple/pom.xml
deleted file mode 100644
index 9c96c28..0000000
--- a/metamodels/simple/pom.xml
+++ /dev/null
@@ -1,86 +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.
--->
-<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.metamodels</groupId>
- <artifactId>tamaya-metamodels</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>tamaya-metamodels-simple</artifactId>
- <name>Apache Tamaya Modules Metamodels - Simple</name>
- <description>Simple Tamaya Metamodel, e.g. feasible for SE commandline tools and simple use cases.</description>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-resources</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-formats</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>
- org.apache.tamaya,
- org.apache.tamaya.spi,
- org.apache.tamaya.format,
- javax.annotation,
- *
- </Import-Package>
- <Export-Package>
- org.apache.tamaya.metamodel.simple
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/ConfigDirPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/ConfigDirPropertySourceProvider.java b/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/ConfigDirPropertySourceProvider.java
deleted file mode 100644
index e3c9cbf..0000000
--- a/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/ConfigDirPropertySourceProvider.java
+++ /dev/null
@@ -1,81 +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.metamodel.simple.internal;
-
-
-import org.apache.tamaya.format.ConfigurationData;
-import org.apache.tamaya.format.ConfigurationFormats;
-import org.apache.tamaya.format.FlattenedDefaultPropertySource;
-import org.apache.tamaya.resource.AbstractPathPropertySourceProvider;
-import org.apache.tamaya.spi.PropertySource;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Created by Anatole on 20.03.2015.
- */
-public class ConfigDirPropertySourceProvider extends AbstractPathPropertySourceProvider {
-
- public ConfigDirPropertySourceProvider() {
- super(getConfigLocation());
- }
-
- private static String getConfigLocation() {
- String location = System.getProperty("configdir");
- if (location == null) {
- location = "./config";
- }
- if (!location.endsWith("/")) {
- location += "/";
- }
- if (!location.startsWith("file:")) {
- location = "file:" + location;
- }
- return location + "**/*.*";
- }
-
- @Override
- protected Collection<PropertySource> getPropertySources(URL url) {
- try {
- ConfigurationData config = ConfigurationFormats.readConfigurationData(url);
- if (config == null) {
- Logger.getLogger(getClass().getName()).log(Level.INFO,
- "Failed to read configuration from " + url);
- return Collections.emptySet();
- }
- return asCollection(new FlattenedDefaultPropertySource(config));
- } catch (Exception e) {
- Logger.getLogger(getClass().getName()).log(Level.SEVERE,
- "Failed to read configuration from " + url, e);
- return Collections.emptySet();
- }
- }
-
- private Collection<PropertySource> asCollection(PropertySource propertySource) {
- List<PropertySource> result = new ArrayList<>(1);
- result.add(propertySource);
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/MetainfConfigPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/MetainfConfigPropertySourceProvider.java b/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/MetainfConfigPropertySourceProvider.java
deleted file mode 100644
index 0edbbc7..0000000
--- a/metamodels/simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/MetainfConfigPropertySourceProvider.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.metamodel.simple.internal;
-
-
-import org.apache.tamaya.format.ConfigurationData;
-import org.apache.tamaya.format.ConfigurationFormats;
-import org.apache.tamaya.format.FlattenedDefaultPropertySource;
-import org.apache.tamaya.resource.AbstractPathPropertySourceProvider;
-import org.apache.tamaya.spi.PropertySource;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Created by Anatole on 20.03.2015.
- */
-public class MetainfConfigPropertySourceProvider extends AbstractPathPropertySourceProvider {
-
- public MetainfConfigPropertySourceProvider() {
- super("classpath:META-INF/config/**/*.*");
- }
-
- @Override
- protected Collection<PropertySource> getPropertySources(URL url) {
- try {
- ConfigurationData config = ConfigurationFormats.readConfigurationData(url);
- return asCollection(new FlattenedDefaultPropertySource(config));
- } catch (Exception e) {
- Logger.getLogger(getClass().getName()).log(Level.SEVERE,
- "Failed to read configuration from " + url, e);
- return Collections.emptySet();
- }
- }
-
- private Collection<PropertySource> asCollection(PropertySource propertySource) {
- List<PropertySource> result = new ArrayList<>(1);
- result.add(propertySource);
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/simple/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
----------------------------------------------------------------------
diff --git a/metamodels/simple/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider b/metamodels/simple/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
deleted file mode 100644
index 2e963e2..0000000
--- a/metamodels/simple/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
+++ /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.
-#
-org.apache.tamaya.metamodel.simple.internal.ConfigDirPropertySourceProvider
-org.apache.tamaya.metamodel.simple.internal.MetainfConfigPropertySourceProvider
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/simple/src/test/java/org/apache/tamaya/metamodel/simple/SimpleTest.java
----------------------------------------------------------------------
diff --git a/metamodels/simple/src/test/java/org/apache/tamaya/metamodel/simple/SimpleTest.java b/metamodels/simple/src/test/java/org/apache/tamaya/metamodel/simple/SimpleTest.java
deleted file mode 100644
index 677d8fc..0000000
--- a/metamodels/simple/src/test/java/org/apache/tamaya/metamodel/simple/SimpleTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.apache.tamaya.metamodel.simple;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Created by Anatole on 26.07.2015.
- */
-public class SimpleTest {
-
- @Test
- public void testClasspathConfig() {
- Configuration config = ConfigurationProvider.getConfiguration();
- assertEquals(config.get("test1"), "1");
- assertEquals(config.get("test2"), "2");
- // overridden by file config
- assertEquals(config.get("test3"), "3-overridden");
- assertEquals(config.get("test4"), "4");
- // added by file config
- assertEquals(config.get("test5"), "value5");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/simple/src/test/resources/META-INF/config/test.properties
----------------------------------------------------------------------
diff --git a/metamodels/simple/src/test/resources/META-INF/config/test.properties b/metamodels/simple/src/test/resources/META-INF/config/test.properties
deleted file mode 100644
index af16b23..0000000
--- a/metamodels/simple/src/test/resources/META-INF/config/test.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.
-#
-test1=1
-test2=2
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/simple/src/test/resources/META-INF/config/test2.properties
----------------------------------------------------------------------
diff --git a/metamodels/simple/src/test/resources/META-INF/config/test2.properties b/metamodels/simple/src/test/resources/META-INF/config/test2.properties
deleted file mode 100644
index 58524b7..0000000
--- a/metamodels/simple/src/test/resources/META-INF/config/test2.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.
-#
-test3=3
-test4=4
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/pom.xml
----------------------------------------------------------------------
diff --git a/metamodels/staged/pom.xml b/metamodels/staged/pom.xml
deleted file mode 100644
index b5c96a2..0000000
--- a/metamodels/staged/pom.xml
+++ /dev/null
@@ -1,114 +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.metamodels</groupId>
- <artifactId>tamaya-metamodels</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <artifactId>tamaya-metamodel-staged</artifactId>
- <name>Apache Tamaya Modules - Staged Configuration</name>
- <packaging>bundle</packaging>
-
- <dependencies>
- <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-functions</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-resolver</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-spisupport</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-resources</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-formats</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-yaml</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>
- org.apache.tamaya,
- org.apache.tamaya.spi,
- org.apache.tamaya.resources,
- org.apache.tamaya.spisupport,
- org.apache.tamaya.functions,
- javax.annotation,
- *
- </Import-Package>
- <Export-Package>
- org.apache.tamaya.metamodel.simple
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodels/staged/src/main/java/org/apache/tamaya/dsl/DSLFormatManager.java
----------------------------------------------------------------------
diff --git a/metamodels/staged/src/main/java/org/apache/tamaya/dsl/DSLFormatManager.java b/metamodels/staged/src/main/java/org/apache/tamaya/dsl/DSLFormatManager.java
deleted file mode 100644
index 916fa49..0000000
--- a/metamodels/staged/src/main/java/org/apache/tamaya/dsl/DSLFormatManager.java
+++ /dev/null
@@ -1,115 +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.dsl;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.format.ConfigurationFormat;
-import org.apache.tamaya.format.ConfigurationFormats;
-import org.apache.tamaya.functions.ConfigurationFunctions;
-
-import java.util.*;
-
-/**
- * Component that manages the current supported formats:
- * <pre>
- * TAMAYA:
- * FORMAT-DEF:
- * - formats: yaml, properties, xml-properties
- * </pre>
- * Hereby:
- * <ul>
- * <li><b>profiles</b> defines the available profiles, including implicit default profiles.</li>
- * </ul>
- */
-public final class DSLFormatManager {
-
- private static final DSLFormatManager INSTANCE = new DSLFormatManager();
-
- /** The currently active formats, in order of precedence, the most significant are the last ones. */
- private List<ConfigurationFormat> formats = new ArrayList<>();
- /** The currently active suffixes, in order of precedence, the most significant are the last ones. */
- private List<String> suffixes = new ArrayList<>();
-
-
- /**
- * Get the current instance.
- * @return the current profile manager, never null.
- */
- public static DSLFormatManager getInstance(){
- return INSTANCE;
- }
-
- private DSLFormatManager(){
- Configuration metaConfig = MetaConfiguration.getConfiguration();
- Configuration formatsConfig = metaConfig.with(
- ConfigurationFunctions.section("TAMAYA.FORMATS"));
- String[] formats = formatsConfig.getOrDefault("formats","yamk,properties,ini").split(",");
- this.formats.addAll(ConfigurationFormats.getFormats(formats));
- String[] suffixes = formatsConfig.getOrDefault("suffixes","yml,properties,ini").split(",");
- for(String sfx:suffixes){
- sfx = sfx.trim();
- if(sfx.isEmpty()){
- continue;
- }
- this.suffixes.add(sfx);
- }
- }
-
-
- /**
- * Allows to check if a suffix is currently activated.
- * @param suffix the suffix name, not null.
- * @return true, if the profile is defined.
- */
- public boolean isSuffixDefined(String suffix){
- return this.suffixes.contains(suffix);
- }
-
- /**
- * Allows to check if a format is selected.
- * @param formatName the format name, not null.
- * @return true, if the format is a selected.
- */
- public boolean isFormatSelected(String formatName){
- for(ConfigurationFormat format:formats){
- if(format.getName().equals(formatName)){
- return true;
- }
- }
- return false;
- }
-
- /**
- * Get the list of currently active suffixes.
- * @return the list of currently active suffixes, never null.
- */
- public List<String> getSuffixes(){
- return Collections.unmodifiableList(suffixes);
- }
-
- /**
- * Get the list of currently active formats.
- * @return the list of currently active formats, never null.
- */
- public List<ConfigurationFormat> getFormats(){
- return Collections.unmodifiableList(formats);
- }
-
-
-}
[3/3] incubator-tamaya-sandbox git commit: Simplified the sandbox
structure.
Posted by pl...@apache.org.
Simplified the sandbox structure.
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/07b10131
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/07b10131
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/07b10131
Branch: refs/heads/master
Commit: 07b101310c9b50ed6def069e092f8556328f3483
Parents: 194a48b
Author: Oliver B. Fischer <pl...@apache.org>
Authored: Tue Sep 6 19:44:58 2016 +0200
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Tue Sep 6 19:44:58 2016 +0200
----------------------------------------------------------------------
apache-commons/pom.xml | 75 ++++++
.../commons/CommonsConfigPropertySource.java | 81 +++++++
.../commons/IniConfigurationFormat.java | 75 ++++++
integration/commons/pom.xml | 75 ------
.../commons/CommonsConfigPropertySource.java | 81 -------
.../commons/IniConfigurationFormat.java | 75 ------
integration/pom.xml | 39 ----
.../internal/FileProprtyStoreProviderSpi.java | 85 -------
...he.tamaya.store.spi.PropertyStoreProviderSpi | 18 --
.../HazelcastProprtyStoreProviderSpi.java | 87 -------
.../org.apache.tamaya.store.PropertyStore | 19 --
metamodel-simple/config/README.txt | 20 ++
metamodel-simple/config/test3.properties | 21 ++
metamodel-simple/pom.xml | 86 +++++++
.../ConfigDirPropertySourceProvider.java | 81 +++++++
.../MetainfConfigPropertySourceProvider.java | 62 +++++
...org.apache.tamaya.spi.PropertySourceProvider | 20 ++
.../tamaya/metamodel/simple/SimpleTest.java | 26 +++
.../resources/META-INF/config/test.properties | 20 ++
.../resources/META-INF/config/test2.properties | 20 ++
metamodel-staged/pom.xml | 114 +++++++++
.../org/apache/tamaya/dsl/DSLFormatManager.java | 115 +++++++++
.../apache/tamaya/dsl/MetaConfiguration.java | 144 ++++++++++++
.../org/apache/tamaya/dsl/ProfileManager.java | 213 +++++++++++++++++
.../apache/tamaya/dsl/TamayaConfigurator.java | 234 +++++++++++++++++++
.../tamaya/dsl/WrappedPropertySource.java | 100 ++++++++
.../DSLLoadingConfigurationProviderSpi.java | 82 +++++++
.../NamedDSLPropertySourceProvider.java | 53 +++++
.../ResourceDSLPropertySourceProvider.java | 82 +++++++
.../org/apache/tamaya/dsl/package-info.java | 23 ++
.../spi/BaseStagedPropertySourceProvider.java | 121 ++++++++++
.../staged/spi/DSLPropertySourceProvider.java | 51 ++++
.../spi/StagedConfigPropertiesProvider.java | 137 +++++++++++
.../apache/tamaya/staged/spi/package-info.java | 23 ++
...g.apache.tamaya.spi.ConfigurationProviderSpi | 19 ++
....tamaya.staged.spi.DSLPropertySourceProvider | 20 ++
.../apache/tamaya/dsl/ProfileManagerTest.java | 78 +++++++
.../src/test/resources/GLOBAL.properties | 19 ++
.../src/test/resources/TEST.properties | 19 ++
.../src/test/resources/tamaya-TEST.yaml | 27 +++
.../src/test/resources/tamaya-config.yaml | 37 +++
metamodels/pom.xml | 40 ----
metamodels/simple/config/README.txt | 20 --
metamodels/simple/config/test3.properties | 21 --
metamodels/simple/pom.xml | 86 -------
.../ConfigDirPropertySourceProvider.java | 81 -------
.../MetainfConfigPropertySourceProvider.java | 62 -----
...org.apache.tamaya.spi.PropertySourceProvider | 20 --
.../tamaya/metamodel/simple/SimpleTest.java | 26 ---
.../resources/META-INF/config/test.properties | 20 --
.../resources/META-INF/config/test2.properties | 20 --
metamodels/staged/pom.xml | 114 ---------
.../org/apache/tamaya/dsl/DSLFormatManager.java | 115 ---------
.../apache/tamaya/dsl/MetaConfiguration.java | 144 ------------
.../org/apache/tamaya/dsl/ProfileManager.java | 213 -----------------
.../apache/tamaya/dsl/TamayaConfigurator.java | 234 -------------------
.../tamaya/dsl/WrappedPropertySource.java | 100 --------
.../DSLLoadingConfigurationProviderSpi.java | 82 -------
.../NamedDSLPropertySourceProvider.java | 53 -----
.../ResourceDSLPropertySourceProvider.java | 82 -------
.../org/apache/tamaya/dsl/package-info.java | 23 --
.../spi/BaseStagedPropertySourceProvider.java | 121 ----------
.../staged/spi/DSLPropertySourceProvider.java | 51 ----
.../spi/StagedConfigPropertiesProvider.java | 137 -----------
.../apache/tamaya/staged/spi/package-info.java | 23 --
...g.apache.tamaya.spi.ConfigurationProviderSpi | 19 --
....tamaya.staged.spi.DSLPropertySourceProvider | 20 --
.../apache/tamaya/dsl/ProfileManagerTest.java | 78 -------
.../staged/src/test/resources/GLOBAL.properties | 19 --
.../staged/src/test/resources/TEST.properties | 19 --
.../staged/src/test/resources/tamaya-TEST.yaml | 27 ---
.../src/test/resources/tamaya-config.yaml | 37 ---
.../internal/FileProprtyStoreProviderSpi.java | 85 +++++++
...he.tamaya.store.spi.PropertyStoreProviderSpi | 18 ++
.../HazelcastProprtyStoreProviderSpi.java | 87 +++++++
.../org.apache.tamaya.store.PropertyStore | 19 ++
76 files changed, 2507 insertions(+), 2586 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/apache-commons/pom.xml
----------------------------------------------------------------------
diff --git a/apache-commons/pom.xml b/apache-commons/pom.xml
new file mode 100644
index 0000000..2b5eda0
--- /dev/null
+++ b/apache-commons/pom.xml
@@ -0,0 +1,75 @@
+<!--
+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-integrations</artifactId>
+ <version>0.2-incubating-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+ <artifactId>tamaya-commons-config</artifactId>
+ <name>Apache Tamaya Commons Integration - Apache Commons</name>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tamaya</groupId>
+ <artifactId>tamaya-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-formats</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-configuration</groupId>
+ <artifactId>commons-configuration</artifactId>
+ <version>1.10</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Import-Package>
+ org.apache.tamaya,
+ org.apache.tamaya.spi,
+ org.apache.tamaya.format,
+ org.apache.commons,
+ javax.annotation,
+ *
+ </Import-Package>
+ <Export-Package>
+ org.apache.tamaya.integration.commons
+ </Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/apache-commons/src/main/java/org/apache/tamaya/integration/commons/CommonsConfigPropertySource.java
----------------------------------------------------------------------
diff --git a/apache-commons/src/main/java/org/apache/tamaya/integration/commons/CommonsConfigPropertySource.java b/apache-commons/src/main/java/org/apache/tamaya/integration/commons/CommonsConfigPropertySource.java
new file mode 100644
index 0000000..b2f2e82
--- /dev/null
+++ b/apache-commons/src/main/java/org/apache/tamaya/integration/commons/CommonsConfigPropertySource.java
@@ -0,0 +1,81 @@
+/*
+ * 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.commons;
+
+//X TODO Move out into separate commons-config integration module...
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.tamaya.spi.PropertySource;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * PropertySource that wraps {@link org.apache.commons.configuration.Configuration}.
+ */
+public class CommonsConfigPropertySource implements PropertySource {
+
+ private Configuration commonsConfig;
+ private int ordinal;
+ private String name;
+
+ public CommonsConfigPropertySource(int ordinal, String name, Configuration commonsConfig) {
+ this.commonsConfig = Objects.requireNonNull(commonsConfig);
+ this.ordinal = ordinal;
+ this.name = Objects.requireNonNull(name);
+ }
+
+ public CommonsConfigPropertySource(String name, Configuration commonsConfig) {
+ commonsConfig = Objects.requireNonNull(commonsConfig);
+ this.name = Objects.requireNonNull(name);
+ try {
+ this.ordinal = commonsConfig.getInt(PropertySource.TAMAYA_ORDINAL);
+ } catch (Exception e) {
+ this.ordinal = 0;
+ }
+ }
+
+ @Override
+ public int getOrdinal() {
+ return ordinal;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String get(String key) {
+ return commonsConfig.getString(key);
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ Map<String, String> config = new HashMap<>();
+ Iterator<String> keyIter = commonsConfig.getKeys();
+ while (keyIter.hasNext()) {
+ String key = keyIter.next();
+ config.put(key, commonsConfig.getString(key));
+ }
+ return config;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/apache-commons/src/main/java/org/apache/tamaya/integration/commons/IniConfigurationFormat.java
----------------------------------------------------------------------
diff --git a/apache-commons/src/main/java/org/apache/tamaya/integration/commons/IniConfigurationFormat.java b/apache-commons/src/main/java/org/apache/tamaya/integration/commons/IniConfigurationFormat.java
new file mode 100644
index 0000000..0e21f4f
--- /dev/null
+++ b/apache-commons/src/main/java/org/apache/tamaya/integration/commons/IniConfigurationFormat.java
@@ -0,0 +1,75 @@
+/*
+ * 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.commons;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalINIConfiguration;
+import org.apache.commons.configuration.SubnodeConfiguration;
+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.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * Implements a ini file format based on the APache Commons
+ * {@link org.apache.commons.configuration.HierarchicalINIConfiguration}.
+ */
+public class IniConfigurationFormat implements ConfigurationFormat {
+
+ public ConfigurationData readConfiguration(URL url) {
+ ConfigurationDataBuilder builder = ConfigurationDataBuilder.of(url.toString(), this);
+ try {
+ HierarchicalINIConfiguration commonIniConfiguration = new HierarchicalINIConfiguration(url);
+ for(String section:commonIniConfiguration.getSections()){
+ SubnodeConfiguration sectionConfig = commonIniConfiguration.getSection(section);
+ Map<String, String> properties = new HashMap<>();
+ Iterator<String> keyIter = sectionConfig.getKeys();
+ while(keyIter.hasNext()){
+ String key = keyIter.next();
+ properties.put(key, sectionConfig.getString(key));
+ }
+ builder.addProperties(section, properties);
+ }
+ } catch (ConfigurationException e) {
+ throw new ConfigException("Failed to parse ini-file format from " + url, e);
+ }
+ return builder.build();
+ }
+
+ @Override
+ public String getName() {
+ throw new RuntimeException("Not implemented yet!");
+ }
+
+ @Override
+ public boolean accepts(URL url) {
+ throw new RuntimeException("Not implemented yet!");
+ }
+
+ @Override
+ public ConfigurationData readConfiguration(String resource, InputStream inputStream) {
+ throw new RuntimeException("Not implemented yet!");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/integration/commons/pom.xml
----------------------------------------------------------------------
diff --git a/integration/commons/pom.xml b/integration/commons/pom.xml
deleted file mode 100644
index 2b5eda0..0000000
--- a/integration/commons/pom.xml
+++ /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 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-integrations</artifactId>
- <version>0.2-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>tamaya-commons-config</artifactId>
- <name>Apache Tamaya Commons Integration - Apache Commons</name>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-formats</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-configuration</groupId>
- <artifactId>commons-configuration</artifactId>
- <version>1.10</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>
- org.apache.tamaya,
- org.apache.tamaya.spi,
- org.apache.tamaya.format,
- org.apache.commons,
- javax.annotation,
- *
- </Import-Package>
- <Export-Package>
- org.apache.tamaya.integration.commons
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/integration/commons/src/main/java/org/apache/tamaya/integration/commons/CommonsConfigPropertySource.java
----------------------------------------------------------------------
diff --git a/integration/commons/src/main/java/org/apache/tamaya/integration/commons/CommonsConfigPropertySource.java b/integration/commons/src/main/java/org/apache/tamaya/integration/commons/CommonsConfigPropertySource.java
deleted file mode 100644
index b2f2e82..0000000
--- a/integration/commons/src/main/java/org/apache/tamaya/integration/commons/CommonsConfigPropertySource.java
+++ /dev/null
@@ -1,81 +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.commons;
-
-//X TODO Move out into separate commons-config integration module...
-
-import org.apache.commons.configuration.Configuration;
-import org.apache.tamaya.spi.PropertySource;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * PropertySource that wraps {@link org.apache.commons.configuration.Configuration}.
- */
-public class CommonsConfigPropertySource implements PropertySource {
-
- private Configuration commonsConfig;
- private int ordinal;
- private String name;
-
- public CommonsConfigPropertySource(int ordinal, String name, Configuration commonsConfig) {
- this.commonsConfig = Objects.requireNonNull(commonsConfig);
- this.ordinal = ordinal;
- this.name = Objects.requireNonNull(name);
- }
-
- public CommonsConfigPropertySource(String name, Configuration commonsConfig) {
- commonsConfig = Objects.requireNonNull(commonsConfig);
- this.name = Objects.requireNonNull(name);
- try {
- this.ordinal = commonsConfig.getInt(PropertySource.TAMAYA_ORDINAL);
- } catch (Exception e) {
- this.ordinal = 0;
- }
- }
-
- @Override
- public int getOrdinal() {
- return ordinal;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public String get(String key) {
- return commonsConfig.getString(key);
- }
-
- @Override
- public Map<String, String> getProperties() {
- Map<String, String> config = new HashMap<>();
- Iterator<String> keyIter = commonsConfig.getKeys();
- while (keyIter.hasNext()) {
- String key = keyIter.next();
- config.put(key, commonsConfig.getString(key));
- }
- return config;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/integration/commons/src/main/java/org/apache/tamaya/integration/commons/IniConfigurationFormat.java
----------------------------------------------------------------------
diff --git a/integration/commons/src/main/java/org/apache/tamaya/integration/commons/IniConfigurationFormat.java b/integration/commons/src/main/java/org/apache/tamaya/integration/commons/IniConfigurationFormat.java
deleted file mode 100644
index 0e21f4f..0000000
--- a/integration/commons/src/main/java/org/apache/tamaya/integration/commons/IniConfigurationFormat.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.integration.commons;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.HierarchicalINIConfiguration;
-import org.apache.commons.configuration.SubnodeConfiguration;
-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.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * Implements a ini file format based on the APache Commons
- * {@link org.apache.commons.configuration.HierarchicalINIConfiguration}.
- */
-public class IniConfigurationFormat implements ConfigurationFormat {
-
- public ConfigurationData readConfiguration(URL url) {
- ConfigurationDataBuilder builder = ConfigurationDataBuilder.of(url.toString(), this);
- try {
- HierarchicalINIConfiguration commonIniConfiguration = new HierarchicalINIConfiguration(url);
- for(String section:commonIniConfiguration.getSections()){
- SubnodeConfiguration sectionConfig = commonIniConfiguration.getSection(section);
- Map<String, String> properties = new HashMap<>();
- Iterator<String> keyIter = sectionConfig.getKeys();
- while(keyIter.hasNext()){
- String key = keyIter.next();
- properties.put(key, sectionConfig.getString(key));
- }
- builder.addProperties(section, properties);
- }
- } catch (ConfigurationException e) {
- throw new ConfigException("Failed to parse ini-file format from " + url, e);
- }
- return builder.build();
- }
-
- @Override
- public String getName() {
- throw new RuntimeException("Not implemented yet!");
- }
-
- @Override
- public boolean accepts(URL url) {
- throw new RuntimeException("Not implemented yet!");
- }
-
- @Override
- public ConfigurationData readConfiguration(String resource, InputStream inputStream) {
- throw new RuntimeException("Not implemented yet!");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/integration/pom.xml
----------------------------------------------------------------------
diff --git a/integration/pom.xml b/integration/pom.xml
deleted file mode 100644
index e0d54d6..0000000
--- a/integration/pom.xml
+++ /dev/null
@@ -1,39 +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-sandbox</artifactId>
-
- <modules>
- <module>store</module>
- <module>commons</module>
- </modules>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/integration/store-file/src/main/java/org/apache/tamaya/store/internal/FileProprtyStoreProviderSpi.java
----------------------------------------------------------------------
diff --git a/integration/store-file/src/main/java/org/apache/tamaya/store/internal/FileProprtyStoreProviderSpi.java b/integration/store-file/src/main/java/org/apache/tamaya/store/internal/FileProprtyStoreProviderSpi.java
deleted file mode 100644
index 3ea768a..0000000
--- a/integration/store-file/src/main/java/org/apache/tamaya/store/internal/FileProprtyStoreProviderSpi.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.store.internal;
-
-import com.hazelcast.config.Config;
-import com.hazelcast.config.GroupConfig;
-import com.hazelcast.core.Hazelcast;
-import com.hazelcast.core.HazelcastInstance;
-import org.apache.tamaya.spi.ServiceContextManager;
-import org.apache.tamaya.store.PropertyStore;
-import org.apache.tamaya.store.spi.PropertyStoreProviderSpi;
-
-import java.util.Map;
-import java.util.ServiceLoader;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * SPI implmentation for a providing Hazelcast based PropertyStores.
- */
-public class FileProprtyStoreProviderSpi implements PropertyStoreProviderSpi {
- private static final String CONFIG_CLASS_SYS_PROP = "tamaya.store.file.configClass";
- private static final String CONFIG_GROUP_SYS_PROP = "tamaya.store.file.groupName";
-
- private static final Logger LOG = Logger.getLogger(HazelcastProprtyStoreProviderSpi.class.getName());
-
- private File file;
- private Map<String,HazelcastProprtyStore> stores = new ConcurrentHashMap<>();
-
- public HazelcastProprtyStoreProviderSpi() {
- String customConfig = System.getProperty(CONFIG_CLASS_SYS_PROP);
- Config config = null;
- if(customConfig!=null){
- try {
- config = (Config)Class.forName(customConfig).newInstance();
- LOG.info("Successfully created custom store config for HazelCast store: " + customConfig);
- } catch (Exception e) {
- LOG.log(Level.SEVERE, "Failed to instantiate custom store config for HazelCast store: " + customConfig, e);
- }
- }
- if(config==null){
- config = ServiceContextManager.getServiceContext().getService(Config.class);
- }
- if(config==null) {
- config = new Config();
- GroupConfig gc = new GroupConfig();
- String groupName = System.getProperty(CONFIG_GROUP_SYS_PROP, "Tamaya");
- gc.setName(groupName);
- config.setGroupConfig(gc);
- }
- LOG.info("Starting HazelCast storage with config: " + config);
- store = Hazelcast.getOrCreateHazelcastInstance(config);
- }
-
- @Override
- public PropertyStore getPropertyStore(String storeId) {
- HazelcastProprtyStore propertyStore = stores.get(storeId);
- if(propertyStore==null){
- LOG.info("Creating new distributed configuration map in HazelCast store for " + storeId + "...");
- propertyStore = new HazelcastProprtyStore(store, storeId);
- this.stores.put(storeId, propertyStore);
- }
- return propertyStore;
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/integration/store-file/src/main/resources/META-INF/services/org.apache.tamaya.store.spi.PropertyStoreProviderSpi
----------------------------------------------------------------------
diff --git a/integration/store-file/src/main/resources/META-INF/services/org.apache.tamaya.store.spi.PropertyStoreProviderSpi b/integration/store-file/src/main/resources/META-INF/services/org.apache.tamaya.store.spi.PropertyStoreProviderSpi
deleted file mode 100644
index f3199f2..0000000
--- a/integration/store-file/src/main/resources/META-INF/services/org.apache.tamaya.store.spi.PropertyStoreProviderSpi
+++ /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 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.
-#
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/integration/store-hazelcast/src/main/java/org/apache/tamaya/store/internal/HazelcastProprtyStoreProviderSpi.java
----------------------------------------------------------------------
diff --git a/integration/store-hazelcast/src/main/java/org/apache/tamaya/store/internal/HazelcastProprtyStoreProviderSpi.java b/integration/store-hazelcast/src/main/java/org/apache/tamaya/store/internal/HazelcastProprtyStoreProviderSpi.java
deleted file mode 100644
index db567ac..0000000
--- a/integration/store-hazelcast/src/main/java/org/apache/tamaya/store/internal/HazelcastProprtyStoreProviderSpi.java
+++ /dev/null
@@ -1,87 +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.store.internal;
-
-import com.hazelcast.config.Config;
-import com.hazelcast.config.GroupConfig;
-import com.hazelcast.core.Hazelcast;
-import com.hazelcast.core.HazelcastInstance;
-import org.apache.tamaya.spi.ServiceContextManager;
-import org.apache.tamaya.store.PropertyStore;
-import org.apache.tamaya.store.spi.PropertyStoreProviderSpi;
-
-import java.util.Map;
-import java.util.ServiceLoader;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * SPI implmentation for a providing Hazelcast based PropertyStores.
- */
-public class HazelcastProprtyStoreProviderSpi implements PropertyStoreProviderSpi {
- private static final String CONFIG_CLASS_SYS_PROP = "tamaya.store.hazelcast.configClass";
- private static final String CONFIG_GROUP_SYS_PROP = "tamaya.store.hazelcast.groupName";
-
-
-
- private static final Logger LOG = Logger.getLogger(HazelcastProprtyStoreProviderSpi.class.getName());
-
- private HazelcastInstance store;
- private Map<String,HazelcastProprtyStore> stores = new ConcurrentHashMap<>();
-
- public HazelcastProprtyStoreProviderSpi() {
- String customConfig = System.getProperty(CONFIG_CLASS_SYS_PROP);
- Config config = null;
- if(customConfig!=null){
- try {
- config = (Config)Class.forName(customConfig).newInstance();
- LOG.info("Successfully created custom store config for HazelCast store: " + customConfig);
- } catch (Exception e) {
- LOG.log(Level.SEVERE, "Failed to instantiate custom store config for HazelCast store: " + customConfig, e);
- }
- }
- if(config==null){
- config = ServiceContextManager.getServiceContext().getService(Config.class);
- }
- if(config==null) {
- config = new Config();
- GroupConfig gc = new GroupConfig();
- String groupName = System.getProperty(CONFIG_GROUP_SYS_PROP, "Tamaya");
- gc.setName(groupName);
- config.setGroupConfig(gc);
- }
- LOG.info("Starting HazelCast storage with config: " + config);
- store = Hazelcast.getOrCreateHazelcastInstance(config);
- }
-
- @Override
- public PropertyStore getPropertyStore(String storeId) {
- HazelcastProprtyStore propertyStore = stores.get(storeId);
- if(propertyStore==null){
- LOG.info("Creating new distributed configuration map in HazelCast store for " + storeId + "...");
- propertyStore = new HazelcastProprtyStore(store, storeId);
- this.stores.put(storeId, propertyStore);
- }
- return propertyStore;
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/integration/store-ignite/src/main/resources/META-INF/services/org.apache.tamaya.store.PropertyStore
----------------------------------------------------------------------
diff --git a/integration/store-ignite/src/main/resources/META-INF/services/org.apache.tamaya.store.PropertyStore b/integration/store-ignite/src/main/resources/META-INF/services/org.apache.tamaya.store.PropertyStore
deleted file mode 100644
index 0833eac..0000000
--- a/integration/store-ignite/src/main/resources/META-INF/services/org.apache.tamaya.store.PropertyStore
+++ /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.store.internal.IgniteProprtyStore
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-simple/config/README.txt
----------------------------------------------------------------------
diff --git a/metamodel-simple/config/README.txt b/metamodel-simple/config/README.txt
new file mode 100644
index 0000000..3dd71f5
--- /dev/null
+++ b/metamodel-simple/config/README.txt
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+This folder is for testing only. It contains some config files that are to be included by the
+ConfigDirPropertySourceProvider config provider.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-simple/config/test3.properties
----------------------------------------------------------------------
diff --git a/metamodel-simple/config/test3.properties b/metamodel-simple/config/test3.properties
new file mode 100644
index 0000000..9ddef76
--- /dev/null
+++ b/metamodel-simple/config/test3.properties
@@ -0,0 +1,21 @@
+#
+# 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.
+#
+tamaya.ordinal=100000
+test3=3-overridden
+test5=value5
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-simple/pom.xml
----------------------------------------------------------------------
diff --git a/metamodel-simple/pom.xml b/metamodel-simple/pom.xml
new file mode 100644
index 0000000..9c96c28
--- /dev/null
+++ b/metamodel-simple/pom.xml
@@ -0,0 +1,86 @@
+<!--
+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.metamodels</groupId>
+ <artifactId>tamaya-metamodels</artifactId>
+ <version>0.3-incubating-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+ <artifactId>tamaya-metamodels-simple</artifactId>
+ <name>Apache Tamaya Modules Metamodels - Simple</name>
+ <description>Simple Tamaya Metamodel, e.g. feasible for SE commandline tools and simple use cases.</description>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tamaya</groupId>
+ <artifactId>tamaya-core</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tamaya</groupId>
+ <artifactId>tamaya-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-resources</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-formats</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Import-Package>
+ org.apache.tamaya,
+ org.apache.tamaya.spi,
+ org.apache.tamaya.format,
+ javax.annotation,
+ *
+ </Import-Package>
+ <Export-Package>
+ org.apache.tamaya.metamodel.simple
+ </Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/ConfigDirPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/metamodel-simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/ConfigDirPropertySourceProvider.java b/metamodel-simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/ConfigDirPropertySourceProvider.java
new file mode 100644
index 0000000..e3c9cbf
--- /dev/null
+++ b/metamodel-simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/ConfigDirPropertySourceProvider.java
@@ -0,0 +1,81 @@
+/*
+ * 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.metamodel.simple.internal;
+
+
+import org.apache.tamaya.format.ConfigurationData;
+import org.apache.tamaya.format.ConfigurationFormats;
+import org.apache.tamaya.format.FlattenedDefaultPropertySource;
+import org.apache.tamaya.resource.AbstractPathPropertySourceProvider;
+import org.apache.tamaya.spi.PropertySource;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Created by Anatole on 20.03.2015.
+ */
+public class ConfigDirPropertySourceProvider extends AbstractPathPropertySourceProvider {
+
+ public ConfigDirPropertySourceProvider() {
+ super(getConfigLocation());
+ }
+
+ private static String getConfigLocation() {
+ String location = System.getProperty("configdir");
+ if (location == null) {
+ location = "./config";
+ }
+ if (!location.endsWith("/")) {
+ location += "/";
+ }
+ if (!location.startsWith("file:")) {
+ location = "file:" + location;
+ }
+ return location + "**/*.*";
+ }
+
+ @Override
+ protected Collection<PropertySource> getPropertySources(URL url) {
+ try {
+ ConfigurationData config = ConfigurationFormats.readConfigurationData(url);
+ if (config == null) {
+ Logger.getLogger(getClass().getName()).log(Level.INFO,
+ "Failed to read configuration from " + url);
+ return Collections.emptySet();
+ }
+ return asCollection(new FlattenedDefaultPropertySource(config));
+ } catch (Exception e) {
+ Logger.getLogger(getClass().getName()).log(Level.SEVERE,
+ "Failed to read configuration from " + url, e);
+ return Collections.emptySet();
+ }
+ }
+
+ private Collection<PropertySource> asCollection(PropertySource propertySource) {
+ List<PropertySource> result = new ArrayList<>(1);
+ result.add(propertySource);
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/MetainfConfigPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/metamodel-simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/MetainfConfigPropertySourceProvider.java b/metamodel-simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/MetainfConfigPropertySourceProvider.java
new file mode 100644
index 0000000..0edbbc7
--- /dev/null
+++ b/metamodel-simple/src/main/java/org/apache/tamaya/metamodel/simple/internal/MetainfConfigPropertySourceProvider.java
@@ -0,0 +1,62 @@
+/*
+ * 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.metamodel.simple.internal;
+
+
+import org.apache.tamaya.format.ConfigurationData;
+import org.apache.tamaya.format.ConfigurationFormats;
+import org.apache.tamaya.format.FlattenedDefaultPropertySource;
+import org.apache.tamaya.resource.AbstractPathPropertySourceProvider;
+import org.apache.tamaya.spi.PropertySource;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Created by Anatole on 20.03.2015.
+ */
+public class MetainfConfigPropertySourceProvider extends AbstractPathPropertySourceProvider {
+
+ public MetainfConfigPropertySourceProvider() {
+ super("classpath:META-INF/config/**/*.*");
+ }
+
+ @Override
+ protected Collection<PropertySource> getPropertySources(URL url) {
+ try {
+ ConfigurationData config = ConfigurationFormats.readConfigurationData(url);
+ return asCollection(new FlattenedDefaultPropertySource(config));
+ } catch (Exception e) {
+ Logger.getLogger(getClass().getName()).log(Level.SEVERE,
+ "Failed to read configuration from " + url, e);
+ return Collections.emptySet();
+ }
+ }
+
+ private Collection<PropertySource> asCollection(PropertySource propertySource) {
+ List<PropertySource> result = new ArrayList<>(1);
+ result.add(propertySource);
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-simple/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
----------------------------------------------------------------------
diff --git a/metamodel-simple/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider b/metamodel-simple/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
new file mode 100644
index 0000000..2e963e2
--- /dev/null
+++ b/metamodel-simple/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
@@ -0,0 +1,20 @@
+#
+# 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.metamodel.simple.internal.ConfigDirPropertySourceProvider
+org.apache.tamaya.metamodel.simple.internal.MetainfConfigPropertySourceProvider
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-simple/src/test/java/org/apache/tamaya/metamodel/simple/SimpleTest.java
----------------------------------------------------------------------
diff --git a/metamodel-simple/src/test/java/org/apache/tamaya/metamodel/simple/SimpleTest.java b/metamodel-simple/src/test/java/org/apache/tamaya/metamodel/simple/SimpleTest.java
new file mode 100644
index 0000000..677d8fc
--- /dev/null
+++ b/metamodel-simple/src/test/java/org/apache/tamaya/metamodel/simple/SimpleTest.java
@@ -0,0 +1,26 @@
+package org.apache.tamaya.metamodel.simple;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.ConfigurationProvider;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Created by Anatole on 26.07.2015.
+ */
+public class SimpleTest {
+
+ @Test
+ public void testClasspathConfig() {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ assertEquals(config.get("test1"), "1");
+ assertEquals(config.get("test2"), "2");
+ // overridden by file config
+ assertEquals(config.get("test3"), "3-overridden");
+ assertEquals(config.get("test4"), "4");
+ // added by file config
+ assertEquals(config.get("test5"), "value5");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-simple/src/test/resources/META-INF/config/test.properties
----------------------------------------------------------------------
diff --git a/metamodel-simple/src/test/resources/META-INF/config/test.properties b/metamodel-simple/src/test/resources/META-INF/config/test.properties
new file mode 100644
index 0000000..af16b23
--- /dev/null
+++ b/metamodel-simple/src/test/resources/META-INF/config/test.properties
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+test1=1
+test2=2
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-simple/src/test/resources/META-INF/config/test2.properties
----------------------------------------------------------------------
diff --git a/metamodel-simple/src/test/resources/META-INF/config/test2.properties b/metamodel-simple/src/test/resources/META-INF/config/test2.properties
new file mode 100644
index 0000000..58524b7
--- /dev/null
+++ b/metamodel-simple/src/test/resources/META-INF/config/test2.properties
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+test3=3
+test4=4
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/pom.xml
----------------------------------------------------------------------
diff --git a/metamodel-staged/pom.xml b/metamodel-staged/pom.xml
new file mode 100644
index 0000000..b5c96a2
--- /dev/null
+++ b/metamodel-staged/pom.xml
@@ -0,0 +1,114 @@
+<!--
+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.metamodels</groupId>
+ <artifactId>tamaya-metamodels</artifactId>
+ <version>0.3-incubating-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>tamaya-metamodel-staged</artifactId>
+ <name>Apache Tamaya Modules - Staged Configuration</name>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <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-functions</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-resolver</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-spisupport</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-resources</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-formats</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-yaml</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>java-hamcrest</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Import-Package>
+ org.apache.tamaya,
+ org.apache.tamaya.spi,
+ org.apache.tamaya.resources,
+ org.apache.tamaya.spisupport,
+ org.apache.tamaya.functions,
+ javax.annotation,
+ *
+ </Import-Package>
+ <Export-Package>
+ org.apache.tamaya.metamodel.simple
+ </Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/src/main/java/org/apache/tamaya/dsl/DSLFormatManager.java
----------------------------------------------------------------------
diff --git a/metamodel-staged/src/main/java/org/apache/tamaya/dsl/DSLFormatManager.java b/metamodel-staged/src/main/java/org/apache/tamaya/dsl/DSLFormatManager.java
new file mode 100644
index 0000000..916fa49
--- /dev/null
+++ b/metamodel-staged/src/main/java/org/apache/tamaya/dsl/DSLFormatManager.java
@@ -0,0 +1,115 @@
+/*
+ * 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.dsl;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.format.ConfigurationFormat;
+import org.apache.tamaya.format.ConfigurationFormats;
+import org.apache.tamaya.functions.ConfigurationFunctions;
+
+import java.util.*;
+
+/**
+ * Component that manages the current supported formats:
+ * <pre>
+ * TAMAYA:
+ * FORMAT-DEF:
+ * - formats: yaml, properties, xml-properties
+ * </pre>
+ * Hereby:
+ * <ul>
+ * <li><b>profiles</b> defines the available profiles, including implicit default profiles.</li>
+ * </ul>
+ */
+public final class DSLFormatManager {
+
+ private static final DSLFormatManager INSTANCE = new DSLFormatManager();
+
+ /** The currently active formats, in order of precedence, the most significant are the last ones. */
+ private List<ConfigurationFormat> formats = new ArrayList<>();
+ /** The currently active suffixes, in order of precedence, the most significant are the last ones. */
+ private List<String> suffixes = new ArrayList<>();
+
+
+ /**
+ * Get the current instance.
+ * @return the current profile manager, never null.
+ */
+ public static DSLFormatManager getInstance(){
+ return INSTANCE;
+ }
+
+ private DSLFormatManager(){
+ Configuration metaConfig = MetaConfiguration.getConfiguration();
+ Configuration formatsConfig = metaConfig.with(
+ ConfigurationFunctions.section("TAMAYA.FORMATS"));
+ String[] formats = formatsConfig.getOrDefault("formats","yamk,properties,ini").split(",");
+ this.formats.addAll(ConfigurationFormats.getFormats(formats));
+ String[] suffixes = formatsConfig.getOrDefault("suffixes","yml,properties,ini").split(",");
+ for(String sfx:suffixes){
+ sfx = sfx.trim();
+ if(sfx.isEmpty()){
+ continue;
+ }
+ this.suffixes.add(sfx);
+ }
+ }
+
+
+ /**
+ * Allows to check if a suffix is currently activated.
+ * @param suffix the suffix name, not null.
+ * @return true, if the profile is defined.
+ */
+ public boolean isSuffixDefined(String suffix){
+ return this.suffixes.contains(suffix);
+ }
+
+ /**
+ * Allows to check if a format is selected.
+ * @param formatName the format name, not null.
+ * @return true, if the format is a selected.
+ */
+ public boolean isFormatSelected(String formatName){
+ for(ConfigurationFormat format:formats){
+ if(format.getName().equals(formatName)){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Get the list of currently active suffixes.
+ * @return the list of currently active suffixes, never null.
+ */
+ public List<String> getSuffixes(){
+ return Collections.unmodifiableList(suffixes);
+ }
+
+ /**
+ * Get the list of currently active formats.
+ * @return the list of currently active formats, never null.
+ */
+ public List<ConfigurationFormat> getFormats(){
+ return Collections.unmodifiableList(formats);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/src/main/java/org/apache/tamaya/dsl/MetaConfiguration.java
----------------------------------------------------------------------
diff --git a/metamodel-staged/src/main/java/org/apache/tamaya/dsl/MetaConfiguration.java b/metamodel-staged/src/main/java/org/apache/tamaya/dsl/MetaConfiguration.java
new file mode 100644
index 0000000..a16bfa8
--- /dev/null
+++ b/metamodel-staged/src/main/java/org/apache/tamaya/dsl/MetaConfiguration.java
@@ -0,0 +1,144 @@
+/*
+ * 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.dsl;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.format.ConfigurationData;
+import org.apache.tamaya.format.ConfigurationFormat;
+import org.apache.tamaya.format.ConfigurationFormats;
+import org.apache.tamaya.json.YAMLFormat;
+import org.apache.tamaya.resource.ConfigResources;
+import org.apache.tamaya.spi.ConfigurationContextBuilder;
+import org.apache.tamaya.spisupport.DefaultConfiguration;
+import org.apache.tamaya.spisupport.MapPropertySource;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Meta environment configuration builder and accessor. Normally this class shoulds never be accessed
+ * by client code. But it could be useful for extensions that extend the meta-configuration capabilities
+ * of tamaya having access to the meta-configuration, so they can read their own meta-entries to
+ * setup whatever features they implement.
+ */
+public final class MetaConfiguration {
+
+ private static final Logger LOGGER = Logger.getLogger(MetaConfiguration.class.getName());
+ private static MetaConfiguration INSTANCE = new MetaConfiguration();
+
+ private Configuration config;
+ private String resourceExpression;
+ private String[] formatNames;
+
+ /**
+ * Initializes the metaconfiguration.
+ * @param resourceExpression the resource expression that defines the resources to load.
+ * @param formatNames the format names to be used.
+ */
+ private void init(String resourceExpression, String... formatNames){
+ if(this.config!=null){
+ LOGGER.warning(">>> Reset of Meta-Configuration resource : " + resourceExpression);
+ LOGGER.warning(">>> Reset of Meta-Configuration formats : " + Arrays.toString(formatNames));
+ }
+ if(resourceExpression==null){
+ resourceExpression = "tamaya-config.*";
+ }
+ LOGGER.info(">>> Meta-Configuration resource : " + resourceExpression);
+ ConfigurationFormat[] formats = loadFormats(formatNames);
+ ConfigurationContextBuilder builder = ConfigurationProvider.getConfigurationContextBuilder();
+ for(URL url:ConfigResources.getResourceResolver().getResources(resourceExpression)) {
+ for(ConfigurationFormat format:formats) {
+ if(format.accepts(url)){
+ try(InputStream is = url.openStream()){
+ ConfigurationData data = format.readConfiguration(url.toString(), is);
+ builder.addPropertySources(new MapPropertySource(
+ url.toString(), data.getCombinedProperties()));
+ }catch(Exception e){
+ LOGGER.log(Level.INFO, "Failed to read " + url + " with format " + format, e);
+ }
+ }
+ }
+ }
+ this.config = new DefaultConfiguration(builder.build());
+ LOGGER.info("Meta-Configuration read: " + this.config.getProperties().size() + " entries.");
+ }
+
+ private ConfigurationFormat[] loadFormats(String... formatNames) {
+ List<ConfigurationFormat> formats = new ArrayList<>();
+ if(formatNames.length==0) {
+ String metaFormats = System.getProperty("tamaya.meta-formats");
+ if (metaFormats != null) {
+ formatNames = metaFormats.split(",");
+ }
+ }
+ for (String formatName : formatNames) {
+ formats.addAll(ConfigurationFormats.getFormats(formatName));
+ }
+ if(formats.isEmpty()){
+ formats.addAll(ConfigurationFormats.getFormats("yaml"));
+ }
+ if(formats.isEmpty()){
+ formats.add(new YAMLFormat());
+ }
+ LOGGER.info(">>> Meta-Configuration formats : " + formats);
+ return formats.toArray(new ConfigurationFormat[formats.size()]);
+ }
+
+ /**
+ * Access the system's meta-configuration, initialize if necessary. Normally this class shoulds never be accessed
+ * by client code. But it could be useful for extensions that extend the meta-configuration capabilities
+ * of tamaya having access to the meta-configuration, so they can read their own meta-entries to
+ * setup whatever features they implement.
+ * @return the meta-configuration instance used for setting up the Tamaya's application configuration
+ * model.
+ */
+ public static Configuration getConfiguration(){
+ if(INSTANCE.config==null) {
+ INSTANCE.init(null);
+ }
+ return INSTANCE.config;
+ }
+
+ /**
+ * Access the system's meta-configuration, initialize if necessary. Normally this class shoulds never be accessed
+ * by client code. But it could be useful for extensions that extend the meta-configuration capabilities
+ * of tamaya having access to the meta-configuration, so they can read their own meta-entries to
+ * setup whatever features they implement.
+ *
+ * @param resourceExpression the resource expression that defines where the metaconfiguration
+ * files/resources are located.
+ * @param formatNames the formats supported, if null all formats found are tried for each resource(=URL).
+ * @return the meta-configuration instance used for setting up the Tamaya's application configuration
+ * model.
+ */
+ public static Configuration getConfiguration(String resourceExpression,
+ String... formatNames){
+ if(INSTANCE.config==null) {
+ INSTANCE.init(resourceExpression, formatNames);
+ }
+ return INSTANCE.config;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/07b10131/metamodel-staged/src/main/java/org/apache/tamaya/dsl/ProfileManager.java
----------------------------------------------------------------------
diff --git a/metamodel-staged/src/main/java/org/apache/tamaya/dsl/ProfileManager.java b/metamodel-staged/src/main/java/org/apache/tamaya/dsl/ProfileManager.java
new file mode 100644
index 0000000..70211ca
--- /dev/null
+++ b/metamodel-staged/src/main/java/org/apache/tamaya/dsl/ProfileManager.java
@@ -0,0 +1,213 @@
+/*
+ * 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.dsl;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.functions.ConfigurationFunctions;
+import org.apache.tamaya.resolver.Resolver;
+import org.apache.tamaya.resolver.spi.ExpressionResolver;
+import org.apache.tamaya.spi.ServiceContextManager;
+
+import java.util.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Component that manages the current setup profiles for this environment/runtime. The profile manager
+ * reads the profile meta configuration that looks as follows:
+ * <pre>
+ * TAMAYA:
+ * PROFILES-DEF:
+ * - profiles: DEFAULTS,DEV,TEST,PTA,PROD
+ * - defaults: DEFAULTS
+ * - default-active: DEV
+ * - evaluation: ${sys:ENV}, ${env:ENV}
+ * </pre>
+ * Hereby:
+ * <ul>
+ * <li><b>profiles</b> defines the available profiles, including implicit default profiles.</li>
+ * <li><b>defaults</b> defines the profiles that are loaded implicitly first as defaults.</li>
+ * <li><b>default-active</b> defines the profile(s) activated by default, when no profile setting could be evaluated.
+ * <li><b>evaluation</b> defines the resolution expressions to be used to evaluate the current profiles active.
+ * By default {@code ${sys:ENV}, ${env:ENV}} is used, which tries to evaluate {@code ENV} using system and
+ * environment properties. Refere to the {@code tamaya-resolver} module for further details on resolvers and
+ * expressions and see {@link Resolver#evaluateExpression(String, boolean)}.
+ * </ul>
+ */
+public final class ProfileManager {
+
+ private static final Logger LOG = Logger.getLogger(ProfileManager.class.getName());
+ private static final ProfileManager INSTANCE = new ProfileManager();
+
+ /** The currently active profiles, in order of precedence, the most significant are the last ones. */
+ private List<String> activeProfiles = new ArrayList<>();
+ /** A set of all defined profiles. */
+ private Set<String> profiles = new HashSet<>();
+ /** The current used default profiles, loaded initially, before all other profiles are loaded. */
+ private List<String> defaultProfiles = new ArrayList<>();
+
+
+ /**
+ * Get the current instance.
+ * @return the current profile manager, never null.
+ */
+ public static ProfileManager getInstance(){
+ return INSTANCE;
+ }
+
+ private ProfileManager(){
+ Configuration metaConfig = MetaConfiguration.getConfiguration();
+ Configuration profileConfig = metaConfig.with(
+ ConfigurationFunctions.section("TAMAYA.PROFILES-DEF"));
+ String[] selectables = profileConfig.getOrDefault("profiles","DEFAULT,DEV,TEST,PROD").split(",");
+ for(String sel:selectables){
+ sel = sel.trim();
+ if(sel.isEmpty()){
+ continue;
+ }
+ this.profiles.add(sel);
+ }
+ String[] defaults = profileConfig.getOrDefault("defaults","DEFAULT").split(",");
+ for(String def:defaults){
+ def = def.trim();
+ if(def.isEmpty()){
+ continue;
+ }
+ if(!isProfileDefined(def)){
+ throw new ConfigException("Invalid profile encountered: " +def + ", valid are: " + profiles);
+ }
+ this.defaultProfiles.add(def);
+ }
+ String[] expressions = profileConfig.getOrDefault("evaluation","${sys:ENV}, ${env:ENV}").split(",");
+ String currentEnvironment = null;
+ for(String exp:expressions){
+ exp = exp.trim();
+ if(exp.isEmpty()){
+ continue;
+ }
+ currentEnvironment = evaluateExpression(exp);
+ if(currentEnvironment!=null){
+ currentEnvironment = currentEnvironment.trim();
+ if(!currentEnvironment.isEmpty()){
+ break;
+ }
+ }
+ }
+ if(currentEnvironment==null|| currentEnvironment.isEmpty()){
+ currentEnvironment = profileConfig.getOrDefault("default-active", "DEV");
+ }
+ this.activeProfiles.addAll(defaultProfiles);
+ String[] profilesActive = currentEnvironment.split(",");
+ for(String prof:profilesActive){
+ prof = prof.trim();
+ if(prof.isEmpty()){
+ continue;
+ }
+ if(!isProfileDefined(prof)){
+ throw new ConfigException("Invalid profile encountered: " +prof + ", valid are: " + profiles);
+ }
+ this.activeProfiles.add(prof);
+ }
+ }
+
+ /**
+ * Evaluates the expressions to evaluate the current profile.
+ * Currently the following expressions are supported
+ * <pre>
+ * sys-property:xxx
+ * env-property:xxx
+ * </pre>
+ * {@code xxx} is the corresponding key.
+ * @param currentProfileExpression the profile expression.
+ * @return the evaluated String, or null.
+ */
+ private String evaluateExpression(String currentProfileExpression){
+ currentProfileExpression = currentProfileExpression.trim();
+ List<ExpressionResolver> resolvers = new ArrayList<>();
+ for(ExpressionResolver res: ServiceContextManager.getServiceContext().getServices(ExpressionResolver.class)){
+ resolvers.add(res);
+ }
+ for(ExpressionResolver res:resolvers){
+ if(currentProfileExpression.startsWith(res.getResolverPrefix())){
+ try{
+ return res.evaluate(currentProfileExpression.substring(res.getResolverPrefix().length()));
+ }catch(Exception e){
+ LOG.log(Level.FINEST, "Error evaluating resolver: " + res, e);
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Allows to check if a profile is currently active.
+ * @param profileName the profile name, not null.
+ * @return true, if the profile is active.
+ */
+ public boolean isProfileActive(String profileName){
+ return this.activeProfiles.contains(profileName);
+ }
+
+ /**
+ * Allows to check if a profile is currently defined.
+ * @param profileName the profile name, not null.
+ * @return true, if the profile is defined.
+ */
+ public boolean isProfileDefined(String profileName){
+ return this.profiles.contains(profileName);
+ }
+
+ /**
+ * Allows to check if a profile is a default profile.
+ * @param profileName the profile name, not null.
+ * @return true, if the profile is a default profile.
+ */
+ public boolean isProfileDefault(String profileName){
+ return this.defaultProfiles.contains(profileName);
+ }
+
+ /**
+ * Get the list of currently active profiles.
+ * @return the list of currently active profiles, in order of precedence, the most significant
+ * are the last ones, never null.
+ */
+ public List<String> getActiveProfiles(){
+ return Collections.unmodifiableList(activeProfiles);
+ }
+
+ /**
+ * Get the list of currently active profiles.
+ * @return the list of currently active profiles, in order of precedence, the most significant
+ * are the last ones, never null.
+ */
+ public List<String> getDefaultProfiles(){
+ return Collections.unmodifiableList(defaultProfiles);
+ }
+
+ /**
+ * Get the list of currently active profiles.
+ * @return the list of currently active profiles, in order of precedence, the most significant
+ * are the last ones, never null.
+ */
+ public Set<String> getAllProfiles(){
+ return Collections.unmodifiableSet(profiles);
+ }
+
+}