/** * create module data for target interface class. * @param clazz the interface class. * @param <T> the module type. must be interface. * @return the module data. */ public static <T> T createData(Class<T> clazz){ try { return (T) Class.forName(getImplClassName(clazz)).newInstance(); } catch (Exception e) { throw new IllegalArgumentException("can't create module for class("+ clazz.getName() + ")! have you make project or rebuild ? ", e); } }
/** * create module data for target interface class. * @param clazz the interface class. * @param <T> the module type. must be interface. * @return the module data. */ public static <T> T createData(Class<T> clazz){ try { return (T) Class.forName(getImplClassName(clazz)).newInstance(); } catch (Exception e) { throw new IllegalArgumentException("can't create module for class("+ clazz.getName() + ")! have you make project or rebuild ? ", e); } }
/* package */ static <T> T obtain(Class<T> clazz){ final String name = clazz.getName(); Entry entry = sMap.get(clazz.getName()); final Class<?> impl; try { if(entry != null ){ T result = (T) entry.obtain(); if(result != null){ return result; } } impl = Class.forName(getImplClassName(clazz)); return (T) sFactory.create(impl); }catch (Exception e){ throw new UnsupportedOperationException("can't find impl class ("+ (name + SUFFIX_IMPL) +")" ,e); } }
/* package */ static <T> T obtain(Class<T> clazz){ final String name = clazz.getName(); Entry entry = sMap.get(clazz.getName()); final Class<?> impl; try { if(entry != null ){ T result = (T) entry.obtain(); if(result != null){ return result; } } impl = Class.forName(getImplClassName(clazz)); return (T) sFactory.create(impl); }catch (Exception e){ throw new UnsupportedOperationException("can't find impl class ("+ (name + SUFFIX_IMPL) +")" ,e); } }
clazz = Class.forName(DataMediatorFactory.getImplClassName(clazz)); } catch (ClassNotFoundException e) { throw new UnsupportedOperationException(e);