Package jodd.introspector

Examples of jodd.introspector.ClassDescriptor


  /**
   * Inspect action for all In/Out annotations.
   * Returns <code>null</code> if there are no In and Out data.
   */
  protected ScopeData inspectClassScopeData(Class actionClass, ScopeType scopeType) {
    ClassDescriptor cd = ClassIntrospector.lookup(actionClass);

    PropertyDescriptor[] allProperties = cd.getAllPropertyDescriptors();

    List<ScopeData.In> listIn = new ArrayList<ScopeData.In>(allProperties.length);
    List<ScopeData.Out> listOut = new ArrayList<ScopeData.Out>(allProperties.length);

    for (PropertyDescriptor pd : allProperties) {
View Full Code Here


    targetType = replaceWithMappedTypeForPath(targetType);

    Object target;
    boolean isTargetTypeMap = true;
    boolean isTargetRealTypeMap = true;
    ClassDescriptor targetTypeClassDescriptor = null;

    if (targetType != null) {
      targetTypeClassDescriptor = ClassIntrospector.lookup(targetType);

      // find if the target is really a map
      // because when classMetadataName != null we are forcing
      // map usage locally in this method

      isTargetRealTypeMap = targetTypeClassDescriptor.isMap();
    }

    if (isTargetRealTypeMap) {
      // resolve keys only for real maps
      path.push(KEYS);
      valueKeyType = replaceWithMappedTypeForPath(valueKeyType);
      path.pop();
    }

    if (classMetadataName == null) {
      // create instance of target type, no 'class' information
      target = newObjectInstance(targetType);

      isTargetTypeMap = isTargetRealTypeMap;
    } else {
      // all beans will be created first as a map
      target = new HashMap();
    }

    boolean koma = false;

    mainloop:
    while (true) {
      skipWhiteSpaces();

      char c = input[ndx];

      if (c == '}') {
        if (koma) {
          syntaxError("Trailing comma");
        }

        ndx++;
        break;
      }

      koma = false;

      String key = parseString();

      skipWhiteSpaces();

      consume(':');

      skipWhiteSpaces();

      // read the type of the simple property

      PropertyDescriptor pd = null;
      Class propertyType = null;
      Class keyType = null;
      Class componentType = null;

      // resolve simple property

      if (!isTargetRealTypeMap) {
        // replace key with real property value
        key = JoddJson.annotationManager.resolveRealName(targetType, key);
      }

      if (!isTargetTypeMap) {
        pd = targetTypeClassDescriptor.getPropertyDescriptor(key, true);

        if (pd != null) {
          propertyType = pd.getType();
          keyType = pd.resolveKeyType(true);
          componentType = pd.resolveComponentType(true);
View Full Code Here

   */
  public void registerPetiteCtorInjectionPoint(String beanName, Class[] paramTypes, String[] references) {
    BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName);
    String[][] ref = PetiteUtil.convertRefToReferences(references);

    ClassDescriptor cd = ClassIntrospector.lookup(beanDefinition.type);
    Constructor constructor = null;

    if (paramTypes == null) {
      CtorDescriptor[] ctors = cd.getAllCtorDescriptors();
      if (ctors != null && ctors.length > 0) {
        if (ctors.length > 1) {
          throw new PetiteException(ctors.length + " suitable constructor found as injection point for: " + beanDefinition.type.getName());
        }
        constructor = ctors[0].getConstructor();
      }
    } else {
      CtorDescriptor ctorDescriptor = cd.getCtorDescriptor(paramTypes, true);

      if (ctorDescriptor != null) {
        constructor = ctorDescriptor.getConstructor();
      }
    }
View Full Code Here

   */
  public void registerPetitePropertyInjectionPoint(String beanName, String property, String reference) {
    BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName);
    String[] references = reference == null ? null : new String[] {reference};

    ClassDescriptor cd = ClassIntrospector.lookup(beanDefinition.type);
    PropertyDescriptor propertyDescriptor = cd.getPropertyDescriptor(property, true);
    if (propertyDescriptor == null) {
      throw new PetiteException("Property not found: " + beanDefinition.type.getName() + '#' + property);
    }

    PropertyInjectionPoint pip =
View Full Code Here

   * @param beanName bean name
   * @param property set property name
   */
  public void registerPetiteSetInjectionPoint(String beanName, String property) {
    BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName);
    ClassDescriptor cd = ClassIntrospector.lookup(beanDefinition.type);

    PropertyDescriptor propertyDescriptor = cd.getPropertyDescriptor(property, true);

    if (propertyDescriptor == null) {
      throw new PetiteException("Property not found: " + beanDefinition.type.getName() + '#' + property);
    }

View Full Code Here

    this.injectionPointFactory = injectionPointFactory;
  }

  public MethodInjectionPoint[] resolve(Class type) {
    // lookup methods
    ClassDescriptor cd = ClassIntrospector.lookup(type);
    List<MethodInjectionPoint> list = new ArrayList<MethodInjectionPoint>();
    MethodDescriptor[] allMethods = cd.getAllMethodDescriptors();

    for (MethodDescriptor methodDescriptor : allMethods) {
      Method method = methodDescriptor.getMethod();

      if (ReflectUtil.isBeanPropertySetter(method)) {
View Full Code Here

   * @param references injection references
   */
  public void registerPetiteMethodInjectionPoint(String beanName, String methodName, Class[] arguments, String[] references) {
    BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName);
    String[][] ref = PetiteUtil.convertRefToReferences(references);
    ClassDescriptor cd = ClassIntrospector.lookup(beanDefinition.type);

    Method method = null;
    if (arguments == null) {
      MethodDescriptor[] methods = cd.getAllMethodDescriptors(methodName);
      if (methods != null && methods.length > 0) {
        if (methods.length > 1) {
          throw new PetiteException(methods.length + " suitable methods found as injection points for: " + beanDefinition.type.getName() + '#' + methodName);
        }
        method = methods[0].getMethod();
      }
    } else {
      MethodDescriptor md = cd.getMethodDescriptor(methodName, arguments, true);
      if (md != null) {
        method = md.getMethod();
      }
    }
    if (method == null) {
View Full Code Here

   * @param initMethodNames init method names
   */
  public void registerPetiteInitMethods(String beanName, InitMethodInvocationStrategy invocationStrategy, String... initMethodNames) {
    BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName);

    ClassDescriptor cd = ClassIntrospector.lookup(beanDefinition.type);
    if (initMethodNames == null) {
      initMethodNames = StringPool.EMPTY_ARRAY;
    }

    int total = initMethodNames.length;
    InitMethodPoint[] initMethodPoints = new InitMethodPoint[total];

    int i;
    for (i = 0; i < initMethodNames.length; i++) {
      MethodDescriptor md = cd.getMethodDescriptor(initMethodNames[i], ReflectUtil.NO_PARAMETERS, true);
      if (md == null) {
        throw new PetiteException("Init method not found: " + beanDefinition.type.getName() + '#' + initMethodNames[i]);
      }
      initMethodPoints[i] = new InitMethodPoint(md.getMethod(), i, invocationStrategy);
    }
View Full Code Here

   * @param destroyMethodNames destroy method names
   */
  public void registerPetiteDestroyMethods(String beanName, String... destroyMethodNames) {
    BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName);

    ClassDescriptor cd = ClassIntrospector.lookup(beanDefinition.type);
    if (destroyMethodNames == null) {
      destroyMethodNames = StringPool.EMPTY_ARRAY;
    }

    int total = destroyMethodNames.length;
    DestroyMethodPoint[] destroyMethodPoints = new DestroyMethodPoint[total];

    int i;
    for (i = 0; i < destroyMethodNames.length; i++) {
      MethodDescriptor md = cd.getMethodDescriptor(destroyMethodNames[i], ReflectUtil.NO_PARAMETERS, true);
      if (md == null) {
        throw new PetiteException("Destroy method not found: " + beanDefinition.type.getName() + '#' + destroyMethodNames[i]);
      }
      destroyMethodPoints[i] = new DestroyMethodPoint(md.getMethod());
    }
View Full Code Here

      throw new PetiteException("Bean not found: " + beanName);
    }

    Class beanType = beanDefinition.type;

    ClassDescriptor cd = ClassIntrospector.lookup(beanType);
    MethodDescriptor md = cd.getMethodDescriptor(methodName, arguments, true);

    if (md == null) {
      throw new PetiteException("Provider method not found: " + methodName);
    }
View Full Code Here

TOP

Related Classes of jodd.introspector.ClassDescriptor

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.