Package org.codehaus.plexus.component.annotations

Examples of org.codehaus.plexus.component.annotations.Requirement


      if (field.getAnnotation(Inject.class) != null) {
        lookupField(field, "");
        continue;
      }

      Requirement requirement = field.getAnnotation(Requirement.class);
      if (requirement != null) {
        lookupField(field, requirement.hint());
      }
    }
  }
View Full Code Here


    private ComponentRequirement findRequirement(final AnnField field, AnnClass annClass, ClassLoader cl)
        throws ComponentGleanerException
    {
        assert field != null;

        Requirement anno = field.getAnnotation(Requirement.class);
       
        if (anno == null) {
            return null;
        }

        String fieldType = field.getType();
       
        // TODO implement type resolution without loading classes
        Class<?> type;
        try {
          type = Class.forName(fieldType, false, cl);
        } catch (ClassNotFoundException ex) {
          // TODO Auto-generated catch block
          throw new ComponentGleanerException("Can't load class " + fieldType);
        }

        ComponentRequirement requirement;

        if (isRequirementListType(type)) {
            requirement = new ComponentRequirementList();

            String[] hints = anno.hints();

            if (hints != null && hints.length > 0) {
                ((ComponentRequirementList)requirement).setRoleHints(Arrays.asList(hints));
            }

            //
            // TODO: See if we can glean any type details out of any generic information from the map or collection
            //
        }
        else {
            requirement = new ComponentRequirement();

            requirement.setRoleHint(filterEmptyAsNull(anno.hint()));
        }

        // TODO need to read default annotation values
        // if (anno.role()==null || anno.role().isAssignableFrom(Object.class)) {
        if (anno.role().isAssignableFrom(Object.class)) {
            requirement.setRole(type.getName());
        }
        else {
            requirement.setRole(anno.role().getName());
        }

        requirement.setFieldName(field.getName());

        requirement.setFieldMappingType(type.getName());

        requirement.setOptional( anno.optional() );

        return requirement;
    }
View Full Code Here

    private ComponentRequirement findRequirement(final AnnField field, AnnClass annClass, ClassLoader cl)
        throws ComponentGleanerException
    {
        assert field != null;

        Requirement anno = field.getAnnotation(Requirement.class);
       
        if (anno == null) {
            return null;
        }

        String fieldType = field.getType();
       
        // TODO implement type resolution without loading classes
        Class<?> type;
        try {
          type = Class.forName(fieldType, false, cl);
        } catch (ClassNotFoundException ex) {
          // TODO Auto-generated catch block
          throw new ComponentGleanerException("Can't load class " + fieldType);
        }

        ComponentRequirement requirement;

        if (isRequirementListType(type)) {
            requirement = new ComponentRequirementList();

            String[] hints = anno.hints();

            if (hints != null && hints.length > 0) {
                ((ComponentRequirementList)requirement).setRoleHints(Arrays.asList(hints));
            }

            //
            // TODO: See if we can glean any type details out of any generic information from the map or collection
            //
        }
        else {
            requirement = new ComponentRequirement();

            requirement.setRoleHint(filterEmptyAsNull(anno.hint()));
        }

        // TODO need to read default annotation values
        // if (anno.role()==null || anno.role().isAssignableFrom(Object.class)) {
        if (anno.role().isAssignableFrom(Object.class)) {
            requirement.setRole(type.getName());
        }
        else {
            requirement.setRole(anno.role().getName());
        }

        requirement.setFieldName(field.getName());

        requirement.setFieldMappingType(type.getName());
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.component.annotations.Requirement

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.