当前位置: 首页>>代码示例>>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;未经允许,请勿转载。