org.apache.ws.pubsub.emitter
Class EmitterTask

java.lang.Object
  extended byorg.apache.ws.pubsub.emitter.EmitterTask
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
FileEmitterTask, HttpEmitterTask

public abstract class EmitterTask
extends java.lang.Object
implements java.lang.Runnable

This task is to be used to send notifications to client subscriber destinations. This class contains a factory method, createEmitterTask(SOAPMessage, URL), that creates a task specific to the protocol for the given destination; this factory method must be used to create emitter tasks. All subclasses to this class will be responsible for sending notifications over particular protocol transports. Each subclass must have a constructor that takes a SOAP message (the notification message itself) and a destination URL. These constructors are called by this class' factory method. TODO (ips): refactor the code from this class into SoapMessageEmitterEngine


Constructor Summary
protected EmitterTask(javax.xml.soap.SOAPMessage notif, java.net.URL url)
          Constructor to build the task.
 
Method Summary
static void addEmitter(java.lang.String protocol, java.lang.Class emitterClass)
          Configures a notification emitter to handle emitting notifications to consumer EPRs with addresses of the specified protocol type.
static EmitterTask createEmitterTask(javax.xml.soap.SOAPMessage notif, java.net.URL destination)
          Factory method that creates the appropriate emitter task based on the protocol required to send the notification.
protected abstract  void emit()
          Method that will actually send the notification to the destination via the appropriate protocol transport.
protected  java.net.URL getDestinationUrl()
          Returns the destination URL where the notification will be sent
protected  javax.xml.soap.SOAPMessage getNotification()
          Returns the actual notification object that is to be emitted.
 void run()
          This template method runs the task's thread and will call the appropriate emitter task's emit() method to send the notification.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmitterTask

protected EmitterTask(javax.xml.soap.SOAPMessage notif,
                      java.net.URL url)
Constructor to build the task. This is protected to enforce that fact that only createEmitterTask(javax.xml.soap.SOAPMessage, URL) should be used by clients to create these task objects.

Parameters:
notif - notification to send
url - endpoint URL of notification consumer
Method Detail

addEmitter

public static void addEmitter(java.lang.String protocol,
                              java.lang.Class emitterClass)
Configures a notification emitter to handle emitting notifications to consumer EPRs with addresses of the specified protocol type.

Parameters:
protocol - a URL protocol (e.g. http, https, or mailto)
emitterClass - the emitter class - must extend EmitterTask

createEmitterTask

public static EmitterTask createEmitterTask(javax.xml.soap.SOAPMessage notif,
                                            java.net.URL destination)
                                     throws EmitterException
Factory method that creates the appropriate emitter task based on the protocol required to send the notification.

Parameters:
notif - notification to send
destination - notification is to be sent to this destination endpoint
Returns:
the task to be used to send the notification
Throws:
EmitterException - if failed to create the task

run

public void run()
This template method runs the task's thread and will call the appropriate emitter task's emit() method to send the notification.

Specified by:
run in interface java.lang.Runnable
See Also:
Runnable.run()

getDestinationUrl

protected java.net.URL getDestinationUrl()
Returns the destination URL where the notification will be sent

Returns:
the destination URL where the notification will be sent

getNotification

protected javax.xml.soap.SOAPMessage getNotification()
Returns the actual notification object that is to be emitted.

Returns:
the actual notification object that is to be emitted.

emit

protected abstract void emit()
                      throws EmitterException
Method that will actually send the notification to the destination via the appropriate protocol transport.

Throws:
EmitterException - on error attempting to send notification


Copyright © 2004-2005 Apache Software Foundation. All Rights Reserved.