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 32 import org.apache.log4j.Category; 33 import java.util.Collection ; 34 35 public class LdapMapper extends Mapper { 36 37 private static final Category log = Category.getInstance(LdapMapper.class); 39 40 41 public LdapMapper(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("hero.mapper.LdapGroupMembers"); 52 RoleMapperI ndh =(RoleMapperI)clmapper.newInstance(); 53 Class [] param={ 54 Class.forName("java.lang.Object"), 55 Class.forName("hero.interfaces.BnRoleLocal"), 56 Class.forName("java.lang.String")}; 57 Method evth=clmapper.getMethod("searchMembers",param); 58 Object [] o={bean,role,userName}; 59 return((Collection )evth.invoke(ndh,o)); 60 } catch (InvocationTargetException ite) { 61 throw new HeroException("Failure during mapper execution : " + ite.getMessage()); 62 } catch (Exception e) { 63 throw new HeroException("Dynamic invocation of mapper failed :"+this.getName()+"#"+role.getName()+"--> mapper type = "+type+" ///"+e); 64 } 65 } 66 67 68 } 69 | Popular Tags |