1 45 46 47 package org.openejb.util.proxy; 48 49 50 import java.lang.reflect.Method ; 51 52 53 62 public abstract class Proxy implements java.io.Serializable { 63 64 public InvocationHandler handler; 65 66 70 public InvocationHandler getInvocationHandler() { 71 return handler; 72 } 73 74 public InvocationHandler setInvocationHandler(InvocationHandler newHandler) { 75 InvocationHandler oldHandler = handler; 76 handler = newHandler; 77 return oldHandler; 78 } 79 80 84 protected static final Class [] NO_ARGS_C = new Class [0]; 85 86 90 protected static final Object [] NO_ARGS_O = new Object [0]; 91 92 protected final void _proxyMethod$throws_default$returns_void(int methodNumber, String methodName, Class [] argTypes, Object [] args) throws java.rmi.RemoteException { 93 _proxyMethod$throws_default$returns_Object( methodNumber, methodName, argTypes, args); 94 return; 95 } 96 97 protected final Object _proxyMethod$throws_default$returns_Object(int methodNumber, String methodName, Class [] argTypes, Object [] args) throws java.rmi.RemoteException { 98 java.lang.reflect.Method method = _proxyMethod$lookupMethod( methodNumber, methodName, argTypes); 99 try{ 100 return handler.invoke(this,method,args); 101 }catch(Throwable t){ 102 if(t instanceof java.rmi.RemoteException ) 104 throw (java.rmi.RemoteException )t; 105 if(t instanceof java.lang.RuntimeException ) 106 throw (java.lang.RuntimeException )t; 107 else throw _proxyError$(t); 108 } 109 } 110 111 protected final void _proxyMethod$throws_AppException$returns_void(int methodNumber, String methodName, Class [] argTypes, Object [] args) throws java.rmi.RemoteException , org.openejb.ApplicationException { 112 _proxyMethod$throws_AppException$returns_Object( methodNumber, methodName, argTypes, args); 113 return; 114 } 115 116 protected final Object _proxyMethod$throws_AppException$returns_Object(int methodNumber, String methodName, Class [] argTypes, Object [] args) throws java.rmi.RemoteException , org.openejb.ApplicationException{ 117 java.lang.reflect.Method method = _proxyMethod$lookupMethod( methodNumber, methodName, argTypes); 118 try{ 119 return handler.invoke(this,method,args); 120 }catch(Throwable t){ 121 if(t instanceof java.rmi.RemoteException ) 123 throw (java.rmi.RemoteException )t; 124 if(t instanceof java.lang.RuntimeException ) 125 throw (java.lang.RuntimeException )t; 126 if(t instanceof org.openejb.ApplicationException) 127 throw (org.openejb.ApplicationException)t; 128 else throw _proxyError$(t); 129 130 } 131 } 132 133 137 protected final int _proxyMethod$throws_default$returns_int(int methodNumber, String methodName, Class [] argTypes, Object [] args) throws java.rmi.RemoteException { 138 Integer retval = (Integer )_proxyMethod$throws_default$returns_Object(methodNumber, methodName, argTypes, args); 139 return retval.intValue(); 140 } 141 142 protected final double _proxyMethod$throws_default$returns_double(int methodNumber, String methodName, Class [] argTypes, Object [] args) throws java.rmi.RemoteException { 143 Double retval = (Double ) _proxyMethod$throws_default$returns_Object(methodNumber, methodName, argTypes, args); 144 return retval.doubleValue(); 145 } 146 147 148 protected final long _proxyMethod$throws_default$returns_long(int methodNumber, String methodName, Class [] argTypes, Object [] args) throws java.rmi.RemoteException { 149 Long retval = (Long ) _proxyMethod$throws_default$returns_Object(methodNumber, methodName, argTypes, args); 150 return retval.longValue(); 151 } 152 153 154 protected final boolean _proxyMethod$throws_default$returns_boolean(int methodNumber, String methodName, Class [] argTypes, Object [] args) throws java.rmi.RemoteException { 155 Boolean retval = (Boolean ) _proxyMethod$throws_default$returns_Object(methodNumber, methodName, argTypes, args); 156 return retval.booleanValue(); 157 } 158 159 160 protected final float _proxyMethod$throws_default$returns_float(int methodNumber,String methodName, Class [] argTypes, Object [] args) throws java.rmi.RemoteException { 161 Float retval = (Float ) _proxyMethod$throws_default$returns_Object(methodNumber, methodName, argTypes, args); 162 return retval.floatValue(); 163 } 164 165 166 protected final char _proxyMethod$throws_default$returns_char(int methodNumber, String methodName, Class [] argTypes, Object [] args) throws java.rmi.RemoteException { 167 Character retval = (Character ) _proxyMethod$throws_default$returns_Object(methodNumber, methodName, argTypes, args); 168 return retval.charValue(); 169 } 170 171 172 protected final byte _proxyMethod$throws_default$returns_byte(int methodNumber, String methodName, Class [] argTypes, Object [] args) throws java.rmi.RemoteException { 173 Byte retval = (Byte ) _proxyMethod$throws_default$returns_Object(methodNumber, methodName, argTypes, args); 174 return retval.byteValue(); 175 } 176 177 178 protected final short _proxyMethod$throws_default$returns_short(int methodNumber, String methodName, Class [] argTypes, Object [] args) throws java.rmi.RemoteException { 179 Short retval = (Short ) _proxyMethod$throws_default$returns_Object(methodNumber, methodName, argTypes, args); 180 return retval.shortValue(); 181 } 182 183 187 188 192 protected final int _proxyMethod$throws_AppException$returns_int(int methodNumber, String methodName, Class [] argTypes, Object [] args) throws java.rmi.RemoteException , org.openejb.ApplicationException { 193 Integer retval = (Integer )_proxyMethod$throws_AppException$returns_Object(methodNumber, methodName, argTypes, args); 194 return retval.intValue(); 195 } 196 197 protected final double _proxyMethod$throws_AppException$returns_double(int methodNumber, String methodName, Class [] argTypes, Object [] args) throws java.rmi.RemoteException , org.openejb.ApplicationException { 198 Double retval = (Double ) _proxyMethod$throws_AppException$returns_Object(methodNumber, methodName, argTypes, args); 199 return retval.doubleValue(); 200 } 201 202 203 protected final long _proxyMethod$throws_AppException$returns_long(int methodNumber, String methodName, Class [] argTypes, Object [] args) throws java.rmi.RemoteException , org.openejb.ApplicationException { 204 Long retval = (Long ) _proxyMethod$throws_AppException$returns_Object(methodNumber, methodName, argTypes, args); 205 return retval.longValue(); 206 } 207 208 209 protected final boolean _proxyMethod$throws_AppException$returns_boolean(int methodNumber, String methodName, Class [] argTypes, Object [] args) throws java.rmi.RemoteException , org.openejb.ApplicationException { 210 Boolean retval = (Boolean ) _proxyMethod$throws_AppException$returns_Object(methodNumber, methodName, argTypes, args); 211 return retval.booleanValue(); 212 } 213 214 215 protected final float _proxyMethod$throws_AppException$returns_float(int methodNumber,String methodName, Class [] argTypes, Object [] args) throws java.rmi.RemoteException , org.openejb.ApplicationException { 216 Float retval = (Float ) _proxyMethod$throws_AppException$returns_Object(methodNumber, methodName, argTypes, args); 217 return retval.floatValue(); 218 } 219 220 221 protected final char _proxyMethod$throws_AppException$returns_char(int methodNumber, String methodName, Class [] argTypes, Object [] args) throws java.rmi.RemoteException , org.openejb.ApplicationException { 222 Character retval = (Character ) _proxyMethod$throws_AppException$returns_Object(methodNumber, methodName, argTypes, args); 223 return retval.charValue(); 224 } 225 226 227 protected final byte _proxyMethod$throws_AppException$returns_byte(int methodNumber, String methodName, Class [] argTypes, Object [] args) throws java.rmi.RemoteException , org.openejb.ApplicationException { 228 Byte retval = (Byte ) _proxyMethod$throws_AppException$returns_Object(methodNumber, methodName, argTypes, args); 229 return retval.byteValue(); 230 } 231 232 233 protected final short _proxyMethod$throws_AppException$returns_short(int methodNumber, String methodName, Class [] argTypes, Object [] args) throws java.rmi.RemoteException , org.openejb.ApplicationException { 234 Short retval = (Short ) _proxyMethod$throws_AppException$returns_Object(methodNumber, methodName, argTypes, args); 235 return retval.shortValue(); 236 } 237 238 242 protected abstract Method _proxyMethod$lookupMethod(int index, String methodName, Class [] argTypes); 243 244 protected final Method _proxyMethod$lookupMethod(Class interfce, Method [] methodMap, int index, String methodName, Class [] argTypes){ 245 java.lang.reflect.Method method = methodMap[index]; 247 if(method == null){ 248 try{ method = interfce.getMethod( methodName, argTypes ); 250 methodMap[index] = method; 251 }catch(NoSuchMethodException nsme){ throw new RuntimeException ("Method not found: " +nsme.getMessage());} 252 } 253 return method; 254 } 255 256 protected final java.rmi.RemoteException _proxyError$(Throwable throwable){ 257 return new java.rmi.RemoteException ("[OpenEJB] Proxy Error: ",throwable ); 258 } 259 260 protected final java.rmi.RemoteException _proxyError$(org.openejb.ApplicationException ae){ 261 return new java.rmi.RemoteException ("[OpenEJB] Proxy Error: The returned application exception is not defined in the throws clause. ", ae.getRootCause()); 262 } 263 264 } 265 | Popular Tags |