Bug 34440

Summary: sandbox:IMAppender - comma-seperated recipient list patch
Product: Log4j Reporter: Darren Hartford <dhartford>
Component: AppenderAssignee: log4j-dev <log4j-dev>
Status: NEW ---    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Darren Hartford 2005-04-13 17:15:31 UTC
log4j-sandbox, org.apache.log4j.net.IMAppender

Modify IMAppender class to support comma-seperated 'recipient' field in the
log4j properties file to allow for broadcast/multiple recipients.
-dhartford, 4/13/05

/*
 * Copyright 1999,2004 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.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.StringTokenizer;
.....
protected void sendBuffer() {
.....
      if (chatroom) {
        groupchat.sendMessage(buf.toString());
      } else {
//DRH 4/13/05 change in favor of recipient list.       
//chat.sendMessage(buf.toString());
		  psuedoBroadcast(buf.toString());
	  }
    } catch (Exception e) {
      errorHandler.error(
        "Could not send message in IMAppender [" + name + "]", e,
        ErrorCode.GENERIC_FAILURE);
    }
  }

  /**
   * This method breaks up a comma-seperated recipient list
   * to allow for psuedo-broadcasting.
   */
  private void psuedoBroadcast(String bufferedmessage) throws XMPPException{
		StringTokenizer st = new StringTokenizer(recipient, ","); 
		while (st.hasMoreTokens()) {
	        chat = con.createChat(st.nextToken());
			chat.sendMessage(bufferedmessage);
		}  
  }

//=====end snippet=====
Comment 1 Paul Smith 2005-04-14 00:21:42 UTC
Could you please do us a favour and attach the patch as an actual attachment
text file/patch attachment?  This makes applying them much easier (patch text
can get mangled otherwise).

cheers,

Paul