01: package hero.initiatorMapper;
02:
03: /*
04: *
05: * LdapInitiatorMapper.java -
06: *
07: *
08: * This program is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU Lesser General Public License
10: * as published by the Free Software Foundation; either version 2
11: * of the License, or (at your option) any later version.
12: *
13: * This program is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: * GNU Lesser General Public License for more details.
17: *
18: * You should have received a copy of the GNU Lesser General Public License
19: * along with this program; if not, write to the Free Software
20: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21: */
22:
23: import hero.interfaces.BnProjectLocal;
24: import hero.initiatorMapper.InitiatorMapperI;
25: import hero.util.HeroException;
26:
27: import java.lang.reflect.InvocationTargetException;
28: import java.lang.reflect.Method;
29:
30: import org.apache.log4j.Category;
31: import java.util.Collection;
32:
33: public class LdapInitiatorMapper extends InitiatorMapper {
34:
35: // Utility variable
36: private static final Category log = Category
37: .getInstance(LdapInitiatorMapper.class);
38:
39: public LdapInitiatorMapper(String name, int type) {
40: super (name, type);
41: }
42:
43: public Collection execute(Object bean, int type,
44: BnProjectLocal role, String userName) throws HeroException {
45: log.debug("execute: type=" + type + " role=" + role.getName());
46:
47: try {
48: // The name of the class depend only on the mapper type
49: //Class clmapper=Class.forName(this.getName(), true, Thread.currentThread().getContextClassLoader());
50: Class clmapper = Class.forName(
51: "hero.initiatorMapper.LdapGroupMembers", true,
52: Thread.currentThread().getContextClassLoader());
53: InitiatorMapperI ndh = (InitiatorMapperI) clmapper
54: .newInstance();
55: Class[] param = {
56: Class.forName("java.lang.Object"),
57: Class.forName("hero.interfaces.BnProjectLocal",
58: true, Thread.currentThread()
59: .getContextClassLoader()),
60: Class.forName("java.lang.String") };
61: // Call method searchMembers of clmapper Class
62: Method evth = clmapper.getMethod("searchMembers", param);
63: Object[] o = { bean, role, userName };
64: return ((Collection) evth.invoke(ndh, o));
65: } catch (InvocationTargetException ite) {
66: throw new HeroException(
67: "Failure during mapper execution : "
68: + ite.getMessage());
69: } catch (Exception e) {
70: throw new HeroException(
71: "Dynamic invocation of mapper failed :"
72: + this .getName() + "#" + role.getName()
73: + "--> mapper type = " + type + " ///" + e);
74: }
75: }
76:
77: }
|