Package jodd.introspector

Examples of jodd.introspector.ClassDescriptor


  public DestroyMethodPoint[] resolve(Object bean) {
    Class<?> type = bean.getClass();

    // lookup methods
    List<DestroyMethodPoint> list = new ArrayList<DestroyMethodPoint>();
    ClassDescriptor cd = new ClassDescriptor(type, false, false, false, null);
    MethodDescriptor[] allMethods = cd.getAllMethodDescriptors();

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

      PetiteDestroyMethod petiteDestroyMethod = method.getAnnotation(PetiteDestroyMethod.class);
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);
    FieldDescriptor fieldDescriptor = cd.getFieldDescriptor(property, true);
    if (fieldDescriptor == 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);
    FieldDescriptor fieldDescriptor = cd.getFieldDescriptor(property, true);
    if (fieldDescriptor == null) {
      throw new PetiteException("Property not found: " + beanDefinition.type.getName() + '#' + property);
    }

    SetInjectionPoint sip =
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

   * @param type class type
   * @param staticMethodName static method name
   * @param arguments method argument types, may be <code>null</code>
   */
  public void registerPetiteProvider(String providerName, Class type, String staticMethodName, Class[] arguments) {
    ClassDescriptor cd = ClassIntrospector.lookup(type);
    MethodDescriptor md = cd.getMethodDescriptor(staticMethodName, arguments, true);

    if (md == null) {
      throw new PetiteException("Provider method not found: " + staticMethodName);
    }

View Full Code Here

   * If there is only one constructor, that one will be used as injection point. If more
   * constructors exist, the default one will be used as injection point. Otherwise, exception
   * is thrown.
   */
  public CtorInjectionPoint resolve(Class type, boolean useAnnotation) {
    ClassDescriptor cd = ClassIntrospector.lookup(type);
    CtorDescriptor[] allCtors = cd.getAllCtorDescriptors();
    Constructor foundedCtor = null;
    Constructor defaultCtor = null;
    String refValues = null;

    for (CtorDescriptor ctorDescriptor : allCtors) {
View Full Code Here

  /**
   * Resolves all collections for given type.
   */
  public SetInjectionPoint[] resolve(Class type, boolean autowire) {
    // lookup fields
    ClassDescriptor cd = ClassIntrospector.lookup(type);
    List<SetInjectionPoint> list = new ArrayList<SetInjectionPoint>();
    FieldDescriptor[] allFields = cd.getAllFieldDescriptors();

    for (FieldDescriptor fieldDescriptor : allFields) {
      Field field = fieldDescriptor.getField();

      PetiteInject ref = field.getAnnotation(PetiteInject.class);
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.