當前位置: 首頁>>代碼示例>>Java>>正文


Java Produces.value方法代碼示例

本文整理匯總了Java中javax.ws.rs.Produces.value方法的典型用法代碼示例。如果您正苦於以下問題:Java Produces.value方法的具體用法?Java Produces.value怎麽用?Java Produces.value使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.ws.rs.Produces的用法示例。


在下文中一共展示了Produces.value方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findMediaTypesInAnnotations

import javax.ws.rs.Produces; //導入方法依賴的package包/類
/**
 * Find media types of a @Produces or @Consumes Annotation.
 * 
 * @param method
 *            method to analyze the annotations
 * @param type
 *            annotation type
 * @return list of media types
 * @throws ParserException
 *             Error while the parsing process
 */
private List<String> findMediaTypesInAnnotations(java.lang.reflect.Method method, ResourceAcceptType type)
        throws ParserException {
    List<String> mediaTypes = new ArrayList<>();
    Consumes consumes = method.getAnnotation(Consumes.class);
    Produces produces = method.getAnnotation(Produces.class);
    String[] values = null;
    if (type.equals(ResourceAcceptType.CONSUMES) && consumes != null && consumes.value().length != 0) {
        values = consumes.value();
    } else if (type.equals(ResourceAcceptType.PRODUCES) && produces != null && produces.value().length != 0) {
        values = produces.value();
    }
    if (values != null) {
        for (String str : values) {
            mediaTypes.add(str);
        }
    }
    return mediaTypes;
}
 
開發者ID:SPIRIT-21,項目名稱:javadoc2swagger,代碼行數:30,代碼來源:OperationParser.java

示例2: process

import javax.ws.rs.Produces; //導入方法依賴的package包/類
@Override
public void process(Object annotation, OperationGenerator operationGenerator) {
  Produces produces = (Produces) annotation;

  for (String produce : produces.value()) {
    if (!StringUtils.isEmpty(produce)) {
      operationGenerator.getOperation().addProduces(produce);
    }
  }
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:11,代碼來源:ProducesAnnotationProcessor.java

示例3: scan

import javax.ws.rs.Produces; //導入方法依賴的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 ");
}
 
開發者ID:limberest,項目名稱:limberest,代碼行數:35,代碼來源:Initializer.java

示例4: handleProducesAnnotation

import javax.ws.rs.Produces; //導入方法依賴的package包/類
private void handleProducesAnnotation(MethodMetadata data, Produces produces, String name) {
  String[] serverProduces = produces.value();
  String clientAccepts = serverProduces.length == 0 ? null : emptyToNull(serverProduces[0]);
  checkState(clientAccepts != null, "Produces.value() was empty on %s", name);
  data.template().header(ACCEPT, (String) null); // remove any previous produces
  data.template().header(ACCEPT, clientAccepts);
}
 
開發者ID:wenwu315,項目名稱:XXXX,代碼行數:8,代碼來源:JAXRSContract.java

示例5: addMediaTypes

import javax.ws.rs.Produces; //導入方法依賴的package包/類
private void addMediaTypes(List<MediaType> graphMediaTypes, Produces produceAnnotation) {
  for (String mediaType : produceAnnotation.value()) {
    graphMediaTypes.add(MediaType.valueOf(mediaType));
  }
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:6,代碼來源:SupportedMediaTypesScanner.java


注:本文中的javax.ws.rs.Produces.value方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。