tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject [08/15] incubator-tamaya git commit: - Removed dependency from Dropwizard, using tomcat embedded now.
Date Tue, 19 Apr 2016 11:54:41 GMT
- Removed dependency from Dropwizard, using tomcat embedded now.


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

Branch: refs/heads/master
Commit: 4b2d041bdf028b66e595dd19073aefd67136cbb3
Parents: d736136
Author: anatole <anatole@apache.org>
Authored: Sun Apr 17 21:01:07 2016 +0200
Committer: anatole <anatole@apache.org>
Committed: Tue Apr 19 13:53:44 2016 +0200

----------------------------------------------------------------------
 modules/server/pom.xml                          | 67 +++++++++++++++++---
 .../apache/tamaya/server/ConfigServiceApp.java  | 66 ++++++++++++-------
 .../server/ConfigServiceConfiguration.java      | 41 ------------
 .../tamaya/server/ConfigurationResource.java    |  4 --
 4 files changed, 101 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/4b2d041b/modules/server/pom.xml
----------------------------------------------------------------------
diff --git a/modules/server/pom.xml b/modules/server/pom.xml
index 55c75ec..4e706ce 100644
--- a/modules/server/pom.xml
+++ b/modules/server/pom.xml
@@ -32,23 +32,74 @@ under the License.
 
     <properties>
         <jdkVersion>1.7</jdkVersion>
-        <dropwizard.version>0.9.2</dropwizard.version>
+        <tomcat.version>7.0.57</tomcat.version>
+        <jersey.version>1.19.1</jersey.version>
     </properties>
 
-    <!-- Add typical dependencies for a web application -->
     <dependencies>
         <dependency>
-            <groupId>io.dropwizard</groupId>
-            <artifactId>dropwizard-core</artifactId>
-            <version>${dropwizard.version}</version>
-        </dependency>
-        <dependency>
             <groupId>org.apache.tamaya</groupId>
             <artifactId>tamaya-api</artifactId>
             <version>${project.version}</version>
-            <scope>compile</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-core</artifactId>
+            <version>${tomcat.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-jasper</artifactId>
+            <version>${tomcat.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-logging-juli</artifactId>
+            <version>${tomcat.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.ws.rs</groupId>
+            <artifactId>jsr311-api</artifactId>
+            <version>1.1.1</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-server</artifactId>
+            <version>${jersey.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-servlet</artifactId>
+            <version>${jersey.version}</version>
+        </dependency>
+
+        <!--<dependency>-->
+        <!--<groupId>org.apache.tomcat.embed</groupId>-->
+        <!--<artifactId>tomcat-embed-jasper</artifactId>-->
+        <!--<version>${tomcat.version}</version>-->
+        <!--</dependency>-->
+        <!--<dependency>-->
+        <!--<groupId>org.apache.tomcat</groupId>-->
+        <!--<artifactId>tomcat-jasper</artifactId>-->
+        <!--<version>${tomcat.version}</version>-->
+        <!--</dependency>-->
+        <!--<dependency>-->
+        <!--<groupId>org.apache.tomcat</groupId>-->
+        <!--<artifactId>tomcat-jasper-el</artifactId>-->
+        <!--<version>${tomcat.version}</version>-->
+        <!--</dependency>-->
+        <!--<dependency>-->
+        <!--<groupId>org.apache.tomcat</groupId>-->
+        <!--<artifactId>tomcat-jsp-api</artifactId>-->
+        <!--<version>${tomcat.version}</version>-->
+        <!--</dependency>-->
+        <!--<dependency>-->
+        <!--<groupId>jstl</groupId>-->
+        <!--<artifactId>jstl</artifactId>-->
+        <!--<version>1.2</version>-->
+        <!--</dependency>-->
+        <dependency>
             <groupId>org.apache.tamaya</groupId>
             <artifactId>tamaya-core</artifactId>
             <version>${project.version}</version>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/4b2d041b/modules/server/src/main/java/org/apache/tamaya/server/ConfigServiceApp.java
----------------------------------------------------------------------
diff --git a/modules/server/src/main/java/org/apache/tamaya/server/ConfigServiceApp.java b/modules/server/src/main/java/org/apache/tamaya/server/ConfigServiceApp.java
index 2e98998..2c74ea1 100644
--- a/modules/server/src/main/java/org/apache/tamaya/server/ConfigServiceApp.java
+++ b/modules/server/src/main/java/org/apache/tamaya/server/ConfigServiceApp.java
@@ -18,39 +18,57 @@
  */
 package org.apache.tamaya.server;
 
-import io.dropwizard.Application;
-import io.dropwizard.setup.Bootstrap;
-import io.dropwizard.setup.Environment;
+
+import com.sun.jersey.api.core.ResourceConfig;
+import com.sun.jersey.spi.container.servlet.ServletContainer;
+import org.apache.catalina.Context;
+import org.apache.catalina.Wrapper;
+import org.apache.catalina.startup.Tomcat;
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.ConfigurationProvider;
+
+import javax.servlet.Servlet;
+import javax.ws.rs.core.Application;
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
 
 /**
  * Main Application for the Tamaya Configuration Server.
  */
-public class ConfigServiceApp extends Application<ConfigServiceConfiguration> {
+public class ConfigServiceApp {
 
-    public static void main(String... args) throws Exception {
-        new ConfigServiceApp().run(args);
-    }
+    public class ResourceLoader extends Application{
 
-    @Override
-    public String getName() {
-        return "Tamaya Config-Server";
-    }
+        @Override
+        public Set<Class<?>> getClasses() {
+            final Set<Class<?>> classes = new HashSet<Class<?>>();
 
-    @Override
-    public void initialize(Bootstrap<ConfigServiceConfiguration> bootstrap) {
-        // nothing to do yet
+            // register root resource
+            classes.add(ConfigurationResource.class);
+            return classes;
+        }
     }
 
-    @Override
-    public void run(ConfigServiceConfiguration configuration,
-                    Environment environment) {
-        final ConfigurationResource resource = new ConfigurationResource(
-                configuration.getScope()
-        );
-    //    final TemplateHealthCheck healthCheck =
-    //            new TemplateHealthCheck(configuration.getTemplate());
-    //    environment.healthChecks().register("template", healthCheck);
-        environment.jersey().register(resource);
+    public static void main(String[] args) throws Exception {
+        Configuration config = ConfigurationProvider.getConfiguration();
+        String contextPath = config.getOrDefault("tamaya.server.contextPath", "/tamaya");
+        String appBase = ".";
+        Tomcat tomcat = new Tomcat();
+        tomcat.setPort(Integer.valueOf(config.getOrDefault("tamaya.server.port", Integer.class,
8085) ));
+
+        // Define a web application context.
+        Context context = tomcat.addWebapp(contextPath, new File(
+                appBase).getAbsolutePath());
+//        tomcat.getHost().setAppBase(appBase);
+        // Add servlet that will register Jersey REST resources
+        Wrapper wrapper = tomcat.addServlet(context, "jersey-container-servlet",
+                ServletContainer.class.getName());
+        wrapper.addInitParameter("com.sun.jersey.config.property.packages",
+                ConfigurationResource.class.getPackage().getName());
+        context.addServletMapping("/*", "jersey-container-servlet");
+        tomcat.start();
+        tomcat.getServer().await();
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/4b2d041b/modules/server/src/main/java/org/apache/tamaya/server/ConfigServiceConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/server/src/main/java/org/apache/tamaya/server/ConfigServiceConfiguration.java
b/modules/server/src/main/java/org/apache/tamaya/server/ConfigServiceConfiguration.java
deleted file mode 100644
index 6248e82..0000000
--- a/modules/server/src/main/java/org/apache/tamaya/server/ConfigServiceConfiguration.java
+++ /dev/null
@@ -1,41 +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;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import io.dropwizard.Configuration;
-
-/**
- *Configuration Server DropWizard Configuration.
- */
-public class ConfigServiceConfiguration extends Configuration {
-
-    private String scope;
-
-    @JsonProperty
-    public String getScope() {
-        return scope;
-    }
-
-    @JsonProperty
-    public void setScope(String scope) {
-        this.scope = scope;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/4b2d041b/modules/server/src/main/java/org/apache/tamaya/server/ConfigurationResource.java
----------------------------------------------------------------------
diff --git a/modules/server/src/main/java/org/apache/tamaya/server/ConfigurationResource.java
b/modules/server/src/main/java/org/apache/tamaya/server/ConfigurationResource.java
index ebc6eca..f13446a 100644
--- a/modules/server/src/main/java/org/apache/tamaya/server/ConfigurationResource.java
+++ b/modules/server/src/main/java/org/apache/tamaya/server/ConfigurationResource.java
@@ -51,14 +51,10 @@ import org.apache.tamaya.functions.ConfigurationFunctions;
 @Path("/")
 @Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN})
 public class ConfigurationResource {
-    private final String scope;
     private final AtomicLong readCounter = new AtomicLong();
     private final AtomicLong writeCounter = new AtomicLong();
     private final AtomicLong deleteCounter = new AtomicLong();
 
-    public ConfigurationResource(String scope) {
-        this.scope = scope;
-    }
 
     @GET
     @Path("/version")


Mime
View raw message