Package java.lang.reflect

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


          for (int i = 0; i < theMethods.length; i++) {
            String methodString = theMethods[i].getName();

            if (methodString.equals((set + mName))) {
              Method mth1 = clUI.getMethod((set + mName), theMethods[i].getParameterTypes());
              mth1.invoke(objUIVO, argList);
            }
          }

        }
      } // end of if statement (hm != null)
View Full Code Here


    Object dirContext = context.getAttribute("org.apache.catalina.resources");
    Class dirContextClass = dirContext.getClass();

    try {
      Method hostMethod = dirContextClass.getMethod("getHostName", null);
      host = (String) hostMethod.invoke(dirContext, null);
    } catch (Exception e) {
      logger.error("[getHostName] Cannot retrieve hostname.", e);
    }

    // if it is null the above method call failed for some reason.
View Full Code Here

      // iterate the parameters array and get the types to build a Class[] to
      // find the method.
      Class[] methodArgType = CVUtility.getClassArray(parameters);
      Method remoteMethod = ejbClass.getMethod(remoteMethodName, methodArgType);
      // it'd be really cool if this actually works consistently.
      result = remoteMethod.invoke(ejb, parameters);
    } catch (Exception e) {
      // Catch all possible exceptions log and rethrow as a generic exception
      // the struts world should handle this somehow or wrap up in a servlet
      // exception
      // and bubble it up.
View Full Code Here

      // Get the home object
      Object ejbHome = CVUtility.getHomeObject(remoteClassName, jndiName);
      Class ejbHomeClass = ejbHome.getClass();
      // Call create
      Method homeCreateMethod = ejbHomeClass.getMethod("create", null);
      ejb = homeCreateMethod.invoke(ejbHome, null);
      Class ejbClass = ejb.getClass();
      // set the dataSource
      Class[] setDataSourceArgType = { String.class };
      Method setDataSourceMethod = ejbClass.getMethod("setDataSource", setDataSourceArgType);
      Object[] setDataSourceArg = { dataSource };
View Full Code Here

      Class ejbClass = ejb.getClass();
      // set the dataSource
      Class[] setDataSourceArgType = { String.class };
      Method setDataSourceMethod = ejbClass.getMethod("setDataSource", setDataSourceArgType);
      Object[] setDataSourceArg = { dataSource };
      setDataSourceMethod.invoke(ejb, setDataSourceArg);
    } catch (Exception e) {
      throw e;
    }
    return ejb;
  }
View Full Code Here

public abstract class BaseSampleBeanFactory implements BeanFactory {

  protected static void setCreatedByFactoryName(Object target, String name) {
    try {
      Method method = target.getClass().getMethod("setCreatedByFactoryName", new Class[] { String.class });
      method.invoke(target, new Object[] { name });
    } catch (Exception e) {
      // this object is only used for unit testing so do a catch all for ease of use
    }
  }
}
View Full Code Here

    String applicationClassName = "com.eteks.furniturelibraryeditor.FurnitureLibraryEditor";
    Class<?> applicationClass = java3DClassLoader.loadClass(applicationClassName);
    Method applicationClassMain =
        applicationClass.getMethod("main", Array.newInstance(String.class, 0).getClass());
    // Call application class main method with reflection
    applicationClassMain.invoke(null, new Object [] {args});
  }
}
View Full Code Here

            Method m = methods.get(property);
            try {
                if (m == null)
                    throw new IllegalStateException("No getter found for " + property);

                Object result = m.invoke(object);
                if (result != null) {
                    Writing writing = getWriting(m.getReturnType());
                    if (writing == null)
                        throw new UnsupportedOperationException("No writing found for " + m.getReturnType());
View Full Code Here

            if (m == null)
                throw new NullPointerException("Cannot find setter for element:" + element.getName());
            try {
                Class setterType = m.getParameterTypes()[0];
                Object result = getResult(object, setterType, element);
                m.invoke(object, result);
            } catch (Exception ex) {
                throw new RuntimeException("Exception while parsing ("
                        + element.getName() + ") to "
                        + object.getClass().getName() + " " + object, ex);
            }
View Full Code Here

                    param = new HashSet((Collection) param);
                } else if (Map.class.isAssignableFrom(getter.getValue().getReturnType())) {
                    param = new HashMap((Map) param);
                }

                setter.invoke(newObj, param);
            } catch (Exception ex) {
                logger.fatal("Cannot set:" + getter.getKey(), ex);
            }
        }
    }
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.