Author: | Unspecified |
Home Page: | |
Version: | Unspecified |
Release Tag: | Unknown |
Release Date: | Unknown |
JVM Required: | Unspecified |
License: | GNU Library General Public License |
Categories: | None |
Requirements: | |
Dependencies: | No dependencies |
Externals: | None |
The PAS event topic tree is organized like this:package com.protomatter.pas.event; public class PASEvent { public PASEvent(Object payload) { ... } public Object getPayload() { ... } } public interface PASEventListener { public void handlePASEvent(String topic, PASEvent event); } public interface PASEventManager { public void sendEvent(String topic, PASEvent event); public void registerListener(String topic, PASEventListener l); public void unregisterListener(String topic, PASEventListener l); }
"*" is the root of all topics. The higher up the tree, the more general the topic. If you're listening to the "*" topic, you get everything that passes through the event system. If you're listening to "weather.usa.co.denver" you only get events for that topic. If you're listening to "weather.usa.co" you'll get events for the "weather.usa.co", "weather.usa.co.denver" and "weather.usa.co.boulder" topics. The topic tree is dynamically created and pruned as listeners are added an removed. Events are delivered to listeners in the tree from top to bottom (so a listener to "weather" will get events before a listener to "weather.usa"). Events are delivered via a pool of threads, so that the PASEventManager.deliverEvent(...) method returns immediately, before the event is actually delivered.* +------------+ | | weather stocks +---------+ | | canada usa +----------+ | | co va +--------+ | | denver boulder
You can get access to the default implementation of the PASEventManager interface like this:
From there you can register for events, un-register for events, and send events of your own.import javax.naming.*; // JNDI stuff import com.protomatter.pas.event.*; // PASEventManager ... Context context = get_A_JNDI_Context(); PASEventManager em = (PASEventManager)context.lookup(PASEventManager.JNDI_NAME);
Event listeners can also be configured through the PAS properties file as follows:
pas.event.SOMENAME=\ topics=TOPIC1;TOPIC2;...;TOPICn,\ listener=event.listener.class.name
The class specified in the "listener" option above must implement the PASEventListener interface. It's default constructor is called, and it is then registered with the event manager to listen to the given event topics. When used in conjuntion with the {@linkcom.protomatter.pas.cron} facility this can provide a robust mechanism for performing actions at pre-determined dates and times, and on regular schedules.