In the work of some special treatment in some cases the code, so adding a single file processing String className = ""; // file full path, for example com.abc "special definition of a variable name + +" BLImpl // If there are plug-bl bl take the plug, do not take the default IF (this.classIsExsits (className)) { the try { class = clazz the Class.forName (className) <?>; method, method clazz.getMethod = ( "class method names defined" ); Method.invoke (clazz.newInstance ()); } the catch (Exception E) { e.printStackTrace (); the throw new new BLException ( "IGCO10000.E141", "plug-in performs error BL"); } } the else { }
/** * @param className * @return * @Description 检测类是否存在 */ protected boolean classIsExsits(String className) { try { Object obj = null != Class.forName(className); return true; } catch (Throwable t) { return false; } }