Package ptolemy.actor.lib.mail
Class ExceptionEmailer
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.actor.AbstractInitializableAttribute
-
- ptolemy.actor.lib.mail.ExceptionEmailer
-
- All Implemented Interfaces:
java.lang.Cloneable
,Initializable
,ExceptionSubscriber
,Changeable
,Debuggable
,DebugListener
,Derivable
,HierarchyListener
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class ExceptionEmailer extends AbstractInitializableAttribute implements ExceptionSubscriber
An ExceptionEmailer sends an email to the specified party upon occurrence of an exception. The functionality is a simplified version ofSendMail
without attachments or an output. The password is read from a file to avoid storing it in the model.- Since:
- Ptolemy II 10.0
- Version:
- $Id: ExceptionSubscriber.java 69467 2014-06-29 14:35:19Z beth@berkeley.edu$
- Author:
- Edward A. Lee, Elizabeth Latronico
- See Also:
SendMail
- Pt.AcceptedRating:
- Red (beth)
- Pt.ProposedRating:
- Red (beth)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description StringParameter
cc
Email address to copy on the message.Parameter
enableSSL
Enable the Secure Sockets Layer (SSL) protocol.StringParameter
from
Email address from which this is sent.FileParameter
passwordFile
The file that the password is stored in.Parameter
reallySendMail
If true, then actually send the email.StringParameter
replyTo
The address to which replies should be directed.StringParameter
SMTPHostName
Host name for the send mail server.StringParameter
SMTPPort
Outgoing SMTP mail port.StringParameter
SMTPUserName
User name for the send mail server.StringParameter
statusMessage
A status message reflecting the success or failure of actions taken upon occurrence of an exception.StringParameter
to
Email address(es) to which this is sent.-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
-
Constructor Summary
Constructors Constructor Description ExceptionEmailer(NamedObj container, java.lang.String name)
Invoked by an exception handler (e.g.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
attributeChanged(Attribute attribute)
React to a change in an attribute.java.lang.Object
clone(Workspace workspace)
Clone the object into the specified workspace.boolean
exceptionHandled(boolean succesful, java.lang.String message)
Invoked by an exception handler (e.g.boolean
exceptionOccurred(java.lang.String policy, java.lang.Throwable exception)
Send a mail upon occurrence of an exception.-
Methods inherited from class ptolemy.actor.AbstractInitializableAttribute
_getInitializableContainer, addInitializable, hierarchyChanged, hierarchyWillChange, initialize, preinitialize, removeInitializable, setContainer, wrapup
-
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
cc
public StringParameter cc
Email address to copy on the message.
-
enableSSL
public Parameter enableSSL
Enable the Secure Sockets Layer (SSL) protocol.
-
from
public StringParameter from
Email address from which this is sent.
-
passwordFile
public FileParameter passwordFile
The file that the password is stored in.
-
reallySendMail
public Parameter reallySendMail
If true, then actually send the email. This is a boolean that defaults to false, meaning that the message is only sent to the output port. This parameter will be set back to false in the wrapup() method, to help prevent duplicate mailings.
-
replyTo
public StringParameter replyTo
The address to which replies should be directed. This is a comma-separated list that defaults to an empty string, which indicates that the reply should go to the address specified by from.
-
SMTPHostName
public StringParameter SMTPHostName
Host name for the send mail server.
-
SMTPPort
public StringParameter SMTPPort
Outgoing SMTP mail port.
-
SMTPUserName
public StringParameter SMTPUserName
User name for the send mail server.
-
statusMessage
public StringParameter statusMessage
A status message reflecting the success or failure of actions taken upon occurrence of an exception. Implemented as a public parameter so the message can be displayed in the icon.
-
to
public StringParameter to
Email address(es) to which this is sent. This is a comma-separated list that defaults to "nobody1@nowhere.com, nobody2@nowhere.com".
-
-
Constructor Detail
-
ExceptionEmailer
public ExceptionEmailer(NamedObj container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Invoked by an exception handler (e.g. CatchExceptionAttribute) when an exception occurs. Some subscribers may need to set up access to resources (such as opening a file) prior to being notified of an exception. These could extend AbstractInitalizableAttribute to do so.This attribute requires the JavaMail 1.5 javax.mail.jar file be in the classpath.
To use this actor, download
javax.mail.jar
https://java.net/projects/javamail/pages/Home
and place it in$PTII/vendors/misc/javamail
. Below are the steps:cd $PTII/vendors/misc/javamail wget --no-check-certificate http://java.net/projects/javamail/downloads/download/javax.mail.jar cd $PTII ./configure
In Eclipse, you will then need to refresh the project.
*- Parameters:
container
- The container.name
- The name.- Throws:
IllegalActionException
- If the superclass throws it.NameDuplicationException
- If the superclass throws it.
-
-
Method Detail
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
React to a change in an attribute. This method is called by a contained attribute when its value changes. In this class, if the SMTP host or user name is changed, this method forgets the password.- Overrides:
attributeChanged
in classNamedObj
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If the change is not acceptable to this container (not thrown in this base class).
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the object into the specified workspace.- Overrides:
clone
in classAbstractInitializableAttribute
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new NamedObj.
- Throws:
java.lang.CloneNotSupportedException
- If any of the attributes cannot be cloned.- See Also:
Object.clone()
-
exceptionHandled
public boolean exceptionHandled(boolean succesful, java.lang.String message)
Description copied from interface:ExceptionSubscriber
Invoked by an exception handler (e.g.ExceptionManager
) after an exception has been handled.- Specified by:
exceptionHandled
in interfaceExceptionSubscriber
- Parameters:
succesful
- True if the exception was successfully handled; false otherwisemessage
- A status message from the exception handler- Returns:
- True if the subscriber successfully processed the information; false otherwise (for example, an ExceptionEmailer that fails to send an email)
-
exceptionOccurred
public boolean exceptionOccurred(java.lang.String policy, java.lang.Throwable exception)
Send a mail upon occurrence of an exception.- Specified by:
exceptionOccurred
in interfaceExceptionSubscriber
- Parameters:
policy
- The exception handling policyexception
- The exception that occurred- Returns:
- True if email was sent successfully (or if notification message was successfully generated if reallySendMail is false), false otherwise
-
-