* @param params
* @return
*/
public Service lookupResource(String uri) {
String[] routePath = uri.split("/");
ServiceRoute current = root;
ServiceRoute child = null;
List<ServiceRoute> paramChild = null;
int index = 0;
int len = routePath.length;
for (String path : routePath) {
index++;
if (current == null)
break;
path = path.trim();
if ("".equals(path))
continue;
paramChild = current.getParamChild(PARAM_KEY);
if (paramChild != null) {
for (ServiceRoute p : paramChild)
RestContextManager.getModelMap()
.put(p.getParamName(), path);
}
child = current.getRouteChild(path);
if (child == null && paramChild != null && index < len) {
child = this.lookupNextRoute(routePath[index], paramChild);
}
if (child == null && paramChild != null) {
child = this.lookupNextRoute(null, paramChild);
}
ServiceRoute parent = current.getParent();
if (child == null
&& (parent != null && this.hasRouteNode(path, parent
.getRouteChildren()))) {
continue;
}
current = child;