01: package org.jicengine.operation;
02:
03: import java.util.*;
04:
05: /**
06: * <p>
07: * Copyright (C) 2004 Timo Laitinen
08: * </p>
09: * @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 signature,
17: Operation instantiatedClass, Operation[] parameters) {
18: super (signature, instantiatedClass, parameters);
19: }
20:
21: protected Object execute(Object actor, Object[] arguments)
22: throws OperationException {
23: try {
24: return instantiate((Class) actor, arguments);
25: } catch (RuntimeException e) {
26: throw e;
27: } catch (Exception e) {
28: throw new OperationException(e.toString(), e);
29: }
30: }
31:
32: /**
33: * instantiates a class.
34: */
35: private Object instantiate(Class instantiatedClass,
36: Object[] arguments) throws Exception {
37: try {
38: return org.jicengine.operation.ReflectionUtils.instantiate(
39: instantiatedClass, arguments);
40: } catch (java.lang.reflect.InvocationTargetException e) {
41: throw (Exception) e.getTargetException();
42: }
43: }
44:
45: }
|