• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Router类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中play.mvc.Router的典型用法代码示例。如果您正苦于以下问题:Java Router类的具体用法?Java Router怎么用?Java Router使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Router类属于play.mvc包,在下文中一共展示了Router类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onApplicationStart

import play.mvc.Router; //导入依赖的package包/类
@Override
public void onApplicationStart() {

	final Set<Class<?>> resourceClasses = 
			ApiHelpInventory.getInstance().getRootResources();		

	if (resourceClasses.size() > 0) {

		Map<String, Route> router = new HashMap<>();

		for(Route route : Router.routes){ 	
			router.put(route.action, route);
		}

		RouteWrapper routeWrapper = new RouteWrapper(router);
		RouteFactory.setRoute(routeWrapper);

		PlaySwaggerConfig playSwaggerConfig = new PlaySwaggerConfig();			
		PlayConfigFactory.setConfig(playSwaggerConfig);

		Router.prependRoute("GET", RESOURCES_JSON, "ApiHelpController.catchAll");
		Logger.info("Swagger: Added ROOT help api @ " + RESOURCES_JSON);
	}
}
 
开发者ID:abhishekShukla,项目名称:swagger-play,代码行数:25,代码来源:SwaggerPlugin.java


示例2: getTransformedFilesRelativeURLs

import play.mvc.Router; //导入依赖的package包/类
ArrayList<String> getTransformedFilesRelativeURLs() throws IOException {
	ArrayList<JSSourceDatabaseEntry> all_entries = getDatabase().getSortedEntries();
	ArrayList<String> results = new ArrayList<String>(all_entries.size() + 1);
	String url;
	
	if (reduced_declaration_file.exists()) {
		try {
			url = Router.reverse(VirtualFile.open(reduced_declaration_file));
			results.add(url);
		} catch (NoRouteFoundException e) {
			throw new IOException("Play can't resolve route for " + reduced_declaration_file.getPath());
		}
	}
	
	File transformed_file;
	for (int pos = 0; pos < all_entries.size(); pos++) {
		transformed_file = all_entries.get(pos).computeTransformedFilepath(module_path, transformed_directory);
		if (transformed_file.exists() == false) {
			Loggers.Play_JSSource.warn("A transformed file don't exists: " + transformed_file);
			continue;
		}
		url = Router.reverse(VirtualFile.open(transformed_file));
		results.add(url);
	}
	return results;
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:27,代码来源:JSSourceModule.java


示例3: pack

import play.mvc.Router; //导入依赖的package包/类
/**
 * @param hashtag_to_add (should be start with #)
 */
void pack(String hashtag_to_add) {
	if (url != null) {
		return;
	}
	if (hashtag_to_add == null) {
		hashtag_to_add = "";
	}
	
	try {
		if (controler_args.isEmpty()) {
			url = Router.reverse(controler_name).url + hashtag_to_add;
		} else {
			url = Router.reverse(controler_name, controler_args).url + hashtag_to_add;
		}
	} catch (NoRouteFoundException e) {
		Loggers.Play.error("Can't found route for " + controler_name);
		return;
	}
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:23,代码来源:HeaderJS.java


示例4: onApplicationStart

import play.mvc.Router; //导入依赖的package包/类
@Override public void onApplicationStart() {
  genericRouteIndex = Router.routes.size();
  for (int i = 0; i < Router.routes.size(); i++) {
    Router.Route route = Router.routes.get(i);
    if (route.action.startsWith("{controller}")) {
      genericRouteIndex = i; break;
    }
  }

  addWebRoutes(WebPage.ROOT.children());

  for (WebPage page : WebPage.all()) {
    String alias = page.metadata.getProperty("alias");
    if (isNotEmpty(alias)) {
      if (!alias.startsWith("/")) alias = "/" + alias;
      Router.appendRoute("GET", alias + "/?", "Web." + WEB_REDIRECT_ALIAS_METHOD, "{path:'" + page.path + "'}", null, null, 0);
    }

    if ("news".equals(page.metadata.getProperty("template"))) {
      WebPage.News.pathPrefixes.add(page.path.replaceFirst("/$", ""));
      Router.addRoute(genericRouteIndex, "GET", page.path + ".*", "Web." + WEB_NEWS_METHOD, null);
    }
  }

  lastModified = WebPage.ROOT.dir.lastModified();
}
 
开发者ID:codeborne,项目名称:play-web,代码行数:27,代码来源:WebContentPlugin.java


示例5: setUp

import play.mvc.Router; //导入依赖的package包/类
@Before
public void setUp() {
  Play.configuration.clear();
  Http.Request.current.set(request = newHttpRequest());
  Http.Response.current.set(response = new Http.Response());
  Scope.Session.current.set(new Scope.Session());
  Scope.RenderArgs.current.set(new Scope.RenderArgs());
  request.path = "/";
  Play.langs.add("en");
  Play.langs.add("ru");
  Play.mode = DEV;
  Router.routes.clear();
  plugin = new WebContentPlugin();
  pages = asList(forPath("/en/marketing/"), forPath("/ru/marketing/"));
  resetWebCacheSetting();
}
 
开发者ID:codeborne,项目名称:play-web,代码行数:17,代码来源:WebContentPluginTest.java


示例6: onRoutesLoaded

import play.mvc.Router; //导入依赖的package包/类
@Override
public void onRoutesLoaded() {
    Router.addRoute("GET", "/@tests", "TestRunner.index");
    Router.addRoute("GET", "/@tests.list", "TestRunner.list");
    Router.addRoute("GET", "/@tests/{<.*>test}", "TestRunner.run");
    Router.addRoute("POST", "/@tests/{<.*>test}", "TestRunner.saveResult");
    Router.addRoute("GET", "/@tests/emails", "TestRunner.mockEmail");
    Router.addRoute("GET", "/@tests/cache", "TestRunner.cacheEntry");
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:10,代码来源:TestRunnerPlugin.java


示例7: onRoutesLoaded

import play.mvc.Router; //导入依赖的package包/类
@Override
public void onRoutesLoaded() {
    if (Play.configuration.contains("play.search.password" ) || Play.mode == Play.Mode.DEV) {
        Router.addRoute("GET", "/@search/?", "modules.search.Administration.index");
        Router.addRoute("GET", "/@search/optimize/{name}", "modules.search.Administration.optimize");
        Router.addRoute("GET", "/@search/reindex/{name}", "modules.search.Administration.reindex");
        Router.addRoute("GET", "/@search/reopen/{name}", "modules.search.Administration.reopen");
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:10,代码来源:SearchPlugin.java


示例8: stop

import play.mvc.Router; //导入依赖的package包/类
/**
 * Stop the application
 */
public static synchronized void stop() {
    if (started) {
        Logger.trace("Stopping the play application");
        pluginCollection.onApplicationStop();
        started = false;
        Cache.stop();
        Router.lastLoading = 0L;
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:13,代码来源:Play.java


示例9: loadRouter

import play.mvc.Router; //导入依赖的package包/类
private static synchronized void loadRouter(String contextPath) {
    // Reload the rules, but this time with the context. Not really efficient through...
    // Servlet 2.4 does not allow you to get the context path from the servletcontext...
    if (routerInitializedWithContext) return;
    Play.ctxPath = contextPath;
    Router.load(contextPath);
    routerInitializedWithContext = true;
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:9,代码来源:ServletWrapper.java


示例10: getConcatedFileRelativeURL

import play.mvc.Router; //导入依赖的package包/类
public String getConcatedFileRelativeURL() throws IOException {
	CopyMove.checkExistsCanRead(allfiles_concated_file);
	
	HashMap<String, Object> args = new HashMap<String, Object>(2);
	args.put("name", allfiles_concated_file.getName());
	args.put("suffix_date", allfiles_concated_file.lastModified() / 1000);
	return Router.reverse(AsyncJavascript.class.getName() + "." + "JavascriptRessource", args).url;
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:9,代码来源:JSSourceModule.java


示例11: setStaticFile

import play.mvc.Router; //导入依赖的package包/类
/**
 * Not need to pack.
 */
void setStaticFile(String relative_file) {
	try {
		url = Router.reverse(VirtualFile.fromRelativePath(relative_file));
	} catch (NoRouteFoundException e) {
		Loggers.Play.error("Can't found route for " + relative_file);
		url = "/";
	}
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:12,代码来源:HeaderJS.java


示例12: addWebRoutes

import play.mvc.Router; //导入依赖的package包/类
void addWebRoutes(List<WebPage> pages) {
  for (WebPage page : pages) {
    String path = page.path;
    if (path.endsWith("/")) path = substring(path, 0, -1);
    Router.addRoute(genericRouteIndex, "GET", path + "/?.*", "Web." + WEB_CONTENT_METHOD, null);
    if (cacheEnabled())  // cache top-level pages on production
      Router.addRoute(genericRouteIndex, "GET", path + "/", "Web." + WEB_CACHED_CONTENT_METHOD, null);
  }
}
 
开发者ID:codeborne,项目名称:play-web,代码行数:10,代码来源:WebContentPlugin.java


示例13: onRoutesLoaded

import play.mvc.Router; //导入依赖的package包/类
@Override
public void onRoutesLoaded() {
    Router.prependRoute("GET", "/@accesslog", "AccessLogs.index");
    Router.prependRoute("WS", "/@accesslog/logs", "AccessLogWebsockets.logs");
}
 
开发者ID:sismics,项目名称:play-accesslog,代码行数:6,代码来源:AccessLogPlugin.java


示例14: onRoutesLoaded

import play.mvc.Router; //导入依赖的package包/类
@Override
public void onRoutesLoaded() {
    Router.addRoute("GET", "/@profiler/results", "ProfilerActions.results");
    Router.addRoute("GET", "/@profiler/public/", "staticDir:public/");
}
 
开发者ID:PerfectCarl,项目名称:play-profiler,代码行数:6,代码来源:ProfilerPlugin.java


示例15: getListAction

import play.mvc.Router; //导入依赖的package包/类
public Object getListAction() {
    return Router.reverse(controllerClass.getName().replace("$", "") + ".list");
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:4,代码来源:CRUD.java


示例16: getBlankAction

import play.mvc.Router; //导入依赖的package包/类
public Object getBlankAction() {
    return Router.reverse(controllerClass.getName().replace("$", "") + ".blank");
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:4,代码来源:CRUD.java


示例17: __reverseWithCheck

import play.mvc.Router; //导入依赖的package包/类
private String __reverseWithCheck(String action, boolean absolute) {
    return Router.reverseWithCheck(action, Play.getVirtualFile(action), absolute);
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:4,代码来源:GroovyTemplate.java


示例18: parseRequest

import play.mvc.Router; //导入依赖的package包/类
public static Request parseRequest(HttpServletRequest httpServletRequest) throws Exception {

        URI uri = new URI(httpServletRequest.getRequestURI());
        String method = httpServletRequest.getMethod().intern();
        String path = uri.getPath();
        String querystring = httpServletRequest.getQueryString() == null ? "" : httpServletRequest.getQueryString();

        if (Logger.isTraceEnabled()) {
            Logger.trace("httpServletRequest.getContextPath(): " + httpServletRequest.getContextPath());
            Logger.trace("request.path: " + path + ", request.querystring: " + querystring);
        }

        String contentType = null;
        if (httpServletRequest.getHeader("Content-Type") != null) {
            contentType = httpServletRequest.getHeader("Content-Type").split(";")[0].trim().toLowerCase().intern();
        } else {
            contentType = "text/html".intern();
        }

        if (httpServletRequest.getHeader("X-HTTP-Method-Override") != null) {
            method = httpServletRequest.getHeader("X-HTTP-Method-Override").intern();
        }

        InputStream body = httpServletRequest.getInputStream();
        boolean secure = httpServletRequest.isSecure();

        String url = uri.toString() + (httpServletRequest.getQueryString() == null ? "" : "?" + httpServletRequest.getQueryString());
        String host = httpServletRequest.getHeader("host");
        int port = 0;
        String domain = null;
        if (host.contains(":")) {
            port = Integer.parseInt(host.split(":")[1]);
            domain = host.split(":")[0];
        } else {
            port = 80;
            domain = host;
        }

        String remoteAddress = httpServletRequest.getRemoteAddr();

        boolean isLoopback = host.matches("^127\\.0\\.0\\.1:?[0-9]*$");


        final Request request = Request.createRequest(
                remoteAddress,
                method,
                path,
                querystring,
                contentType,
                body,
                url,
                host,
                isLoopback,
                port,
                domain,
                secure,
                getHeaders(httpServletRequest),
                getCookies(httpServletRequest));


        Request.current.set(request);
        Router.routeOnlyStatic(request);

        return request;
    }
 
开发者ID:eBay,项目名称:restcommander,代码行数:66,代码来源:ServletWrapper.java


示例19: onRequestRouting

import play.mvc.Router; //导入依赖的package包/类
public void onRequestRouting(Router.Route route){
    for (PlayPlugin plugin : getEnabledPlugins()) {
        plugin.onRequestRouting(route);
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:6,代码来源:PluginCollection.java


示例20: assertCached

import play.mvc.Router; //导入依赖的package包/类
private void assertCached(String url) {
  assertEquals("Web.serveContentCached", Router.route("GET", url).get("action"));
}
 
开发者ID:codeborne,项目名称:play-web,代码行数:4,代码来源:WebContentPluginTest.java



注:本文中的play.mvc.Router类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StandardSessionFacade类代码示例发布时间:2022-05-23
下一篇:
Java ForkContentHandler类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap