Examples of ClassMethod


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

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

    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

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

        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

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

    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

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

   * @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

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

    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

Examples of org.apache.jdo.impl.enhancer.classfile.ClassMethod

    private void scanMethods()
    {
        // check methods
        for (final Enumeration e = classFile.methods().elements();
             e.hasMoreElements();) {
            final ClassMethod method = (ClassMethod)e.nextElement();
            final String name = method.name().asString();
            final String sig = method.signature().asString();
            affirm(name != null);
            affirm(sig != null);

            final String key = methodKey(name, sig);
            affirm(key != null);

            // for non-abstract, non-native methods, map names to class methods
            if (!method.isAbstract() && !method.isNative()) {
                final Object m = annotatableMethods.put(key, method);
                affirm(m == null);
            }

            // for 'jdo*' like methods, map names to class methods
View Full Code Here

Examples of org.apache.jdo.impl.enhancer.classfile.ClassMethod

        int res = NEGATIVE;
       
        Enumeration e = classFile.methods().elements();
        while (e.hasMoreElements()) {
            final ClassMethod method = (ClassMethod)e.nextElement();
            final String methodSig = method.signature().asString();
            final String methodArgs = Descriptor.userMethodArgs(methodSig);
            final String methodName = method.name().asString() + methodArgs;
           
            // check class-specific enhancement
            final StringWriter s = new StringWriter();
            int r = hasAnnotation(new PrintWriter(s), method, methodName);
            if (r < NEGATIVE) {
View Full Code Here

Examples of org.apache.jdo.impl.enhancer.classfile.ClassMethod

                               Set found,
                               Set missing,
                               boolean annotatable)
    {
        final String key = methodKey(methodName, expectedSig);
        final ClassMethod method = (ClassMethod)jdoLikeMethods.get(key);
        if (method == null) {
            missing.add(key);
            return;
        }
        found.add(key);

        final String foundSig = method.signature().asString();
        final int foundMods = method.access();
        if (!expectedSig.equals(foundSig) || expectedMods != foundMods) {
            env.error(
                getI18N("enhancer.class_has_illegally_declared_jdo_member",
                        new Object[]{ userClassName,
                                      methodName,
View Full Code Here

Examples of org.apache.jdo.impl.enhancer.classfile.ClassMethod

                new SyntheticAttribute(
                    pool.addUtf8(SyntheticAttribute.expectedAttrName)));
        }
       
        // create and add the method
        final ClassMethod method
            = new ClassMethod(accessFlags,
                              pool.addUtf8(methodName),
                              pool.addUtf8(methodSig),
                              methodAttrs);
        affirm(classFile.findMethod(methodName, methodSig) == null,
               "Attempt to add a repeated method.");
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.