|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object PIRL.Conductor.Notify
public class Notify
Notify is a mechanism for delivering messages to destinations.
Each of Notify's destinations is represented by a URI
address which specifies the recipient of the message
and the protocol to be used to deliver it. The mailto URI, which
specifies how to deliver an e-mail message, is typical. If the
address does not specify a protocol, it is treated as a mailto URI.
If, for any reason, a destination cannot be used during the delivery
of the notice, that destination is added to a Vector of
undeliverable destinations.
Notify's message consists of text that is delivered to each
destination via a URLConnection
. The message
contents may be provided by a resource specifier which may be a
local resource - either a system filename or path within an
enclosing jar file - or an external resource via a URL. The message
may also be specified directly on the command line. The size of the
message may be limited to a maximum number of lines and the number
of last lines to always be retained in the message body may also be
controlled. This is particularly useful for preventing unexpectedly
large message files from causing memory exhaustion while still
delivering the beginning and end of the message.
For mailto deliveries a From and Reply-To address and a Subject line may be provided.
Field Summary | |
---|---|
static int |
CANNOT_READ_MESSAGE_FILE
Exit status values. |
static String |
DEFAULT_SMTP_SERVER
|
static char |
FILENAME_MARKER
Marker for a message source as opposed to a message string. |
static String |
ID
|
static int |
ILLEGAL_SYNTAX
Exit status values. |
static int |
NO_DESTINATION
Exit status values. |
static int |
SUCCESS
Exit status values. |
Constructor Summary | |
---|---|
Notify()
Constructs a Notify object with no destinations. |
|
Notify(Vector destinations)
Constructs a Notify object with the specified destinations. |
Method Summary | |
---|---|
int |
Deliver()
Delivers the notice to each destination. |
int |
Deliver(Vector destinations)
Delivers the notice to each destination. |
Vector |
Destinations()
Gets the list of destinations to which the notice will be delivered. |
Notify |
Destinations(Vector destinations)
Sets the list of destinations to which the message will be delivered. |
String |
From()
Gets the From address for e-mail deliveries of the notice. |
Notify |
From(String from_address)
Sets the From address for e-mail deliveries of the notice. |
static void |
main(String[] args)
Processes the command line arguments. |
int |
Max_Last_Lines()
Gets the maximum number of message last lines to be delivered. |
Notify |
Max_Last_Lines(int max_lines)
Sets the maximum number of message last lines to be delivered. |
int |
Max_Message_Lines()
Gets the maximum number of message lines to be delivered. |
Notify |
Max_Message_Lines(int max_lines)
Sets the maximum number of message lines to be delivered. |
Notify |
Message_Source(String source)
Reads a message from a named source. |
Notify |
Message_Source(String source,
boolean convert_escapes,
boolean append)
Reads a message from a named source. |
String |
Message()
Gets the message to be delivered. |
Notify |
Message(String message)
Sets the message to be delivered. |
Notify |
Message(String message,
boolean convert_escapes,
boolean append)
Sets the message to be delivered. |
String |
Reply_To()
Gets the Reply-To address for e-mail deliveries of the notice. |
Notify |
Reply_To(String reply_to_address)
Sets the Reply-To address for e-mail deliveries of the notice. |
String |
SMTP_Server()
Gets the current SMTP Server setting. |
Notify |
SMTP_Server(String smtp_server)
Sets the outgoing SMTP server hostname. |
String |
Subject()
Gets the Subject line for e-mail deliveries of the notice. |
Notify |
Subject(String subject_line)
Sets the Subject line for e-mail deliveries of the notice. |
Vector |
Undeliverable()
Gets the list of destinations to which the notice could not be delivered. |
static void |
Usage(int exit_status)
Prints the command line usage. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ID
public static final char FILENAME_MARKER
public static final int SUCCESS
public static final int ILLEGAL_SYNTAX
public static final int NO_DESTINATION
public static final int CANNOT_READ_MESSAGE_FILE
public static final String DEFAULT_SMTP_SERVER
Constructor Detail |
---|
public Notify(Vector destinations)
destinations
- The Vector of destinations to which the
notification message will be delivered.public Notify()
Method Detail |
---|
public Notify SMTP_Server(String smtp_server)
smtp_server
- The hostname of the outgoing SMTP server. The
default hostname is DEFAULT_SMTP_SERVER
.
public String SMTP_Server()
public Vector Destinations()
Notify will attempt to deliver to each of these destinations on the
next invocation of the Deliver()
method. A failed delivery
will add that destination to the list of undeliverable destinations.
Undeliverable()
public Notify Destinations(Vector destinations)
Redundant destination addresses are removed from the list.
Setting the destinations list has the side effect of resetting the list of undeliverable destinations.
destinations
- The Vector of destination URIs.
Undeliverable()
public Vector Undeliverable()
Whenever a Deliver
y cycle is done destinations
to which the notice could not be delivered - for whatever reason -
are added to a list of undeliverable destinations.
Deliver()
public String From()
The From address is not used for other types of deliveries.
public Notify From(String from_address)
The From address is not used for other types of deliveries. Furthermore, if the From address is null, it will not be used at all. In this case, the underlying Java e-mail delivery mechanism (the mailto URL handler) will attempt to use an appropriate From address based on the owner of the Notify process.
Note that there is no checking provided to ensure that the From address is a valid e-mail address. The address should be a regular e-mail address and not a mailto URL.
from_address
- The From address String.
public String Reply_To()
The Reply-To address is not used for other types of deliveries.
public Notify Reply_To(String reply_to_address)
The Reply-To address is not used for other types of deliveries. Furthermore, if the Reply-To address is null, it will not be used at all.
Note that there is no checking provided to ensure that the Reply-To address is a valid e-mail address. The address should be a regular e-mail address and not a mailto URL.
reply_to_address
- The Reply-To address String.
public String Subject()
The Subject line is not used for other types of deliveries.
public Notify Subject(String subject_line)
The Subject line is not used for other types of deliveries. Furthermore, if the Subject line is null, it will not be used at all.
subject_line
- The Subject line String.
public int Max_Message_Lines()
public Notify Max_Message_Lines(int max_lines)
max_lines
- The maximum number of message lines to be
delivered. If this is less than or equal to 0, the maximum integer value
will be used. If it is
less than Max_Last_Lines()
then Max_Last_Lines()
will be lowered to the same value and there
will be no initial message lines.
public int Max_Last_Lines()
public Notify Max_Last_Lines(int max_lines)
max_lines
- The maximum number of message lines to be
delivered. If this is less than 0, 0 will be used. If it is
greater than Max_Message_Lines()
then Max_Message_Lines()
will be used and there will be no initial
message lines.
public String Message()
The message is composed of two parts: The initial lines of the
message and the last lines of the message. No more than Max_Message_Lines()
user provided lines - where a line is a sequence
of characters terminated by a line separator - will be included. If
this limit is exceeded additional lines will be dropped; however,
the last Max_Last_Lines()
lines will always be included. In
this case the initial lines will be separated from the last lines
by a line of the form:
... [number> lines omitted]
where number> is number of user provided lines that were omitted from the message.
public Notify Message_Source(String source, boolean convert_escapes, boolean append) throws IOException
The source can be the name of a local file, the full pathname to that file, the name of a file contained within a jar that packages Notify, a file URL that points to a local file, or a URL that points to an external resource.
Only Max_Message_Lines()
lines - where a line is a sequence
of characters terminated by a line separator - will be retained. The
last Max_Last_Lines()
lines from the source will be saved
separately so they will be included in the delivered message
regardless of the total number of lines available from the source
(@see #Message()).
source
- The name of the message file. If null an empty
message is used.convert_escapes
- If true, any escape sequences
in the message are converted to their character equivalents;
otherwise the string is unchanged.append
- If true, the message is appended to any existing
message; otherwise the any existing message is replaced.
IOException
- If an input stream cannot be obtained
from the message source or if there is a problem reading
from the input stream.Streams.Get_Stream(String)
,
String_Buffer.escape_to_special()
public Notify Message_Source(String source) throws IOException
Any escape sequences are converted and any existing message appended.
source
- The name of the message file. If null the
message is set to the empty String.
IOException
- If an input stream cannot be obtained
from the message source or if there is a problem reading
from the input stream.Message_Source(String, boolean, boolean)
public Notify Message(String message, boolean convert_escapes, boolean append)
message
- The message String. A null message is empty.convert_escapes
- If true, any escape sequences in the message
are converted to their character equivalents; otherwise the
string is unchanged.append
- If true, the message is appended to any existing
message; otherwise an existing message is replaced.
String_Buffer.escape_to_special()
public Notify Message(String message)
Any escape sequences are expanded. Any existing message is cleared.
message
- The message String to be delivered. A null message
is empty.
Message(String, boolean, boolean)
public int Deliver()
The list of undeliverable destinations (destinations for which, for whatever reason, the delivery could not be made) is cleared prior to delivery.
Undeliverable()
public int Deliver(Vector destinations)
destinations
- The Vector of desinations.
Deliver()
public static void main(String[] args)
All error messages are written to stderr. If any destinations are undeliverable, they are listed.
The exit status will be one of:
args
- The array of command line arguments.Usage(int)
public static void Usage(int exit_status)
Usage: Notify <Switches> Switches - [-To] <address | URI>[,...] [-From <address>] (default: username) [-Reply-to <address>] [-Subject <subject line>] [-Message <message> | @<source>] [-Limit[_Last] <lines> (default: message 1000, last 50) [-Outgoing_server] <hostname> (default: localhost) [-Version [-Help
At least one destination (To) address must be provided. Each destination is treated as a URI. If the address does not specify a protocol, it is treated as a mailto URI. A comma separated list of addresses may be provided.
The From and Reply-to addresses are optional and only used in association with mailto destinations. By default the user's address, if available, will be used for the From address. If no Reply-to address is provided, none will be used.
The Subject line is optional and only used in association with mailto destinations. If none is provided, none will be used.
To message may be any text. If the message text begins with the
FILENAME_MARKER
('@') the text without the marker is
interpreted as a file or URL resource specifiction. This may be a
local resource, either a system filename or path within an enclosing
jar file, or it may refer to an external resource via a URL.
Multiple messages may be specified. They will be concatenated in the order they occur on the command line.
The size of the message may be limited to a maximum number of lines. Excess lines will be dropped but the last lines of the message - the number may be specified - will be retained.
The hostname of an SMTP server to which the message will be transmitted may be specified. The default hostname is "localhost".
N.B.: Command line options are applied in the order in which they are encountered. Thus, for example, message limit values should be set before the message body is specified.
The -Version option causes the class ID
to be written to
stdout followed by a System.exit.
N.B.: This method always results in a System.exit.
exit_status
- The exit status code. The usage statement is
written to the stdout if the exit_status is SUCCESS
,
otherwise to stderr.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |