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

Examples of net.sourceforge.javautil.common.reflection.cache.ClassMethod.invoke()


  }

  @Override protected ILifecycle createLifecycle() {
    ClassMethod method = ClassCache.getFor(pojoContainer.getClass()).getMethod(Lifecycle.class);
    if (method != null) {
      return (ILifecycle) method.invoke(pojoContainer);
    } else {
      return new LifecyclePojo(pojoContainer);
    }
  }
View Full Code Here


      ClassMethod handler = this.handlers.get(name);
      Event event = (Event) ClassCache.getFor(handler.getParameterTypes()[0]).newInstance(CollectionUtil.insert(arguments, 0, source, name));
      for (java.util.EventListener listener : listeners) {
        if (this.condition != null && (Boolean) this.condition.invoke(listener, event)) continue;

        handler.invoke(listener, event);
      }
    } else {
      EventObject event = eventType.newInstance(CollectionUtil.insert(arguments, 0, source, name));
      for (java.util.EventListener listener : listeners) {
        if (this.condition != null && !(Boolean) this.condition.invoke(listener, event)) continue;
View Full Code Here

  public <V> V invokeAnnotated (Class<? extends Annotation> annotationType, V defaultValue, Object... optionalArguments) {
    ClassMethod method = this.descriptor.getMethod(annotationType);
    if (method != null) {
      switch (method.compareArguments(optionalArguments)) {
        case EXACT: case FUNCTIONAL:
          return (V) method.invoke(instance, optionalArguments);
         
        default:
          if (method.getParameterTypes().length == 0) {
            return (V) method.invoke(instance);
          } else {
View Full Code Here

        case EXACT: case FUNCTIONAL:
          return (V) method.invoke(instance, optionalArguments);
         
        default:
          if (method.getParameterTypes().length == 0) {
            return (V) method.invoke(instance);
          } else {
            throw new ReflectionException("Parameters required for method: " + method.getJavaMember());
          }
      }
    } else {
View Full Code Here

    if (pojo != null) {
      cm = targetType.getMethod(pojo.value());
    } else {
      cm = targetType.findMethod(method.getName(), args);
    }
    if (cm != null) returnValue = cm.invoke(target, args);
    else if (this.allEventHandler != null && method.getAnnotation(CollectionProxyCondition.class) == null) {
      returnValue = this.allEventHandler.invoke(target, args);
    }
   
    if (method.getReturnType() == void.class) return null;
View Full Code Here

    } else {
      ClassMethod method = this.getTypeIndicator(child.getClass());
      if (method != null) {
        cnode = method.getAnnotation(Node.class);
        parentRequired = cnode.parentRequired();
        type = (Node.Type) method.invoke(child);
      } else {
        type = Node.Type.Branch;
        parentRequired = false;
      }
    }
View Full Code Here

 
  protected void setParent (Object child, Object parent) {
    ClassMethod property = this.getParentSetter(child.getClass());
    if (property == null) return;

    property.invoke(child, parent);
  }

  protected void addChild (Object parent, Object child) {
    ClassMethod method = this.getChildAggregator(parent.getClass());
    if (method == null) return;
View Full Code Here

  protected void addChild (Object parent, Object child) {
    ClassMethod method = this.getChildAggregator(parent.getClass());
    if (method == null) return;
   
    method.invoke(parent, child);
  }
 
  protected ClassMethod getParentSetter (Class clazz) {
    if (!this.setParent.containsKey(clazz)) {
      this.setParent.put(clazz, ClassCache.getFor(clazz).getMethod(Parent.class));
View Full Code Here

   * 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);
  }

  protected ClassMethod getAttributeApplicator (Class clazz) {
    if (!this.apply.containsKey(clazz)) {
View Full Code Here

    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

TOP
Copyright © 2018 www.massapi.com. 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.