Author: julien_viet
Date: 2010-09-01 17:17:15 -0400 (Wed, 01 Sep 2010)
New Revision: 4023
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Router.java
Log:
encapsulate the route creation inside the Route object
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java 2010-09-01
19:59:16 UTC (rev 4022)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java 2010-09-01
21:17:15 UTC (rev 4023)
@@ -269,8 +269,25 @@
/** . */
private static final Pattern PARAMETER_REGEX =
Pattern.compile("^(?:\\{([^\\}]*)\\})?(.*)$");
- Route append(String path)
+ Route append(
+ String path,
+ String controllerRef,
+ Map<QualifiedName, String[]> parameters)
{
+ Route route = append(path);
+ route.controllerRef = controllerRef;
+ route.routeParameters.putAll(parameters);
+ return route;
+ }
+
+ /**
+ * Append a path, creates the necessary routes and returns the last route added.
+ *
+ * @param path the path to append
+ * @return the last route added
+ */
+ private Route append(String path)
+ {
int pos = path.length();
int level = 0;
List<Integer> start = new ArrayList<Integer>();
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Router.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Router.java 2010-09-01
19:59:16 UTC (rev 4022)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Router.java 2010-09-01
21:17:15 UTC (rev 4023)
@@ -25,7 +25,6 @@
import org.exoplatform.web.controller.metadata.ControllerRefMetaData;
import org.exoplatform.web.controller.metadata.RouterMetaData;
import org.exoplatform.web.controller.protocol.ControllerResponse;
-import org.exoplatform.web.controller.protocol.ProcessResponse;
import java.io.IOException;
import java.util.Map;
@@ -48,9 +47,7 @@
for (Map.Entry<String, ControllerRefMetaData> routeMetaData :
metaData.getRoutes().entrySet())
{
String path = routeMetaData.getKey();
- Route route = root.append(path);
- route.controllerRef = routeMetaData.getValue().getRef();
- route.routeParameters.putAll(routeMetaData.getValue().getParameters());
+ root.append(path, routeMetaData.getValue().getRef(),
routeMetaData.getValue().getParameters());
}
//
Show replies by date