public final class SampleEventListener extends Object
EventListener
and includes the enterprise session bean annotation
@Stateless. Most session bean options/attributes are not supported;
for example, @LocalBean must not adorn the class.
The event listener class must also be specified in the properties.xml
file with the event_listener_class tag as shown here:
<smgr> <description>My Service</description> <orig_order>1</orig_order> <orig_group>1</orig_group> <fs_component>true</fs_component> </smgr> <event_listener_class>com.mycompany.MyListener</event_listener_class>The eventReceived method is called when an event is delivered. The listener then performs different actions based on the type of the event that is received. Events are identified and organized by family and type can be represented in a fully-qualified form as family:type. The first selection in the switch statement matches a special event called "SUBSCRIPTION_EXPIRING". Subscriptions for events expire after about 8 hours, and this event is passed to a consumer by the Eventing Framework a few minutes before expiration. The body of the event contains the subscription ID of the expiring subscription. Therefore, a consumer can renew a subscriptinon simply by calling the renewSubscription method of the EventingService object and passing the body of the event as the subscription ID. Failing to implement this portion of the event listener will result in subscriptions "disappearing" about 8 - 9 hours after their creation. Important Note: Please refer to the Important Note section of
EventListener
for caveats
regarding the detection of the listener by the Eventing Framework.
package com.mycompany; import com.avaya.collaboration.eventing.Event; import com.avaya.collaboration.eventing.EventListener; import com.avaya.collaboration.eventing.EventingFactory; import com.avaya.collaboration.eventing.TheEventListener; import com.avaya.collaboration.eventing.families.EventFamilyCall; import com.avaya.collaboration.eventing.families.EventFamilyEventing; @Stateless public class MyListener implements EventListener { // My receiver for events. @Override public void eventReceived(final Event event) { switch (event.getTypeQualified()) { // // Resubscribe when my subscription is expiring. // case EventFamilyEventing.EVENT_SUBSCRIPTION_EXPIRING_QUALIFIED: EventingFactory.createEventingService() .renewSubscription(event.getPayload()); return; // // Call events. // case EventFamilyCall.EVENT_CALL_OFFERED_FROM_CALLING_PARTY_QUALIFIED: // do something break; case EventFamilyCall.EVENT_CALL_ANSWERED_QUALIFIED: // do something else break; } } }
Copyright © 2014 Avaya. All Rights Reserved.