Package net.sourceforge.javautil.common.reflection.cache

Examples of net.sourceforge.javautil.common.reflection.cache.ClassMethod


   * This will see if there is a {@link Attributes} annotation so as to specify a method that will
   * take a single {@link Map} attribute so as to apply its attributes in a specific way. Otherwise
   * it will simply pass on to the {@link StandardAttributeApplicator#applyAttributes(ObjectFactoryInterceptor, String, Object, Map)}.
   */
  public void applyAttributes(GroovyBuilder builder, ObjectFactoryInterceptor ofi, String nodeName, Object instance, Map<Object, Object> attributes) {
    ClassMethod apply = this.getAttributeApplicator(instance.getClass());
    if (apply != null && attributes != null) apply.invoke(instance, attributes);
    else if (attributes != null) super.applyAttributes(builder, ofi, nodeName, instance, attributes);
  }
View Full Code Here


    boolean stop = false;
    boolean destroy = false;

    ClassDescriptor desc = ClassCache.getFor(managed.getClass());
   
    ClassMethod postConstruct = desc.getMethod(PostConstruct.class);
    if (postConstruct != null) {
      this.phases.add(new PojoPhase(PhaseType.INITIALIZE, "Post Construct", 0, postConstruct));
      initialize = true;
    }
   
    ClassMethod preDestroy = desc.getMethod(PreDestroy.class);
    if (preDestroy != null)
      this.phases.add(new PojoPhase(PhaseType.POSTSTOP, "Pre Destroy", 1000, preDestroy));
   
   
    ClassMethod[] methods = desc.getMethods(Phase.class);
View Full Code Here

        if (!accessible) method.getJavaMember().setAccessible(false);
      }
    }

    public void rollback(T target) {
      ClassMethod rollback = rollbacks.get(this.type);
      if (rollback == null) rollback = rollbacks.get(null);
     
      if (rollback != null) rollback.invoke(target, this);
    }
View Full Code Here

    if (!cache.containsKey(method)) {
      Pojo pojo = method.getAnnotation(Pojo.class);
      cache.put(method, pojo == null ? null : targetDesc.getMethod(pojo.value()));
    }
   
    ClassMethod cm = cache.get(method);
    if (cm != null) {
      Object[] modifiedArguments = null;
      if (cm.getParameterTypes().length == 0) {
        modifiedArguments = CollectionUtil.EMPTY_OBJECT_ARRAY;
      } else if (cm.getParameterTypes().length == 1 && cm.getParameterTypes()[0] == method.getDeclaringClass()) {
        modifiedArguments = new Object[] { defaultTarget };
      } else if (cm.compareArguments(args) == ArgumentMatch.FUNCTIONAL) {
        modifiedArguments = args;
      } else {
        throw new IllegalArgumentException("Cannot call method appropriately");
      }
     
      return interceptor.invoke(target, cm.getJavaMember(), modifiedArguments);
    } else {
      return interceptor.invoke(defaultTarget, method, args);
    }
  }
View Full Code Here

   * @return The matching method
   *
   * @throws Throwable Could be access related or simply that no method was found
   */
  public static Method findMethod (Class clazz, String name, String descriptor, Class... classes) throws Throwable {
    ClassMethod method = ClassCache.getFor(clazz).findMethod(name, classes);
    if (method != null) return method.getJavaMember();
    throw new InterceptorInvocationException("Could not find method: " + name + " (" + descriptor + ") for: " + clazz.getName());
  }
View Full Code Here

    Class<? extends T> proxyClass = this.getProxyClass(type);
    ClassDescriptor<? extends T> pcDesc = ClassCache.getFor(proxyClass);
   
    T instance =  pcDesc.newInstance(CollectionUtil.insert(parameters, 0, interceptor));
    if (interceptor == null) {
      ClassMethod method = ClassCache.getFor(proxyClass).findMethod("set$Interceptor", IInterceptorManager.class);
     
      ReflectionContext.getReflectionManager().ensureAccesssibility(method.getJavaMember());
      method.invoke(instance, this.getDefaultInterceptorManager(instance, type));
    }
    return instance;
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.javautil.common.reflection.cache.ClassMethod

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.