org.asmatron.messengine.engines
Class DefaultEngine

java.lang.Object
  extended by org.asmatron.messengine.engines.DefaultEngine
All Implemented Interfaces:
ControlEngine, EngineController, Engine, MessEngine, ViewEngine
Direct Known Subclasses:
TestEngine

public class DefaultEngine
extends java.lang.Object
implements Engine


Constructor Summary
  DefaultEngine()
           
protected DefaultEngine(ActionDelegate actionDelegate, EventDelegate eventDelegate, MessagingDelegate messagingDelegate, ModelDelegate modelDelegate)
           
 
Method Summary
<T extends ActionObject>
void
addActionHandler(ActionId<T> actionType, ActionHandler<T> actionHandler)
           
<T extends EventObject>
void
addListener(EventId<T> type, Listener<T> listener)
           
 void addMessageListener(java.lang.String type, MessageListener<? extends Message<?>> listener)
           
 void fireEvent(EventId<EmptyEvent> type)
          Fires an event and allows all event listeners to handle it.
<T extends EventObject>
void
fireEvent(EventId<T> eventType, T argument)
          Fires the event with an argument passed to listeners.
<T> void
fireValueEvent(EventId<ValueEvent<T>> type, T argument)
          Convenience method that fires a value event (a wrapper of a simple class into an eventObject).
<T> T
get(ModelId<T> type)
          Gets a value from the engine model repository.
<T extends ActionObject>
void
removeActionHandler(ActionId<T> action)
           
<T extends EventObject>
void
removeListener(EventId<T> type, Listener<T> listener)
           
 void removeMessageListener(java.lang.String type, MessageListener<? extends Message<?>> listener)
           
<T> void
request(ActionId<RequestAction<java.lang.Void,T>> type, ResponseCallback<T> callback)
           
<V,T> void
request(ActionId<RequestAction<V,T>> type, V requestParameter, ResponseCallback<T> callback)
           
 java.util.concurrent.Future<Message<?>> request(Message<?> message, java.lang.String responseType, long timeout)
           
 void send(ActionId<EmptyAction> type)
           
<T extends ActionObject>
void
send(ActionId<T> type, T arg)
           
 void send(Message<?> message)
           
<T> void
sendValueAction(ActionId<ValueAction<T>> action, T argument)
           
<T> void
set(ModelId<T> type, T value, EventId<ValueEvent<T>> event)
           
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultEngine

public DefaultEngine()

DefaultEngine

protected DefaultEngine(ActionDelegate actionDelegate,
                        EventDelegate eventDelegate,
                        MessagingDelegate messagingDelegate,
                        ModelDelegate modelDelegate)
Method Detail

send

public <T extends ActionObject> void send(ActionId<T> type,
                                          T arg)
Specified by:
send in interface ViewEngine

send

public void send(ActionId<EmptyAction> type)
Specified by:
send in interface ViewEngine

request

public <V,T> void request(ActionId<RequestAction<V,T>> type,
                          V requestParameter,
                          ResponseCallback<T> callback)
Specified by:
request in interface ViewEngine

request

public <T> void request(ActionId<RequestAction<java.lang.Void,T>> type,
                        ResponseCallback<T> callback)
Specified by:
request in interface ViewEngine

fireEvent

public <T extends EventObject> void fireEvent(EventId<T> eventType,
                                              T argument)
Description copied from interface: ControlEngine
Fires the event with an argument passed to listeners.

Specified by:
fireEvent in interface ControlEngine
Type Parameters:
T - The type of the argument, it must extend the EventObject class.
Parameters:
eventType - The id of the event
argument - The argument of matching T type that will be passed to event listeners

fireEvent

public void fireEvent(EventId<EmptyEvent> type)
Description copied from interface: ControlEngine
Fires an event and allows all event listeners to handle it.
This is a convenience method that fires an emptyEvent so eventListeners does not need the event argument.

Specified by:
fireEvent in interface ControlEngine
Parameters:
type - The id of the event (must be an EmptyEvent)

get

public <T> T get(ModelId<T> type)
Description copied from interface: ControlEngine
Gets a value from the engine model repository.

Specified by:
get in interface ControlEngine
Specified by:
get in interface ViewEngine
Type Parameters:
T - The type of the value stored
Parameters:
type - the id of the model variable stored in the engine
Returns:
the model variable value or null if none is found

set

public <T> void set(ModelId<T> type,
                    T value,
                    EventId<ValueEvent<T>> event)
Specified by:
set in interface ControlEngine

addActionHandler

public <T extends ActionObject> void addActionHandler(ActionId<T> actionType,
                                                      ActionHandler<T> actionHandler)
Specified by:
addActionHandler in interface ControlEngine

removeActionHandler

public <T extends ActionObject> void removeActionHandler(ActionId<T> action)
Specified by:
removeActionHandler in interface ControlEngine

removeListener

public <T extends EventObject> void removeListener(EventId<T> type,
                                                   Listener<T> listener)
Specified by:
removeListener in interface ViewEngine

addListener

public <T extends EventObject> void addListener(EventId<T> type,
                                                Listener<T> listener)
Specified by:
addListener in interface ViewEngine

start

public void start()
Specified by:
start in interface EngineController

stop

public void stop()
Specified by:
stop in interface EngineController

fireValueEvent

public <T> void fireValueEvent(EventId<ValueEvent<T>> type,
                               T argument)
Description copied from interface: ControlEngine
Convenience method that fires a value event (a wrapper of a simple class into an eventObject).

Specified by:
fireValueEvent in interface ControlEngine
Type Parameters:
T - Anything that we want to send to eventListeners.
Parameters:
type - The id of the event (must be a ValueEvent)
argument - the argument that will be wrapped on a valueEvent

sendValueAction

public <T> void sendValueAction(ActionId<ValueAction<T>> action,
                                T argument)
Specified by:
sendValueAction in interface ViewEngine

send

public void send(Message<?> message)
Specified by:
send in interface MessEngine

request

public java.util.concurrent.Future<Message<?>> request(Message<?> message,
                                                       java.lang.String responseType,
                                                       long timeout)
Specified by:
request in interface MessEngine

addMessageListener

public void addMessageListener(java.lang.String type,
                               MessageListener<? extends Message<?>> listener)
Specified by:
addMessageListener in interface MessEngine

removeMessageListener

public void removeMessageListener(java.lang.String type,
                                  MessageListener<? extends Message<?>> listener)
Specified by:
removeMessageListener in interface MessEngine


Copyright © 2011. All Rights Reserved.