KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jicengine > operation > ObjectInstantiationOperation


1 package org.jicengine.operation;
2
3 import java.util.*;
4
5 /**
6  * <p>
7  * Copyright (C) 2004 Timo Laitinen
8  * </p>
9  * @author Timo Laitinen
10  * @created 2004-09-20
11  * @since JICE-0.10
12  */

13
14 public class ObjectInstantiationOperation extends InvocationOperation {
15
16     public ObjectInstantiationOperation(String JavaDoc signature, Operation instantiatedClass, Operation[] parameters)
17     {
18         super(signature, instantiatedClass, parameters);
19     }
20
21     protected Object JavaDoc execute(Object JavaDoc actor, Object JavaDoc[] arguments) throws OperationException
22     {
23         try {
24             return instantiate((Class JavaDoc) actor, arguments);
25         } catch (RuntimeException JavaDoc e){
26             throw e;
27         } catch (Exception JavaDoc e){
28             throw new OperationException(e.toString(), e);
29         }
30     }
31
32     /**
33      * instantiates a class.
34      */

35     private Object JavaDoc instantiate(Class JavaDoc instantiatedClass, Object JavaDoc[] arguments) throws Exception JavaDoc {
36         try {
37             return org.jicengine.operation.ReflectionUtils.instantiate(instantiatedClass, arguments);
38         } catch (java.lang.reflect.InvocationTargetException JavaDoc e){
39             throw (Exception JavaDoc) e.getTargetException();
40         }
41     }
42
43 }
44
Popular Tags