KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hero > performerAssign > CallbackPerformerAssign


1 /**
2  *
3  * Bonita
4  * Copyright (C) 1999 Bull S.A.
5  * Bull 68 route de versailles 78434 Louveciennes Cedex France
6  * Further information: bonita@objectweb.org
7  *
8  * This library is free software; you can redistribute it and/or
9  * 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.1 2004/07/30 14:57:58 mvaldes Exp $
26  *
27 --------------------------------------------------------------------------
28  */

29
30 package hero.performerAssign;
31
32
33 import hero.interfaces.BnNodeLocal;
34 import hero.util.HeroException;
35
36 import java.lang.reflect.InvocationTargetException JavaDoc;
37 import java.lang.reflect.Method JavaDoc;
38
39 import org.apache.log4j.Category;
40
41 public class CallbackPerformerAssign extends PerformerAssign {
42
43     // Utility variable
44
private static final Category log = Category.getInstance(CallbackPerformerAssign.class);
45
46
47     public CallbackPerformerAssign(String JavaDoc name, int type) {
48     super(name,type);
49     }
50
51     public void execute(Object JavaDoc bean, int type, BnNodeLocal node, String JavaDoc userName) throws HeroException {
52     log.debug("execute: type="+type+" node="+node.getName());
53         
54     try {
55         // The name of the class depend only on the performerAssign type
56
//Class clperformerAssign=Class.forName("hero.performerAssign.CallbackSelectActors");
57
Class JavaDoc clperformerAssign=Class.forName(this.getName());
58         NodePerformerAssignI ndh =(NodePerformerAssignI)clperformerAssign.newInstance();
59         Class JavaDoc[] param={
60         Class.forName("java.lang.Object"),
61         Class.forName("hero.interfaces.BnNodeLocal"),
62         Class.forName("java.lang.String")};
63         Method JavaDoc evth=clperformerAssign.getMethod("selectActors",param);
64         Object JavaDoc[] o={bean,node,userName};
65         evth.invoke(ndh,o);
66     } catch (InvocationTargetException JavaDoc ite) {
67         ite.printStackTrace();
68         throw new HeroException("Failure during performerAssign execution : " + ite.getMessage());
69     } catch (Exception JavaDoc e) {
70         throw new HeroException("Dynamic invocation of performerAssign failed :"+this.getName()+" Node:"+node.getName()+"--> performerAssign type = "+type+" ///"+e);
71     }
72     }
73
74
75 }
76
Popular Tags