java Source

            BlogJava :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
            14 Posts :: 24 Stories :: 8 Comments :: 0 Trackbacks

          /**
            * 類反射實(shí)現(xiàn)動(dòng)態(tài)類調(diào)用
            * @param instance  一個(gè)信息獲取類的實(shí)例
            * @param methodName 方法名稱
            * @param classes 參數(shù)類型數(shù)組
            * @param objects 參數(shù)數(shù)組
            * @return Object 返回了方法執(zhí)行后的結(jié)果
            */
           private Object invokeInstanceMethod(
                      final Object instance, final String methodName,
             final Class[] classes, final Object[] objects) {
                  try {
                      Method method;
                      try {
                          method = instance.getClass().getDeclaredMethod(methodName, classes);
                      }
                      catch (NoSuchMethodException e) {
                          method = instance.getClass().getMethod(methodName, classes);
                      }
                      method.setAccessible(true);
                      return method.invoke(instance, objects);
                  }
                  catch (NoSuchMethodException e) {
                      throw new RuntimeException(e.getMessage());
                  }
                  catch (IllegalAccessException e) {
                      throw new RuntimeException(e.getMessage());
                  }
                  catch (InvocationTargetException e) {
                      throw new RuntimeException(e.getTargetException().getMessage());
                  }
              }

           /* (非 Javadoc)
            * @see com.eware.dataBaseOperation.dataOperateToolKit
            * .dataBaseOperate.InterFaceGetOwnerDataInfo#getOwnerTables()
            */
           /**
            * 實(shí)現(xiàn)了接口方法獲取當(dāng)前用戶所有表的信息
            */
           public ResultSet getOwnerTables() {
            // TODO 自動(dòng)生成方法存根
            return (ResultSet)invokeInstanceMethod(goic, "getOwnerTables",
              new Class[]{}, new Object[]{});
           }

          posted on 2005-11-15 14:24 JustinLei 閱讀(411) 評(píng)論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 晋宁县| 莆田市| 盐津县| 板桥市| 从江县| 福海县| 故城县| 淮阳县| 建湖县| 西吉县| 大足县| 介休市| 兴海县| 涡阳县| 延边| 垣曲县| 宜黄县| 双柏县| 阿瓦提县| 滦平县| 博爱县| 澄江县| 石河子市| 安平县| 泾阳县| 台北市| 葵青区| 南宫市| 文化| 荃湾区| 恩施市| 马鞍山市| 信宜市| 宁陵县| 大城县| 东源县| 镇宁| 蒙阴县| 千阳县| 武义县| 武功县|