Package org.springframework.beans.factory.annotation

Examples of org.springframework.beans.factory.annotation.Qualifier


      @SuppressWarnings("unchecked")
      @Override
      public ValueInjector createParameterExtractor(Class injectTargetClass,
            AccessibleObject injectTarget, Class type, Type genericType, Annotation[] annotations)
      {
         final Qualifier qualifier = FindAnnotation.findAnnotation(annotations, Qualifier.class);
         if (qualifier == null)
         {
            return super.createParameterExtractor(injectTargetClass, injectTarget, type,
                  genericType, annotations);
         }
         else
         {
            return new ValueInjector()
            {
               public Object inject(HttpRequest request, HttpResponse response)
               {
                  return beanFactory.getBean(qualifier.value());
               }

               public Object inject()
               {
                  // do nothing.
View Full Code Here


   */
  private static final MethodParameter findMatchingPageableParameter(MethodParameter parameter) {

    MethodParameters parameters = new MethodParameters(parameter.getMethod());
    List<MethodParameter> pageableParameters = parameters.getParametersOfType(Pageable.class);
    Qualifier assemblerQualifier = parameter.getParameterAnnotation(Qualifier.class);

    if (pageableParameters.isEmpty()) {
      return null;
    }

View Full Code Here

    if (assemblerQualifier == null) {
      return pageableParameter;
    }

    Qualifier pageableParameterQualifier = pageableParameter.getParameterAnnotation(Qualifier.class);

    if (pageableParameterQualifier == null) {
      return null;
    }

    return pageableParameterQualifier.value().equals(assemblerQualifier.value()) ? pageableParameter : null;
  }
View Full Code Here

    for (int i = 0; i < annotations.length; i++) {

      if (Pageable.class.equals(parameterTypes[i])) {

        Qualifier qualifier = findAnnotation(annotations[i]);

        if (null == qualifier) {
          throw new IllegalStateException(
              "Ambiguous Pageable arguments in handler method. If you use multiple parameters of type Pageable you need to qualify them with @Qualifier");
        }

        if (values.contains(qualifier.value())) {
          throw new IllegalStateException("Values of the user Qualifiers must be unique!");
        }

        values.add(qualifier.value());
      }
    }
  }
View Full Code Here

          }
        }
        if (bd instanceof RootBeanDefinition) {
          Method factoryMethod = ((RootBeanDefinition) bd).getResolvedFactoryMethod();
          if (factoryMethod != null) {
            Qualifier targetAnnotation = factoryMethod.getAnnotation(Qualifier.class);
            if (targetAnnotation != null && qualifier.equals(targetAnnotation.value())) {
              return true;
            }
          }
        }
      }
View Full Code Here

    @Override
    public Object resolve(Injectee injectee, ServiceHandle<?> root) {
        AnnotatedElement parent = injectee.getParent();
        String beanName = null;
        if (parent != null) {
            Qualifier an = parent.getAnnotation(Qualifier.class);
            if (an != null) {
                beanName = an.value();
            }
        }
        boolean required = parent != null ? parent.getAnnotation(Autowired.class).required() : false;
        return getBeanFromSpringContext(beanName, injectee, required);
    }
View Full Code Here

        }
        return result.toArray(values);
    }

    private String getSearchPrefix(MethodParameter parameter) {
        Qualifier qualifier = parameter.getParameterAnnotation(Qualifier.class);

        if (qualifier != null) {
            return new StringBuilder(((Qualifier) qualifier).value()).append("_").append(prefix).toString();
        }
View Full Code Here

     * @param parameter
     * @return
     */
    private String getPagePrefix(MethodParameter parameter) {

        Qualifier qualifier = parameter.getParameterAnnotation(Qualifier.class);

        if (qualifier != null) {
            return new StringBuilder(((Qualifier) qualifier).value()).append("_").append(pagePrefix).toString();
        }

View Full Code Here

    }


    private String getSortPrefix(MethodParameter parameter) {

        Qualifier qualifier = parameter.getParameterAnnotation(Qualifier.class);

        if (qualifier != null) {
            return new StringBuilder(qualifier.value()).append("_").append(sortPrefix).toString();
        }

        return sortPrefix;
    }
View Full Code Here

        for (int i = 0; i < annotations.length; i++) {

            if (Pageable.class.equals(parameterTypes[i])) {

                Qualifier qualifier = findAnnotation(annotations[i]);

                if (null == qualifier) {
                    throw new IllegalStateException(
                            "Ambiguous Pageable arguments in handler method. If you use multiple parameters of type Pageable you need to qualify them with @Qualifier");
                }

                if (values.contains(qualifier.value())) {
                    throw new IllegalStateException("Values of the user Qualifiers must be unique!");
                }

                values.add(qualifier.value());
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.annotation.Qualifier

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.