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


Java ApplicationPath.value方法代码示例

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


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

示例1: getURLMappingFromApplication

import javax.ws.rs.ApplicationPath; //导入方法依赖的package包/类
private String getURLMappingFromApplication(Class<?> appClass) {
    ApplicationPath apath = appClass.getAnnotation(ApplicationPath.class);
    if (apath != null) {
        String urlMapping = apath.value();
        if (urlMapping == null || urlMapping.isEmpty() || urlMapping.equals("/")) {
            return "";
        }
        if (urlMapping != null && !urlMapping.startsWith("/")) {
            urlMapping = "/" + urlMapping;
        }
        return urlMapping;
    } 
    else {
        logger.finest("Didn't find @ApplicationPath in Application classs " + appClass.getName());
    }
    return null;
}
 
开发者ID:WASdev,项目名称:tool.swagger.docgen,代码行数:18,代码来源:SwaggerAnnotationsScanner.java

示例2: getPathSpec

import javax.ws.rs.ApplicationPath; //导入方法依赖的package包/类
private String getPathSpec(Class<? extends Application> appClass) {
  ApplicationPath applicationPath = appClass.getAnnotation(ApplicationPath.class);
  StringBuilder pathSpec = new StringBuilder(applicationPath.value());
  if(pathSpec.length()==0 || pathSpec.charAt(pathSpec.length()-1)!='/') {
    pathSpec.append('/');
  }
  pathSpec.append('*');
  return pathSpec.toString();
}
 
开发者ID:chonton,项目名称:apm-client,代码行数:10,代码来源:HelloMain.java

示例3: getApplicationPath

import javax.ws.rs.ApplicationPath; //导入方法依赖的package包/类
private static String getApplicationPath(Application applicationConfig) {
	if (applicationConfig == null) {
		return null;
	}
	ApplicationPath ap = applicationConfig.getClass().getAnnotation(ApplicationPath.class);
	if (ap == null) {
		return null;
	}
	String applicationPath = ap.value();
	if (isBlank(applicationPath)) {
		return null;
	}
	while (applicationPath.startsWith("/")) {
		applicationPath = applicationPath.substring(1);
	}
	// support Servlet configs
	if (applicationPath.endsWith("/*")) {
		applicationPath = applicationPath.substring(0, applicationPath.length() - 2);
	}
	while (applicationPath.endsWith("/")) {
		applicationPath = applicationPath.substring(0, applicationPath.length() - 1);
	}
	if (isBlank(applicationPath)) {
		return null;
	}
	return applicationPath;
}
 
开发者ID:bbilger,项目名称:jrestless,代码行数:28,代码来源:ApplicationPathFilter.java

示例4: getApplicationPath

import javax.ws.rs.ApplicationPath; //导入方法依赖的package包/类
private static String getApplicationPath(Application application) {
    ApplicationPath applicationPath = application.getClass().getAnnotation(ApplicationPath.class);
    if (applicationPath == null) {
        throw new RuntimeException(application.getClass() + " must have an ApplicationPath annotation");
    }
    return "/" + applicationPath.value();
}
 
开发者ID:binout,项目名称:jaxrs-unit,代码行数:8,代码来源:JaxrsServer.java

示例5: jerseyServlet

import javax.ws.rs.ApplicationPath; //导入方法依赖的package包/类
@Produces
public ServletDescriptor jerseyServlet() {
    String urlPattern = restServerConfiguration.getRestServletMapping();
    if (!applicationInstance.isUnsatisfied() && !applicationInstance.isAmbiguous()) {
        ApplicationPath annotation = ClassUtils.getAnnotation(applicationInstance.get().getClass(), ApplicationPath.class);
        if(annotation != null) {
            String path = annotation.value();
            urlPattern = path.endsWith("/") ? path + "*" : path + "/*";
        }
    }
    return new ServletDescriptor(SERVLET_NAME, null, new String[] { urlPattern }, 1, null, true, ServletContainer.class);
}
 
开发者ID:hammock-project,项目名称:hammock,代码行数:13,代码来源:JerseyContainerConfigurator.java

示例6: resteasyServlet

import javax.ws.rs.ApplicationPath; //导入方法依赖的package包/类
@Produces
public ServletDescriptor resteasyServlet() {
    String path = restServerConfiguration.getRestServerUri();
    if( !(applicationInstance.isUnsatisfied() || applicationInstance.isAmbiguous())) {
        ApplicationPath appPath = ClassUtils.getAnnotation(applicationInstance.get().getClass(), ApplicationPath.class);
        if(appPath != null) {
            path = appPath.value();
        }
    }
    String pattern = path.endsWith("/") ? path + "*" : path + "/*";
    WebInitParam param = new WebParam("resteasy.servlet.mapping.prefix", path);
    return new ServletDescriptor("ResteasyServlet",new String[]{pattern}, new String[]{pattern},
            1,new WebInitParam[]{param},true,HttpServlet30Dispatcher.class);
}
 
开发者ID:hammock-project,项目名称:hammock,代码行数:15,代码来源:ResteasyServletContextAttributeProvider.java

示例7: getApplicationContext

import javax.ws.rs.ApplicationPath; //导入方法依赖的package包/类
/**
 * Retrieve the context from the provided {@link Application}'s {@link ApplicationPath}.
 *
 * @param application with a {@link ApplicationPath} annotation.
 * @return String of the path.
 */
public static String getApplicationContext(Application application) {

	final Class<?> clazz = application.getClass();
	final ApplicationPath applicationPath = clazz.getAnnotation(ApplicationPath.class);

	String path = (applicationPath == null) ? "/" :
		applicationPath.value();

	if(path.length() < 1) {
		return "/";
	} else {
		return path.charAt(0) == '/' ? path : "/" + path;
	}
}
 
开发者ID:kevinbayes,项目名称:vest,代码行数:21,代码来源:UriPathUtil.java

示例8: appPrefix

import javax.ws.rs.ApplicationPath; //导入方法依赖的package包/类
private static String appPrefix(final WebAppInfo info, final Class<?> appClazz) {
    StringBuilder builder = null;

    // no annotation, try servlets
    for (final ServletInfo s : info.servlets) {
        if (s.mappings.isEmpty()) {
            continue;
        }

        String mapping = null;

        final String name = appClazz.getName();
        if (name.equals(s.servletClass) || name.equals(s.servletName) || "javax.ws.rs.core.Application ".equals(s.servletName)) {
            mapping = s.mappings.iterator().next();
        } else {
            for (final ParamValueInfo pvi : s.initParams) {
                if ("javax.ws.rs.Application".equals(pvi.name) || Application.class.getName().equals(pvi.name)) {
                    mapping = s.mappings.iterator().next();
                    break;
                }
            }
        }

        if (mapping != null) {
            if (mapping.endsWith("/*")) {
                mapping = mapping.substring(0, mapping.length() - 2);
            }
            if (mapping.startsWith("/")) {
                mapping = mapping.substring(1);
            }

            builder = new StringBuilder();
            builder.append(mapping);
            break;
        }
    }
    if (builder != null) { // https://issues.apache.org/jira/browse/CXF-5702
        return builder.toString();
    }

    // annotation
    final ApplicationPath path = appClazz.getAnnotation(ApplicationPath.class);
    if (path != null) {
        String appPath = path.value();
        if (appPath.endsWith("*")) {
            appPath = appPath.substring(0, appPath.length() - 1);
        }

        builder = new StringBuilder();
        if (appPath.startsWith("/")) {
            builder.append(appPath.substring(1));
        } else {
            builder.append(appPath);
        }
    }

    if (builder == null) {
        return null;
    }
    return builder.toString();
}
 
开发者ID:apache,项目名称:tomee,代码行数:62,代码来源:RESTService.java


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