ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbeerbo...@apache.org
Subject ambari git commit: AMBARI-10748 - Views: IllegalAccessError: tried to access class - update (tbeerbower)
Date Tue, 28 Apr 2015 16:49:58 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.0.maint f82ed9213 -> 5eab7803f


AMBARI-10748 - Views: IllegalAccessError: tried to access class - update (tbeerbower)


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

Branch: refs/heads/branch-2.0.maint
Commit: 5eab7803f7663082cda772935cc9a9203e78a582
Parents: f82ed92
Author: tbeerbower <tbeerbower@hortonworks.com>
Authored: Tue Apr 28 12:13:39 2015 -0400
Committer: tbeerbower <tbeerbower@hortonworks.com>
Committed: Tue Apr 28 12:47:26 2015 -0400

----------------------------------------------------------------------
 .../server/controller/AmbariHandlerList.java    | 49 +++++++++++++++-----
 1 file changed, 37 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5eab7803/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariHandlerList.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariHandlerList.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariHandlerList.java
index c6aac1d..607da10 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariHandlerList.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariHandlerList.java
@@ -18,7 +18,12 @@
 package org.apache.ambari.server.controller;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -83,7 +88,12 @@ public class AmbariHandlerList extends HandlerCollection implements ViewInstance
   /**
    * Mapping of view instance entities to handlers.
    */
-  private final Map<ViewInstanceEntity, Handler> handlerMap = new HashMap<ViewInstanceEntity,
Handler>();
+  private final Map<ViewInstanceEntity, Handler> viewHandlerMap = new HashMap<ViewInstanceEntity,
Handler>();
+
+  /**
+   * The non-view handlers.
+   */
+  private final Collection<Handler> nonViewHandlers = new HashSet<Handler>();
 
   /**
    * The logger.
@@ -125,7 +135,6 @@ public class AmbariHandlerList extends HandlerCollection implements ViewInstance
   }
 
 
-
   // ----- HandlerCollection -------------------------------------------------
 
   @Override
@@ -158,14 +167,19 @@ public class AmbariHandlerList extends HandlerCollection implements
ViewInstance
     }
   }
 
+  @Override
+  public void addHandler(Handler handler) {
+    nonViewHandlers.add(handler);
+    super.addHandler(handler);
+  }
 
-  // ----- ViewInstanceHandler -----------------------------------------------
+// ----- ViewInstanceHandler -----------------------------------------------
 
   @Override
   public void addViewInstance(ViewInstanceEntity viewInstanceDefinition) throws SystemException
{
     Handler handler = getHandler(viewInstanceDefinition);
-    handlerMap.put(viewInstanceDefinition, handler);
-    addHandler(handler);
+    viewHandlerMap.put(viewInstanceDefinition, handler);
+    super.addHandler(handler);
     // if this is running then start the handler being added...
     if(!isStopped() && !isStopping()) {
       try {
@@ -178,9 +192,9 @@ public class AmbariHandlerList extends HandlerCollection implements ViewInstance
 
   @Override
   public void removeViewInstance(ViewInstanceEntity viewInstanceDefinition) {
-    Handler handler = handlerMap.get(viewInstanceDefinition);
+    Handler handler = viewHandlerMap.get(viewInstanceDefinition);
     if (handler != null) {
-      handlerMap.remove(viewInstanceDefinition);
+      viewHandlerMap.remove(viewInstanceDefinition);
       removeHandler(handler);
     }
   }
@@ -196,13 +210,24 @@ public class AmbariHandlerList extends HandlerCollection implements
ViewInstance
     final Handler[] handlers = getHandlers();
 
     if (handlers != null && isStarted()) {
-      for (Handler handler : handlers) {
-        handler.handle(target, baseRequest, request, response);
-        if (baseRequest.isHandled()) {
-          return;
-        }
+      if (!processHandlers(viewHandlerMap.values(), target, baseRequest, request, response))
{
+        processHandlers(nonViewHandlers, target, baseRequest, request, response);
+      }
+    }
+  }
+
+  // call the given handlers until the request is handled; return true if the request is
handled
+  private boolean processHandlers(Collection<Handler> handlers, String target, Request
baseRequest,
+                               HttpServletRequest request, HttpServletResponse response)
+      throws IOException, ServletException {
+
+    for (Handler handler : handlers) {
+      handler.handle(target, baseRequest, request, response);
+      if (baseRequest.isHandled()) {
+        return true;
       }
     }
+    return false;
   }
 
   /**


Mime
View raw message