1 package hero.mapper; 2 3 25 26 import hero.interfaces.BnRoleLocal; 27 import hero.util.HeroException; 28 29 import java.lang.reflect.InvocationTargetException ; 30 import java.lang.reflect.Method ; 31 import org.apache.log4j.Category; 32 33 import java.util.Collection ; 34 35 public class CustomMapper extends Mapper { 36 37 private static final Category log = Category.getInstance(LdapMapper.class); 39 40 41 public CustomMapper(String name, int type) { 42 super(name,type); 43 } 44 45 public Collection execute(Object bean, int type, BnRoleLocal role, String userName) throws HeroException { 46 log.debug("execute: type="+type+" role="+role.getName()); 47 48 try { 49 Class clmapper=Class.forName(this.getName()); 51 RoleMapperI ndh =(RoleMapperI)clmapper.newInstance(); 52 Class [] param={ 53 Class.forName("java.lang.Object"), 54 Class.forName("hero.interfaces.BnRoleLocal"), 55 Class.forName("java.lang.String")}; 56 Method evth=clmapper.getMethod("searchMembers",param); 57 Object [] o={bean,role,userName}; 58 return((Collection )evth.invoke(ndh,o)); 59 } catch (InvocationTargetException ite) { 60 throw new HeroException("Failure during mapper execution : " + ite.getMessage()); 61 } catch (Exception e) { 62 throw new HeroException("Dynamic invocation of mapper failed :"+this.getName()+"#"+role.getName()+"--> mapper type = "+type+" ///"+e); 63 } 64 } 65 66 67 } 68 | Popular Tags |