01: package bsh;
02:
03: import bsh.Capabilities.Unavailable;
04: import java.lang.reflect.InvocationTargetException;
05:
06: public abstract class ClassGenerator {
07: private static ClassGenerator cg;
08:
09: public static ClassGenerator getClassGenerator()
10: throws UtilEvalError {
11: if (cg == null) {
12: try {
13: Class clas = Class.forName("bsh.ClassGeneratorImpl");
14: cg = (ClassGenerator) clas.newInstance();
15: } catch (Exception e) {
16: throw new Unavailable("ClassGenerator unavailable: "
17: + e);
18: }
19: }
20:
21: return cg;
22: }
23:
24: /**
25: Parse the BSHBlock for the class definition and generate the class.
26: */
27: public abstract Class generateClass(String name,
28: Modifiers modifiers, Class[] interfaces, Class super Class,
29: BSHBlock block, boolean isInterface, CallStack callstack,
30: Interpreter interpreter) throws EvalError;
31:
32: /**
33: Invoke a super.method() style superclass method on an object instance.
34: This is not a normal function of the Java reflection API and is
35: provided by generated class accessor methods.
36: */
37: public abstract Object invokeSuperclassMethod(BshClassManager bcm,
38: Object instance, String methodName, Object[] args)
39: throws UtilEvalError, ReflectError,
40: InvocationTargetException;
41:
42: /**
43: Change the parent of the class instance namespace.
44: This is currently used for inner class support.
45: Note: This method will likely be removed in the future.
46: */
47: public abstract void setInstanceNameSpaceParent(Object instance,
48: String className, NameSpace parent);
49:
50: }
|