當前位置: 首頁>>代碼示例>>Java>>正文


Java EventHandler類代碼示例

本文整理匯總了Java中com.googlecode.openbeans.EventHandler的典型用法代碼示例。如果您正苦於以下問題:Java EventHandler類的具體用法?Java EventHandler怎麽用?Java EventHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EventHandler類屬於com.googlecode.openbeans包,在下文中一共展示了EventHandler類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: EventHandler

import com.googlecode.openbeans.EventHandler; //導入依賴的package包/類
public EventHandler(Object target, String action, String eventPropertyName,
        String listenerMethodName) {
    if (target == null || action == null) {
        throw new NullPointerException();
    }
    this.target = target;
    this.action = action;
    this.eventPropertyName = eventPropertyName;
    this.listenerMethodName = listenerMethodName;
    this.context = AccessController.getContext();
}
 
開發者ID:yippeesoft,項目名稱:NotifyTools,代碼行數:12,代碼來源:EventHandler.java

示例2: create

import com.googlecode.openbeans.EventHandler; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public static <T> T create(Class<T> listenerInterface, Object target,
        String action, String eventPropertyName, String listenerMethodName) {
    if (action == null || target == null || listenerInterface == null) {
        throw new NullPointerException();
    }
    return (T) Proxy.newProxyInstance(target.getClass().getClassLoader(),
            new Class[] { listenerInterface }, new EventHandler(target,
                    action, eventPropertyName, listenerMethodName));
}
 
開發者ID:yippeesoft,項目名稱:NotifyTools,代碼行數:11,代碼來源:EventHandler.java

示例3: invokeImpl

import com.googlecode.openbeans.EventHandler; //導入依賴的package包/類
private Object invokeImpl(Object proxy, Method method, Object[] arguments) {
    Class<?> proxyClass = proxy.getClass();
    Object[] theArguments = arguments == null ? new Object[0] : arguments;
    Object result = null;

    // if a proxy
    if (Proxy.isProxyClass(proxyClass)) {
        InvocationHandler handler = Proxy.getInvocationHandler(proxy);

        // if a valid object
        if (handler instanceof EventHandler) {
            // if the method from the Object class is called
            String methodName = method.getName();
            if (method.getDeclaringClass() == Object.class) {
                if (theArguments.length == 0) {
                    if ("hashCode".equals(methodName)) { //$NON-NLS-1$
                        result = Integer.valueOf(hashCode());
                    } else if ("toString".equals(methodName)) { //$NON-NLS-1$
                        result = proxy.getClass().getSimpleName()
                                + toString().substring(
                                        getClass().getName().length());
                    }
                } else if (theArguments.length == 1
                        && theArguments[0] != null
                        && "equals".equals(methodName)) { //$NON-NLS-1$
                    result = Boolean.valueOf(proxy == theArguments[0]);
                }
            } else if (isValidInvocation(method, theArguments)) {
                // if listener method
                try {
                    // extract value from event property name
                    Object[] args = getArgs(theArguments);
                    // extract method to be invoked on target
                    Method m = getMethod(proxy, method, theArguments, args);

                    // we have a valid listener method at this point
                    result = m.invoke(target, args);
                } catch (RuntimeException e) {
                    throw e;
                } catch (Throwable t) {
                    throw new RuntimeException(t);
                }
            } else {
                // in order to be compatible with RI
                if (listenerMethodName.equals(methodName)) {
                    throw new IllegalArgumentException(Messages
                            .getString("beans.4D")); //$NON-NLS-1$
                }
            }
        }
    } else {
        // HARMONY-2495
        if (null == method) {
            throw new NullPointerException(Messages.getString("beans.55")); //$NON-NLS-1$
        }
    }
    return result;
}
 
開發者ID:yippeesoft,項目名稱:NotifyTools,代碼行數:59,代碼來源:EventHandler.java


注:本文中的com.googlecode.openbeans.EventHandler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。