Java 类java.util.EventListenerProxy 实例源码

项目:gstreamer1.x-java    文件:GstObject.java   
/**
 * Removes an {@link EventListenerProxy} from this object.
 * This is used by subclasses that wish to map between java style event listeners 
 * and gstreamer signals.
 * 
 * @param listenerClass The class of listener the proxy was added for.
 * @param listener The listener the proxy was added for.
 * @return The proxy that was removed, or null if no proxy was found.
 */
protected synchronized EventListenerProxy removeListenerProxy(Class<? extends EventListener> listenerClass, EventListener listener) {
    Map<EventListener, EventListenerProxy> map = getListenerMap().get(listenerClass);
    if (map == null) {
        return null;
    }
    EventListenerProxy proxy = map.remove(listener);

    /*
     * Reclaim memory if this listener class is no longer used
     */
    if (map.isEmpty()) {
        listenerMap.remove(listenerClass);
        if (listenerMap.isEmpty()) {
            listenerMap = null;
        }
    }
    return proxy;
}
项目:gst1-java-core    文件:GstObject.java   
/**
 * Removes an {@link EventListenerProxy} from this object.
 * This is used by subclasses that wish to map between java style event listeners 
 * and gstreamer signals.
 * 
 * @param listenerClass The class of listener the proxy was added for.
 * @param listener The listener the proxy was added for.
 * @return The proxy that was removed, or null if no proxy was found.
 */
protected synchronized EventListenerProxy removeListenerProxy(Class<? extends EventListener> listenerClass, EventListener listener) {
    Map<EventListener, EventListenerProxy> map = getListenerMap().get(listenerClass);
    if (map == null) {
        return null;
    }
    EventListenerProxy proxy = map.remove(listener);

    /*
     * Reclaim memory if this listener class is no longer used
     */
    if (map.isEmpty()) {
        listenerMap.remove(listenerClass);
        if (listenerMap.isEmpty()) {
            listenerMap = null;
        }
    }
    return proxy;
}
项目:gstreamer1.x-java    文件:GstObject.java   
/**
 * Adds an {@link EventListenerProxy} on this object.
 * This is used by subclasses that wish to map between java style event listeners 
 * and gstreamer signals.
 * 
 * @param listenerClass Class of the listener being added.
 * @param listener The listener being added.
 * @param proxy Proxy for the event listener.
 */
protected synchronized void addListenerProxy(Class<? extends EventListener> listenerClass, EventListener listener, EventListenerProxy proxy) {
    Map<EventListener, EventListenerProxy> map = getListenerMap().get(listenerClass);
    /*
     * Create the map for this class if it doesn't exist
     */
    if (map == null) {
        map = new HashMap<EventListener, EventListenerProxy>();
        getListenerMap().put(listenerClass, map);
    }
    map.put(listener, proxy);
}
项目:gst1-java-core    文件:GstObject.java   
/**
 * Adds an {@link EventListenerProxy} on this object.
 * This is used by subclasses that wish to map between java style event listeners 
 * and gstreamer signals.
 * 
 * @param listenerClass Class of the listener being added.
 * @param listener The listener being added.
 * @param proxy Proxy for the event listener.
 */
protected synchronized void addListenerProxy(Class<? extends EventListener> listenerClass, EventListener listener, EventListenerProxy proxy) {
    Map<EventListener, EventListenerProxy> map = getListenerMap().get(listenerClass);
    /*
     * Create the map for this class if it doesn't exist
     */
    if (map == null) {
        map = new HashMap<EventListener, EventListenerProxy>();
        getListenerMap().put(listenerClass, map);
    }
    map.put(listener, proxy);
}
项目:In-the-Box-Fork    文件:EventListenerProxyTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getListener",
    args = {}
)
public void testGetListener() {
    EventListener el = new Mock_EventListener();
    EventListenerProxy elp = new Mock_EventListenerProxy(el);

    assertSame(el, elp.getListener());
}
项目:jdk7-jdk    文件:ChangeListenerMap.java   
/**
 * Extracts a real listener from the proxy listener.
 * It is necessary because default proxy class is not serializable.
 *
 * @return a real listener
 */
public final L extract(L listener) {
    while (listener instanceof EventListenerProxy) {
        EventListenerProxy<L> proxy = (EventListenerProxy<L>) listener;
        listener = proxy.getListener();
    }
    return listener;
}
项目:openjdk-source-code-learn    文件:ChangeListenerMap.java   
/**
 * Extracts a real listener from the proxy listener.
 * It is necessary because default proxy class is not serializable.
 *
 * @return a real listener
 */
public final L extract(L listener) {
    while (listener instanceof EventListenerProxy) {
        EventListenerProxy<L> proxy = (EventListenerProxy<L>) listener;
        listener = proxy.getListener();
    }
    return listener;
}
项目:gstreamer1.x-java    文件:GstObject.java   
private Map<Class<? extends EventListener>, Map<EventListener, EventListenerProxy>> getListenerMap() {
    if (listenerMap == null) {
        listenerMap = new HashMap<Class<? extends EventListener>, Map<EventListener, EventListenerProxy>>();
    }
    return listenerMap;
}
项目:gst1-java-core    文件:GstObject.java   
private Map<Class<? extends EventListener>, Map<EventListener, EventListenerProxy>> getListenerMap() {
    if (listenerMap == null) {
        listenerMap = new HashMap<Class<? extends EventListener>, Map<EventListener, EventListenerProxy>>();
    }
    return listenerMap;
}