⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 avalonlistservmanager.java

📁 java 开发的邮件服务器平台。支持以下协议。 协议可以修改为自己的专门标识
💻 JAVA
字号:
/*********************************************************************** * Copyright (c) 2000-2004 The Apache Software Foundation.             * * All rights reserved.                                                * * ------------------------------------------------------------------- * * 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.                      * ***********************************************************************/package org.apache.james.transport.mailets;import org.apache.avalon.framework.component.ComponentException;import org.apache.avalon.framework.component.ComponentManager;import org.apache.james.Constants;import org.apache.james.services.UsersRepository;import org.apache.james.services.UsersStore;import org.apache.mailet.MailAddress;/** * Adds or removes an email address to a listserv. * * <p>Sample configuration: * <br>&lt;mailet match="CommandForListserv=james@list.working-dogs.com" class="AvalonListservManager"&gt; * <br>&lt;repositoryName&gt;name of user repository configured in UsersStore block &lt;/repositoryName&gt; * <br>&lt;/mailet&gt; * * @version This is $Revision: 1.6.4.3 $ */public class AvalonListservManager extends GenericListservManager {    private UsersRepository members;    /**     * Initialize the mailet     */    public void init() {        ComponentManager compMgr = (ComponentManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);        try {            UsersStore usersStore = (UsersStore) compMgr.lookup("org.apache.james.services.UsersStore");            String repName = getInitParameter("repositoryName");            members = (UsersRepository) usersStore.getRepository(repName);        } catch (ComponentException cnfe) {            log("Failed to retrieve Store component:" + cnfe.getMessage());        } catch (Exception e) {            log("Failed to retrieve Store component:" + e.getMessage());        }    }    /**     * Add an address to the list.     *     * @param address the address to add     *     * @return true if successful, false otherwise     */    public boolean addAddress(MailAddress address) {        members.addUser(address.toString(), "");        return true;    }    /**     * Remove an address from the list.     *     * @param address the address to remove     *     * @return true if successful, false otherwise     */    public boolean removeAddress(MailAddress address) {        members.removeUser(address.toString());        return true;    }    public boolean existsAddress(MailAddress address) {        return members.contains(address.toString());    }    /**     * Return a string describing this mailet.     *     * @return a string describing this mailet     */    public String getMailetInfo() {        return "AvalonListservManager Mailet";    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -