当前位置: 首页>>代码示例>>Java>>正文


Java VaadinRequest.getPathInfo方法代码示例

本文整理汇总了Java中com.vaadin.server.VaadinRequest.getPathInfo方法的典型用法代码示例。如果您正苦于以下问题:Java VaadinRequest.getPathInfo方法的具体用法?Java VaadinRequest.getPathInfo怎么用?Java VaadinRequest.getPathInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vaadin.server.VaadinRequest的用法示例。


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

示例1: getMainDivId

import com.vaadin.server.VaadinRequest; //导入方法依赖的package包/类
@Override
public String getMainDivId(VaadinSession session, VaadinRequest request, Class<? extends UI> uiClass) {
    String appId = request.getPathInfo();
    if (appId == null || "".equals(appId) || "/".equals(appId)) {
        appId = "ROOT";
    }
    appId = appId.replaceAll("[^a-zA-Z0-9]", "");
    // Add hashCode to the end, so that it is still (sort of)
    // predictable, but indicates that it should not be used in CSS
    // and
    // such:
    int hashCode = appId.hashCode();
    if (hashCode < 0) {
        hashCode = -hashCode;
    }
    appId = appId + "-" + hashCode;
    return appId;
}
 
开发者ID:mcollovati,项目名称:vaadin-vertx-samples,代码行数:19,代码来源:VertxVaadinService.java

示例2: extractIdFromCallback

import com.vaadin.server.VaadinRequest; //导入方法依赖的package包/类
@Override
public String extractIdFromCallback(VaadinRequest request) {
	String path = request.getPathInfo();
	if (path==null) {
		return null;
	}
	String[] pathParts = path.split("/");
	int len = pathParts.length;
	if (len < 2) {
		return null;
	}
	if (!CALLBACK_ID_NAME.equals(pathParts[len-2])) {
		return null;
	}
	return pathParts[len-1];
}
 
开发者ID:ahn,项目名称:vaadin-oauthpopup,代码行数:17,代码来源:OAuthCallbackInjecter.java

示例3: isUidlRequest

import com.vaadin.server.VaadinRequest; //导入方法依赖的package包/类
/**
 * Test if current request is an UIDL request
 * @return true if in UIDL request, false otherwise
 */
private boolean isUidlRequest() {
	VaadinRequest request = VaadinService.getCurrentRequest();
	
	if (request == null)
		return false;
	
	 String pathInfo = request.getPathInfo();

	 if (pathInfo == null) {
            return false;
	 }
	 
	 if (pathInfo.startsWith("/" + ApplicationConstants.UIDL_PATH)) {
            return true;
        }

        return false;
}
 
开发者ID:chelu,项目名称:jdal,代码行数:23,代码来源:VaadinAccessDeniedHandler.java

示例4: getBeanNameFromRequest

import com.vaadin.server.VaadinRequest; //导入方法依赖的package包/类
/**
 * Try to match a ant url pattern in url mapping and return the UI bean name
 * @param request vaadin request
 * @return the bean name for request, null if none.
 */
protected String getBeanNameFromRequest(VaadinRequest request) {
	String beanName = null;
	String pathInfo = request.getPathInfo();
	
	if (this.pathMatcher == null)
		this.pathMatcher = new AntPathMatcher();
	
	for (String pattern : this.urlMap.keySet())  {
		if (log.isDebugEnabled())
			log.debug("Matching pattern [" + pattern + "] over path info [" + pathInfo + "]");
		
		if (this.pathMatcher.match(pattern, request.getPathInfo())) {
			beanName = this.urlMap.get(pattern);
			if (log.isDebugEnabled())
				log.debug("Matching success. Using bean name  [" + beanName + "]");
			
			break;
		}
	}
		
	if (beanName == null)
		beanName = request.getPathInfo();
	
	return beanName;
}
 
开发者ID:chelu,项目名称:jdal,代码行数:31,代码来源:UrlBeanNameUiMapping.java

示例5: handleRequest

import com.vaadin.server.VaadinRequest; //导入方法依赖的package包/类
@Override
public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException {
    String path = request.getPathInfo();

    if (StringUtils.isEmpty(path) || StringUtils.isNotEmpty(path) && !path.startsWith(VAADIN_WEBJARS_PREFIX)) {
        return false;
    }

    log.trace("WebJar resource requested: {}", path.replace(VAADIN_WEBJARS_PREFIX, ""));

    String errorMessage = checkResourcePath(path);
    if (StringUtils.isNotEmpty(errorMessage)) {
        log.warn(errorMessage);
        response.sendError(HttpServletResponse.SC_FORBIDDEN, errorMessage);
        return false;
    }

    URL resourceUrl = getStaticResourceUrl(path);

    if (resourceUrl == null) {
        resourceUrl = getClassPathResourceUrl(path);
    }

    if (resourceUrl == null) {
        String msg = String.format("Requested WebJar resource is not found: %s", path);
        response.sendError(HttpServletResponse.SC_NOT_FOUND, msg);
        log.warn(msg);
        return false;
    }

    String resourceName = getResourceName(path);
    String mimeType = servletContext.getMimeType(resourceName);
    response.setContentType(mimeType != null ? mimeType : FileTypesHelper.DEFAULT_MIME_TYPE);

    String cacheControl = "public, max-age=0, must-revalidate";
    int resourceCacheTime = getCacheTime(resourceName);
    if (resourceCacheTime > 0) {
        cacheControl = "max-age=" + String.valueOf(resourceCacheTime);
    }
    response.setHeader("Cache-Control", cacheControl);
    response.setDateHeader("Expires", System.currentTimeMillis() + (resourceCacheTime * 1000));

    InputStream inputStream = null;
    try {
        URLConnection connection = resourceUrl.openConnection();
        long lastModifiedTime = connection.getLastModified();
        // Remove milliseconds to avoid comparison problems (milliseconds
        // are not returned by the browser in the "If-Modified-Since"
        // header).
        lastModifiedTime = lastModifiedTime - lastModifiedTime % 1000;
        response.setDateHeader("Last-Modified", lastModifiedTime);

        if (browserHasNewestVersion(request, lastModifiedTime)) {
            response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
            return true;
        }

        inputStream = connection.getInputStream();

        copy(inputStream, response.getOutputStream());

        return true;
    } finally {
        if (inputStream != null) {
            inputStream.close();
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:69,代码来源:CubaWebJarsHandler.java


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