通过反射调用一个单列的方法(单列必须有“getInstance”方法)

Class<?> _clazz = Class.forName(_clazzName);
if (_clazz != null) {
     Method _getInstance = _clazz.getMethod("getInstance");
     Object _handler = _getInstance.invoke(_clazz);
     Method _method = _clazz.getMethod(_methodName, METHOD_PARAM);
     if (_method != null) {
            _method.invoke(_clazz.cast(_handler), session, _msg);
     }
 }

 

posted @ 2013-08-04 23:48  GTai  阅读(617)  评论(0编辑  收藏  举报