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 2015/08/24 18:25:36 UTC

incubator-tamaya git commit: Checking in immediate version of server module.

Repository: incubator-tamaya
Updated Branches:
  refs/heads/master f41ea3ca1 -> 6d9184401


Checking in immediate version of server module.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/6d918440
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/6d918440
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/6d918440

Branch: refs/heads/master
Commit: 6d91844016aad8d1345db633cfc78ccecb4b0cc8
Parents: f41ea3c
Author: anatole <an...@apache.org>
Authored: Mon Aug 24 18:25:22 2015 +0200
Committer: anatole <an...@apache.org>
Committed: Mon Aug 24 18:25:22 2015 +0200

----------------------------------------------------------------------
 .../tamaya/remote/BaseConfigServerServlet.java  | 51 ---------------
 sandbox/server/pom.xml                          | 66 ++++++++++++++++++++
 .../tamaya/server/BaseConfigServerServlet.java  | 51 +++++++++++++++
 .../org/apache/tamaya/server/CXFServer.java     | 53 ++++++++++++++++
 .../tamaya/server/ConfigProviderService.java    | 17 +++++
 .../org/apache/tamaya/server/ConfigServer.java  | 12 ++++
 .../org/apache/tamaya/server/ConfigService.java | 14 +++++
 7 files changed, 213 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/6d918440/sandbox/remote/src/main/java/org/apache/tamaya/remote/BaseConfigServerServlet.java
----------------------------------------------------------------------
diff --git a/sandbox/remote/src/main/java/org/apache/tamaya/remote/BaseConfigServerServlet.java b/sandbox/remote/src/main/java/org/apache/tamaya/remote/BaseConfigServerServlet.java
deleted file mode 100644
index e931b4e..0000000
--- a/sandbox/remote/src/main/java/org/apache/tamaya/remote/BaseConfigServerServlet.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.remote;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Simple servlet base class that delivers a configuration with the given parameter key/value keys.
- */
-public abstract class BaseConfigServerServlet extends HttpServlet {
-
-    @Override
-    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
-        Map<String,String> params = new HashMap<>();
-        req.getParameterMap().forEach((k,v) -> params.put(k, v[0]));
-        String config = getFormattedConfiguration(params);
-        if(config!=null){
-            // write config to response
-            resp.getWriter().print(config);
-        }
-        else{
-            resp.sendError(404, "No such config: " + params.toString());
-        }
-
-    }
-
-    protected abstract String getFormattedConfiguration(Map<String, String> params);
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/6d918440/sandbox/server/pom.xml
----------------------------------------------------------------------
diff --git a/sandbox/server/pom.xml b/sandbox/server/pom.xml
new file mode 100644
index 0000000..ab55fe5
--- /dev/null
+++ b/sandbox/server/pom.xml
@@ -0,0 +1,66 @@
+<!-- 
+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.1-incubating-SNAPSHOT</version>
+        <relativePath>..</relativePath>
+    </parent>
+
+    <artifactId>tamaya-server</artifactId>
+    <name>Apache Tamaya Configuration: Server Extension</name>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tamaya</groupId>
+            <artifactId>tamaya-java7-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tamaya</groupId>
+            <artifactId>tamaya-java7-core</artifactId>
+            <version>${project.version}</version>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>tamaya-json</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>tamaya-functions</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>apache-cxf</artifactId>
+            <version>3.1.2</version>
+        </dependency>
+    </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/6d918440/sandbox/server/src/main/java/org/apache/tamaya/server/BaseConfigServerServlet.java
----------------------------------------------------------------------
diff --git a/sandbox/server/src/main/java/org/apache/tamaya/server/BaseConfigServerServlet.java b/sandbox/server/src/main/java/org/apache/tamaya/server/BaseConfigServerServlet.java
new file mode 100644
index 0000000..0306803
--- /dev/null
+++ b/sandbox/server/src/main/java/org/apache/tamaya/server/BaseConfigServerServlet.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.server;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Simple servlet base class that delivers a configuration with the given parameter key/value keys.
+ */
+public abstract class BaseConfigServerServlet extends HttpServlet {
+
+    @Override
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+        Map<String,String> params = new HashMap<>();
+        req.getParameterMap().forEach((k,v) -> params.put(k, v[0]));
+        String config = getFormattedConfiguration(params);
+        if(config!=null){
+            // write config to response
+            resp.getWriter().print(config);
+        }
+        else{
+            resp.sendError(404, "No such config: " + params.toString());
+        }
+
+    }
+
+    protected abstract String getFormattedConfiguration(Map<String, String> params);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/6d918440/sandbox/server/src/main/java/org/apache/tamaya/server/CXFServer.java
----------------------------------------------------------------------
diff --git a/sandbox/server/src/main/java/org/apache/tamaya/server/CXFServer.java b/sandbox/server/src/main/java/org/apache/tamaya/server/CXFServer.java
new file mode 100644
index 0000000..2dd06f7
--- /dev/null
+++ b/sandbox/server/src/main/java/org/apache/tamaya/server/CXFServer.java
@@ -0,0 +1,53 @@
+package org.apache.tamaya.server;
+
+/*
+HelloWorldImpl implementor = new HelloWorldImpl();
+JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
+svrFactory.setServiceClass(HelloWorld.class);
+svrFactory.setAddress("http://localhost:9000/helloWorld");
+svrFactory.setServiceBean(implementor);
+svrFactory.getInInterceptors().add(new LoggingInInterceptor());
+svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
+svrFactory.create();
+ */
+
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+
+public class CXFServer implements ConfigServer{
+
+    private Server cxfEndpoint;
+
+    public void start(int port) {
+        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
+        ConfigService confService = new ConfigService();
+        sf.setServiceBeanObjects(confService);
+        sf.setAddress("http://localhost:"+port+"/");
+        cxfEndpoint = sf.create();
+    }
+
+    public boolean isStarted(){
+        if(cxfEndpoint!=null){
+            return cxfEndpoint.isStarted();
+        }
+        return false;
+    }
+
+    public void stop(){
+        if(cxfEndpoint!=null){
+            cxfEndpoint.stop();
+        }
+    }
+
+    public void destroy(){
+        if(cxfEndpoint!=null){
+            cxfEndpoint.destroy();
+            cxfEndpoint = null;
+        }
+    }
+
+    public static void main(String... args){
+        new CXFServer().start(8888);
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/6d918440/sandbox/server/src/main/java/org/apache/tamaya/server/ConfigProviderService.java
----------------------------------------------------------------------
diff --git a/sandbox/server/src/main/java/org/apache/tamaya/server/ConfigProviderService.java b/sandbox/server/src/main/java/org/apache/tamaya/server/ConfigProviderService.java
new file mode 100644
index 0000000..117911a
--- /dev/null
+++ b/sandbox/server/src/main/java/org/apache/tamaya/server/ConfigProviderService.java
@@ -0,0 +1,17 @@
+package org.apache.tamaya.server;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+
+/**
+ * Created by Anatole on 23.08.2015.
+ */
+public interface ConfigProviderService {
+
+    @GET
+    @Path("/config/{id}/")
+    @Produces("application/json")
+    String getConfiguration(@PathParam("id") String configId);
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/6d918440/sandbox/server/src/main/java/org/apache/tamaya/server/ConfigServer.java
----------------------------------------------------------------------
diff --git a/sandbox/server/src/main/java/org/apache/tamaya/server/ConfigServer.java b/sandbox/server/src/main/java/org/apache/tamaya/server/ConfigServer.java
new file mode 100644
index 0000000..c6bfb5d
--- /dev/null
+++ b/sandbox/server/src/main/java/org/apache/tamaya/server/ConfigServer.java
@@ -0,0 +1,12 @@
+package org.apache.tamaya.server;
+
+/**
+ * Created by Anatole on 23.08.2015.
+ */
+public interface ConfigServer {
+
+    void start(int port);
+    boolean isStarted();
+    void stop();
+    void destroy();
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/6d918440/sandbox/server/src/main/java/org/apache/tamaya/server/ConfigService.java
----------------------------------------------------------------------
diff --git a/sandbox/server/src/main/java/org/apache/tamaya/server/ConfigService.java b/sandbox/server/src/main/java/org/apache/tamaya/server/ConfigService.java
new file mode 100644
index 0000000..b1b6283
--- /dev/null
+++ b/sandbox/server/src/main/java/org/apache/tamaya/server/ConfigService.java
@@ -0,0 +1,14 @@
+package org.apache.tamaya.server;
+
+import org.apache.tamaya.ConfigurationProvider;
+import static org.apache.tamaya.functions.ConfigurationFunctions.*;
+/**
+ * Created by Anatole on 23.08.2015.
+ */
+public class ConfigService implements ConfigProviderService{
+    @Override
+    public String getConfiguration(String configId) {
+        // currently ignore: with(section(configId,false))
+        return ConfigurationProvider.getConfiguration().query(jsonInfo());
+    }
+}