本文整理汇总了Java中java.beans.EventSetDescriptor.getAddListenerMethod方法的典型用法代码示例。如果您正苦于以下问题:Java EventSetDescriptor.getAddListenerMethod方法的具体用法?Java EventSetDescriptor.getAddListenerMethod怎么用?Java EventSetDescriptor.getAddListenerMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.beans.EventSetDescriptor
的用法示例。
在下文中一共展示了EventSetDescriptor.getAddListenerMethod方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: __createMergedEventSetStub
import java.beans.EventSetDescriptor; //导入方法依赖的package包/类
static EventSetDescriptor __createMergedEventSetStub(
EventSetDescriptor oldDescriptor,
MethodDescriptor[] listenerDescriptors
)
{
try
{
EventSetDescriptor stubDescriptor = new EventSetDescriptor(
oldDescriptor.getName(),
oldDescriptor.getListenerType(),
listenerDescriptors,
oldDescriptor.getAddListenerMethod(),
oldDescriptor.getRemoveListenerMethod());
// set the unicast attribute
stubDescriptor.setUnicast(oldDescriptor.isUnicast());
return stubDescriptor;
}
catch (Exception e)
{
// _LOG.severe(e);
return null;
}
}
示例2: setResourceListeners
import java.beans.EventSetDescriptor; //导入方法依赖的package包/类
/**
* Adds listeners to a resource.
* @param listeners The listeners to be registered with the resource. A
* {@link java.util.Map} that maps from fully qualified class name (as a
* string) to listener (of the type declared by the key).
* @param resource the resource that listeners will be registered to.
*/
public static void setResourceListeners(Resource resource, Map<String, ? extends Object> listeners)
throws
IntrospectionException, InvocationTargetException,
IllegalAccessException, GateException
{
// get the beaninfo for the resource bean, excluding data about Object
BeanInfo resBeanInfo = getBeanInfo(resource.getClass());
// get all the events the bean can fire
EventSetDescriptor[] events = resBeanInfo.getEventSetDescriptors();
// add the listeners
if (events != null) {
EventSetDescriptor event;
for(int i = 0; i < events.length; i++) {
event = events[i];
// did we get such a listener?
Object listener =
listeners.get(event.getListenerType().getName());
if(listener != null) {
Method addListener = event.getAddListenerMethod();
// call the set method with the parameter value
Object[] args = new Object[1];
args[0] = listener;
addListener.invoke(resource, args);
}
} // for each event
} // if events != null
}
示例3: BeanConnection
import java.beans.EventSetDescriptor; //导入方法依赖的package包/类
/**
* Creates a new <code>BeanConnection</code> instance.
*
* @param source the source bean
* @param target the target bean
* @param esd the EventSetDescriptor for the connection be displayed
*/
public BeanConnection(BeanInstance source, BeanInstance target,
EventSetDescriptor esd, Integer... tab) {
int tabIndex = 0;
if (tab.length > 0) {
tabIndex = tab[0].intValue();
}
Vector<BeanConnection> connections = TABBED_CONNECTIONS.get(tabIndex);
m_source = source;
m_target = target;
// m_sourceEsd = sourceEsd;
m_eventName = esd.getName();
// System.err.println(m_eventName);
// attempt to connect source and target beans
Method registrationMethod =
// m_sourceEsd.getAddListenerMethod();
// getSourceEventSetDescriptor().getAddListenerMethod();
esd.getAddListenerMethod();
Object targetBean = m_target.getBean();
Object[] args = new Object[1];
args[0] = targetBean;
Class<?> listenerClass = esd.getListenerType();
if (listenerClass.isInstance(targetBean)) {
try {
registrationMethod.invoke(m_source.getBean(), args);
// if the target implements BeanCommon, then inform
// it that it has been registered as a listener with a source via
// the named listener interface
if (targetBean instanceof BeanCommon) {
((BeanCommon) targetBean).connectionNotification(esd.getName(),
m_source.getBean());
}
connections.addElement(this);
} catch (Exception ex) {
System.err.println("[BeanConnection] Unable to connect beans");
ex.printStackTrace();
}
} else {
System.err.println("[BeanConnection] Unable to connect beans");
}
}