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
          主站蜘蛛池模板: 江陵县| 承德县| 九龙坡区| 马龙县| 红桥区| 万山特区| 汶川县| 武强县| 五台县| 台安县| 巴南区| 资中县| 磴口县| 永兴县| 海淀区| 姜堰市| 永定县| 镇平县| 高州市| 曲麻莱县| 阿巴嘎旗| 洪洞县| 交城县| 张家港市| 城口县| 西畴县| 彭山县| 安阳县| 崇文区| 五指山市| 定兴县| 永胜县| 商城县| 大埔区| 合肥市| 盐津县| 海丰县| 文水县| 阳朔县| 西乡县| 济南市|