abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From calav...@apache.org
Subject svn commit: r670021 - /incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/RouteManager.java
Date Fri, 20 Jun 2008 18:25:37 GMT
Author: calavera
Date: Fri Jun 20 11:25:36 2008
New Revision: 670021

URL: http://svn.apache.org/viewvc?rev=670021&view=rev
Log:
RouteManager envolves the routes and targetTypes into a class, it eliminates target map. 
Thanks to Ed Ruder

Modified:
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/RouteManager.java

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/RouteManager.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/RouteManager.java?rev=670021&r1=670020&r2=670021&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/RouteManager.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/RouteManager.java
Fri Jun 20 11:25:36 2008
@@ -22,7 +22,6 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Collection;
 
 import org.apache.abdera.i18n.templates.CachingContext;
 import org.apache.abdera.i18n.templates.Context;
@@ -58,12 +57,19 @@
   implements Resolver<Target>,
              TargetBuilder {
 
-  protected Collection<Route> orderedTargets =
-    new ArrayList<Route>();
-    
-  protected Map<Route,TargetType> targets = 
-    new HashMap<Route,TargetType>();
-  
+  protected class RouteTargetType {
+    protected Route route;
+    protected TargetType targetType;
+
+    RouteTargetType(Route route, TargetType targetType) {
+      this.route = route;
+      this.targetType = targetType;
+    }
+  }
+
+  protected List<RouteTargetType> targets =
+      new ArrayList<RouteTargetType>();
+
   protected Map<String,Route> routes = 
     new HashMap<String,Route>();
 
@@ -88,10 +94,8 @@
     Route route, 
     TargetType type) {
       routes.put(route.getName(), route);
-      if (type != null) {
-        targets.put(route, type);
-        orderedTargets.add(route);
-      }
+      if (type != null) 
+        targets.add(new RouteTargetType(route, type));
       return this;
   }
   
@@ -124,13 +128,13 @@
     if (idx != -1) {
       uri = uri.substring(0, idx);
     }
-    for (Route route : orderedTargets) {
-      if (route.match(uri)) {
-        CollectionAdapter ca = route2CA.get(route);
+    for(RouteTargetType target : targets) {
+      if (target.route.match(uri)) {
+        CollectionAdapter ca = route2CA.get(target.route);
         if (ca != null) {
           context.setAttribute(DefaultWorkspaceManager.COLLECTION_ADAPTER_ATTRIBUTE, ca);
         }
-        return getTarget(context, route, uri, targets.get(route));
+        return getTarget(context, target.route, uri, target.targetType);
       }
     }
     return null;



Mime
View raw message