You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2016/02/02 17:16:15 UTC
[6/8] incubator-tamaya git commit: TAMAYA-136: Adding PropertyValue
for PropertySource SPI. All changes and test fixes in all modules/examples
relevant for release.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d778cb81/modules/server/src/main/java/org/apache/tamaya/server/internal/DefaultConfigAdminService.java
----------------------------------------------------------------------
diff --git a/modules/server/src/main/java/org/apache/tamaya/server/internal/DefaultConfigAdminService.java b/modules/server/src/main/java/org/apache/tamaya/server/internal/DefaultConfigAdminService.java
deleted file mode 100644
index 47500d1..0000000
--- a/modules/server/src/main/java/org/apache/tamaya/server/internal/DefaultConfigAdminService.java
+++ /dev/null
@@ -1,136 +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.server.internal;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.server.spi.ConfigAdminService;
-import org.apache.tamaya.spi.PropertyConverter;
-import org.apache.tamaya.spi.PropertyFilter;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.MediaType;
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * Implementation of the ConfigProviderService backend interface for serving configuration.
- */
-public class DefaultConfigAdminService implements ConfigAdminService {
- @Override
- public String formatCombinationPolicy(MediaType mediaType, PropertyValueCombinationPolicy propertyValueCombinationPolicy, HttpServletRequest request) {
- return null;
- }
-
- @Override
- public String formatPropertyConverter(MediaType mediaType, List<PropertyConverter> propertyConverter, HttpServletRequest request) {
- return null;
- }
-
- @Override
- public String formatPropertyFilter(MediaType mediaType, String filterClass, HttpServletRequest request) {
- return null;
- }
-
- @Override
- public String formatPropertySource(MediaType mediaType, String sourceId, String sourceClass, HttpServletRequest request) {
- return null;
- }
-
- @Override
- public List<PropertyConverter> collectPropertyConverters(String converterClass, String targetType) {
- List<PropertyConverter> result = new ArrayList<>();
- TypeLiteral type = null;
- if(targetType!=null){
- try {
- type = TypeLiteral.of(Class.forName(targetType));
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
- List<PropertyConverter> list = ConfigurationProvider.getConfigurationContext().getPropertyConverters(type);
- for(PropertyConverter conv:list){
- if(converterClass!=null && !conv.getClass().getName().matches(converterClass)){
- continue;
- }
- if(targetType!=null && !conv.getClass().getName().matches(converterClass)){
- continue;
- }
- result.add(conv);
- }
- return result;
- }
-
- @Override
- public List<PropertyFilter> collectPropertyFilters(String filterClass) {
- List<PropertyFilter> result = new ArrayList<>();
- for(PropertyFilter conv:ConfigurationProvider.getConfigurationContext().getPropertyFilters()){
- if(filterClass!=null && !conv.getClass().getName().matches(filterClass)){
- continue;
- }
- result.add(conv);
- }
- return result;
- }
-
- @Override
- public List<PropertySource> collectPropertySources(String sourceId, String sourceClass) {
- List<PropertySource> result = new ArrayList<>();
- for(PropertySource conv:ConfigurationProvider.getConfigurationContext().getPropertySources()){
- if(sourceClass!=null && !conv.getClass().getName().matches(sourceClass)){
- continue;
- }
- if(sourceId!=null && !conv.getName().matches(sourceId)) {
- continue;
- }
- result.add(conv);
- }
- return result;
- }
-
-// @Override
-// public String getConfigurationWithPath(String path, MediaType mediaType, String scope, String scopeId, HttpServletRequest request){
-// Map<String,String> requestInfo = new HashMap<>();
-// requestInfo.put("filter",path);
-// requestInfo.put("timestamp", String.valueOf(System.currentTimeMillis()));
-// requestInfo.put("format", mediaType.toString());
-// if(scope!=null && scopeId!=null){
-// return getScopedConfigurationWithPath(scope, scopeId, path, request, mediaType, requestInfo);
-// }
-// Configuration config = ConfigurationProvider.getConfiguration()
-// .with(ConfigurationFunctions.sectionsRecursive(path.split(",")));
-// if(mediaType.equals(MediaType.APPLICATION_JSON_TYPE)) {
-// return config.query(ConfigurationFunctions.jsonInfo(requestInfo));
-// }
-// if(mediaType.equals(MediaType.APPLICATION_XML_TYPE)) {
-// return config.query(ConfigurationFunctions.xmlInfo(requestInfo));
-// }
-// if(mediaType.equals(MediaType.TEXT_HTML_TYPE)) {
-// return config.query(ConfigurationFunctions.htmlInfo(requestInfo));
-// }
-// if(mediaType.equals(MediaType.TEXT_PLAIN_TYPE)) {
-// return config.query(ConfigurationFunctions.textInfo(requestInfo));
-// }
-// return null;
-// }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d778cb81/modules/server/src/main/java/org/apache/tamaya/server/internal/DefaultConfigService.java
----------------------------------------------------------------------
diff --git a/modules/server/src/main/java/org/apache/tamaya/server/internal/DefaultConfigService.java b/modules/server/src/main/java/org/apache/tamaya/server/internal/DefaultConfigService.java
deleted file mode 100644
index 5bb4132..0000000
--- a/modules/server/src/main/java/org/apache/tamaya/server/internal/DefaultConfigService.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.server.internal;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.functions.ConfigurationFunctions;
-import org.apache.tamaya.server.spi.ConfigService;
-import org.apache.tamaya.server.spi.ScopeManager;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.MediaType;
-import java.util.HashMap;
-import java.util.Map;
-
-
-/**
- * Implementation of the ConfigProviderService backend interface for serving configuration.
- */
-public class DefaultConfigService implements ConfigService {
-
- @Override
- public String getConfigurationWithPath(String path, MediaType mediaType, String scope, String scopeId, HttpServletRequest request){
- Map<String,String> requestInfo = new HashMap<>();
- requestInfo.put("filter",path);
- requestInfo.put("timestamp", String.valueOf(System.currentTimeMillis()));
- requestInfo.put("format", mediaType.toString());
- if(scope!=null && scopeId!=null){
- return getScopedConfigurationWithPath(scope, scopeId, path, request, mediaType, requestInfo);
- }
- Configuration config = ConfigurationProvider.getConfiguration()
- .with(ConfigurationFunctions.sectionsRecursive(path.split(",")));
- if(mediaType.equals(MediaType.APPLICATION_JSON_TYPE)) {
- return config.query(ConfigurationFunctions.jsonInfo(requestInfo));
- }
- if(mediaType.equals(MediaType.APPLICATION_XML_TYPE)) {
- return config.query(ConfigurationFunctions.xmlInfo(requestInfo));
- }
- if(mediaType.equals(MediaType.TEXT_HTML_TYPE)) {
- return config.query(ConfigurationFunctions.htmlInfo(requestInfo));
- }
- if(mediaType.equals(MediaType.TEXT_PLAIN_TYPE)) {
- return config.query(ConfigurationFunctions.textInfo(requestInfo));
- }
- return null;
- }
-
- @Override
- public String getConfiguration(MediaType mediaType, String scope, String scopeId, HttpServletRequest request) {
- Map<String,String> requestInfo = new HashMap<>();
- requestInfo.put("timestamp", String.valueOf(System.currentTimeMillis()));
- if(scope!=null && scopeId!=null){
- return getScopedConfiguration(scope, scopeId, request, mediaType, requestInfo);
- }
- Configuration config = ConfigurationProvider.getConfiguration();
- if(mediaType.equals(MediaType.APPLICATION_JSON_TYPE)) {
- return config.query(ConfigurationFunctions.jsonInfo(requestInfo));
- }
- if(mediaType.equals(MediaType.APPLICATION_XML_TYPE)) {
- return config.query(ConfigurationFunctions.xmlInfo(requestInfo));
- }
- if(mediaType.equals(MediaType.TEXT_HTML_TYPE)) {
- return config.query(ConfigurationFunctions.htmlInfo(requestInfo));
- }
- if(mediaType.equals(MediaType.TEXT_PLAIN_TYPE)) {
- return config.query(ConfigurationFunctions.textInfo(requestInfo));
- }
- return null;
- }
-
- private String getScopedConfigurationWithPath(String scope, String scopeId, String path, HttpServletRequest request,
- MediaType mediaType, Map<String,String> requestInfo) {
- requestInfo.put("scope", scope);
- requestInfo.put("scopeId", scopeId);
- Configuration config = ConfigurationProvider.getConfiguration()
- .with(ScopeManager.getScope(scope, scopeId)).with(ConfigurationFunctions.sectionsRecursive(path.split(",")));
- if(mediaType.equals(MediaType.APPLICATION_JSON_TYPE)) {
- return config.query(ConfigurationFunctions.jsonInfo(requestInfo));
- }
- if(mediaType.equals(MediaType.APPLICATION_XML_TYPE)) {
- return config.query(ConfigurationFunctions.xmlInfo(requestInfo));
- }
- if(mediaType.equals(MediaType.TEXT_HTML_TYPE)) {
- return config.query(ConfigurationFunctions.htmlInfo(requestInfo));
- }
- if(mediaType.equals(MediaType.TEXT_PLAIN_TYPE)) {
- return config.query(ConfigurationFunctions.textInfo(requestInfo));
- }
- return null;
- }
-
- private String getScopedConfiguration(String scope, String scopeId, HttpServletRequest request, MediaType mediaType,
- Map<String,String> requestInfo) {
- requestInfo.put("scope", scope);
- requestInfo.put("scopeId", scopeId);
- Configuration config = ConfigurationProvider.getConfiguration().with(ScopeManager.getScope(scope, scopeId));
- if(mediaType.equals(MediaType.APPLICATION_JSON_TYPE)) {
- return config.query(ConfigurationFunctions.jsonInfo(requestInfo));
- }
- if(mediaType.equals(MediaType.APPLICATION_XML_TYPE)) {
- return config.query(ConfigurationFunctions.xmlInfo(requestInfo));
- }
- if(mediaType.equals(MediaType.TEXT_HTML_TYPE)) {
- return config.query(ConfigurationFunctions.htmlInfo(requestInfo));
- }
- if(mediaType.equals(MediaType.TEXT_PLAIN_TYPE)) {
- return config.query(ConfigurationFunctions.textInfo(requestInfo));
- }
- return null;
- }
-
- @Override
- public void updateConfiguration(String payload, HttpServletRequest request) {
- throw new UnsupportedOperationException("UPDATE Configuration: Not implemented");
- }
-
- @Override
- public void deleteConfiguration(String paths, HttpServletRequest request) {
- throw new UnsupportedOperationException("DELETE Configuration: Not implemented");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d778cb81/modules/server/src/main/java/org/apache/tamaya/server/internal/MediaTypeUtil.java
----------------------------------------------------------------------
diff --git a/modules/server/src/main/java/org/apache/tamaya/server/internal/MediaTypeUtil.java b/modules/server/src/main/java/org/apache/tamaya/server/internal/MediaTypeUtil.java
deleted file mode 100644
index 3c5a31c..0000000
--- a/modules/server/src/main/java/org/apache/tamaya/server/internal/MediaTypeUtil.java
+++ /dev/null
@@ -1,58 +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.server.internal;
-
-import javax.ws.rs.core.MediaType;
-
-/**
- * Simple utility class.
- */
-public final class MediaTypeUtil {
- /** Singleton constructor. */
- private MediaTypeUtil(){}
-
- /**
- * Compares the given MIME type String and tries to evaluate the MIME type matching best.
- * Currently it select one of application/xml, application/json, text/plain and text/html.
- * if none is matching application/json is returned by default.
- * @param formats the formats to check.
- * @return the selected MediaType
- */
- public static MediaType getMediaType(String... formats) {
- for(String format:formats) {
- if (format.equalsIgnoreCase(MediaType.APPLICATION_XML)) {
- return MediaType.APPLICATION_XML_TYPE;
- } else if (format.equalsIgnoreCase(MediaType.APPLICATION_JSON)) {
- return MediaType.APPLICATION_JSON_TYPE;
- } else if (format.equalsIgnoreCase(MediaType.TEXT_HTML)) {
- return MediaType.TEXT_HTML_TYPE;
- } else if (format.equalsIgnoreCase(MediaType.TEXT_PLAIN)) {
- return MediaType.TEXT_PLAIN_TYPE;
- }
- }
- for(String format:formats) {
- if (format.contains(MediaType.APPLICATION_XML)) {
- return MediaType.APPLICATION_XML_TYPE;
- } else if (format.contains(MediaType.APPLICATION_JSON)) {
- return MediaType.APPLICATION_JSON_TYPE;
- }
- }
- return MediaType.APPLICATION_JSON_TYPE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d778cb81/modules/server/src/main/java/org/apache/tamaya/server/internal/RestConfigAdminService.java
----------------------------------------------------------------------
diff --git a/modules/server/src/main/java/org/apache/tamaya/server/internal/RestConfigAdminService.java b/modules/server/src/main/java/org/apache/tamaya/server/internal/RestConfigAdminService.java
deleted file mode 100644
index e7f9090..0000000
--- a/modules/server/src/main/java/org/apache/tamaya/server/internal/RestConfigAdminService.java
+++ /dev/null
@@ -1,133 +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.server.internal;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.server.spi.ConfigAdminService;
-import org.apache.tamaya.spi.PropertyConverter;
-import org.apache.tamaya.spi.PropertyFilter;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.util.List;
-
-
-/**
- * Implementation of the JAX-RS interface for serving configuration.
- */
-public class RestConfigAdminService {
-
- private final ConfigAdminService adminService = ServiceContextManager.getServiceContext()
- .getService(ConfigAdminService.class);
-
- @GET
- @Path("/config/admin/source")
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.WILDCARD})
- public String getPropertySource(@Context HttpServletRequest request){
- MediaType mediaType = MediaTypeUtil.getMediaType(request.getParameter("format"), request.getHeader(HttpHeaders.ACCEPT));
- String sourceId = request.getParameter("name");
- String sourceClass = request.getParameter("class");
- List<PropertySource> propertySources = adminService.collectPropertySources(sourceId, sourceClass);
- try {
- String response = adminService.formatPropertySource(mediaType, sourceId, sourceClass, request);
- if(response!=null){
- Response.status(Response.Status.OK).header(HttpHeaders.CONTENT_ENCODING, "utf-8").type(mediaType);
- return response;
- }
- Response.status(Response.Status.BAD_REQUEST).header(HttpHeaders.CONTENT_ENCODING, "utf-8");
- return propertySources.toString();
- } catch(Exception e){
- Response.status(Response.Status.INTERNAL_SERVER_ERROR);
- return null;
- }
- }
-
- @GET
- @Path("/config/admin/filter")
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.WILDCARD})
- public String getPropertyFilter(@Context HttpServletRequest request){
- MediaType mediaType = MediaTypeUtil.getMediaType(request.getParameter("format"), request.getHeader(HttpHeaders.ACCEPT));
- String filterClass = request.getParameter("class");
- List<PropertyFilter> propertyFilter = adminService.collectPropertyFilters(filterClass);
- try {
- String response = adminService.formatPropertyFilter(mediaType, filterClass, request);
- if(response!=null){
- Response.status(Response.Status.OK).header(HttpHeaders.CONTENT_ENCODING, "utf-8").type(mediaType);
- return response;
- }
- Response.status(Response.Status.BAD_REQUEST).header(HttpHeaders.CONTENT_ENCODING, "utf-8");
- return propertyFilter.toString();
- } catch(Exception e){
- Response.status(Response.Status.INTERNAL_SERVER_ERROR);
- return null;
- }
- }
-
- @GET
- @Path("/config/admin/converter")
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.WILDCARD})
- public String getPropertyConverter(@Context HttpServletRequest request){
- MediaType mediaType = MediaTypeUtil.getMediaType(request.getParameter("format"), request.getHeader(HttpHeaders.ACCEPT));
- String converterClass = request.getParameter("class");
- String targetType = request.getParameter("target");
- List<PropertyConverter> propertyConverter = adminService.collectPropertyConverters(converterClass, targetType);
- try {
- String response = adminService.formatPropertyConverter(mediaType, propertyConverter, request);
- if(response!=null){
- Response.status(Response.Status.OK).header(HttpHeaders.CONTENT_ENCODING, "utf-8").type(mediaType);
- return response;
- }
- Response.status(Response.Status.BAD_REQUEST).header(HttpHeaders.CONTENT_ENCODING, "utf-8");
- return propertyConverter.toString();
- } catch(Exception e){
- Response.status(Response.Status.INTERNAL_SERVER_ERROR);
- return null;
- }
- }
-
-
- @GET
- @Path("/config/admin/combination")
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.WILDCARD})
- public String getCombinationPolicy(@Context HttpServletRequest request){
- MediaType mediaType = MediaTypeUtil.getMediaType(request.getParameter("format"), request.getHeader(HttpHeaders.ACCEPT));
- try {
- String response = adminService.formatCombinationPolicy(mediaType, ConfigurationProvider.getConfigurationContext().getPropertyValueCombinationPolicy(), request);
- if(response!=null){
- Response.status(Response.Status.OK).header(HttpHeaders.CONTENT_ENCODING, "utf-8").type(mediaType);
- return response;
- }
- Response.status(Response.Status.BAD_REQUEST).header(HttpHeaders.CONTENT_ENCODING, "utf-8");
- return null;
- } catch(Exception e){
- Response.status(Response.Status.INTERNAL_SERVER_ERROR);
- return null;
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d778cb81/modules/server/src/main/java/org/apache/tamaya/server/internal/RestConfigService.java
----------------------------------------------------------------------
diff --git a/modules/server/src/main/java/org/apache/tamaya/server/internal/RestConfigService.java b/modules/server/src/main/java/org/apache/tamaya/server/internal/RestConfigService.java
deleted file mode 100644
index 6e16c61..0000000
--- a/modules/server/src/main/java/org/apache/tamaya/server/internal/RestConfigService.java
+++ /dev/null
@@ -1,103 +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.server.internal;
-
-import org.apache.tamaya.server.spi.ConfigService;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-
-/**
- * Implementation of the JAX-RS interface for serving configuration.
- */
-public class RestConfigService {
-
- private final ConfigService configService = ServiceContextManager.getServiceContext()
- .getService(ConfigService.class);
-
- @GET
- @Path("/config/filtered/{path}")
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_HTML, MediaType.TEXT_PLAIN, MediaType.WILDCARD})
- public String getConfigurationWithPath(@PathParam("path") String path,
- @Context HttpServletRequest request){
- MediaType mediaType = MediaTypeUtil.getMediaType(request.getParameter("format"), request.getHeader(HttpHeaders.ACCEPT));
- String scope = request.getParameter("scope");
- String scopeId = request.getParameter("scopeId");
- try {
- String response = configService.getConfigurationWithPath(path, mediaType, scope, scopeId, request);
- if(response!=null){
- Response.status(Response.Status.OK).header(HttpHeaders.CONTENT_ENCODING, "utf-8").type(mediaType);
- }else {
- Response.status(Response.Status.BAD_REQUEST);
- }
- return response;
- } catch(Exception e){
- Response.status(Response.Status.INTERNAL_SERVER_ERROR);
- return null;
- }
- }
-
-
-
- @GET
- @Path("/config")
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_HTML, MediaType.TEXT_PLAIN, MediaType.WILDCARD})
- public String getConfiguration(@Context HttpServletRequest request) {
- MediaType mediaType = MediaTypeUtil.getMediaType(request.getParameter("format"), request.getHeader(HttpHeaders.ACCEPT));
- String scope = request.getParameter("scope");
- String scopeId = request.getParameter("scopeId");
- try {
- String response = configService.getConfiguration(mediaType, scope, scopeId, request);
- if(response!=null){
- Response.status(Response.Status.OK).header(HttpHeaders.CONTENT_ENCODING, "utf-8").type(mediaType);
- }else {
- Response.status(Response.Status.BAD_REQUEST);
- }
- return response;
- } catch(Exception e){
- Response.status(Response.Status.INTERNAL_SERVER_ERROR);
- return null;
- }
- }
-
- @Path("/config/update")
- @PUT
- public String updateConfiguration(String payload, @Context HttpServletRequest request) {
- Response.status(Response.Status.INTERNAL_SERVER_ERROR);
- return "UPDATE Configuration: Not implemented";
- }
-
- @Path("/config/delete")
- @DELETE
- public String deleteConfiguration(String paths, @Context HttpServletRequest request) {
- Response.status(Response.Status.INTERNAL_SERVER_ERROR);
- return "DELETE Configuration: Not implemented";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d778cb81/modules/server/src/main/java/org/apache/tamaya/server/internal/SimpleServer.java
----------------------------------------------------------------------
diff --git a/modules/server/src/main/java/org/apache/tamaya/server/internal/SimpleServer.java b/modules/server/src/main/java/org/apache/tamaya/server/internal/SimpleServer.java
deleted file mode 100644
index ee37118..0000000
--- a/modules/server/src/main/java/org/apache/tamaya/server/internal/SimpleServer.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.server.internal;
-
-
-import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
-import org.apache.tamaya.server.Server;
-
-/**
- * CXF based implementation of a JAX-RS server, serving the {@link DefaultConfigService} service.
- */
-public class SimpleServer implements Server {
- /** The CXF endpoint. */
- private org.apache.cxf.endpoint.Server cxfEndpoint;
-
- /**
- * Starts the CXF server under the port.
- * @param port the port.
- */
- public void start(int port) {
- if(cxfEndpoint!=null){
- if(cxfEndpoint.isStarted()){
- return;
- }
- // start it at the end...
- } else {
- JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
- sf.setServiceBeanObjects(new RestConfigService());
- sf.setAddress("http://localhost:" + port + "/");
- cxfEndpoint = sf.create();
- }
- cxfEndpoint.start();
- }
-
- /**
- * Returns the current started state.
- * @return true, if the server is started.
- */
- public boolean isStarted(){
- if(cxfEndpoint!=null){
- return cxfEndpoint.isStarted();
- }
- return false;
- }
-
- /**
- * Stops the server if running.
- */
- public void stop(){
- if(cxfEndpoint!=null){
- cxfEndpoint.stop();
- }
- }
-
- /**
- * Destroy the server.
- */
- public void destroy(){
- if(cxfEndpoint!=null){
- cxfEndpoint.destroy();
- cxfEndpoint = null;
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d778cb81/modules/server/src/main/java/org/apache/tamaya/server/spi/ConfigAdminService.java
----------------------------------------------------------------------
diff --git a/modules/server/src/main/java/org/apache/tamaya/server/spi/ConfigAdminService.java b/modules/server/src/main/java/org/apache/tamaya/server/spi/ConfigAdminService.java
deleted file mode 100644
index 97a67a0..0000000
--- a/modules/server/src/main/java/org/apache/tamaya/server/spi/ConfigAdminService.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.server.spi;
-
-import org.apache.tamaya.spi.PropertyConverter;
-import org.apache.tamaya.spi.PropertyFilter;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.MediaType;
-import java.util.List;
-
-/**
- * Configuration backend used by the Tamaya server module.
- */
-public interface ConfigAdminService {
-
- String formatCombinationPolicy(MediaType mediaType, PropertyValueCombinationPolicy propertyValueCombinationPolicy, HttpServletRequest request);
-
- String formatPropertyConverter(MediaType mediaType, List<PropertyConverter> propertyConverter, HttpServletRequest request);
-
- String formatPropertyFilter(MediaType mediaType, String filterClass, HttpServletRequest request);
-
- String formatPropertySource(MediaType mediaType, String sourceId, String sourceClass, HttpServletRequest request);
-
- List<PropertyConverter> collectPropertyConverters(String converterClass, String targetType);
-
- List<PropertyFilter> collectPropertyFilters(String filterClass);
-
- List<PropertySource> collectPropertySources(String sourceId, String sourceClass);
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d778cb81/modules/server/src/main/java/org/apache/tamaya/server/spi/ConfigService.java
----------------------------------------------------------------------
diff --git a/modules/server/src/main/java/org/apache/tamaya/server/spi/ConfigService.java b/modules/server/src/main/java/org/apache/tamaya/server/spi/ConfigService.java
deleted file mode 100644
index 1c6e76d..0000000
--- a/modules/server/src/main/java/org/apache/tamaya/server/spi/ConfigService.java
+++ /dev/null
@@ -1,64 +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.server.spi;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.MediaType;
-
-/**
- * Configuration backend used by the Tamaya server module.
- */
-public interface ConfigService {
-
- /**
- * Accessor to get a filtered configuration representation.
- * @param path the comma separated paths to be filtered, e.g. {@code java,sub}.
- * @param format the MIME type required, or the client's ACCEPT header field contents.
- * @param scope the target scope, or null.
- * @param scopeId the target scopeId, or null.
- * @param request the current HTTP request.
- * @return the output String to be returned to the caller.
- */
- String getConfigurationWithPath(String path, MediaType format, String scope, String scopeId, HttpServletRequest request);
-
- /**
- * Accessor to get a unfiltered configuration representation.
- * @param format the MIME type required, or the client's ACCEPT header field contents.
- * @param scope the target scope, or null.
- * @param scopeId the target scopeId, or null.
- * @param request the current HTTP request.
- * @return the output String to be returned to the caller.
- */
- String getConfiguration(MediaType format, String scope, String scopeId, HttpServletRequest request);
-
- /**
- * Update the current configuration.
- * @param payload the payload containing the config entries to be updated.
- * @param request the current HTTP request.
- */
- void updateConfiguration(String payload, HttpServletRequest request);
-
- /**
- * Deletes the current configuration.
- * @param paths the (multiple) comma seperated keys, or paths to be deleted. Paths can be fully qualified keys
- * or regular expressions identifying the keys to be removed, e.g. {@code DEL /config/a.b.*,a.c}.
- * @param request the current HTTP request.
- */
- void deleteConfiguration(String paths, HttpServletRequest request);
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d778cb81/modules/server/src/main/resources/META-INF/services/org.apache.tamaya.server.Server
----------------------------------------------------------------------
diff --git a/modules/server/src/main/resources/META-INF/services/org.apache.tamaya.server.Server b/modules/server/src/main/resources/META-INF/services/org.apache.tamaya.server.Server
deleted file mode 100644
index c1f546a..0000000
--- a/modules/server/src/main/resources/META-INF/services/org.apache.tamaya.server.Server
+++ /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.server.internal.SimpleServer
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d778cb81/modules/server/src/main/resources/META-INF/services/org.apache.tamaya.server.spi.ConfigAdminService
----------------------------------------------------------------------
diff --git a/modules/server/src/main/resources/META-INF/services/org.apache.tamaya.server.spi.ConfigAdminService b/modules/server/src/main/resources/META-INF/services/org.apache.tamaya.server.spi.ConfigAdminService
deleted file mode 100644
index b9b735a..0000000
--- a/modules/server/src/main/resources/META-INF/services/org.apache.tamaya.server.spi.ConfigAdminService
+++ /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.server.internal.DefaultConfigAdminService
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d778cb81/modules/server/src/main/resources/META-INF/services/org.apache.tamaya.server.spi.ConfigService
----------------------------------------------------------------------
diff --git a/modules/server/src/main/resources/META-INF/services/org.apache.tamaya.server.spi.ConfigService b/modules/server/src/main/resources/META-INF/services/org.apache.tamaya.server.spi.ConfigService
deleted file mode 100644
index 0e52e0f..0000000
--- a/modules/server/src/main/resources/META-INF/services/org.apache.tamaya.server.spi.ConfigService
+++ /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.server.internal.DefaultConfigService
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d778cb81/modules/server/src/main/resources/banner.txt
----------------------------------------------------------------------
diff --git a/modules/server/src/main/resources/banner.txt b/modules/server/src/main/resources/banner.txt
new file mode 100644
index 0000000..4e2714b
--- /dev/null
+++ b/modules/server/src/main/resources/banner.txt
@@ -0,0 +1,14 @@
+
+ █████╗ ██████╗ █████╗ ██████╗██╗ ██╗███████╗ ████████╗ █████╗ ███╗ ███╗ █████╗ ██╗ ██╗ █████╗
+██╔══██╗██╔══██╗██╔══██╗██╔════╝██║ ██║██╔════╝ ╚══██╔══╝██╔══██╗████╗ ████║██╔══██╗╚██╗ ██╔╝██╔══██╗
+███████║██████╔╝███████║██║ ███████║█████╗ ██║ ███████║██╔████╔██║███████║ ╚████╔╝ ███████║
+██╔══██║██╔═══╝ ██╔══██║██║ ██╔══██║██╔══╝ ██║ ██╔══██║██║╚██╔╝██║██╔══██║ ╚██╔╝ ██╔══██║
+██║ ██║██║ ██║ ██║╚██████╗██║ ██║███████╗ ██║ ██║ ██║██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║
+╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
+ ███████╗███████╗██████╗ ██╗ ██╗███████╗██████╗
+ ██╔════╝██╔════╝██╔══██╗██║ ██║██╔════╝██╔══██╗
+ ███████╗█████╗ ██████╔╝██║ ██║█████╗ ██████╔╝
+ ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██╔══╝ ██╔══██╗
+ ███████║███████╗██║ ██║ ╚████╔╝ ███████╗██║ ██║
+ ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝
+
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d778cb81/modules/server/src/main/resources/config-server.yml
----------------------------------------------------------------------
diff --git a/modules/server/src/main/resources/config-server.yml b/modules/server/src/main/resources/config-server.yml
new file mode 100644
index 0000000..7d3dbe8
--- /dev/null
+++ b/modules/server/src/main/resources/config-server.yml
@@ -0,0 +1,29 @@
+#
+# 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.
+#
+
+scope: java
+
+server:
+ applicationConnectors:
+ - type: http
+ port: 4001
+ adminConnectors:
+ - type: http
+ port: 4099
+
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d778cb81/modules/server/src/test/java/org/apache/tamaya/server/ConfigServiceAppTest.java
----------------------------------------------------------------------
diff --git a/modules/server/src/test/java/org/apache/tamaya/server/ConfigServiceAppTest.java b/modules/server/src/test/java/org/apache/tamaya/server/ConfigServiceAppTest.java
new file mode 100644
index 0000000..5f7163d
--- /dev/null
+++ b/modules/server/src/test/java/org/apache/tamaya/server/ConfigServiceAppTest.java
@@ -0,0 +1,32 @@
+/*
+ * 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.server;
+
+//import static org.junit.Assert.*;
+
+/**
+ * Created by atsticks on 22.01.16.
+ */
+public class ConfigServiceAppTest {
+
+// @org.junit.Test
+// public void testMain() throws Exception {
+//
+// }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d778cb81/modules/server/src/test/java/org/apache/tamaya/server/EtcdAccessor.java
----------------------------------------------------------------------
diff --git a/modules/server/src/test/java/org/apache/tamaya/server/EtcdAccessor.java b/modules/server/src/test/java/org/apache/tamaya/server/EtcdAccessor.java
new file mode 100644
index 0000000..1c8e94b
--- /dev/null
+++ b/modules/server/src/test/java/org/apache/tamaya/server/EtcdAccessor.java
@@ -0,0 +1,519 @@
+///*
+// * 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.etcd;
+//
+//import org.apache.http.HttpEntity;
+//import org.apache.http.HttpStatus;
+//import org.apache.http.NameValuePair;
+//import org.apache.http.client.config.RequestConfig;
+//import org.apache.http.client.entity.UrlEncodedFormEntity;
+//import org.apache.http.client.methods.CloseableHttpResponse;
+//import org.apache.http.client.methods.HttpDelete;
+//import org.apache.http.client.methods.HttpGet;
+//import org.apache.http.client.methods.HttpPut;
+//import org.apache.http.impl.client.CloseableHttpClient;
+//import org.apache.http.impl.client.HttpClients;
+//import org.apache.http.message.BasicNameValuePair;
+//import org.apache.http.util.EntityUtils;
+//
+//import javax.json.Json;
+//import javax.json.JsonArray;
+//import javax.json.JsonObject;
+//import javax.json.JsonReader;
+//import javax.json.JsonReaderFactory;
+//import java.io.IOException;
+//import java.io.StringReader;
+//import java.util.ArrayList;
+//import java.util.HashMap;
+//import java.util.List;
+//import java.util.Map;
+//import java.util.logging.Level;
+//import java.util.logging.Logger;
+//
+///**
+// * Accessor for reading/writing an etcd endpoint.
+// */
+//public class EtcdAccessor {
+//
+// private static final Logger LOG = Logger.getLogger(EtcdAccessor.class.getName());
+//
+// /** Timeout in seconds. */
+// private int timeout = 2;
+// /** Property that make Johnzon accept commentc. */
+// public static final String JOHNZON_SUPPORTS_COMMENTS_PROP = "org.apache.johnzon.supports-comments";
+// /** The JSON reader factory used. */
+// private final JsonReaderFactory readerFactory = initReaderFactory();
+//
+// /** Initializes the factory to be used for creating readers. */
+// private JsonReaderFactory initReaderFactory() {
+// Map<String, Object> config = new HashMap<>();
+// config.put(JOHNZON_SUPPORTS_COMMENTS_PROP, true);
+// return Json.createReaderFactory(config);
+// }
+//
+// /** The base server url. */
+// private final String serverURL;
+// /** The http client. */
+// private CloseableHttpClient httpclient = HttpClients.createDefault();
+//
+// /**
+// * Creates a new instance with the basic access url.
+// * @param server server url, e.g. {@code http://127.0.0.1:4001}, not null.
+// */
+// public EtcdAccessor(String server){
+// this(server, 2);
+// }
+//
+// public EtcdAccessor(String server, int timeout) {
+// this.timeout = timeout;
+// if(server.endsWith("/")){
+// serverURL = server.substring(0, server.length()-1);
+// } else{
+// serverURL = server;
+// }
+//
+// }
+//
+// /**
+// * Get the etcd server version.
+// * @return the etcd server version, never null.
+// */
+// public String getVersion(){
+// CloseableHttpResponse response = null;
+// String version = "<ERROR>";
+// try {
+// CloseableHttpClient httpclient = HttpClients.createDefault();
+// HttpGet httpGet = new HttpGet(serverURL + "/version");
+// httpGet.setConfig(RequestConfig.copy(RequestConfig.DEFAULT).setSocketTimeout(timeout)
+// .setConnectionRequestTimeout(timeout).setConnectTimeout(timeout).build());
+// response = httpclient.execute(httpGet);
+// HttpEntity entity;
+// if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+// entity = response.getEntity();
+// // and ensure it is fully consumed
+// version = EntityUtils.toString(entity);
+// EntityUtils.consume(entity);
+// }
+// return version;
+// } catch(Exception e){
+// LOG.log(Level.INFO, "Error getting etcd version from: " + serverURL, e);
+// } finally {
+// if(response!=null){
+// try {
+// response.close();
+// } catch (IOException e) {
+// LOG.log(Level.WARNING, "Failed to close http response", e);
+// }
+// }
+// }
+// return version;
+// }
+//
+// /**
+// * Ask etcd for s aingle key, value pair. Hereby the response returned from etcd:
+// * <pre>
+// * {
+// "action": "get",
+// "node": {
+// "createdIndex": 2,
+// "key": "/message",
+// "modifiedIndex": 2,
+// "value": "Hello world"
+// }
+// * }
+// * </pre>
+// * is mapped to:
+// * <pre>
+// * key=value
+// * _key.source=[etcd]http://127.0.0.1:4001
+// * _key.createdIndex=12
+// * _key.modifiedIndex=34
+// * _key.ttl=300
+// * _key.expiration=...
+// * </pre>
+// * @param key the requested key
+// * @return the mapped result, including meta-entries.
+// */
+// public Map<String,String> get(String key){
+// CloseableHttpResponse response = null;
+// Map<String,String> result = new HashMap<>();
+// try {
+// HttpGet httpGet = new HttpGet(serverURL + "/v2/keys/"+key);
+// httpGet.setConfig(RequestConfig.copy(RequestConfig.DEFAULT).setSocketTimeout(timeout)
+// .setConnectionRequestTimeout(timeout).setConnectTimeout(timeout).build());
+// response = httpclient.execute(httpGet);
+// if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+// HttpEntity entity = response.getEntity();
+// JsonReader reader = readerFactory.createReader(new StringReader(EntityUtils.toString(entity)));
+// JsonObject o = reader.readObject();
+// JsonObject node = o.getJsonObject("node");
+// result.put(key, node.getString("value"));
+// result.put("_" + key +".source", "[etcd]"+serverURL);
+// if(node.containsKey("createdIndex")) {
+// result.put("_" + key +".createdIndex", String.valueOf(node.getInt("createdIndex")));
+// }
+// if(node.containsKey("modifiedIndex")) {
+// result.put("_" + key +".modifiedIndex", String.valueOf(node.getInt("modifiedIndex")));
+// }
+// if(node.containsKey("expiration")) {
+// result.put("_" + key +".expiration", String.valueOf(node.getString("expiration")));
+// }
+// if(node.containsKey("ttl")) {
+// result.put("_" + key +".ttl", String.valueOf(node.getInt("ttl")));
+// }
+// EntityUtils.consume(entity);
+// }else{
+// result.put("_" + key +".NOT_FOUND.target", "[etcd]"+serverURL);
+// }
+// } catch(Exception e){
+// LOG.log(Level.INFO, "Error reading key '"+key+"' from etcd: " + serverURL, e);
+// result.put("_ERROR", "Error reading key '"+key+"' from etcd: " + serverURL + ": " + e.toString());
+// } finally {
+// if(response!=null){
+// try {
+// response.close();
+// } catch (IOException e) {
+// LOG.log(Level.WARNING, "Failed to close http response", e);
+// }
+// }
+// }
+// return result;
+// }
+//
+// /**
+// * Creates/updates an entry in etcd without any ttl set.
+// * @see #set(String, String, Integer)
+// * @param key the property key, not null
+// * @param value the value to be set
+// * @return the result map as described above.
+// */
+// public Map<String,String> set(String key, String value){
+// return set(key, value, null);
+// }
+//
+// /**
+// * Creates/updates an entry in etcd. The response as follows:
+// * <pre>
+// * {
+// "action": "set",
+// "node": {
+// "createdIndex": 3,
+// "key": "/message",
+// "modifiedIndex": 3,
+// "value": "Hello etcd"
+// },
+// "prevNode": {
+// "createdIndex": 2,
+// "key": "/message",
+// "value": "Hello world",
+// "modifiedIndex": 2
+// }
+// }
+// * </pre>
+// * is mapped to:
+// * <pre>
+// * key=value
+// * _key.source=[etcd]http://127.0.0.1:4001
+// * _key.createdIndex=12
+// * _key.modifiedIndex=34
+// * _key.ttl=300
+// * _key.expiry=...
+// * // optional
+// * _key.prevNode.createdIndex=12
+// * _key.prevNode.modifiedIndex=34
+// * _key.prevNode.ttl=300
+// * _key.prevNode.expiration=...
+// * </pre>
+// * @param key the property key, not null
+// * @param value the value to be set
+// * @param ttlSeconds the ttl in seconds (optional)
+// * @return the result map as described above.
+// */
+// public Map<String,String> set(String key, String value, Integer ttlSeconds){
+// CloseableHttpResponse response = null;
+// Map<String,String> result = new HashMap<>();
+// try{
+// HttpPut put = new HttpPut(serverURL + "/v2/keys/"+key);
+// put.setConfig(RequestConfig.copy(RequestConfig.DEFAULT).setSocketTimeout(timeout)
+// .setConnectionRequestTimeout(timeout).setConnectTimeout(timeout).build());
+// List<NameValuePair> nvps = new ArrayList<>();
+// nvps.add(new BasicNameValuePair("value", value));
+// if(ttlSeconds!=null){
+// nvps.add(new BasicNameValuePair("ttl", ttlSeconds.toString()));
+// }
+// put.setEntity(new UrlEncodedFormEntity(nvps));
+// response = httpclient.execute(put);
+// if (response.getStatusLine().getStatusCode() == HttpStatus.SC_CREATED ||
+// response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+// HttpEntity entity = response.getEntity();
+// JsonReader reader = readerFactory.createReader(new StringReader(EntityUtils.toString(entity)));
+// JsonObject o = reader.readObject();
+// JsonObject node = o.getJsonObject("node");
+// if(node.containsKey("createdIndex")) {
+// result.put("_" + key +".createdIndex", String.valueOf(node.getInt("createdIndex")));
+// }
+// if(node.containsKey("modifiedIndex")) {
+// result.put("_" + key +".modifiedIndex", String.valueOf(node.getInt("modifiedIndex")));
+// }
+// if(node.containsKey("expiration")) {
+// result.put("_" + key +".expiration", String.valueOf(node.getString("expiration")));
+// }
+// if(node.containsKey("ttl")) {
+// result.put("_" + key +".ttl", String.valueOf(node.getInt("ttl")));
+// }
+// result.put(key, node.getString("value"));
+// result.put("_" + key +".source", "[etcd]"+serverURL);
+// if(node.containsKey("prevNode")){
+// JsonObject prevNode = node.getJsonObject("prevNode");
+// if (prevNode.containsKey("createdIndex")) {
+// result.put("_" + key +".prevNode.createdIndex", String.valueOf(prevNode.getInt("createdIndex")));
+// }
+// if (prevNode.containsKey("modifiedIndex")) {
+// result.put("_" + key +".prevNode.modifiedIndex", String.valueOf(prevNode.getInt("modifiedIndex")));
+// }
+// if(prevNode.containsKey("expiration")) {
+// result.put("_" + key +".prevNode.expiration", String.valueOf(prevNode.getString("expiration")));
+// }
+// if(prevNode.containsKey("ttl")) {
+// result.put("_" + key +".prevNode.ttl", String.valueOf(prevNode.getInt("ttl")));
+// }
+// result.put("_" + key +".prevNode.value", prevNode.getString("value"));
+// }
+// EntityUtils.consume(entity);
+// }
+// } catch(Exception e){
+// LOG.log(Level.INFO, "Error writing to etcd: " + serverURL, e);
+// result.put("_ERROR", "Error writing '"+key+"' to etcd: " + serverURL + ": " + e.toString());
+// } finally {
+// if(response!=null){
+// try {
+// response.close();
+// } catch (IOException e) {
+// LOG.log(Level.WARNING, "Failed to close http response", e);
+// }
+// }
+// }
+// return result;
+// }
+//
+//
+// /**
+// * Deletes a given key. The response is as follows:
+// * <pre>
+// * _key.source=[etcd]http://127.0.0.1:4001
+// * _key.createdIndex=12
+// * _key.modifiedIndex=34
+// * _key.ttl=300
+// * _key.expiry=...
+// * // optional
+// * _key.prevNode.createdIndex=12
+// * _key.prevNode.modifiedIndex=34
+// * _key.prevNode.ttl=300
+// * _key.prevNode.expiration=...
+// * _key.prevNode.value=...
+// * </pre>
+// * @param key the key to be deleted.
+// * @return the response mpas as described above.
+// */
+// public Map<String,String> delete(String key){
+// CloseableHttpResponse response = null;
+// Map<String,String> result = new HashMap<>();
+// try{
+// HttpDelete delete = new HttpDelete(serverURL + "/v2/keys/"+key);
+// delete.setConfig(RequestConfig.copy(RequestConfig.DEFAULT).setSocketTimeout(timeout)
+// .setConnectionRequestTimeout(timeout).setConnectTimeout(timeout).build());
+// response = httpclient.execute(delete);
+// if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+// HttpEntity entity = response.getEntity();
+// JsonReader reader = readerFactory.createReader(new StringReader(EntityUtils.toString(entity)));
+// JsonObject o = reader.readObject();
+// JsonObject node = o.getJsonObject("node");
+// if(node.containsKey("createdIndex")) {
+// result.put("_" + key +".createdIndex", String.valueOf(node.getInt("createdIndex")));
+// }
+// if(node.containsKey("modifiedIndex")) {
+// result.put("_" + key +".modifiedIndex", String.valueOf(node.getInt("modifiedIndex")));
+// }
+// if(node.containsKey("expiration")) {
+// result.put("_" + key +".expiration", String.valueOf(node.getString("expiration")));
+// }
+// if(node.containsKey("ttl")) {
+// result.put("_" + key +".ttl", String.valueOf(node.getInt("ttl")));
+// }
+// if(o.containsKey("prevNode")){
+// JsonObject prevNode = o.getJsonObject("prevNode");
+// if (prevNode.containsKey("createdIndex")) {
+// result.put("_" + key +".prevNode.createdIndex", String.valueOf(prevNode.getInt("createdIndex")));
+// }
+// if (prevNode.containsKey("modifiedIndex")) {
+// result.put("_" + key +".prevNode.modifiedIndex", String.valueOf(prevNode.getInt("modifiedIndex")));
+// }
+// if(prevNode.containsKey("expiration")) {
+// result.put("_" + key +".prevNode.expiration", String.valueOf(prevNode.getString("expiration")));
+// }
+// if(prevNode.containsKey("ttl")) {
+// result.put("_" + key +".prevNode.ttl", String.valueOf(prevNode.getInt("ttl")));
+// }
+// result.put("_" + key +".prevNode.value", prevNode.getString("value"));
+// }
+// EntityUtils.consume(entity);
+// }
+// } catch(Exception e){
+// LOG.log(Level.INFO, "Error deleting key '"+key+"' from etcd: " + serverURL, e);
+// result.put("_ERROR", "Error deleting '"+key+"' from etcd: " + serverURL + ": " + e.toString());
+// } finally {
+// if(response!=null){
+// try {
+// response.close();
+// } catch (IOException e) {
+// LOG.log(Level.WARNING, "Failed to close http response", e);
+// }
+// }
+// }
+// return result;
+// }
+//
+// /**
+// * Get all properties for the given directory key recursively.
+// * @see #getProperties(String, boolean)
+// * @param directory the directory entry
+// * @return the properties and its metadata
+// */
+// public Map<String,String> getProperties(String directory){
+// return getProperties(directory, true);
+// }
+//
+// /**
+// * Access all properties.
+// * The response of:
+// * <pre>
+// {
+// "action": "get",
+// "node": {
+// "key": "/",
+// "dir": true,
+// "nodes": [
+// {
+// "key": "/foo_dir",
+// "dir": true,
+// "modifiedIndex": 2,
+// "createdIndex": 2
+// },
+// {
+// "key": "/foo",
+// "value": "two",
+// "modifiedIndex": 1,
+// "createdIndex": 1
+// }
+// ]
+// }
+//}
+// </pre>
+// is mapped to a regular Tamaya properties map as follows:
+// <pre>
+// * key1=myvalue
+// * _key1.source=[etcd]http://127.0.0.1:4001
+// * _key1.createdIndex=12
+// * _key1.modifiedIndex=34
+// * _key1.ttl=300
+// * _key1.expiration=...
+// *
+// * key2=myvaluexxx
+// * _key2.source=[etcd]http://127.0.0.1:4001
+// * _key2.createdIndex=12
+// *
+// * key3=val3
+// * _key3.source=[etcd]http://127.0.0.1:4001
+// * _key3.createdIndex=12
+// * _key3.modifiedIndex=2
+// * </pre>
+// */
+// public Map<String,String> getProperties(String directory, boolean recursive){
+// CloseableHttpResponse response = null;
+// Map<String,String> result = new HashMap<>();
+// try{
+// HttpGet get = new HttpGet(serverURL + "/v2/keys/"+directory+"?recursive="+recursive);
+// get.setConfig(RequestConfig.copy(RequestConfig.DEFAULT).setSocketTimeout(timeout)
+// .setConnectionRequestTimeout(timeout).setConnectTimeout(timeout).build());
+// response = httpclient.execute(get);
+// if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+// HttpEntity entity = response.getEntity();
+// JsonReader reader = readerFactory.createReader(new StringReader(EntityUtils.toString(entity)));
+// JsonObject o = reader.readObject();
+// JsonObject node = o.getJsonObject("node");
+// if(node!=null){
+// addNodes(result, node);
+// }
+// EntityUtils.consume(entity);
+// }
+// } catch(Exception e){
+// LOG.log(Level.INFO, "Error reading properties for '"+directory+"' from etcd: " + serverURL, e);
+// result.put("_ERROR", "Error reading properties for '"+directory+"' from etcd: " + serverURL + ": " + e.toString());
+// } finally {
+// if(response!=null){
+// try {
+// response.close();
+// } catch (IOException e) {
+// LOG.log(Level.WARNING, "Failed to close http response", e);
+// }
+// }
+// }
+// return result;
+// }
+//
+// /**
+// * Recursively read out all key/values from this etcd JSON array.
+// * @param result map with key, values and metadata.
+// * @param node the node to parse.
+// */
+// private void addNodes(Map<String, String> result, JsonObject node) {
+// if(!node.containsKey("dir") || "false".equals(node.get("dir").toString())) {
+// String key = node.getString("key").substring(1);
+// result.put(key, node.getString("value"));
+// if (node.containsKey("createdIndex")) {
+// result.put("_" + key + ".createdIndex", String.valueOf(node.getInt("createdIndex")));
+// }
+// if (node.containsKey("modifiedIndex")) {
+// result.put("_" + key + ".modifiedIndex", String.valueOf(node.getInt("modifiedIndex")));
+// }
+// if (node.containsKey("expiration")) {
+// result.put("_" + key + ".expiration", String.valueOf(node.getString("expiration")));
+// }
+// if (node.containsKey("ttl")) {
+// result.put("_" + key + ".ttl", String.valueOf(node.getInt("ttl")));
+// }
+// result.put("_" + key +".source", "[etcd]"+serverURL);
+// } else {
+// JsonArray nodes = node.getJsonArray("nodes");
+// if (nodes != null) {
+// for (int i = 0; i < nodes.size(); i++) {
+// addNodes(result, nodes.getJsonObject(i));
+// }
+// }
+// }
+// }
+//
+// /**
+// * Access the server root URL used by this accessor.
+// * @return
+// */
+// public String getUrl() {
+// return serverURL;
+// }
+//}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d778cb81/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BasePropertySource.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BasePropertySource.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BasePropertySource.java
index 91496ce..2a6b47e 100644
--- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BasePropertySource.java
+++ b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BasePropertySource.java
@@ -19,6 +19,7 @@
package org.apache.tamaya.spisupport;
import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -48,10 +49,10 @@ public abstract class BasePropertySource implements PropertySource{
@Override
public int getOrdinal() {
- String configuredOrdinal = get(TAMAYA_ORDINAL);
+ PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL);
if(configuredOrdinal!=null){
try{
- return Integer.parseInt(configuredOrdinal);
+ return Integer.parseInt(configuredOrdinal.get(TAMAYA_ORDINAL));
} catch(Exception e){
Logger.getLogger(getClass().getName()).log(Level.WARNING,
"Configured Ordinal is not an int number: " + configuredOrdinal, e);
@@ -69,8 +70,8 @@ public abstract class BasePropertySource implements PropertySource{
}
@Override
- public String get(String key) {
- return getProperties().get(key);
+ public PropertyValue get(String key) {
+ return PropertyValue.of(key, getProperties().get(key), getName());
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d778cb81/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
index a72dc36..fdf5814 100644
--- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
+++ b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
@@ -27,6 +27,7 @@ import org.apache.tamaya.spi.ConfigurationContext;
import org.apache.tamaya.spi.ConversionContext;
import org.apache.tamaya.spi.PropertyConverter;
import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
import java.util.ArrayList;
@@ -70,7 +71,11 @@ public class DefaultConfiguration implements Configuration {
*/
@Override
public String get(String key) {
- return PropertyFiltering.applyFilter(key, evaluteRawValue(key), configurationContext);
+ PropertyValue configData = evaluteRawValue(key);
+ if(configData==null){
+ return null;
+ }
+ return PropertyFiltering.applyFilter(key, configData.getConfigEntries(), configurationContext);
}
/**
@@ -78,15 +83,18 @@ public class DefaultConfiguration implements Configuration {
* @param key the key, not null.
* @return the value, before filtering is applied.
*/
- protected String evaluteRawValue(String key) {
+ protected PropertyValue evaluteRawValue(String key) {
List<PropertySource> propertySources = configurationContext.getPropertySources();
- String unfilteredValue = null;
+ Map<String,String> unfilteredValue = null;
PropertyValueCombinationPolicy combinationPolicy = this.configurationContext
.getPropertyValueCombinationPolicy();
for (PropertySource propertySource : propertySources) {
unfilteredValue = combinationPolicy.collect(unfilteredValue, key, propertySource);
}
- return unfilteredValue;
+ if(unfilteredValue==null){
+ return null;
+ }
+ return PropertyValue.of(key, unfilteredValue.get(key), unfilteredValue.get("_"+key+".source"));
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d778cb81/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java
index 5fa15fe..7d4d9e1 100644
--- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java
+++ b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java
@@ -19,6 +19,7 @@
package org.apache.tamaya.spisupport;
import org.apache.tamaya.spi.ConfigurationContext;
+import org.apache.tamaya.spi.FilterContext;
import org.apache.tamaya.spi.PropertyFilter;
import java.util.HashMap;
@@ -47,13 +48,14 @@ public final class PropertyFiltering{
*/
private PropertyFiltering(){}
- public static String applyFilter(String key, String unfilteredValue, ConfigurationContext configurationContext) {
+ public static String applyFilter(String key, Map<String,String> configData, ConfigurationContext configurationContext) {
// Apply filters to values, prevent values filtered to null!
+ String unfilteredValue = configData.get(key);
for (int i = 0; i < MAX_FILTER_LOOPS; i++) {
boolean changed = false;
// Apply filters to values, prevent values filtered to null!
for (PropertyFilter filter : configurationContext.getPropertyFilters()) {
- String newValue = filter.filterProperty(key, unfilteredValue);
+ String newValue = filter.filterProperty(unfilteredValue, new FilterContext(key, configData, true));
if (newValue != null && !newValue.equals(unfilteredValue)) {
changed = true;
if (LOG.isLoggable(Level.FINEST)) {
@@ -93,7 +95,7 @@ public final class PropertyFiltering{
final String k = entry.getKey();
final String v = entry.getValue();
- String newValue = filter.filterProperty(k, v);
+ String newValue = filter.filterProperty(k, new FilterContext(k, inputMap, false));
if (newValue != null && !newValue.equals(v)) {
changes.incrementAndGet();
LOG.finest("Filter - " + k + ": " + v + " -> " + newValue + " by " + filter);
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d778cb81/src/site/asciidoc/extensions/index.adoc
----------------------------------------------------------------------
diff --git a/src/site/asciidoc/extensions/index.adoc b/src/site/asciidoc/extensions/index.adoc
index 113efbf..fa3a02f 100644
--- a/src/site/asciidoc/extensions/index.adoc
+++ b/src/site/asciidoc/extensions/index.adoc
@@ -43,13 +43,12 @@ Mature extensions have a stable API and SPI, similar to the API and Implementati
|=======
|_Artifact_ |_Description_ |_Links_
| | N/A: currently no extensions have reached that maturity level. | -
-|+org.apache.tamaya.ext:tamaya-resolver+ |Provides placeholder and dynamic resolution functionality for configuration values. |link:mod_resolver.html[Documentation]
|+org.apache.tamaya.ext:tamaya-formats+ |Provides an abstract model for configuration formats |link:mod_formats.html[Documentation]
|+org.apache.tamaya.ext:tamaya-functions+ |Provides several functional extension points. |link:mod_functions.html[Documentation]
+|+org.apache.tamaya.ext:tamaya-json+ |Provides format support for JSON based configuration. |link:mod_json.html[Documentation]
|+org.apache.tamaya.ext:tamaya-optional+ |Lets a Tamaya configuration to be used as an optional project extension only. |link:mod_optional.html[Documentation]
+|+org.apache.tamaya.ext:tamaya-resolver+ |Provides placeholder and dynamic resolution functionality for configuration values. |link:mod_resolver.html[Documentation]
|+org.apache.tamaya.ext:tamaya-spi-support+ |Tamaya support module for SPI implementation. |link:mod_spi-support.html[Documentation]
-|+org.apache.tamaya.ext:tamaya-json+ |Provides format support for JSON based configuration. |link:mod_json.html[Documentation]
-|+org.apache.tamaya.ext:tamaya-mutable-config+|Provides API/SPI for writing configuration |link:mod_mutable_config.html[Documentation]
|=======
@@ -64,14 +63,16 @@ NOTE All extensions currently run on Java 7 as well as on Java 8.
|=======
|_Artifact_ |_Description_ |_Links_
|+org.apache.tamaya.ext:tamaya-builder+ |Provides a fluent-style builder for configurations | link:mod_builder.html[Documentation]
-|+org.apache.tamaya.ext:tamaya-resources+ |Provides ant-style resource path resolution |link:mod_resources.html[Documentation]
+|+org.apache.tamaya.ext:tamaya-classloader-support+ |Manages Tamaya configuration and services considering classloading hierarchies. |link:mod_classloader_support.html[Documentation]
|+org.apache.tamaya.ext:tamaya-events+ |Provides support for publishing configuration changes |link:mod_events.html[Documentation]
+|+org.apache.tamaya.ext:tamaya-filter+ |Provides a programmatic filter for config entries. | link:mod_filter.html[Documentation]
|+org.apache.tamaya.ext:tamaya-injection+ |Provides configuration injection services and congiruation template support. |link:mod_injection.html[Documentation]
-|+org.apache.tamaya.ext:tamaya-model+ |Provides support documenting ang validating configuration during runtime. |link:mod_model.html[Documentation]
|+org.apache.tamaya.ext:tamaya-management+ |Provides JMX support for inspecting configuration. |link:mod_management.html[Documentation]
+|+org.apache.tamaya.ext:tamaya-model+ |Provides support documenting ang validating configuration during runtime. |link:mod_model.html[Documentation]
+|+org.apache.tamaya.ext:tamaya-mutable-config+|Provides API/SPI for writing configuration |link:mod_mutable_config.html[Documentation]
|+org.apache.tamaya.ext:tamaya-remote+ |Provides remote configuration support. |link:mod_remote.html[Documentation]
-|+org.apache.tamaya.ext:tamaya-server+ |Lets a Tamaya configuration instance provide scoped configuration as a http service. |link:mod_server.html[Documentation]
-|+org.apache.tamaya.ext:tamaya-classloader-support+ |Manages Tamaya configuration and services considering classloading hierarchies. |link:mod_classloader_support.html[Documentation]
+|+org.apache.tamaya.ext:tamaya-resources+ |Provides ant-style resource path resolution |link:mod_resources.html[Documentation]
+|+org.apache.tamaya.ext:tamaya-server+ |Lets a Tamaya configuration instance provide scoped configuration as a REST service. |link:mod_server.html[Documentation]
|=======
== Integrations
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d778cb81/src/site/asciidoc/extensions/mod_filter.adoc
----------------------------------------------------------------------
diff --git a/src/site/asciidoc/extensions/mod_filter.adoc b/src/site/asciidoc/extensions/mod_filter.adoc
new file mode 100644
index 0000000..1b810b8
--- /dev/null
+++ b/src/site/asciidoc/extensions/mod_filter.adoc
@@ -0,0 +1,154 @@
+// 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.
+
+= Apache Tamaya -- Extension: Integration with etcd (Core OS)
+
+:name: Tamaya
+:rootpackage: org.apache.tamaya.filter
+:title: Apache Tamaya Extension: Progrmmatic filtering of config entries
+:revdate: January 2016
+:authorinitials: ATR
+:author: Anatole Tresch
+:email: <an...@apache.org>
+:source-highlighter: coderay
+:website: http://tamaya.incubator.apache.org/
+:toc:
+:toc-placement: manual
+:encoding: UTF-8
+:numbered:
+
+'''
+
+<<<
+
+toc::[]
+
+<<<
+:numbered!:
+<<<
+[[Optional]]
+== COnfiguration Filtering (Extension Module)
+=== Overview
+
+The Tamaya filter module provides a simple singleton accessor that allows to explicitly add +PropertyFilter+ instances
+active on the current thread only. This can be very useful in many scenarios. Additionally this module adds
+standard filters that hide metadata entries when the full configuration map is accessed. When keys are accessed
+explcitily no filtering is applied and everything is visible.
+
+=== Compatibility
+
+The module is based on Java 7, so it will not run on Java 7 and beyond.
+
+
+=== Installation
+
+To benefit from configuration builder support you only must add the corresponding dependency to your module:
+
+[source, xml]
+-----------------------------------------------
+<dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-filter</artifactId>
+ <version>{tamayaVersion}</version>
+</dependency>
+-----------------------------------------------
+
+
+=== The Extensions Provided
+
+Tamaya Filter comes basically with 1 artifact:
+
+* The +org.apache.tamaya.filter.ConfigurationFilter+ provides several static methods to register +PropertyFilter+
+instances on the current thread.
+* The +org.apache.tamaya.filter.DefaultMetdataFilter+ is a +PropertyFilter+ with hides all entries starting with
+ an underscore ('_'), when a full property map is accessed.
+
+
+=== The ConfigurationFilter
+
+The accessor mentioned implements the API for for adding 1PropertyFilters+ to the current thread (as thread local):
+
+[source, java]
+-----------------------------------------------
+public final class ConfigurationFilter implements PropertyFilter{
+
+ ...
+
+ /**
+ * Seactivates metadata filtering also on global map access for this thread.
+ * @see #clearFilters()
+ * @param active true,to enable metadata filtering (default).
+ */
+ public static void setMetadataFilter(boolean active);
+
+ /**
+ * Access the filtering configuration that is used for filtering single property values accessed.
+ * @return the filtering config, never null.
+ */
+ public static ProgrammableFilter getSingleFilters();
+
+ /**
+ * Access the filtering configuration that is used for filtering configuration properties accessed as full
+ * map.
+ * @return the filtering config, never null.
+ */
+ public static ProgrammableFilter getMapFilters();
+
+ /**
+ * Removes all programmable filters active on the current thread.
+ */
+ public static void clearFilters();
+
+ ...
+
+}
+-----------------------------------------------
+
+For using regular expression when filtering configuration keys a corresponding implementation of a +PropertyFilter+
+is part of this module, So you can add a customized filter as follows:
+
+[source, java]
+-----------------------------------------------
+try{
+ ConfigurationFilter.getMapFilters().addFilter(new RegexPropertyFilter("\\_.*"));
+
+ // do your code with filtering active
+}
+finally{
+ // cleanup
+ ConfigurationFilter.clearFilters();
+}
+-----------------------------------------------
+
+The +ProgrammableFilter+ is a simple structure just providing some handy accessors to the dynamic thread-local
+managed filters:
+
+[source, java]
+-----------------------------------------------
+public final class ProgrammableFilter implements PropertyFilter{
+
+ public void addFilter(PropertyFilter filter);
+ public void addFilter(int pos, PropertyFilter filter);
+ public PropertyFilter removeFilter(int pos);
+ public void clearFilters();
+ public void setFilters(PropertyFilter... filters);
+ public void setFilters(Collection<PropertyFilter> filters);
+ public List<PropertyFilter> getFilters();
+
+}
+-----------------------------------------------
+