use of com.blade.mvc.route.loader.ClassPathRouteLoader in project blade by biezhi.
the class Blade method routeConf.
/**
* Registration of a configuration file, e.g: "com.xxx.route","route.conf"
*
* @param basePackage controller package name
* @param conf Configuration file path, the configuration file must be in
* classpath
* @return return blade
*/
public Blade routeConf(String basePackage, String conf) {
try {
Assert.notBlank(basePackage);
Assert.notBlank(conf);
InputStream ins = Blade.class.getResourceAsStream("/" + conf);
ClassPathRouteLoader routesLoader = new ClassPathRouteLoader(ins);
routesLoader.setBasePackage(basePackage);
List<Route> routes = routesLoader.load();
routers.addRoutes(routes);
} catch (RouteException | ParseException e) {
throw new BladeException(e);
}
return this;
}
Aggregations