1 /****************************************************************
2 * Licensed to the Apache Software Foundation (ASF) under one *
3 * or more contributor license agreements. See the NOTICE file *
4 * distributed with this work for additional information *
5 * regarding copyright ownership. The ASF licenses this file *
6 * to you under the Apache License, Version 2.0 (the *
7 * "License"); you may not use this file except in compliance *
8 * with the License. You may obtain a copy of the License at *
9 * *
10 * http://www.apache.org/licenses/LICENSE-2.0 *
11 * *
12 * Unless required by applicable law or agreed to in writing, *
13 * software distributed under the License is distributed on an *
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
15 * KIND, either express or implied. See the License for the *
16 * specific language governing permissions and limitations *
17 * under the License. *
18 ****************************************************************/
19
20
21
22 package org.apache.james.transport.mailets.listservcommands;
23
24 import org.apache.avalon.framework.configuration.Configuration;
25 import org.apache.avalon.framework.configuration.ConfigurationException;
26 import org.apache.james.transport.mailets.ICommandListservManager;
27 import org.apache.mailet.Mail;
28
29 import javax.mail.MessagingException;
30
31 /**
32 * IListServCommand is the interface that all pluggable list serv commands must implement.
33 * The lifecycle of a IListServCommand will be controlled by the {@link ICommandListservManager}
34 *
35 * <br />
36 * <br />
37 * Requests sent to the CommandListservManager take the form of:
38 * <pre>
39 * <listName>-<commandName>@domain
40 * </pre>
41 * and if the commandName matches the command's name, then the {@link #onCommand} will be invoked.
42 *
43 * <br />
44 * <br />
45 * A typical command is configured:
46 * <pre>
47 * <command name="subscribe" class="Subscribe"/>
48 * </pre>
49 *
50 * <br />
51 * <br />
52 * Typically, IListServCommands will format some text to reply with based off of resource files
53 * and calls to {@link org.apache.james.util.XMLResources#getString(String)}
54 *
55 * This allows you to customize the messages sent by these commands by editing text files and not editing the javacode.
56 *
57 * @version CVS $Revision: 486089 $ $Date: 2006-12-12 10:42:07 +0000 (Tue, 12 Dec 2006) $
58 * @since 2.2.0
59 * @see ICommandListservManager
60 */
61 public interface IListServCommand {
62
63 /**
64 * The name of this command
65 * specified by the 'name' parameter.
66 * eg:
67 * <pre>
68 * <command name="subscribe" class="Subscribe"/>
69 * </pre>
70 * @return the name of this command
71 */
72 public String getCommandName();
73
74 /**
75 * Perform any required initialization
76 * @param configuration
77 * @throws ConfigurationException
78 */
79 public void init(ICommandListservManager commandListservManager, Configuration configuration) throws ConfigurationException;
80
81 /**
82 * Process this command to your hearts content
83 * @param mail
84 * @throws MessagingException
85 */
86 public void onCommand(Mail mail) throws MessagingException;
87 }