SAP NetWeaver '04

com.sap.netweaver.bc.rf.util.event
Class EventBroker

[contained in: com.sap.netweaver.bc.rf.par - bc.rf.util_api.jar]
java.lang.Object
  |
  +--com.sap.netweaver.bc.rf.util.event.EventBroker
All Implemented Interfaces:
IEventBroker

public class EventBroker
extends java.lang.Object
implements IEventBroker

Default class implementation of an event broker.

See Also:
IEventBroker

Field Summary
protected  java.util.List receivers
           
protected  java.util.HashMap senderMap
           
 
Fields inherited from interface com.sap.netweaver.bc.rf.util.event.IEventBroker
PRIO_MAX, PRIO_MIN
 
Constructor Summary
EventBroker()
          Construct object of class EventBroker.
 
Method Summary
 IEventList clearHoldEvents(IEventReceiver receiver)
          Remove all hold but not yet sent events for the given receiver.
 IEventList getEvents()
          Returns a list of event templates for all possible events this broker can send (determined by querying all registered senders).
 IEventList getHoldEvents(IEventReceiver receiver)
          Get all hold but not yet sent events for the given receiver.
 ReceiverMode getMode(IEventReceiver receiver)
          Get the receiver mode of the receiver, i.e. off, sending and so on.
 void hold(IEventReceiver receiver, boolean collect)
          TBD: Unknown function.
 void register(IEventReceiver receiver, IEvent template)
          Registers an event receiver.
 void register(IEventReceiver receiver, IEvent template, IEventMapper mapper)
          See the general contract of the register(IEventReceiver, IEvent) method.
 void register(IEventReceiver receiver, IEvent template, IEventMapper mapper, int priority, boolean async)
          See the general contract of the register(IEventReceiver, IEvent, IEventMapper) and register(IEventReceiver, IEvent, int, boolean) method.
 void register(IEventReceiver receiver, IEvent template, int priority, boolean async)
          See the general contract of the register(IEventReceiver, IEvent) method.
 void register(IEventSender sender)
          Registers an event sender instance.
 void resume(IEventReceiver receiver)
          Resumes a previously suspended event receiver.
 void send(IEvent event, IEventSender sender)
          Sends the specified event to all receivers that have registered for this kind of event.
 void suspend(IEventReceiver receiver)
          Suspend the event receiver.
 void unregister(IEventReceiver receiver, IEvent template)
          Unregisteres an event receiver instance.
 void unregister(IEventSender sender)
          Unregisteres an event sender instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

senderMap

protected final java.util.HashMap senderMap

receivers

protected java.util.List receivers
Constructor Detail

EventBroker

public EventBroker()
Construct object of class EventBroker.
Method Detail

send

public void send(IEvent event,
                 IEventSender sender)
          throws BaseException
Sends the specified event to all receivers that have registered for this kind of event.
Specified by:
send in interface IEventBroker
Parameters:
event - event to be sent
sender - event sender instance sending the event
Throws:
BaseException - when the event sender is not registered

register

public void register(IEventSender sender)
              throws BaseException
Registers an event sender instance.
Specified by:
register in interface IEventBroker
Parameters:
sender - event sender to be registered
Throws:
BaseException - when the registration fails

register

public void register(IEventReceiver receiver,
                     IEvent template)
              throws BaseException
Registers an event receiver. The receiver will only receive events which match the template event. This depends on the matching rules implemented in the events IEvent.isLike(com.sap.netweaver.bc.rf.util.event.IEvent) method. Usually the event's instance and type are relevant. It is allowed to register the same event receiver instance several times with different templates.
Specified by:
register in interface IEventBroker
Parameters:
receiver - event receiver to be registered
template - event template on which the event receiver will receive events
Throws:
BaseException - when the registration fails

register

public void register(IEventReceiver receiver,
                     IEvent template,
                     IEventMapper mapper)
              throws BaseException
See the general contract of the register(IEventReceiver, IEvent) method. This regstration method has an additional IEventMapper argument, i.e. that the mapper will be called prior to giving the event to the receiver.
Specified by:
register in interface IEventBroker
Parameters:
receiver - event receiver to be registered
template - event template on which the event receiver will receive events
mapper - event mapper to be called prior to giving the event to the receiver
Throws:
BaseException - when the registration fails
See Also:
IEventMapper

register

public void register(IEventReceiver receiver,
                     IEvent template,
                     int priority,
                     boolean async)
              throws BaseException
See the general contract of the register(IEventReceiver, IEvent) method. This regstration method has two additional arguments for priority and asynchronous events.

The priority controls the order of multible receivers which have registered for the same event(s). Receivers with higher priority (smaller values) will receive an event before receivers with lower priority (greater values).

An event receiver can choose to receive events asynchronously. This means that a dedicated event queue and sender thread is created for each receiver and template. The event sender will not be blocked, that means the send() method puts the event into the queue and returns immediatelly.

Specified by:
register in interface IEventBroker
Parameters:
receiver - event receiver to be registered
template - event template on which the event receiver will receive events
priority - priority of this receiver and template
async - true when the receiver whould receive the events on a seperate thread
Throws:
BaseException - when the registration fails

register

public void register(IEventReceiver receiver,
                     IEvent template,
                     IEventMapper mapper,
                     int priority,
                     boolean async)
              throws BaseException
See the general contract of the register(IEventReceiver, IEvent, IEventMapper) and register(IEventReceiver, IEvent, int, boolean) method.
Specified by:
register in interface IEventBroker
Parameters:
receiver - event receiver to be registered
template - event template on which the event receiver will receive events
mapper - event mapper to be called prior to giving the event to the receiver
priority - priority of this receiver and template
async - true when the receiver whould receive the events on a seperate thread
Throws:
BaseException - when the registration fails
See Also:
IEventMapper

unregister

public void unregister(IEventSender sender)
                throws BaseException
Unregisteres an event sender instance.
Specified by:
unregister in interface IEventBroker
Parameters:
sender - event sender to be unregistered
Throws:
BaseException - when the unregistration fails

unregister

public void unregister(IEventReceiver receiver,
                       IEvent template)
                throws BaseException
Unregisteres an event receiver instance.
Specified by:
unregister in interface IEventBroker
Parameters:
receiver - event receiver to be unregistered
template - event template on which the event receiver will no longer receive events
Throws:
BaseException - when the unregistration fails

suspend

public void suspend(IEventReceiver receiver)
Suspend the event receiver. The broker will stop delivering any events until resume(com.sap.netweaver.bc.rf.util.event.IEventReceiver) is called.
Specified by:
suspend in interface IEventBroker
Parameters:
receiver - event receiver

resume

public void resume(IEventReceiver receiver)
Resumes a previously suspended event receiver. The broker will continue delivering events to the receiver.
Specified by:
resume in interface IEventBroker
Parameters:
receiver - event receiver

hold

public void hold(IEventReceiver receiver,
                 boolean collect)
TBD: Unknown function.
Specified by:
hold in interface IEventBroker
Parameters:
receiver - TBD: Unknown parameter
collect - TBD: Unknown parameter

getMode

public ReceiverMode getMode(IEventReceiver receiver)
Get the receiver mode of the receiver, i.e. off, sending and so on.
Specified by:
getMode in interface IEventBroker
Parameters:
receiver - event receiver
Returns:
receiver mode of the receiver
See Also:
ReceiverMode

getHoldEvents

public IEventList getHoldEvents(IEventReceiver receiver)
Get all hold but not yet sent events for the given receiver.
Specified by:
getHoldEvents in interface IEventBroker
Parameters:
receiver - event receiver
Returns:
all hold but not yet sent events for the given receiver

clearHoldEvents

public IEventList clearHoldEvents(IEventReceiver receiver)
Remove all hold but not yet sent events for the given receiver.
Specified by:
clearHoldEvents in interface IEventBroker
Parameters:
receiver - event receiver
Returns:
all hold but not yet sent events for the given receiver

getEvents

public IEventList getEvents()
Returns a list of event templates for all possible events this broker can send (determined by querying all registered senders). The event instances contained in the list are "templates", that means the event parameter is not relevant.
Specified by:
getEvents in interface IEventBroker
Returns:
list of event templates for all possible events this broker can send

SAP NetWeaver '04

Copyright © 2004 by SAP AG. All Rights Reserved.
SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.

These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.