org.bushe.swing.event.annotation
Class ProxyTopicSubscriber

java.lang.Object
  extended by org.bushe.swing.event.annotation.AbstractProxySubscriber
      extended by org.bushe.swing.event.annotation.ProxyTopicSubscriber
All Implemented Interfaces:
EventTopicSubscriber, Prioritized, ProxySubscriber, VetoTopicEventListener
Direct Known Subclasses:
ProxyTopicPatternSubscriber

public class ProxyTopicSubscriber
extends AbstractProxySubscriber
implements EventTopicSubscriber, VetoTopicEventListener

A class that subscribes to an EventService on behalf of another object. This class is not used directly (though you could), but rather through the use of the @org.bushe.swing.event.annotation.EventTopicSubscriber. Advanced EventBus users could use this class in Aspect-Oriented code. Consider using the AnnotationProcessor instead, it may suit your needs and be easier.


Field Summary
 
Fields inherited from class org.bushe.swing.event.annotation.AbstractProxySubscriber
veto
 
Constructor Summary
ProxyTopicSubscriber(Object proxiedSubscriber, Method subscriptionMethod, ReferenceStrength referenceStrength, EventService es, String topic, boolean veto)
          Creates a proxy.
ProxyTopicSubscriber(Object proxiedSubscriber, Method subscriptionMethod, ReferenceStrength referenceStrength, int priority, EventService es, String topic, boolean veto)
          Creates a proxy.
 
Method Summary
 boolean equals(Object obj)
           
 void onEvent(String topic, Object data)
          Handles the event publication by pushing it to the real subscriber's subscription Method.
 boolean shouldVeto(String topic, Object data)
          Determine whether a topic publication should be vetoed or allowed.
 String toString()
           
protected  void unsubscribe(String topic)
           
 
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

ProxyTopicSubscriber

public ProxyTopicSubscriber(Object proxiedSubscriber,
                            Method subscriptionMethod,
                            ReferenceStrength referenceStrength,
                            EventService es,
                            String topic,
                            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
topic - the topic to subscribe to, used for unsubscription only
veto - if this proxy is for a veto subscriber

ProxyTopicSubscriber

public ProxyTopicSubscriber(Object proxiedSubscriber,
                            Method subscriptionMethod,
                            ReferenceStrength referenceStrength,
                            int priority,
                            EventService es,
                            String topic,
                            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
topic - the topic to subscribe to, used for unsubscription only
veto - if this proxy is for a veto subscriber
Method Detail

onEvent

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

Specified by:
onEvent in interface EventTopicSubscriber
Parameters:
topic - the topic on which the object is being published
data - The Object that is being published on the topic.

shouldVeto

public boolean shouldVeto(String topic,
                          Object data)
Description copied from interface: VetoTopicEventListener
Determine whether a topic publication should be vetoed or allowed.

The EventService calls this method before publication of on a topic name. If any of the VetoTopicEventListeners return true, then none of the subscribers to that topic are called.

Prerequisite: VetoTopicEventListener has to be subscribed with the EventService for the topic name.

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

Specified by:
shouldVeto in interface VetoTopicEventListener
Parameters:
topic - The topic name the data object is published on.
data - The data object being published on the topic.
Returns:
true if the publication on the topic should be vetoed and not published, false if the data should be published on the topic.

unsubscribe

protected void unsubscribe(String topic)

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.