eneter.net.system
Class EventImpl<T>

java.lang.Object
  extended by eneter.net.system.EventImpl<T>
Type Parameters:
T - type of the event

public class EventImpl<T>
extends java.lang.Object

Implements event similar way as in .NET.
The class is intended to be used by a class that wants to raise events.

 // Class exposing some event.
 class MyExposingClass
 {
      // Exposed to a user for subscribing.
      public Event<TMyEvent> calculationCompleted()
      {
          // Returns event, so that the user can only subscribe or unsubscribe.
          // Note: User of the event cannot raise the event.
          return myCalculationCompletedEvent.getApi();
      }
      
      ...
      
      private void someMethod()
      {
          // Raise the event.
          myCalculationCompletedEvent.raise(this, new TMyEvent(...));
      }
      
      // Declaring the event.
      private EventImpl<TMyEvent> myCalculationCompletedEvent = new EventImpl<TMyEvent>(); 
 }

 ...

 // Class consuming the event.
 class MyConsumingClass
 {
      // Subscribing for the event.
      private void someMethod()
      {
          myExposingClass.subscribe(myOnCalculationCompleted);
      }
      
      // Method processing the event.
      private void onCalculationCompleted(object sender, TMyEvent e)
      {
          ...
      }
      
      // Declaring the event handler.
      private EventHandler<TMyEvent> myOnCalculationCompleted = new EventHandler<TMyEvent>()
      {
          public void onEvent(Object x, TMyEvent y)
          {
              onCalculationCompleted(x, y);
          }
      }
 }
 
 
 


Constructor Summary
EventImpl()
           
 
Method Summary
 Event<T> getApi()
          Returns event for the user.
 boolean isSubscribed()
          REturns true if somebody is subscribe.
 void raise(java.lang.Object sender, T eventArgs)
          Raises the event to all subscribers.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventImpl

public EventImpl()
Method Detail

raise

public void raise(java.lang.Object sender,
                  T eventArgs)
           throws java.lang.Exception
Raises the event to all subscribers.

Parameters:
sender - reference to the sender
eventArgs - event parameter
Throws:
java.lang.Exception

getApi

public Event<T> getApi()
Returns event for the user. The user can subscribe/unsubscribe.

Returns:

isSubscribed

public boolean isSubscribed()
REturns true if somebody is subscribe.

Returns: