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, ProxySubscriber
Direct Known Subclasses:
ProxyTopicPatternSubscriber

public class ProxyTopicSubscriber
extends AbstractProxySubscriber
implements EventTopicSubscriber

A class that subscribes to an EventService on behalf of another object.


Constructor Summary
ProxyTopicSubscriber(java.lang.Object proxiedSubscriber, java.lang.reflect.Method subscriptionMethod, ReferenceStrength referenceStrength, EventService es, java.lang.String topic)
          Creates a proxy.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 void onEvent(java.lang.String topic, java.lang.Object data)
          Handles the event publication by pushing it to the real subscriber's subcription Method.
 java.lang.String toString()
           
protected  void unsubscribe(java.lang.String topic)
           
 
Methods inherited from class org.bushe.swing.event.annotation.AbstractProxySubscriber
getEventService, getProxiedSubscriber, getReferenceStrength, getSubscriptionMethod, hashCode, proxyUnsubscribed
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProxyTopicSubscriber

public ProxyTopicSubscriber(java.lang.Object proxiedSubscriber,
                            java.lang.reflect.Method subscriptionMethod,
                            ReferenceStrength referenceStrength,
                            EventService es,
                            java.lang.String topic)
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
Method Detail

onEvent

public void onEvent(java.lang.String topic,
                    java.lang.Object data)
Handles the event publication by pushing it to the real subscriber's subcription 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.

unsubscribe

protected void unsubscribe(java.lang.String topic)

equals

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

toString

public java.lang.String toString()
Overrides:
toString in class AbstractProxySubscriber