ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sevdoki...@apache.org
Subject [04/26] incubator-ignite git commit: # IGNITE-894 Code cleanup.
Date Thu, 14 May 2015 14:40:31 GMT
# IGNITE-894 Code cleanup.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/96ad5a86
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/96ad5a86
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/96ad5a86

Branch: refs/heads/ignite-709_2
Commit: 96ad5a8605b54e02057253ad7d330f2726ddd687
Parents: f027ac5
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Tue May 12 18:39:37 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Tue May 12 18:39:37 2015 +0300

----------------------------------------------------------------------
 .../processors/resource/GridResourceField.java    |  5 +----
 .../processors/resource/GridResourceIoc.java      | 18 ++++++++++--------
 .../apache/ignite/internal/util/IgniteUtils.java  |  3 +++
 3 files changed, 14 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/96ad5a86/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceField.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceField.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceField.java
index 162de1c..fed7ebd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceField.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceField.java
@@ -44,10 +44,7 @@ class GridResourceField {
      * @param field Field where resource should be injected.
      * @param ann Resource annotation.
      */
-    GridResourceField(Field field, @Nullable Annotation ann) {
-        assert field != null;
-        assert ann != null || GridResourceUtils.mayRequireResources(field);
-
+    GridResourceField(@NotNull Field field, @NotNull Annotation ann) {
         this.field = field;
         this.ann = ann;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/96ad5a86/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceIoc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceIoc.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceIoc.java
index c2ef116..3d853d6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceIoc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceIoc.java
@@ -21,6 +21,7 @@ import org.apache.ignite.*;
 import org.apache.ignite.internal.managers.deployment.*;
 import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
 import org.jetbrains.annotations.*;
 import org.jsr166.*;
 
@@ -142,9 +143,9 @@ class GridResourceIoc {
 
         boolean injected = false;
 
-        for (GridResourceField field : descr.recursiveFields()) {
+        for (Field field : descr.recursiveFields()) {
             try {
-                Object obj = field.getField().get(target);
+                Object obj = field.get(target);
 
                 if (obj != null) {
                     assert checkedObjs != null;
@@ -153,7 +154,7 @@ class GridResourceIoc {
                 }
             }
             catch (IllegalAccessException e) {
-                throw new IgniteCheckedException("Failed to inject resource [field=" + field.getField().getName()
+
+                throw new IgniteCheckedException("Failed to inject resource [field=" + field.getName()
+
                     ", target=" + target + ']', e);
             }
         }
@@ -253,7 +254,7 @@ class GridResourceIoc {
      */
     private static class ClassDescriptor {
         /** */
-        private final GridResourceField[] recursiveFields;
+        private final Field[] recursiveFields;
 
         /** */
         private final Map<Class<? extends Annotation>, T2<GridResourceField[],
GridResourceMethod[]>> annMap;
@@ -265,7 +266,7 @@ class GridResourceIoc {
             Map<Class<? extends Annotation>, T2<List<GridResourceField>,
List<GridResourceMethod>>> annMap
                 = new HashMap<>();
 
-            Collection<GridResourceField> recursiveFieldsList = new ArrayList<>();
+            List<Field> recursiveFieldsList = new ArrayList<>();
 
             boolean allowImplicitInjection = !GridNoImplicitInjection.class.isAssignableFrom(cls);
 
@@ -291,7 +292,7 @@ class GridResourceIoc {
                         && fieldAnns.length == 0
                         && GridResourceUtils.mayRequireResources(field)) {
                         // Account for anonymous inner classes.
-                        recursiveFieldsList.add(new GridResourceField(field, null));
+                        recursiveFieldsList.add(field);
                     }
                 }
 
@@ -312,7 +313,8 @@ class GridResourceIoc {
                 }
             }
 
-            recursiveFields = GridResourceField.toArray(recursiveFieldsList);
+            recursiveFields = recursiveFieldsList.isEmpty() ? U.EMPTY_FIELDS
+                : recursiveFieldsList.toArray(new Field[recursiveFieldsList.size()]);
 
             this.annMap = IgniteUtils.limitedMap(annMap.size());
 
@@ -328,7 +330,7 @@ class GridResourceIoc {
         /**
          * @return Recursive fields.
          */
-        public GridResourceField[] recursiveFields() {
+        public Field[] recursiveFields() {
             return recursiveFields;
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/96ad5a86/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index ffb4e99..673287d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -113,6 +113,9 @@ public abstract class IgniteUtils {
     /** Empty  longs. */
     public static final long[] EMPTY_LONGS = new long[0];
 
+    /** Empty  longs. */
+    public static final Field[] EMPTY_FIELDS = new Field[0];
+
     /** System line separator. */
     private static final String NL = System.getProperty("line.separator");
 


Mime
View raw message