ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [01/50] [abbrv] incubator-ignite git commit: # ignite-47 Disable unnecessary injection. (cherry picked from commit 2c29387)
Date Thu, 12 Mar 2015 15:46:47 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-409 ac3987b78 -> 3eca9cc6c


# ignite-47 Disable unnecessary injection.
(cherry picked from commit 2c29387)


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

Branch: refs/heads/ignite-409
Commit: 6717796eb5f06f71c6da7d0fd8b0f03e960a6a7f
Parents: 330a705
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Sat Mar 7 21:14:48 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Wed Mar 11 18:34:16 2015 +0300

----------------------------------------------------------------------
 .../closure/GridClosureProcessor.java           | 49 ++++++++++++++------
 .../resource/GridNoImplicitInjection.java       | 25 ++++++++++
 .../processors/resource/GridResourceField.java  | 12 ++++-
 .../processors/resource/GridResourceIoc.java    | 15 +++---
 4 files changed, 79 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6717796e/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
index f1558b3..4fb1bdb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
@@ -22,6 +22,7 @@ import org.apache.ignite.cluster.*;
 import org.apache.ignite.compute.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.processors.*;
+import org.apache.ignite.internal.processors.resource.*;
 import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.future.*;
 import org.apache.ignite.internal.util.lang.*;
@@ -1092,7 +1093,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * Task that is free of dragged in enclosing context for the method
      * {@link GridClosureProcessor#runAsync(GridClosureCallMode, Collection, Collection)}.
      */
-    private class T1 extends TaskNoReduceAdapter<Void> {
+    private class T1 extends TaskNoReduceAdapter<Void> implements GridNoImplicitInjection
{
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -1126,7 +1127,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * Task that is free of dragged in enclosing context for the method
      * {@link GridClosureProcessor#runAsync(GridClosureCallMode, Runnable, Collection)}.
      */
-    private class T2 extends TaskNoReduceAdapter<Void> {
+    private class T2 extends TaskNoReduceAdapter<Void> implements GridNoImplicitInjection
{
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -1157,7 +1158,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * Task that is free of dragged in enclosing context for the method
      * {@link GridClosureProcessor#forkjoinAsync(GridClosureCallMode, Collection, org.apache.ignite.lang.IgniteReducer,
Collection)}
      */
-    private class T3<R1, R2> extends GridPeerDeployAwareTaskAdapter<Void, R2>
{
+    private class T3<R1, R2> extends GridPeerDeployAwareTaskAdapter<Void, R2>
implements GridNoImplicitInjection {
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -1210,7 +1211,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
     /**
      */
-    private static class T4 extends TaskNoReduceAdapter<Void> {
+    private static class T4 extends TaskNoReduceAdapter<Void> implements GridNoImplicitInjection
{
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -1241,7 +1242,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
     /**
      */
-    private static class T5<R> extends GridPeerDeployAwareTaskAdapter<Void, R>
{
+    private static class T5<R> extends GridPeerDeployAwareTaskAdapter<Void, R>
implements GridNoImplicitInjection {
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -1284,7 +1285,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * Task that is free of dragged in enclosing context for the method
      * {@link GridClosureProcessor#callAsync(GridClosureCallMode, Collection, Collection)}
      */
-    private class T6<R> extends GridPeerDeployAwareTaskAdapter<Void, Collection<R>>
{
+    private class T6<R> extends GridPeerDeployAwareTaskAdapter<Void, Collection<R>>
implements GridNoImplicitInjection {
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -1327,7 +1328,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * Task that is free of dragged in enclosing context for the method
      * {@link GridClosureProcessor#callAsync(GridClosureCallMode, Callable, Collection)}
      */
-    private class T7<R> extends GridPeerDeployAwareTaskAdapter<Void, R> {
+    private class T7<R> extends GridPeerDeployAwareTaskAdapter<Void, R> implements
GridNoImplicitInjection {
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -1365,7 +1366,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
     /**
      */
-    private static class T8<T, R> extends GridPeerDeployAwareTaskAdapter<Void, R>
{
+    private static class T8<T, R> extends GridPeerDeployAwareTaskAdapter<Void, R>
implements GridNoImplicitInjection {
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -1409,7 +1410,8 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
     /**
      */
-    private class T9<T, R> extends GridPeerDeployAwareTaskAdapter<Void, Collection<R>>
{
+    private class T9<T, R> extends GridPeerDeployAwareTaskAdapter<Void, Collection<R>>
+        implements GridNoImplicitInjection {
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -1460,7 +1462,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
     /**
      */
-    private class T10<T, R1, R2> extends GridPeerDeployAwareTaskAdapter<Void, R2>
{
+    private class T10<T, R1, R2> extends GridPeerDeployAwareTaskAdapter<Void, R2>
implements GridNoImplicitInjection {
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -1526,7 +1528,8 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
     /**
      */
-    private class T11<T, R> extends GridPeerDeployAwareTaskAdapter<Void, Collection<R>>
{
+    private class T11<T, R> extends GridPeerDeployAwareTaskAdapter<Void, Collection<R>>
+        implements GridNoImplicitInjection {
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -1574,7 +1577,8 @@ public class GridClosureProcessor extends GridProcessorAdapter {
     /**
      *
      */
-    private static class C1<T, R> implements ComputeJob, Externalizable {
+    private static class C1<T, R> implements ComputeJob, Externalizable, GridNoImplicitInjection,
+        GridInternalWrapper<IgniteClosure> {
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -1624,6 +1628,11 @@ public class GridClosureProcessor extends GridProcessorAdapter {
         }
 
         /** {@inheritDoc} */
+        @Override public IgniteClosure userObject() {
+            return job;
+        }
+
+        /** {@inheritDoc} */
         @Override public String toString() {
             return S.toString(C1.class, this);
         }
@@ -1665,7 +1674,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
     /**
      *
      */
-    private static class C2<R> implements ComputeJob, Externalizable {
+    private static class C2<R> implements ComputeJob, Externalizable, GridNoImplicitInjection,
GridInternalWrapper<Callable> {
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -1712,6 +1721,11 @@ public class GridClosureProcessor extends GridProcessorAdapter {
         }
 
         /** {@inheritDoc} */
+        @Override public Callable userObject() {
+            return c;
+        }
+
+        /** {@inheritDoc} */
         @Override public String toString() {
             return S.toString(C2.class, this);
         }
@@ -1751,7 +1765,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
     /**
      */
-    private static class C4 implements ComputeJob, Externalizable {
+    private static class C4 implements ComputeJob, Externalizable, GridNoImplicitInjection,
GridInternalWrapper<Runnable> {
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -1795,6 +1809,11 @@ public class GridClosureProcessor extends GridProcessorAdapter {
         }
 
         /** {@inheritDoc} */
+        @Override public Runnable userObject() {
+            return r;
+        }
+
+        /** {@inheritDoc} */
         @Override public String toString() {
             return S.toString(C4.class, this);
         }
@@ -1803,7 +1822,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
     /**
      *
      */
-    private static class C4MLA extends C4 implements ComputeJobMasterLeaveAware{
+    private static class C4MLA extends C4 implements ComputeJobMasterLeaveAware {
         /** */
         private static final long serialVersionUID = 0L;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6717796e/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridNoImplicitInjection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridNoImplicitInjection.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridNoImplicitInjection.java
new file mode 100644
index 0000000..93b833d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridNoImplicitInjection.java
@@ -0,0 +1,25 @@
+/*
+ * 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.ignite.internal.processors.resource;
+
+/**
+ * Disables injection.
+ */
+public interface GridNoImplicitInjection {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6717796e/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 04f750f..6b921f4 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
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.resource;
 
 import org.apache.ignite.internal.util.typedef.internal.*;
+import org.jetbrains.annotations.*;
 
 import java.lang.annotation.*;
 import java.lang.reflect.*;
@@ -42,12 +43,14 @@ class GridResourceField {
      * @param field Field where resource should be injected.
      * @param ann Resource annotation.
      */
-    GridResourceField(Field field, Annotation ann) {
+    GridResourceField(Field field, @Nullable Annotation ann) {
         assert field != null;
         assert ann != null || GridResourceUtils.mayRequireResources(field);
 
         this.field = field;
         this.ann = ann;
+
+        field.setAccessible(true);
     }
 
     /**
@@ -68,6 +71,13 @@ class GridResourceField {
         return ann;
     }
 
+    /**
+     * Return {@code true} if field contains object that should be process too.
+     */
+    public boolean processFieldValue() {
+        return ann == null;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(GridResourceField.class, this);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6717796e/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 de1ce60..10e0884 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
@@ -158,10 +158,8 @@ class GridResourceIoc {
         boolean injected = false;
 
         for (GridResourceField field : getFieldsWithAnnotation(dep, targetCls, annCls)) {
-            Field f = field.getField();
-
-            if (GridResourceUtils.mayRequireResources(f)) {
-                f.setAccessible(true);
+            if (field.processFieldValue()) {
+                Field f = field.getField();
 
                 try {
                     Object obj = f.get(target);
@@ -361,13 +359,18 @@ class GridResourceIoc {
         if (fields == null) {
             List<GridResourceField> fieldsList = new ArrayList<>();
 
+            boolean allowImplicitInjection = !GridNoImplicitInjection.class.isAssignableFrom(cls);
+
             for (Class cls0 = cls; !cls0.equals(Object.class); cls0 = cls0.getSuperclass())
{
                 for (Field field : cls0.getDeclaredFields()) {
                     Annotation ann = field.getAnnotation(annCls);
 
-                    if (ann != null || GridResourceUtils.mayRequireResources(field))
-                        // Account for anonymous inner classes.
+                    if (ann != null)
                         fieldsList.add(new GridResourceField(field, ann));
+                    else if (allowImplicitInjection && GridResourceUtils.mayRequireResources(field))
{
+                        // Account for anonymous inner classes.
+                        fieldsList.add(new GridResourceField(field, null));
+                    }
                 }
             }
 


Mime
View raw message