本文整理汇总了Java中javax.ws.rs.Path.value方法的典型用法代码示例。如果您正苦于以下问题:Java Path.value方法的具体用法?Java Path.value怎么用?Java Path.value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.Path
的用法示例。
在下文中一共展示了Path.value方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scan
import javax.ws.rs.Path; //导入方法依赖的package包/类
public void scan(List<String> scanPackages) {
ExecutionTimer timer = new ExecutionTimer(LogLevel.Info, true);
for (String scanPackage : scanPackages) {
logger.debug("Scanning for limberest services in package: {}", scanPackage);
Reflections reflect = new Reflections(scanPackage);
// service classes
for (Class<?> classWithPath : reflect.getTypesAnnotatedWith(Path.class)) {
logger.info("Found service class: {}", classWithPath.getName());
Path pathAnnotation = classWithPath.getAnnotation(Path.class);
if (pathAnnotation != null) {
String path = pathAnnotation.value();
if (path != null) {
logger.info(" -> and registering with path: {}", path);
Produces producesAnnotation = classWithPath.getAnnotation(Produces.class);
if (producesAnnotation != null && producesAnnotation.value() != null) {
// TODO can only produce one thing and consume if present must match produce
Consumes consumesAnnotation = classWithPath.getAnnotation(Consumes.class);
for (String contentType : producesAnnotation.value()) {
logger.info(" -> for content-type: {}", contentType);
@SuppressWarnings({"unchecked", "rawtypes"})
Class<? extends RestService<?>> serviceClass = (Class)classWithPath.asSubclass(RestService.class);
if (!RestService.class.isAssignableFrom(serviceClass))
throw new IllegalArgumentException(serviceClass + " does not extend " + RestService.class);
RegistryKey key = new RegistryKey(new ResourcePath(path), contentType);
ServiceRegistry.getInstance().put(key, serviceClass);
}
}
}
}
}
}
if (timer.isEnabled())
timer.log("limberest initializer scanned " + scanPackages.size() + " packages in ");
}
示例2: getPath
import javax.ws.rs.Path; //导入方法依赖的package包/类
@Override
public String getPath(ReaderContext context, Method method) {
String p = null;
Api apiAnnotation = context.getCls().getAnnotation(Api.class);
ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
String operationPath = apiOperation == null ? null : apiOperation.nickname();
if (operationPath != null && !operationPath.isEmpty()) {
// same logic as ServletReaderExtension
p = PathUtils.collectPath(context.getParentPath(),
apiAnnotation == null ? null : apiAnnotation.value(), operationPath);
}
else {
// try JAX-RS annotations
Path parentPath = ReflectionUtils.getAnnotation(method.getDeclaringClass(), Path.class);
if (parentPath != null && parentPath.value() != null && !parentPath.value().isEmpty()) {
p = parentPath.value();
}
Path path = ReflectionUtils.getAnnotation(method, Path.class);
if (path != null && path.value() != null && !path.value().isEmpty()) {
if (p == null)
p = path.value();
else {
if (path.value().startsWith("/"))
p += path.value();
else
p = p + "/" + path.value();
}
}
}
return p;
}