org.apache.commons.messenger.task
Class ProducerTask

java.lang.Object
  extended byorg.apache.tools.ant.ProjectComponent
      extended byorg.apache.tools.ant.Task
          extended byorg.apache.commons.messenger.task.ProducerTask
All Implemented Interfaces:
java.lang.Cloneable

public class ProducerTask
extends org.apache.tools.ant.Task

ProducerTask is an Ant task which will publish all of the given text files as a JMS Text Message using a given JMS Connection (Messenger) and a Destination

Version:
$Revision: 1.6 $
Author:
James Strachan

Field Summary
private  javax.jms.Destination destination
           
private  java.io.File file
           
private  java.util.Vector filesets
           
private  Messenger messenger
           
private  MessengerManager messengerManager
           
private  java.lang.String messengerName
           
private  long sleep
          Holds value of property sleep.
private  java.lang.String subject
           
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
ProducerTask()
           
 
Method Summary
 void addFileset(org.apache.tools.ant.types.FileSet set)
          Adds a set of files (nested fileset attribute).
 void execute()
          Performs the copy operation.
 javax.jms.Destination getDestination()
          Getter for property destination.
 java.io.File getFile()
          Returns the single file to be sent instead of a FileSet
 Messenger getMessenger()
           
 MessengerManager getMessengerManager()
          Getter for property messengerManager.
 java.lang.String getMessengerName()
          Getter for property messengerName.
 long getSleep()
          Getter for property sleep, which defines the number of milliseconds to sleep for before each send.
 java.lang.String getSubject()
          Getter for property subject.
protected  java.lang.String readText(java.io.Reader in)
          Reads the given text stream into a single string
protected  void sendFile(java.io.File file, Messenger messenger, javax.jms.Destination destination)
          Sends the contents of the given file to the given Destination using the given Messenger instance
 void setConfiguration(java.lang.String uri)
          Sets the URI of the Messenger.xml configuration document to use to configure the messengers to use for this task.
 void setDestination(javax.jms.Destination destination)
          Setter for property destination.
 void setFile(java.io.File file)
          Allows a single file to be sent via the Ant Task
 void setMessenger(Messenger messenger)
          Sets the Messenger to be used
 void setMessengerManager(MessengerManager messengerManager)
          Setter for property messengerManager.
 void setMessengerName(java.lang.String messengerName)
          Setter for property messengerName.
 void setSleep(long sleep)
          Setter for property sleep, which defines the number of milliseconds to sleep for before each send.
 void setSubject(java.lang.String subject)
          Setter for property subject.
protected  void sleep()
          Sleeps for a configurable amount of time between each message send
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filesets

private java.util.Vector filesets

messenger

private Messenger messenger

messengerName

private java.lang.String messengerName

destination

private javax.jms.Destination destination

subject

private java.lang.String subject

messengerManager

private MessengerManager messengerManager

file

private java.io.File file

sleep

private long sleep
Holds value of property sleep.

Constructor Detail

ProducerTask

public ProducerTask()
Method Detail

addFileset

public void addFileset(org.apache.tools.ant.types.FileSet set)
Adds a set of files (nested fileset attribute).


getMessenger

public Messenger getMessenger()
                       throws javax.jms.JMSException
Throws:
javax.jms.JMSException

setMessenger

public void setMessenger(Messenger messenger)
Sets the Messenger to be used


getMessengerName

public java.lang.String getMessengerName()
Getter for property messengerName.

Returns:
Value of property messengerName.

setMessengerName

public void setMessengerName(java.lang.String messengerName)
Setter for property messengerName.

Parameters:
messengerName - New value of property messengerName.

getDestination

public javax.jms.Destination getDestination()
                                     throws javax.jms.JMSException
Getter for property destination.

Returns:
Value of property destination.
Throws:
javax.jms.JMSException

setDestination

public void setDestination(javax.jms.Destination destination)
Setter for property destination.

Parameters:
destination - New value of property destination.

getSubject

public java.lang.String getSubject()
Getter for property subject.

Returns:
Value of property subject.

setSubject

public void setSubject(java.lang.String subject)
Setter for property subject.

Parameters:
subject - New value of property subject.

getMessengerManager

public MessengerManager getMessengerManager()
Getter for property messengerManager.

Returns:
Value of property messengerManager.

setMessengerManager

public void setMessengerManager(MessengerManager messengerManager)
Setter for property messengerManager.

Parameters:
messengerManager - New value of property messengerManager.

setConfiguration

public void setConfiguration(java.lang.String uri)
                      throws javax.jms.JMSException
Sets the URI of the Messenger.xml configuration document to use to configure the messengers to use for this task.

Throws:
javax.jms.JMSException

getSleep

public long getSleep()
Getter for property sleep, which defines the number of milliseconds to sleep for before each send.

Returns:
Value of property sleep.

setSleep

public void setSleep(long sleep)
Setter for property sleep, which defines the number of milliseconds to sleep for before each send.

Parameters:
sleep - New value of property sleep.

getFile

public java.io.File getFile()
Returns the single file to be sent instead of a FileSet

Returns:
File

setFile

public void setFile(java.io.File file)
Allows a single file to be sent via the Ant Task

Parameters:
file - The file to set

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Performs the copy operation.

Throws:
org.apache.tools.ant.BuildException

sendFile

protected void sendFile(java.io.File file,
                        Messenger messenger,
                        javax.jms.Destination destination)
                 throws java.io.IOException,
                        javax.jms.JMSException
Sends the contents of the given file to the given Destination using the given Messenger instance

Throws:
java.io.IOException
javax.jms.JMSException

readText

protected java.lang.String readText(java.io.Reader in)
                             throws java.io.IOException
Reads the given text stream into a single string

Throws:
java.io.IOException

sleep

protected void sleep()
Sleeps for a configurable amount of time between each message send