@Override public MultivaluedParameterExtractor get(Parameter p) { return process( w, p.getDefaultValue(), p.getParameterClass(), p.getParameterType(), p.getAnnotations(), p.getSourceName()); }
paramClass = ct.c; return new Parameter( annotations, paramAnnotation, paramSource,
@Override public Param createParam( AbstractResource r, AbstractMethod m, final Parameter p ) { if (p.getSource() == Parameter.Source.UNKNOWN) return null; wadlParam.setName(p.getSourceName()); switch (p.getSource()) { case FORM: wadlParam.setStyle(ParamStyle.QUERY); wadlParam.setPath(p.getSourceName()); break; default: if (p.hasDefaultValue()) wadlParam.setDefault(p.getDefaultValue()); Class<?> pClass = p.getParameterClass(); if (pClass.isArray()) { wadlParam.setRepeating(true);
private Injectable processEntityParameter( Parameter parameter, Annotation[] annotations) { return new EntityInjectable(parameter.getParameterClass(), parameter.getParameterType(), annotations); } }
@Override public boolean isParameterTypeRegistered(Parameter p) { if (p.getAnnotation() == null) return false; if (isAnnotationRegistered(p.getAnnotation().annotationType(), p.getClass())) return true; return isAnnotationRegistered(p.getAnnotation().annotationType(), p.getParameterType().getClass()); }
protected List<Injectable> getInjectables(AbstractResourceMethod method) { List<Injectable> is = new ArrayList<Injectable>(method.getParameters().size()); for (int i = 0; i < method.getParameters().size(); i++) { Parameter p = method.getParameters().get(i); if (Parameter.Source.ENTITY == p.getSource()) { if (MultivaluedMap.class.isAssignableFrom(p.getParameterClass())) { is.add(new FormEntityInjectable(p.getParameterClass(), p.getParameterType(), p.getAnnotations())); } else is.add(null); } else { Injectable injectable = getInjectableProviderContext(). getInjectable(method.getMethod(), p, ComponentScope.PerRequest); is.add(injectable); } } return is; } }
public Injectable<?> getInjectable(ComponentContext ic, PathParam a, Parameter c) { String parameterName = c.getSourceName(); if (parameterName == null || parameterName.length() == 0) { // Invalid URI parameter name return null; } if (c.getParameterClass() == PathSegment.class) { return new PathParamPathSegmentInjectable(parameterName, !c.isEncoded()); } else if (c.getParameterClass() == List.class && c.getParameterType() instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType)c.getParameterType(); Type[] targs = pt.getActualTypeArguments(); if (targs.length == 1 && targs[0] == PathSegment.class) { return new PathParamListPathSegmentInjectable( parameterName, !c.isEncoded()); } } MultivaluedParameterExtractor e = getWithoutDefaultValue(c); if (e == null) return null; return new PathParamInjectable(e, !c.isEncoded()); } }
private Parameter unpack(Parameter param) { final Type typeParameter = ((ParameterizedType) param.getParameterType()).getActualTypeArguments()[0]; return new Parameter(param.getAnnotations(), param.getAnnotation(), param.getSource(), param.getSourceName(), typeParameter, (Class<?>) typeParameter, param.isEncoded(), param.getDefaultValue()); }
public Injectable getInjectable(ComponentContext ic, QueryParam a, Parameter c) { String parameterName = c.getSourceName(); if (parameterName == null || parameterName.length() == 0) { // Invalid query parameter name return null; } MultivaluedParameterExtractor e = get(c); if (e == null) return null; return new QueryParamInjectable(e, !c.isEncoded()); } }
@Override public Injectable<?> getInjectable(ComponentContext ic, QueryParam a, Parameter c) { final String parameterName = c.getSourceName(); if ((parameterName != null) && !parameterName.isEmpty() && c.getParameterClass().isAssignableFrom(Optional.class)) { return new MultivaluedParameterExtractorQueryParamInjectable( new OptionalExtractor(parameterName, c.getDefaultValue()), !c.isEncoded() ); } return null; } }
@Override public InjectableScopePair getInjectableiWithScope(AccessibleObject ao, Parameter p, ComponentScope s) { if (p.getAnnotation() == null) return null; ComponentContext ic = new AnnotatedContext(ao, p.getAnnotations()); p.getAnnotation().annotationType(), ic, p.getAnnotation(), p, ComponentScope.PerRequest); p.getAnnotation().annotationType(), ic, p.getAnnotation(), p.getParameterType(), ComponentScope.PERREQUEST_UNDEFINED_SINGLETON ); p.getAnnotation().annotationType(), ic, p.getAnnotation(), p.getParameterType(), ComponentScope.UNDEFINED_SINGLETON );
if (p.getSource() == Parameter.Source.ENTITY) { for (MediaType mediaType : m.getSupportedInputTypes()) { setRepresentationForMediaType(r, m, mediaType, wadlRequest); } else if (p.getAnnotation().annotationType() == FormParam.class) { if (getParamByName(wadlRepresentation.getParam(), p.getSourceName()) == null) { final Param wadlParam = generateParam(r, m, p); if (wadlParam != null) { } else if (p.getAnnotation().annotationType().getName().equals("com.sun.jersey.multipart.FormDataParam")) { // jersey-multipart support if (getParamByName(wadlRepresentation.getParam(), p.getSourceName()) == null) { final Param wadlParam = generateParam(r, m, p); if (wadlParam != null) {
public Class getPrimaryClass() { return param.getParameterClass(); } public Type getType() {
public Injectable getInjectable(ComponentContext ic, CookieParam a, Parameter c) { String parameterName = c.getSourceName(); if (parameterName == null || parameterName.length() == 0) { // Invalid cookie parameter name return null; } if (c.getParameterClass() == Cookie.class) { return new CookieTypeParamInjectable(parameterName); } else { MultivaluedParameterExtractor e = get(c); if (e == null) return null; return new CookieParamInjectable(e); } } }
private boolean isExtractable(Parameter param) { return (param.getSourceName() != null) && !param.getSourceName().isEmpty() && param.getParameterClass().isAssignableFrom(Optional.class) && (param.getParameterType() instanceof ParameterizedType); }
private void checkParameter(Parameter p, Object source, String nameForLogging, String paramNameForLogging) { int annotCount = 0; for (Annotation a : p.getAnnotations()) { if (ParamAnnotationSET.contains(a.annotationType())) { annotCount++; if (annotCount > 1) { issueList.add(new ResourceModelIssue( source, ImplMessages.AMBIGUOUS_PARAMETER(nameForLogging, paramNameForLogging), false)); break; } } } final Type t = p.getParameterType(); if (!isConcreteType(t)) { issueList.add(new ResourceModelIssue( source, "Parameter " + paramNameForLogging + " of type " + t + " from " + nameForLogging + " is not resolvable to a concrete type", false)); } }
/** * * @param resourceClass * @param method * @param p * @return param doc type */ public ParamDocType getParamDoc( Class<?> resourceClass, Method method, Parameter p ) { final MethodDocType methodDoc = getMethodDoc( resourceClass, method ); if ( methodDoc != null ) { for ( ParamDocType paramDocType : methodDoc.getParamDocs() ) { for ( AnnotationDocType annotationDocType : paramDocType.getAnnotationDocs() ) { final Class<? extends Annotation> annotationType = p.getAnnotation().annotationType(); if ( annotationType != null ) { final String sourceName = getSourceName(annotationDocType); if ( sourceName != null && sourceName.equals( p.getSourceName() ) ) { return paramDocType; } } } } } return null; }
public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) { return getAnnotation(annotationType) != null; } }
final Parameter parameter = method.getParameters().get(i); if (Parameter.Source.ENTITY == parameter.getSource()) { hasEntity = true; is.add(processEntityParameter( final int i = is.lastIndexOf(null); final Parameter parameter = method.getParameters().get(i); if (Parameter.Source.UNKNOWN == parameter.getSource()) { if (!parameter.isQualified()) { final Injectable ij = processEntityParameter( parameter,