logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ceki Gülcü <...@qos.ch>
Subject Re: [PATCH] SMTPAppender.java
Date Sun, 20 May 2001 14:48:22 GMT

Jim,

Most of the setter/getter method you requested had been already added some time ago. I have
made "cb" and "msg" protected and checked in a changed version. Let me know if the results
are OK with you. Ceki

At 17:42 19.05.2001 -0400, you wrote:
>Here are the changes I was talking about before regarding making the
>SMTPAppender friendlier to extension.  The patch is against rev 1.22 in CVS.
>
>Specific changes:
>  * Private members are declared to be private.
>  * Private members that is needed by subclasses (like the CyclicBuffer,
>TriggerEventEvaluator and Message objects) now have protected methods for
>setting and getting them.
>  * The Session member was removed as a member because it's only used in one
>method, and therefore made local.
>
>-Jim Moore
>
>====================================
>
>--- SMTPAppender.old    Sat May 19 17:06:16 2001
>+++ SMTPAppender.java   Fri Apr 13 10:04:24 2001
>@@ -48,12 +48,11 @@
> public class SMTPAppender extends AppenderSkeleton {
>-  String to;
>-  String from;
>-  String subject;
>-  String smtpHost;
>-  int bufferSize = 512;
>+  private String to;
>+  private String from;
>+  private String subject;
>+  private String smtpHost;
>+  private int bufferSize = 512;
> 
>-  CyclicBuffer cb = new CyclicBuffer(bufferSize);
>-  Session session;
>-  Message msg;
>-  boolean locationInfo = false;
>+  private CyclicBuffer _cb;
>+  private Message _msg;
>+  private boolean locationInfo = false;
> 
>@@ -166,2 +165,3 @@
>     this.evaluator = evaluator;
>+    setCyclicBuffer(new CyclicBuffer(bufferSize));
>   }
>@@ -194,5 +194,5 @@
> 
>-     session = Session.getDefaultInstance(props, null);
>+     Session session = Session.getDefaultInstance(props, null);
>      //session.setDebug(true);
>-     msg = new MimeMessage(session);
>+     MimeMessage msg = new MimeMessage(session);
>      
>@@ -210,2 +210,4 @@
>      }
>+
>+     setMessage(msg);
>   }
>@@ -228,3 +230,3 @@
>     }
>-    cb.add(event);    
>+    getCyclicBuffer().add(event);
>     if(evaluator.isTriggeringEvent(event)) {
>@@ -242,3 +244,3 @@
>   boolean checkEntryConditions() {
>-    if(this.msg == null) {
>+    if(getMessage() == null) {
>       errorHandler.error("Message object not configured.");
>@@ -320,2 +322,3 @@
>        sbuf.append(t);
>+      CyclicBuffer cb = getCyclicBuffer();
>       int len =  cb.length(); 
>@@ -341,2 +344,3 @@
>       mp.addBodyPart(part);
>+      Message msg = getMessage();
>       msg.setContent(mp);
>@@ -350,3 +354,34 @@
>   
>+  /**
>+   * Sets the CyclicBuffer this will use for keeping track
>+   *   of {@link LoggingEvent}s.
>+   * 
>+   * @param cb     the CyclicBuffer to store the events in
>+   */
>+  protected void setCyclicBuffer(CyclicBuffer cb) {
>+    _cb = cb;
>+  }
>+
>+  /**
>+   * Returns the CyclicBuffer the {@link LoggingEvent}s are stored in.
>+   */
>+  protected CyclicBuffer getCyclicBuffer() {
>+    return _cb;
>+  }
>+
>+  /**
>+   * Sets the Message object used for sending the emails.
>+   * 
>+   * @param msg    the Message object to use for the emails.
>+   */
>+  protected void setMessage(Message msg) {
>+    _msg = msg;
>+  }
> 
>+  /**
>+   * Gets the Message object used for sending the emails.
>+   */
>+  protected Message getMessage() {
>+    return _msg;
>+  }
> 
>@@ -361,2 +396,10 @@
>   /**
>+     Returns the TriggeringEventEvaluator this uses.
>+   */
>+  protected
>+  TriggeringEventEvaluator getEvaluator() {
>+    return evaluator;
>+  }
>+  
>+  /**
>      Returns value of the <b>From</b> option.
>@@ -400,3 +443,3 @@
>       bufferSize = OptionConverter.toInt(value, bufferSize);    
>-      cb.resize(bufferSize);
>+      getCyclicBuffer().resize(bufferSize);
>     } else if (option.equals(LOCATION_INFO_OPTION))
>@@ -437,3 +480,3 @@
>     this.bufferSize = bufferSize;
>-    cb.resize(bufferSize);
>+    getCyclicBuffer().resize(bufferSize);
>   }
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-dev-help@jakarta.apache.org

--
Ceki Gülcü


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org


Mime
View raw message