Package java.lang.reflect

Examples of java.lang.reflect.Method.invoke()


  public static SocketFactory getFactory(String sfcn) {
    SocketFactory socketFactory = null;
    try {
      Class factoryClass = Class.forName(sfcn);
      Method method = factoryClass.getMethod("getFactory", (Class[]) null);
      socketFactory = (SocketFactory) method.invoke(null, (Object[]) null);
    } catch (Exception exc) {
      logger.log(BasicLevel.ERROR,
                 "Use default SocketFactory, unable to instantiate : " + sfcn, exc);
      socketFactory = getDefaultFactory();
    }
View Full Code Here


          // continue
        }
      }
      if (clazz != null) {
        Method method = clazz.getMethod("getFactory", (Class[]) null);
        factory = (SocketFactory) method.invoke(null, (Object[]) null);
      } else {
        throw new Exception("Socket factory class not found");
      }
    }
    return factory;
View Full Code Here

   private Object getValue(Object bean, Field field) throws Exception
   {
      Class clazz = bean.getClass();
      Method method = getMethod("get", field, clazz);
      if (method != null)
         return method.invoke(bean, new Object[]{});
      method = getMethod("is", field, clazz);
      if (method != null)
         return method.invoke(bean, new Object[]{});
      field.setAccessible(true);
      return field.get(bean);
View Full Code Here

      Method method = getMethod("get", field, clazz);
      if (method != null)
         return method.invoke(bean, new Object[]{});
      method = getMethod("is", field, clazz);
      if (method != null)
         return method.invoke(bean, new Object[]{});
      field.setAccessible(true);
      return field.get(bean);
   }

   private Method getMethod(String prefix, Field field, Class clazz) throws Exception
View Full Code Here

            byte[].class,
            Integer.TYPE,
            Integer.TYPE
          });

          method.invoke(null, new Object[] {
            dest,
            new Integer(src),
            new Integer(size)
          });
          memmove_type = 1;
View Full Code Here

            byte[].class,
            Integer.TYPE,
            Integer.TYPE
          });

          method.invoke(null, new Object[] {
            dest,
            new Integer(src),
            new Integer(size)
          });
View Full Code Here

          signature[i] = boolean.class;
        else
          signature[i] = thisClass;
      }
      Method method = clazz.getMethod(methodName, signature);
      return method.invoke(target, args);
    } catch (Exception e) {
      throw new IllegalStateException(e);
    }
  }
View Full Code Here

  private static Object invoke(Class<?> clazz, Object target,
      String methodName, Class<?>[] signature, Object[] args) {
    try {
      Method method = clazz.getDeclaredMethod(methodName, signature);
      method.setAccessible(true);
      return method.invoke(target, args);
    } catch (Exception e) {
      throw new IllegalStateException(e);
    }
  }
View Full Code Here

            }
        }
        Method method = primeClass.getDeclaredMethod(methodName, classTypes);
        method.setAccessible(true);

        return method.invoke(method, args);
    }

    /**
     * Calls a static method with the given class and the given arguments.
     * use this method when the specified arguments includes null object.
View Full Code Here

        Class primeClass = Class.forName(className);
        Method method = primeClass.getDeclaredMethod(methodName, classTypes);
        method.setAccessible(true);

        return method.invoke(method, objects);
    }
}
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.