public final DispatchBridge createDispatch(Phase phase, final MethodHandle target, final Map<String, ResponseParameter> parameters) {
ControllerHandler handler = bridge.getApplication().resolveBean(ControllerService.class).getDescriptor().getMethodByHandle(target);
//
Route route = this.handler.getRoute(handler.getHandle());
if (route == null) {
if (bridge.getApplication().resolveBean(ControllerService.class).getResolver().isIndex(handler)) {
route = this.handler.getRoot();
}
}
//
if (route != null) {
Map<String, String> params;
if (parameters.isEmpty()) {
params = Collections.emptyMap();
} else {
params = new HashMap<String, String>(parameters.size());
for (ResponseParameter parameter : parameters.values()) {
params.put(parameter.getName(), parameter.get(0));
}
}
//
final RouteMatch match = route.matches(params);
if (match != null) {
return new DispatchBridge() {
public MethodHandle getTarget() {
return target;