Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright (C) the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ninja;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import ninja.utils.MethodReference;
import ninja.utils.NinjaProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Provider;
import java.lang.reflect.Method;
import ninja.websockets.WebSockets;
public class RouterImpl implements Router {
static private final Logger logger = LoggerFactory.getLogger(RouterImpl.class);
private final NinjaProperties ninjaProperties;
private final List allRouteBuilders = new ArrayList<>();
private final Injector injector;
private final WebSockets webSockets;
private List routes;
// for fast reverse route lookups
private Map reverseRoutes;
private final Provider routeBuilderImplProvider;
@Inject
public RouterImpl(Injector injector,
NinjaProperties ninjaProperties,
WebSockets webSockets,
Provider routeBuilderImplProvider) {
this.injector = injector;
this.ninjaProperties = ninjaProperties;
this.webSockets = webSockets;
this.routeBuilderImplProvider = routeBuilderImplProvider;
}
@Override
public Route getRouteFor(String httpMethod, String uri) {
if (routes == null) {
throw new IllegalStateException(
"Attempt to get route when routes not compiled");
}
for (Route route : routes) {
if (route.matches(httpMethod, uri)) {
return route;
}
}
return null;
}
@Override
public String getReverseRoute(
Class> controllerClass,
String controllerMethodName) {
Optional