src/share/classes/java/beans/EventHandler.java

Print this page




 420      *
 421      * @see EventHandler
 422      */
 423     public Object invoke(final Object proxy, final Method method, final Object[] arguments) {
 424         AccessControlContext acc = this.acc;
 425         if ((acc == null) && (System.getSecurityManager() != null)) {
 426             throw new SecurityException("AccessControlContext is not set");
 427         }
 428         return AccessController.doPrivileged(new PrivilegedAction<Object>() {
 429             public Object run() {
 430                 return invokeInternal(proxy, method, arguments);
 431             }
 432         }, acc);
 433     }
 434 
 435     private Object invokeInternal(Object proxy, Method method, Object[] arguments) {
 436         String methodName = method.getName();
 437         if (method.getDeclaringClass() == Object.class)  {
 438             // Handle the Object public methods.
 439             if (methodName.equals("hashCode"))  {
 440                 return new Integer(System.identityHashCode(proxy));
 441             } else if (methodName.equals("equals")) {
 442                 return (proxy == arguments[0] ? Boolean.TRUE : Boolean.FALSE);
 443             } else if (methodName.equals("toString")) {
 444                 return proxy.getClass().getName() + '@' + Integer.toHexString(proxy.hashCode());
 445             }
 446         }
 447 
 448         if (listenerMethodName == null || listenerMethodName.equals(methodName)) {
 449             Class<?>[] argTypes = null;
 450             Object[] newArgs = null;
 451 
 452             if (eventPropertyName == null) {     // Nullary method.
 453                 newArgs = new Object[]{};
 454                 argTypes = new Class<?>[]{};
 455             }
 456             else {
 457                 Object input = applyGetters(arguments[0], getEventPropertyName());
 458                 newArgs = new Object[]{input};
 459                 argTypes = new Class<?>[]{input == null ? null :
 460                                        input.getClass()};




 420      *
 421      * @see EventHandler
 422      */
 423     public Object invoke(final Object proxy, final Method method, final Object[] arguments) {
 424         AccessControlContext acc = this.acc;
 425         if ((acc == null) && (System.getSecurityManager() != null)) {
 426             throw new SecurityException("AccessControlContext is not set");
 427         }
 428         return AccessController.doPrivileged(new PrivilegedAction<Object>() {
 429             public Object run() {
 430                 return invokeInternal(proxy, method, arguments);
 431             }
 432         }, acc);
 433     }
 434 
 435     private Object invokeInternal(Object proxy, Method method, Object[] arguments) {
 436         String methodName = method.getName();
 437         if (method.getDeclaringClass() == Object.class)  {
 438             // Handle the Object public methods.
 439             if (methodName.equals("hashCode"))  {
 440                 return System.identityHashCode(proxy);
 441             } else if (methodName.equals("equals")) {
 442                 return (proxy == arguments[0] ? Boolean.TRUE : Boolean.FALSE);
 443             } else if (methodName.equals("toString")) {
 444                 return proxy.getClass().getName() + '@' + Integer.toHexString(proxy.hashCode());
 445             }
 446         }
 447 
 448         if (listenerMethodName == null || listenerMethodName.equals(methodName)) {
 449             Class<?>[] argTypes = null;
 450             Object[] newArgs = null;
 451 
 452             if (eventPropertyName == null) {     // Nullary method.
 453                 newArgs = new Object[]{};
 454                 argTypes = new Class<?>[]{};
 455             }
 456             else {
 457                 Object input = applyGetters(arguments[0], getEventPropertyName());
 458                 newArgs = new Object[]{input};
 459                 argTypes = new Class<?>[]{input == null ? null :
 460                                        input.getClass()};