ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adorosz...@apache.org
Subject [ambari] branch trunk updated: Upgrade Ambari to Guice 4.1 (#358)
Date Wed, 14 Feb 2018 18:27:22 GMT
This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new b4b8e16  Upgrade Ambari to Guice 4.1 (#358)
b4b8e16 is described below

commit b4b8e16c75538f412f74a344e096d9bd0721312c
Author: Doroszlai, Attila <6454655+adoroszlai@users.noreply.github.com>
AuthorDate: Wed Feb 14 19:27:20 2018 +0100

    Upgrade Ambari to Guice 4.1 (#358)
---
 ambari-project/pom.xml                             | 22 ++++++++++++++--------
 ambari-server/pom.xml                              | 16 +++++++---------
 .../inject/persist/jpa/AmbariJpaPersistModule.java | 18 ++++++++----------
 .../persist/jpa/AmbariJpaPersistService.java       |  6 ++----
 .../org/apache/ambari/server/StaticallyInject.java |  5 +----
 .../users/CsvFilePersisterService.java             |  2 --
 6 files changed, 32 insertions(+), 37 deletions(-)

diff --git a/ambari-project/pom.xml b/ambari-project/pom.xml
index 690d7fa..b862190 100644
--- a/ambari-project/pom.xml
+++ b/ambari-project/pom.xml
@@ -36,6 +36,7 @@
     <swagger.version>1.5.10</swagger.version>
     <swagger.maven.plugin.version>3.1.4</swagger.maven.plugin.version>
     <slf4j.version>1.7.20</slf4j.version>
+    <guice.version>4.1.0</guice.version>
     <forkCount>4</forkCount>
     <reuseForks>false</reuseForks>
     <surefire.argLine>-Xmx1024m -Xms512m</surefire.argLine>
@@ -91,11 +92,6 @@
         <version>1.1</version>
       </dependency>
       <dependency>
-        <groupId>com.google.inject.extensions</groupId>
-        <artifactId>guice-servlet</artifactId>
-        <version>3.0</version>
-      </dependency>
-      <dependency>
         <groupId>org.codehaus.jettison</groupId>
         <artifactId>jettison</artifactId>
         <version>1.1</version>
@@ -103,17 +99,27 @@
       <dependency>
         <groupId>com.google.inject</groupId>
         <artifactId>guice</artifactId>
-        <version>3.0</version>
+        <version>${guice.version}</version>
       </dependency>
       <dependency>
         <groupId>com.google.inject.extensions</groupId>
         <artifactId>guice-assistedinject</artifactId>
-        <version>3.0</version>
+        <version>${guice.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>com.google.inject.extensions</groupId>
+        <artifactId>guice-multibindings</artifactId>
+        <version>${guice.version}</version>
       </dependency>
       <dependency>
         <groupId>com.google.inject.extensions</groupId>
         <artifactId>guice-persist</artifactId>
-        <version>3.0</version>
+        <version>${guice.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>com.google.inject.extensions</groupId>
+        <artifactId>guice-servlet</artifactId>
+        <version>${guice.version}</version>
       </dependency>
       <dependency>
         <groupId>com.google.code.gson</groupId>
diff --git a/ambari-server/pom.xml b/ambari-server/pom.xml
index 21c7777..a5d4f26 100644
--- a/ambari-server/pom.xml
+++ b/ambari-server/pom.xml
@@ -1168,21 +1168,24 @@
       <version>1.9.2</version>
     </dependency>
     <dependency>
+      <groupId>com.google.inject</groupId>
+      <artifactId>guice</artifactId>
+    </dependency>
+    <dependency>
       <groupId>com.google.inject.extensions</groupId>
       <artifactId>guice-assistedinject</artifactId>
     </dependency>
     <dependency>
       <groupId>com.google.inject.extensions</groupId>
-      <artifactId>guice-persist</artifactId>
+      <artifactId>guice-multibindings</artifactId>
     </dependency>
     <dependency>
       <groupId>com.google.inject.extensions</groupId>
-      <artifactId>guice-servlet</artifactId>
+      <artifactId>guice-persist</artifactId>
     </dependency>
     <dependency>
       <groupId>com.google.inject.extensions</groupId>
-      <artifactId>guice-multibindings</artifactId>
-      <version>3.0</version>
+      <artifactId>guice-servlet</artifactId>
     </dependency>
     <dependency>
       <groupId>com.h2database</groupId>
@@ -1467,11 +1470,6 @@
       <version>3.3.1</version>
     </dependency>
     <dependency>
-      <groupId>com.google.inject</groupId>
-      <artifactId>guice</artifactId>
-      <version>3.0</version>
-    </dependency>
-    <dependency>
       <groupId>com.google.code.gson</groupId>
       <artifactId>gson</artifactId>
       <version>2.2.2</version>
diff --git a/ambari-server/src/main/java/com/google/inject/persist/jpa/AmbariJpaPersistModule.java
b/ambari-server/src/main/java/com/google/inject/persist/jpa/AmbariJpaPersistModule.java
index ec51627..705b565 100644
--- a/ambari-server/src/main/java/com/google/inject/persist/jpa/AmbariJpaPersistModule.java
+++ b/ambari-server/src/main/java/com/google/inject/persist/jpa/AmbariJpaPersistModule.java
@@ -25,7 +25,7 @@ import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.util.List;
-import java.util.Properties;
+import java.util.Map;
 
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
@@ -38,13 +38,13 @@ import org.apache.ambari.server.orm.RequiresSession;
 
 import com.google.common.collect.Lists;
 import com.google.inject.Inject;
+import com.google.inject.Provides;
 import com.google.inject.Singleton;
 import com.google.inject.persist.PersistModule;
 import com.google.inject.persist.PersistService;
 import com.google.inject.persist.UnitOfWork;
 import com.google.inject.persist.finder.DynamicFinder;
 import com.google.inject.persist.finder.Finder;
-import com.google.inject.util.Providers;
 
 /**
  * Copy of guice persist module for local modifications
@@ -60,18 +60,12 @@ public class AmbariJpaPersistModule extends PersistModule {
     }
   }
 
-  private Properties properties;
+  private Map<?, ?> properties;
   private MethodInterceptor transactionInterceptor;
 
   @Override protected void configurePersistence() {
     bindConstant().annotatedWith(Jpa.class).to(jpaUnit);
 
-    if (null != properties) {
-      bind(Properties.class).annotatedWith(Jpa.class).toInstance(properties);
-    } else {
-      bind(Properties.class).annotatedWith(Jpa.class).toProvider(Providers.of(null));
-    }
-
     bind(AmbariJpaPersistService.class).in(Singleton.class);
 
     bind(PersistService.class).to(AmbariJpaPersistService.class);
@@ -100,13 +94,17 @@ public class AmbariJpaPersistModule extends PersistModule {
     return transactionInterceptor;
   }
 
+  @Provides @Jpa Map<?, ?> provideProperties() {
+    return properties;
+  }
+
   /**
    * Configures the JPA persistence provider with a set of properties.
    *
    * @param properties A set of name value pairs that configure a JPA persistence
    * provider as per the specification.
    */
-  public AmbariJpaPersistModule properties(Properties properties) {
+  public AmbariJpaPersistModule properties(Map<?, ?> properties) {
     this.properties = properties;
     return this;
   }
diff --git a/ambari-server/src/main/java/com/google/inject/persist/jpa/AmbariJpaPersistService.java
b/ambari-server/src/main/java/com/google/inject/persist/jpa/AmbariJpaPersistService.java
index 68b20e1..10a8af2 100644
--- a/ambari-server/src/main/java/com/google/inject/persist/jpa/AmbariJpaPersistService.java
+++ b/ambari-server/src/main/java/com/google/inject/persist/jpa/AmbariJpaPersistService.java
@@ -17,11 +17,9 @@
  */
 package com.google.inject.persist.jpa;
 
-
-import java.util.Properties;
+import java.util.Map;
 
 import com.google.inject.Inject;
-import com.google.inject.internal.util.$Nullable;
 
 /**
  * Override non-public class limitations as we need non-interface method
@@ -29,7 +27,7 @@ import com.google.inject.internal.util.$Nullable;
 public class AmbariJpaPersistService extends JpaPersistService {
 
   @Inject
-  public AmbariJpaPersistService(@Jpa String persistenceUnitName, @$Nullable @Jpa Properties
persistenceProperties) {
+  public AmbariJpaPersistService(@Jpa String persistenceUnitName, @Jpa Map<?, ?> persistenceProperties)
{
     super(persistenceUnitName, persistenceProperties);
   }
 
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/StaticallyInject.java b/ambari-server/src/main/java/org/apache/ambari/server/StaticallyInject.java
index ad793db..8937aae 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/StaticallyInject.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/StaticallyInject.java
@@ -22,13 +22,10 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
-import com.google.inject.ScopeAnnotation;
-
 /**
- * Annotation indicating there are static members that should be injected 
+ * Annotation indicating there are static members that should be injected
  */
 @Retention(RetentionPolicy.RUNTIME)
 @Target({ ElementType.TYPE })
-@ScopeAnnotation
 public @interface StaticallyInject {
 }
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/users/CsvFilePersisterService.java
b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/users/CsvFilePersisterService.java
index 67aa159..5c869e0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/users/CsvFilePersisterService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/users/CsvFilePersisterService.java
@@ -32,7 +32,6 @@ import java.util.Map;
 import java.util.Set;
 
 import javax.inject.Inject;
-import javax.inject.Singleton;
 
 import org.apache.commons.csv.CSVFormat;
 import org.apache.commons.csv.CSVPrinter;
@@ -42,7 +41,6 @@ import org.slf4j.LoggerFactory;
 import com.google.inject.assistedinject.Assisted;
 import com.google.inject.assistedinject.AssistedInject;
 
-@Singleton
 public class CsvFilePersisterService implements CollectionPersisterService<String, List<String>>
{
 
   private static final Logger LOGGER = LoggerFactory.getLogger(CsvFilePersisterService.class);

-- 
To stop receiving notification emails like this one, please contact
adoroszlai@apache.org.

Mime
View raw message