01: /**
02: *
03: * Bonita
04: * Copyright (C) 1999 Bull S.A.
05: * Bull 68 route de versailles 78434 Louveciennes Cedex France
06: * Further information: bonita@objectweb.org
07: *
08: * This library is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU Lesser General Public
10: * License as published by the Free Software Foundation; either
11: * version 2.1 of the License, or any later version.
12: *
13: * This library 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 GNU
16: * Lesser General Public License for more details.
17: *
18: * You should have received a copy of the GNU Lesser General Public
19: * License along with this library; if not, write to the Free Software
20: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21: * USA
22: *
23: *
24: --------------------------------------------------------------------------
25: * $Id: CallbackPerformerAssign.java,v 1.2 2005/11/16 22:31:59 brice Exp $
26: *
27: --------------------------------------------------------------------------
28: */package hero.performerAssign;
29:
30: import hero.interfaces.BnNodeLocal;
31: import hero.util.HeroException;
32:
33: import java.lang.reflect.InvocationTargetException;
34: import java.lang.reflect.Method;
35:
36: import org.apache.log4j.Category;
37:
38: public class CallbackPerformerAssign extends PerformerAssign {
39:
40: // Utility variable
41: private static final Category log = Category
42: .getInstance(CallbackPerformerAssign.class);
43:
44: public CallbackPerformerAssign(String name, int type) {
45: super (name, type);
46: }
47:
48: public void execute(Object bean, int type, BnNodeLocal node,
49: String userName) throws HeroException {
50: log.debug("execute: type=" + type + " node=" + node.getName());
51:
52: try {
53: // The name of the class depend only on the performerAssign type
54: //Class clperformerAssign=Class.forName("hero.performerAssign.CallbackSelectActors", true, Thread.currentThread().getContextClassLoader());
55: Class clperformerAssign = Class.forName(this .getName(),
56: true, Thread.currentThread()
57: .getContextClassLoader());
58: NodePerformerAssignI ndh = (NodePerformerAssignI) clperformerAssign
59: .newInstance();
60: Class[] param = {
61: Class.forName("java.lang.Object"),
62: Class.forName("hero.interfaces.BnNodeLocal", true,
63: Thread.currentThread()
64: .getContextClassLoader()),
65: Class.forName("java.lang.String") };
66: Method evth = clperformerAssign.getMethod("selectActors",
67: param);
68: Object[] o = { bean, node, userName };
69: evth.invoke(ndh, o);
70: } catch (InvocationTargetException ite) {
71: ite.printStackTrace();
72: throw new HeroException(
73: "Failure during performerAssign execution : "
74: + ite.getMessage());
75: } catch (Exception e) {
76: throw new HeroException(
77: "Dynamic invocation of performerAssign failed :"
78: + this .getName() + " Node:"
79: + node.getName()
80: + "--> performerAssign type = " + type
81: + " ///" + e);
82: }
83: }
84:
85: }
|