tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: fixing application runner injections when there is a parent
Date Tue, 04 Oct 2016 10:22:48 GMT
Repository: tomee
Updated Branches:
  refs/heads/master 3bb08cbe1 -> 5c33866d9


fixing application runner injections when there is a parent


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/5c33866d
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/5c33866d
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/5c33866d

Branch: refs/heads/master
Commit: 5c33866d94742043a6ed301286adc22eb8502e3b
Parents: 3bb08cb
Author: rmannibucau <rmannibucau@apache.org>
Authored: Tue Oct 4 12:22:41 2016 +0200
Committer: rmannibucau <rmannibucau@apache.org>
Committed: Tue Oct 4 12:22:41 2016 +0200

----------------------------------------------------------------------
 .../TomEEEmbeddedApplicationRunner.java         | 65 ++++++++++----------
 1 file changed, 32 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/5c33866d/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/TomEEEmbeddedApplicationRunner.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/TomEEEmbeddedApplicationRunner.java
b/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/TomEEEmbeddedApplicationRunner.java
index 34826c3..7721aa7 100644
--- a/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/TomEEEmbeddedApplicationRunner.java
+++ b/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/TomEEEmbeddedApplicationRunner.java
@@ -387,43 +387,42 @@ public class TomEEEmbeddedApplicationRunner implements AutoCloseable
{
             OWBInjector.inject(webBeansContext.getBeanManagerImpl(), target, null);
         }
 
-        final Class<?> aClass = target.getClass();
-        for (final Field f : aClass.getDeclaredFields()) {
-            final RandomPort randomPort = f.getAnnotation(RandomPort.class);
-            if (randomPort != null) {
-                for (final Field field : app.getClass().getDeclaredFields()) {
-                    final RandomPort appPort = field.getAnnotation(RandomPort.class);
-                    if (field.getType() == f.getType() && appPort != null &&
appPort.value().equals(randomPort.value())) {
-                        if (!field.isAccessible()) {
-                            field.setAccessible(true);
+        Class<?> aClass = target.getClass();
+        while (aClass != null && aClass != Object.class) {
+            for (final Field f : aClass.getDeclaredFields()) {
+                final RandomPort randomPort = f.getAnnotation(RandomPort.class);
+                if (randomPort != null) {
+                    for (final Field field : app.getClass().getDeclaredFields()) {
+                        final RandomPort appPort = field.getAnnotation(RandomPort.class);
+                        if (field.getType() == f.getType() && appPort != null &&
appPort.value().equals(randomPort.value())) {
+                            if (!field.isAccessible()) {
+                                field.setAccessible(true);
+                            }
+                            if (!f.isAccessible()) {
+                                f.setAccessible(true);
+                            }
+
+                            final Object value = field.get(app);
+                            f.set(target, value);
+                            break;
                         }
-                        if (!f.isAccessible()) {
-                            f.setAccessible(true);
-                        }
-
-                        final Object value = field.get(app);
-                        f.set(target, value);
-                        break;
                     }
+                } else if (f.isAnnotationPresent(Application.class)) {
+                    if (!f.isAccessible()) {
+                        f.setAccessible(true);
+                    }
+                    f.set(target, app);
+                } else if (f.isAnnotationPresent(LifecycleTask.class)) {
+                    if (!f.isAccessible()) {
+                        f.setAccessible(true);
+                    }
+                    final LifecycleTaskAccessor accessor = SystemInstance.get().getComponent(LifecycleTaskAccessor.class);
+                    final Class type = f.getType();
+                    final Object taskByType = accessor.getTaskByType(type);
+                    f.set(target, taskByType);
                 }
-            } else if (f.isAnnotationPresent(Application.class)) {
-                if (!f.isAccessible()) {
-                    f.setAccessible(true);
-                }
-                f.set(target, app);
-            } else if (f.isAnnotationPresent(LifecycleTask.class)) {
-                if (!f.isAccessible()) {
-                    f.setAccessible(true);
-                }
-                final LifecycleTaskAccessor accessor = SystemInstance.get().getComponent(LifecycleTaskAccessor.class);
-                final Class type = f.getType();
-                final Object taskByType = accessor.getTaskByType(type);
-                f.set(target, taskByType);
             }
-        }
-        final Class<?> superclass = aClass.getSuperclass();
-        if (superclass != Object.class) {
-            composerInject(superclass);
+            aClass = aClass.getSuperclass();
         }
 
         SystemInstance.get().fireEvent(new TomEEEmbeddedApplicationRunnerInjection(target));


Mime
View raw message