KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > binding > mail > MailBCImpl


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2006 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: MailBCImpl.java 154 25 sept. 06 ofabre $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.binding.mail;
23
24 import org.objectweb.petals.binding.mail.listeners.MailBCExternalListenerManager;
25 import org.objectweb.petals.binding.mail.listeners.MailBCJBIListener;
26 import org.objectweb.petals.binding.mail.listeners.MailSessionManager;
27 import org.objectweb.petals.binding.mail.listeners.MimeMessageManager;
28 import org.objectweb.petals.binding.mail.listeners.SessionDescriptorBuilder;
29 import org.objectweb.petals.component.common.bc.AbstractBindingComponent;
30 import org.objectweb.petals.component.common.bc.ExternalListenerManager;
31 import org.objectweb.petals.component.common.bc.JBIListener;
32
33 /**
34  * The Mail Binding Component.
35  * <p>
36  * It creates some sub components like :
37  * <p>
38  * the <b>{@link MailSessionManager}</b> used to manage session with mail
39  * servers : create and open sessions, send and receive mails,
40  * <p>
41  * the <b>{@link MimeMessageManager}</b> used to process (reading or creating)
42  * mail messages,
43  * <p>
44  * the <b>{@link SessionDescriptorBuilder}</b> used to extract information
45  * from a Mail URI String,
46  * <p>
47  * the <b>{@link MailBCExternalListenerManager}</b> used to manage listeners
48  * for external mail addresses registered during SU deployment,
49  * <p>
50  * the <b>{@link MailBCJBIListener}</b> used to process incoming JBI messages
51  * <p>
52  * This class defines some Default Value for mail features like :
53  * <p>
54  * <b>SMTP</b> (25), <b>IMAP</b> (143) and <b>POP3</b> (110) default ports,
55  * <p>
56  * default mail folder (INBOX),
57  * <p>
58  * default mail checking period (60 seconds).
59  *
60  * @author ofabre - EBM Websourcing
61  *
62  */

63 public class MailBCImpl extends AbstractBindingComponent {
64
65     public final static String JavaDoc FROM_PATHELEMENT = "from:";
66
67     public final static String JavaDoc MAIL_FROM_KEY = "mail.from";
68
69     public final static String JavaDoc MAIL_HOST_KEY = "mail.host";
70
71     public final static String JavaDoc MAIL_USER_KEY = "mail.user";
72
73     public final static String JavaDoc MAIL_STORE_PROTOCOL_KEY = "mail.store.protocol";
74
75     public final static String JavaDoc MAIL_SMTP_PORT_DEFAULT = "25";
76
77     public final static String JavaDoc MAIL_IMAP_PORT_DEFAULT = "143";
78
79     public final static String JavaDoc MAIL_POP3_PORT_DEFAULT = "110";
80
81     public final static String JavaDoc MAIL_SCHEME_SMTP = "smtp";
82
83     public final static String JavaDoc MAIL_SCHEME_IMAP = "imap";
84
85     public final static String JavaDoc MAIL_SCHEME_POP3 = "pop3";
86
87     public final static String JavaDoc MAIL_TRANSPORT_PROTOCOL_KEY = "mail.transport.protocol";
88
89     public final static String JavaDoc TO_PATHELEMENT = "to:";
90
91     public final static String JavaDoc PERIOD_QUERYELEMENT = "period";
92
93     public final static String JavaDoc PERIOD_DEFAULT = "60000";
94
95     public final static String JavaDoc FOLDER_QUERYELEMENT = "folder";
96
97     public final static String JavaDoc FOLDER_DEFAULT = "INBOX";
98
99     public final static String JavaDoc QUERY_SEPARATOR = "&";
100     
101     public final static String JavaDoc DESTINATION_ADDRESS = "destinationAddress";
102
103     protected SessionDescriptorBuilder sessionDescriptorBuilder;
104
105     protected MimeMessageManager mimeMessageManager;
106
107     protected MailSessionManager mailSessionManager;
108
109
110     @Override JavaDoc
111     protected void init(BindingComponentInitializer initializer) {
112         this.sessionDescriptorBuilder = new SessionDescriptorBuilder(
113             getLogger());
114         this.mimeMessageManager = new MimeMessageManager(getLogger(), this);
115         this.mailSessionManager = new MailSessionManager(getLogger());
116         ExternalListenerManager externalListenerManager = new MailBCExternalListenerManager(
117             getLogger(), mailSessionManager, sessionDescriptorBuilder,
118             mimeMessageManager);
119         JBIListener listener = new MailBCJBIListener(mimeMessageManager,
120             mailSessionManager, sessionDescriptorBuilder, getLogger());
121         
122         initializer.setExternalListenerManager(externalListenerManager);
123         initializer.setJbiListener(listener);
124
125     }
126
127 }
128
Popular Tags