KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > james > samples > mailets > HelloWorldMailet


1 package org.apache.james.samples.mailets;
2
3 /*
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 import javax.mail.MessagingException JavaDoc;
18
19 import org.apache.mailet.Mail;
20 import org.apache.mailet.Mailet;
21 import org.apache.mailet.MailetConfig;
22 import org.apache.mailet.MailetContext;
23
24 /**
25  * Simply logs a message.
26  */

27 public class HelloWorldMailet implements Mailet {
28
29     private MailetConfig config;
30     
31     public void destroy() {
32
33     }
34
35     public String JavaDoc getMailetInfo() {
36         return "Example mailet";
37     }
38
39     public MailetConfig getMailetConfig() {
40         return config;
41     }
42
43     public void init(MailetConfig config) throws MessagingException JavaDoc {
44         this.config = config;
45     }
46
47     public void service(Mail mail) throws MessagingException JavaDoc {
48         MailetContext context = config.getMailetContext();
49         context.log("Hello, World!");
50         context.log("You have mail from " + mail.getSender().getUser());
51     }
52 }
53
Popular Tags