java Source

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            14 Posts :: 24 Stories :: 8 Comments :: 0 Trackbacks

          /**
            * 類反射實現動態類調用
            * @param instance  一個信息獲取類的實例
            * @param methodName 方法名稱
            * @param classes 參數類型數組
            * @param objects 參數數組
            * @return Object 返回了方法執行后的結果
            */
           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()
            */
           /**
            * 實現了接口方法獲取當前用戶所有表的信息
            */
           public ResultSet getOwnerTables() {
            // TODO 自動生成方法存根
            return (ResultSet)invokeInstanceMethod(goic, "getOwnerTables",
              new Class[]{}, new Object[]{});
           }

          posted on 2005-11-15 14:24 JustinLei 閱讀(405) 評論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 阿拉善左旗| 会同县| 师宗县| 枣强县| 绥阳县| 会东县| 怀集县| 根河市| 冕宁县| 永定县| 陆河县| 苍南县| 仁布县| 无极县| 辽宁省| 宣汉县| 宜兰市| 曲靖市| 准格尔旗| 布拖县| 香格里拉县| 图们市| 开平市| 伊通| 安顺市| 禹城市| 开原市| 沙田区| 思南县| 卫辉市| 启东市| 镇安县| 万宁市| 铁岭市| 盐津县| 朝阳县| 江油市| 土默特右旗| 雅安市| 东乌珠穆沁旗| 新竹县|