Methods Summary |
---|
java.lang.String | getFromAddress() return fromAddress;
|
boolean | getIncludeDiagnostics() return includeDiagnostics;
|
java.lang.String | getMailResourceName() return mailResourceName;
|
java.lang.String | getMailSMTPHost()getter for Testing purpose. return mailSMTPHost;
|
java.lang.String | getRecipients()getter for testing purpose. return recipients;
|
java.lang.String | getSubject()getter added for testing purpose. return subject;
|
public void | handleNotification(javax.management.Notification notification, java.lang.Object handback)javax.managament.NotificationHandler interface implementation.
try {
Properties props = System.getProperties( );
props.put("mail.smtp.host", mailSMTPHost );
Session session = Session.getDefaultInstance( props, null );
MimeMessage message = new MimeMessage(session);
message.setFrom( fromSMTPAddress );
message.setRecipients( Message.RecipientType.TO, recipients );
message.setSubject( subject );
message.setText( notification.toString() );
Transport.send( message );
} catch( Exception e ) {
alertLogger.log( Level.FINE,
"Exception in MailAlert.handleNotification ->" + e );
// _REVISIT_: Add the appropriate exception and make sure there
// is no recursion here.
// Add a new Key Value Pair to makesure that WARNING message here
// doesn't result in an alert resulting in a loop
}
|
public void | setFromAddress(java.lang.String fromAddress)From Address for the e-mail alert.
if( alertLogger.isLoggable( Level.FINE ) ) {
alertLogger.log( Level.FINE,
"setFromAddress called with address ->" + fromAddress );
}
this.fromAddress = fromAddress;
try {
fromSMTPAddress = new InternetAddress( fromAddress );
} catch( Exception e ) {
alertLogger.log( Level.FINE,
"Exception in MailAlert.setFromAddress ->" + e );
// _REVISIT_: Exception log and make sure there is no recursion
}
|
public void | setIncludeDiagnostics(boolean includeDiagnostics)If IncludeDiagnostics is true, then Diagnostics will be sent along with
the error. Note: Diagnostics may be available for some of the Logged
message alerts only.
this.includeDiagnostics = includeDiagnostics;
|
public void | setMailResourceName(java.lang.String mailResourceName)A JNDI name that will be used to look up the MailResource.
//_REVISIT_: Currently not using it.
this.mailResourceName = mailResourceName;
|
public void | setMailSMTPHost(java.lang.String mailSMTPHost)Set's the SMTP Host used to send out the mail. This is usually a
mail proxy.
this.mailSMTPHost = mailSMTPHost;
if( alertLogger.isLoggable( Level.FINE ) ) {
alertLogger.log( Level.FINE,
"setMailSMTPHost called with ->" + mailSMTPHost );
}
|
public void | setRecipients(java.lang.String recipients)Set's the recipient e-mail addresses to recieve alerts. This is a
comma separated list of e-mail ids.
this.recipients = recipients;
if( alertLogger.isLoggable( Level.FINE ) ) {
alertLogger.log( Level.FINE,
"setRecipients called with -> " + recipients );
}
|
public void | setSubject(java.lang.String subject)Set's the subjectLine for the E-mail Alert.
this.subject = subject;
if( alertLogger.isLoggable( Level.FINE ) ) {
alertLogger.log( Level.FINE,
"setSubject called with -> " + subject );
}
|
public void | setUnitTestData(java.lang.String unitTestData)These are Unit Test Method provided for internal testing only.
alertLogger.log( Level.FINE,
"UnitTestData -> " + unitTestData );
new UnitTest(
UnitTest.UNIT_TEST_MAIL_ALERT, unitTestData, this ).start();
|