javax.ws.rs.HeaderParam#value ( )源码实例Demo

下面列出了javax.ws.rs.HeaderParam#value ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: msf4j   文件: HttpResourceModelProcessor.java
@SuppressWarnings("unchecked")
private Object getHeaderParamValue(HttpResourceModel.ParameterInfo<List<String>> info, Request request) {
    HeaderParam headerParam = info.getAnnotation();
    String headerName = headerParam.value();
    String header = request.getHeader(headerName);
    if (header == null || header.isEmpty()) {
        String defaultVal = info.getDefaultVal();
        if (defaultVal != null) {
            header = defaultVal;
        }
    }
    return info.convert(Collections.singletonList(header));
}
 
源代码2 项目: portals-pluto   文件: PortletParamProducer.java
private String _getParamName(Annotation[] annotations) {

		for (Annotation annotation : annotations) {
			Class<? extends Annotation> annotationClass = annotation.getClass();

			if (CookieParam.class.isAssignableFrom(annotationClass)) {
				CookieParam cookieParam = (CookieParam) annotation;

				return cookieParam.value();
			}

			if (FormParam.class.isAssignableFrom(annotationClass)) {
				FormParam formParam = (FormParam) annotation;

				return formParam.value();
			}

			if (HeaderParam.class.isAssignableFrom(annotationClass)) {
				HeaderParam headerParam = (HeaderParam) annotation;

				return headerParam.value();
			}

			if (QueryParam.class.isAssignableFrom(annotationClass)) {
				QueryParam queryParam = (QueryParam) annotation;

				return queryParam.value();
			}
		}

		return null;
	}
 
@Override
public String getParameterName(HeaderParam annotation) {
  return annotation.value();
}
 
源代码4 项目: portals-pluto   文件: BeanValidationInterceptor.java
@AroundInvoke
public Object validateMethodInvocation(InvocationContext invocationContext) throws Exception {

	Validator validator = validatorFactory.getValidator();

	if (validator == null) {
		return invocationContext.proceed();
	}

	Set<ConstraintViolation<Object>> constraintViolations = validator.validate(invocationContext.getTarget());

	for (ConstraintViolation<Object> constraintViolation : constraintViolations) {

		Path propertyPath = constraintViolation.getPropertyPath();

		Path.Node lastPathNode = null;

		for (Path.Node pathNode : propertyPath) {
			lastPathNode = pathNode;
		}

		if ((lastPathNode != null) && (lastPathNode.getKind() == ElementKind.PROPERTY)) {

			Object leafBean = constraintViolation.getLeafBean();
			Class<?> leafBeanClass = leafBean.getClass();

			BeanInfo beanInfo = Introspector.getBeanInfo(leafBean.getClass());

			PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();

			for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
				String propertyDescriptorName = propertyDescriptor.getName();

				if (propertyDescriptorName.equals("targetClass")) {
					Method readMethod = propertyDescriptor.getReadMethod();
					leafBeanClass = (Class<?>) readMethod.invoke(leafBean);
				}
			}

			Field leafBeanField = leafBeanClass.getDeclaredField(lastPathNode.getName());

			String paramName = null;

			Annotation[] annotations = leafBeanField.getAnnotations();

			for (Annotation annotation : annotations) {

				if (annotation instanceof CookieParam) {
					CookieParam cookieParam = (CookieParam) annotation;
					paramName = cookieParam.value();

					break;
				}
				else if (annotation instanceof FormParam) {
					FormParam formParam = (FormParam) annotation;
					paramName = formParam.value();

					break;
				}
				else if (annotation instanceof HeaderParam) {
					HeaderParam headerParam = (HeaderParam) annotation;
					paramName = headerParam.value();

					break;
				}
				else if (annotation instanceof QueryParam) {
					QueryParam queryParam = (QueryParam) annotation;
					paramName = queryParam.value();
				}
			}

			String interpolatedMessage = constraintViolation.getMessage();

			if (messageInterpolator != null) {
				interpolatedMessage = messageInterpolator.interpolate(constraintViolation.getMessageTemplate(),
						new MessageInterpolatorContextImpl(constraintViolation), mvcContext.getLocale());
			}

			mutableBindingResult.addValidationError(new ValidationErrorImpl(paramName, interpolatedMessage,
					constraintViolation));
		}

	}

	return invocationContext.proceed();
}
 
源代码5 项目: cxf   文件: ResourceUtils.java
public static Parameter getParameter(int index, Annotation[] anns, Class<?> type) {

        Context ctx = AnnotationUtils.getAnnotation(anns, Context.class);
        if (ctx != null) {
            return new Parameter(ParameterType.CONTEXT, index, null);
        }

        boolean isEncoded = AnnotationUtils.getAnnotation(anns, Encoded.class) != null;

        BeanParam bp = AnnotationUtils.getAnnotation(anns, BeanParam.class);
        if (bp != null) {
            return new Parameter(ParameterType.BEAN, index, null, isEncoded, null);
        }

        String dValue = AnnotationUtils.getDefaultParameterValue(anns);

        PathParam a = AnnotationUtils.getAnnotation(anns, PathParam.class);
        if (a != null) {
            return new Parameter(ParameterType.PATH, index, a.value(), isEncoded, dValue);
        }
        QueryParam q = AnnotationUtils.getAnnotation(anns, QueryParam.class);
        if (q != null) {
            return new Parameter(ParameterType.QUERY, index, q.value(), isEncoded, dValue);
        }
        MatrixParam m = AnnotationUtils.getAnnotation(anns, MatrixParam.class);
        if (m != null) {
            return new Parameter(ParameterType.MATRIX, index, m.value(), isEncoded, dValue);
        }

        FormParam f = AnnotationUtils.getAnnotation(anns, FormParam.class);
        if (f != null) {
            return new Parameter(ParameterType.FORM, index, f.value(), isEncoded, dValue);
        }

        HeaderParam h = AnnotationUtils.getAnnotation(anns, HeaderParam.class);
        if (h != null) {
            return new Parameter(ParameterType.HEADER, index, h.value(), isEncoded, dValue);
        }

        CookieParam c = AnnotationUtils.getAnnotation(anns, CookieParam.class);
        if (c != null) {
            return new Parameter(ParameterType.COOKIE, index, c.value(), isEncoded, dValue);
        }

        return new Parameter(ParameterType.REQUEST_BODY, index, null);

    }
 
private String _getParamName(Annotation[] annotations) {

		for (Annotation annotation : annotations) {

			Class<? extends Annotation> annotationClass = annotation.getClass();

			if (CookieParam.class.isAssignableFrom(annotationClass)) {
				CookieParam cookieParam = (CookieParam) annotation;

				return cookieParam.value();
			}

			if (FormParam.class.isAssignableFrom(annotationClass)) {
				FormParam formParam = (FormParam) annotation;

				return formParam.value();
			}

			if (HeaderParam.class.isAssignableFrom(annotationClass)) {
				HeaderParam headerParam = (HeaderParam) annotation;

				return headerParam.value();
			}

			if (QueryParam.class.isAssignableFrom(annotationClass)) {
				QueryParam queryParam = (QueryParam) annotation;

				return queryParam.value();
			}
		}

		return null;
	}
 
 方法所在类
 同类方法