Package java.lang.reflect

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


   }

   public Object getFieldValue(Object bean, String field) throws Exception
   {
      Method method = ReflectionUtil.getGetBindingMethod(bean, field);
      return method.invoke(bean, ReflectionUtil.EMPTY_ARGS);
   }

   @SuppressWarnings("unchecked")
   public void loadPortalConfigs() throws Exception
   {
View Full Code Here


                continue;
              }
                final Class<?> argType = method.getParameterTypes()[0];
                try {
                    final Object[] params = new Object[] {StringUtil.valueOf(propertyValue, argType)};
                    method.invoke(bean, params);
                } catch (Throwable e) {
                  throw new InvalidPropertyException(propertyName, propertyValue, argType, e);
                }
          }
      }
View Full Code Here

                try {
                  Object[] params = new Object[] {value};
                  if (!argType.isAssignableFrom(value.getClass())) {
                    params = new Object[] {StringUtil.valueOf(value.toString(), argType)};
                  }
                    method.invoke(bean, params);
                } catch (Throwable e) {
                  throw new InvalidPropertyException(propertyName, value.toString(), argType, e);
                }
          }
      }
View Full Code Here

        m = object.getClass().getDeclaredMethod(method.getName(), method.getParameterTypes());
      } catch (NoSuchMethodException e) {
      }
      if (m != null) {
        try {
          return m.invoke(object, args);
        } catch (InvocationTargetException e) {
          throw e.getTargetException();
        }
      }
        }
View Full Code Here

        Map reportValueMap = new HashMap<String, String>();
        while (methodIter.hasNext()) {
          String fieldName = (String) methodIter.next();
          String methodName = fieldName;
          Method meth = cls.getMethod(methodName, (Class[]) null);
          Object retObj = meth.invoke(object, (Object[]) null);
          reportValueMap.put(fieldName, retObj);
        }
        reportResultList.add(reportValueMap);
      } catch (Throwable e) {
        System.err.println(e);
View Full Code Here

  public JMXServer() {
    try {
      // Try to get the default platform MBeanServer (since JDK 1.5)
      Class clazz = Class.forName("java.lang.management.ManagementFactory");
      Method method = clazz.getMethod("getPlatformMBeanServer", (Class[]) null);
      mxserver = (MBeanServer) method.invoke(null, (Object[]) null);
    } catch (Exception exc) {
      // Prior JDK1.5 (with JMXRI implementation).
      mxserver = MBeanServerFactory.createMBeanServer("AgentServer");
    }
    MXWrapper.setMXServer(this);
View Full Code Here

                    Method keyReadMethod   = keyProperty.getReadMethod();
                    Method valueReadMethod   = valueProperty != null ? valueProperty.getReadMethod() : null;
                    HashMap<String,Object> map = new LinkedHashMap<String,Object>();
                    while(iterator.hasNext()){
                      Object ob = iterator.next();
                      map.put(String.valueOf(keyReadMethod.invoke(ob)), valueReadMethod != null ? valueReadMethod.invoke(ob) : ob);
                    }
                    map(map, keyReadMethod, customInfo);
                    return;
                  }
          }catch(Throwable th){
View Full Code Here

                */ 
                 if(accessor != null){
                  
                     Object value = null;
                     try{
                       value  = accessor.invoke(object, new Object[0]);
                     }catch(Throwable th){
                       if(property instanceof PublicFieldPropertyDescriptor){
                         value = ((PublicFieldPropertyDescriptor)property).getValue(object);
                       }
                       /*TODO trace*/
 
View Full Code Here

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

      }
      Class clazz = bean.getClass();
      Method method = getMethod("set", field, clazz);
      if (method != null)
      {
         method.invoke(bean, new Object[]{value});
         return;
      }
      field.setAccessible(true);
      field.set(bean, value);
   }
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.