ASF Bugzilla – Attachment 16885 Details for
Bug 19125
SMTP Appender should support more of the JavaMail configurations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch against 11/5/2005 head with priority and cc options
SMTPAppender.head.patch (text/plain), 7.13 KB, created by
Jon Wilmoth
on 2005-11-06 03:11:40 UTC
(
hide
)
Description:
patch against 11/5/2005 head with priority and cc options
Filename:
MIME Type:
Creator:
Jon Wilmoth
Created:
2005-11-06 03:11:40 UTC
Size:
7.13 KB
patch
obsolete
>Index: SMTPAppender.java >=================================================================== >--- SMTPAppender.java (revision 331046) >+++ SMTPAppender.java (working copy) >@@ -1,12 +1,12 @@ > /* > * Copyright 1999,2005 The Apache Software Foundation. >- * >+ * > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > * You may obtain a copy of the License at >- * >+ * > * http://www.apache.org/licenses/LICENSE-2.0 >- * >+ * > * Unless required by applicable law or agreed to in writing, software > * distributed under the License is distributed on an "AS IS" BASIS, > * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >@@ -53,36 +53,52 @@ > <code>BufferSize</code> logging events in its cyclic buffer. This > keeps memory requirements at a reasonable level while still > delivering useful application context. >- >+ > <p>There are three ways in which the trigger is fired, resulting in an email > containing the buffered events: >- >- <p>* DEFAULT BEHAVIOR: relies on an internal TriggeringEventEvaluator class that >+ >+ <p>* DEFAULT BEHAVIOR: relies on an internal TriggeringEventEvaluator class that > triggers the sending of an email when an event with a severity of ERROR or greater is received. >- <p>* Set the 'evaluatorClass' param to the fully qualified class name of a class you >+ <p>* Set the 'evaluatorClass' param to the fully qualified class name of a class you > have written that implements the TriggeringEventEvaluator interface. >- <p>* Set the 'expression' param to a valid (infix) expression supported by ExpressionRule and >+ <p>* Set the 'expression' param to a valid (infix) expression supported by ExpressionRule and > ExpressionRule's supported operators and operands. >- >+ > As events are received, events are evaluated against the expression rule. An event > that causes the rule to evaluate to true triggers the email send. >- >+ > If both evaluatorClass and expression params are set, the evaluatorClass is used. >- >+ > See org.apache.log4j.rule.ExpressionRule for a more information. >- >+ > <p> >- >+ > @author Ceki Gülcü > @since 1.0 */ > public class SMTPAppender extends AppenderSkeleton { > private String to; >+ /** >+ * Comma separated list of email addresses for the Cc line. >+ */ >+ private String cc; > private String from; > private String subjectStr = ""; > private String smtpHost; > private String charset = "ISO-8859-1"; > private int bufferSize = 512; > private boolean locationInfo = false; >+ >+ /** >+ * Email header used to set messages to higher or lower priority given a numerical value of 1 through 5. >+ * <ol> >+ * <li>Highest Priority</li> >+ * <li>High Priority</li> >+ * <li>Normal (default if not defined)</li> >+ * <li>Low Priority</li> >+ * <li>Lowest Priority</li> >+ * </ol> >+ */ >+ private int priority = 3; > protected CyclicBuffer cb = new CyclicBuffer(bufferSize); > protected MimeMessage msg; > protected TriggeringEventEvaluator evaluator; >@@ -128,6 +144,15 @@ > } > > msg.setRecipients(Message.RecipientType.TO, parseAddress(to)); >+ >+ //Add CC receipients if defined. >+ if (cc != null && !"".equals(cc)) { >+ msg.setRecipients(Message.RecipientType.CC, parseAddress(cc)); >+ } >+ >+ //Set email priority >+ msg.addHeader("X-Priority", String.valueOf(getPriority())); >+ > } catch (MessagingException e) { > errorCount++; > getLogger().error("Could not activate SMTPAppender options.", e); >@@ -153,7 +178,7 @@ > getLogger().error(errMsg); > throw new IllegalStateException(errMsg); > } >- >+ > if(errorCount == 0) { > super.activateOptions(); > } >@@ -252,10 +277,10 @@ > // appender. This frees us from needing to synchronize on 'cb'. > try { > MimeBodyPart part = new MimeBodyPart(); >- >+ > String computedSubject = computeSubject(triggeringEvent); > msg.setSubject(computedSubject, charset); >- >+ > StringBuffer sbuf = new StringBuffer(); > String t = layout.getHeader(); > >@@ -321,7 +346,7 @@ > public String getFrom() { > return from; > } >- >+ > /** > Returns value of the <b>Subject</b> option. > */ >@@ -338,15 +363,15 @@ > } > > /** >- * The <b>Subject</b> option takes a string value which will be the subject >- * of the e-mail message. This value can be string literal or a conversion >- * pattern in the same format as expected by >+ * The <b>Subject</b> option takes a string value which will be the subject >+ * of the e-mail message. This value can be string literal or a conversion >+ * pattern in the same format as expected by > * {@link org.apache.log4j.PatternLayout}. >- * >+ * > * <p>The conversion pattern is applied on the triggering event to dynamically >- * compute the subject of the outging email message. For example, setting >+ * compute the subject of the outging email message. For example, setting > * the <b>Subject</b> option to "%properties{host} - %m" >- * will set the subject of outgoing message to the "host" property of the >+ * will set the subject of outgoing message to the "host" property of the > * triggering event followed by the message of the triggering event. > */ > public void setSubject(String subject) { >@@ -388,6 +413,36 @@ > this.to = to; > } > >+ /** >+ The <b>Cc</b> option takes a string value which should be a >+ comma separated list of e-mail address of the recipients. >+ */ >+ public void setCc(String cc) { >+ this.cc = cc; >+ } >+ >+ /** >+ Returns value of the <b>Cc</b> option. >+ */ >+ public String getCc() { >+ return cc; >+ } >+ >+ /** >+ The <b>Priority</b> option takes a positive integer (1 through 5) >+ representing the priority of the email message. Default is 3 (aka normal). >+ */ >+ public void setPriority(int priority) { >+ this.priority = priority; >+ } >+ >+ /** >+ Returns value of the <b>Priority</b> option. >+ */ >+ public int getPriority() { >+ return priority; >+ } >+ > /** > Returns value of the <b>BufferSize</b> option. > */ >@@ -396,11 +451,11 @@ > } > > /** >- * The <b>EvaluatorClass</b> option takes a string value representing the >- * name of the class implementing the {@link TriggeringEventEvaluator} >- * interface. A corresponding object will be instantiated and assigned as >+ * The <b>EvaluatorClass</b> option takes a string value representing the >+ * name of the class implementing the {@link TriggeringEventEvaluator} >+ * interface. A corresponding object will be instantiated and assigned as > * the triggering event evaluator for the SMTPAppender. >- * >+ * > * @deprecated replaced by {@link #setEvaluator}. > */ > public void setEvaluatorClass(String value) { >@@ -465,13 +520,13 @@ > > private Rule expressionRule; > private String expression; >- >+ > public DefaultEvaluator() {} >- >+ > public void setExpression(String expression) { > this.expression = expression; > } >- >+ > public void activateOptions() { > if(expression != null) { > try { >@@ -481,7 +536,7 @@ > } > } > } >- >+ > /** > Is this <code>event</code> the e-mail triggering event? >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 19125
:
5892
| 16885