1 32 package org.jruby.runtime; 33 34 import org.jruby.Ruby; 35 import org.jruby.runtime.callback.Callback; 36 import org.jruby.runtime.callback.ReflectionCallbackFactory; 37 import org.jruby.runtime.callback.InvocationCallbackFactory; 38 import org.jruby.runtime.callback.DumpingInvocationCallbackFactory; 39 40 46 public abstract class CallbackFactory { 47 public static final Class [] NULL_CLASS_ARRAY = new Class [0]; 48 49 54 public abstract Callback getMethod(String method); 55 public abstract Callback getFastMethod(String method); 56 57 63 public abstract Callback getMethod(String method, Class arg1); 64 public abstract Callback getFastMethod(String method, Class arg1); 65 66 73 public abstract Callback getMethod(String method, Class arg1, Class arg2); 74 public abstract Callback getFastMethod(String method, Class arg1, Class arg2); 75 76 84 public abstract Callback getMethod(String method, Class arg1, Class arg2, Class arg3); 85 public abstract Callback getFastMethod(String method, Class arg1, Class arg2, Class arg3); 86 87 92 public abstract Callback getSingletonMethod(String method); 93 public abstract Callback getFastSingletonMethod(String method); 94 95 101 public abstract Callback getSingletonMethod(String method, Class arg1); 102 public abstract Callback getFastSingletonMethod(String method, Class arg1); 103 104 109 public abstract Callback getSingletonMethod(String method, Class arg1, Class arg2); 110 public abstract Callback getFastSingletonMethod(String method, Class arg1, Class arg2); 111 112 117 public abstract Callback getSingletonMethod(String method, Class arg1, Class arg2, Class arg3); 118 public abstract Callback getFastSingletonMethod(String method, Class arg1, Class arg2, Class arg3); 119 120 public abstract Callback getBlockMethod(String method); 121 public abstract CompiledBlockCallback getBlockCallback(String method); 122 123 128 public abstract Callback getOptSingletonMethod(String method); 129 public abstract Callback getFastOptSingletonMethod(String method); 130 131 136 public abstract Callback getOptMethod(String method); 137 public abstract Callback getFastOptMethod(String method); 138 139 private static boolean reflection = false; 140 private static boolean dumping = false; 141 private static String dumpingPath = null; 142 143 static { 144 if(System.getProperty("jruby.reflection") != null && Boolean.getBoolean("jruby.reflection")) { 145 reflection = true; 146 } 147 if(System.getProperty("jruby.dump_invocations") != null) { 148 dumping = true; 149 dumpingPath = System.getProperty("jruby.dump_invocations").toString(); 150 } 151 } 152 153 public static CallbackFactory createFactory(Ruby runtime, Class type) { 154 if(reflection) { 155 return new ReflectionCallbackFactory(type); 156 } else if(dumping) { 157 return new DumpingInvocationCallbackFactory(runtime, type, dumpingPath); 158 } else { 159 return new InvocationCallbackFactory(runtime, type); 160 } 161 } 162 } 163 | Popular Tags |