本文整理汇总了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;
}
示例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();
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}
示例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;
}
}
示例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();
}