當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。