org.bushe.swing.event.annotation
Class BaseProxySubscriber

java.lang.Object
  extended by org.bushe.swing.event.annotation.AbstractProxySubscriber
      extended by org.bushe.swing.event.annotation.BaseProxySubscriber
All Implemented Interfaces:
EventSubscriber, Prioritized, ProxySubscriber, VetoEventListener

public class BaseProxySubscriber
extends AbstractProxySubscriber
implements EventSubscriber, VetoEventListener

A class is subscribed to an EventService on behalf of another object.


Field Summary
 
Fields inherited from class org.bushe.swing.event.annotation.AbstractProxySubscriber
veto
 
Constructor Summary
BaseProxySubscriber(Object proxiedSubscriber, Method subscriptionMethod, ReferenceStrength referenceStrength, EventService es, Class subscription, boolean veto)
          Creates a proxy.
BaseProxySubscriber(Object proxiedSubscriber, Method subscriptionMethod, ReferenceStrength referenceStrength, int priority, EventService es, Class subscription, boolean veto)
          Creates a proxy with a priority.
 
Method Summary
 boolean equals(Object obj)
           
 void onEvent(Object event)
          Handles the event publication by pushing it to the real subscriber's subscription Method.
 boolean shouldVeto(Object event)
          Determine whether an event should be vetoed or published.
 String toString()
           
 
Methods inherited from class org.bushe.swing.event.annotation.AbstractProxySubscriber
getEventService, getPriority, getProxiedSubscriber, getReferenceStrength, getSubscriptionMethod, hashCode, proxyUnsubscribed, retryReflectiveCallUsingAccessibleObject
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BaseProxySubscriber

public BaseProxySubscriber(Object proxiedSubscriber,
                           Method subscriptionMethod,
                           ReferenceStrength referenceStrength,
                           EventService es,
                           Class subscription,
                           boolean veto)
Creates a proxy. This does not subscribe it.

Parameters:
proxiedSubscriber - the subscriber that the proxy will call when an event is published
subscriptionMethod - the method the proxy will call, must have an Object as it's first and only parameter
referenceStrength - if the subscription is weak, the reference from the proxy to the real subscriber should be too
es - the EventService we will be subscribed to, since we may need to unsubscribe when weak refs no longer exist
subscription - the class to subscribe to, used for unsubscription only
veto - whether this is a veto subscriber

BaseProxySubscriber

public BaseProxySubscriber(Object proxiedSubscriber,
                           Method subscriptionMethod,
                           ReferenceStrength referenceStrength,
                           int priority,
                           EventService es,
                           Class subscription,
                           boolean veto)
Creates a proxy with a priority. This does not subscribe it.

Parameters:
proxiedSubscriber - the subscriber that the proxy will call when an event is published
subscriptionMethod - the method the proxy will call, must have an Object as it's first and only parameter
referenceStrength - if the subscription is weak, the reference from the proxy to the real subscriber should be too
es - the EventService we will be subscribed to, since we may need to unsubscribe when weak refs no longer exist
subscription - the class to subscribe to, used for unsubscription only
veto - whether this is a veto subscriber
Method Detail

onEvent

public void onEvent(Object event)
Handles the event publication by pushing it to the real subscriber's subscription Method.

Specified by:
onEvent in interface EventSubscriber
Parameters:
event - The Object that is being published.

shouldVeto

public boolean shouldVeto(Object event)
Description copied from interface: VetoEventListener
Determine whether an event should be vetoed or published.

The EventService calls this method before class-based publication of objects. If any of the VetoEventListeners return true, then none of the subscribers for that event are called.

Prerequisite: VetoEventListener has to be subscribed with the EventService for the event object's class.

Guaranteed to be called in the SwingEventThread when using the SwingEventService (EventBus). See EventService

Specified by:
shouldVeto in interface VetoEventListener
Parameters:
event - The event object to veto or allow to be published.
Returns:
true if the event should be vetoed and not published, false if the event should be published.

equals

public boolean equals(Object obj)
Overrides:
equals in class AbstractProxySubscriber

toString

public String toString()
Overrides:
toString in class AbstractProxySubscriber


Copyright © 2011 Bushe Enterprises, Inc.. All Rights Reserved.