1 17 18 package org.apache.james.transport.mailets; 19 20 import org.apache.avalon.framework.component.ComponentException; 21 import org.apache.avalon.framework.component.ComponentManager; 22 import org.apache.james.Constants; 23 import org.apache.james.services.UsersRepository; 24 import org.apache.james.services.UsersStore; 25 import org.apache.mailet.MailAddress; 26 27 37 public class AvalonListservManager extends GenericListservManager { 38 39 private UsersRepository members; 40 41 44 public void init() { 45 ComponentManager compMgr = (ComponentManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER); 46 try { 47 UsersStore usersStore = (UsersStore) compMgr.lookup("org.apache.james.services.UsersStore"); 48 String repName = getInitParameter("repositoryName"); 49 50 members = (UsersRepository) usersStore.getRepository(repName); 51 } catch (ComponentException cnfe) { 52 log("Failed to retrieve Store component:" + cnfe.getMessage()); 53 } catch (Exception e) { 54 log("Failed to retrieve Store component:" + e.getMessage()); 55 } 56 } 57 58 65 public boolean addAddress(MailAddress address) { 66 members.addUser(address.toString(), ""); 67 return true; 68 } 69 70 77 public boolean removeAddress(MailAddress address) { 78 members.removeUser(address.toString()); 79 return true; 80 } 81 82 public boolean existsAddress(MailAddress address) { 83 return members.contains(address.toString()); 84 } 85 86 91 public String getMailetInfo() { 92 return "AvalonListservManager Mailet"; 93 } 94 } 95 96 | Popular Tags |