01: package org.claros.commons.mail.protocols;
02:
03: import org.claros.commons.auth.models.AuthProfile;
04: import org.claros.commons.mail.models.ConnectionMetaHandler;
05: import org.claros.commons.mail.models.ConnectionProfile;
06: import org.claros.commons.mail.utility.Constants;
07:
08: /**
09: * @author Umut Gokbayrak
10: */
11: public class ProtocolFactory {
12: private ConnectionProfile profile;
13: private AuthProfile auth;
14: private ConnectionMetaHandler handler;
15:
16: /**
17: *
18: * @param profile
19: * @param auth
20: * @param handler
21: */
22: public ProtocolFactory(ConnectionProfile profile, AuthProfile auth,
23: ConnectionMetaHandler handler) {
24: this .profile = profile;
25: this .auth = auth;
26: this .handler = handler;
27: }
28:
29: /**
30: *
31: * @return
32: */
33: public Protocol getPop3() {
34: return new Pop3ProtocolImpl(profile, auth, handler);
35: }
36:
37: /**
38: *
39: * @param folder
40: * @return
41: */
42: public Protocol getImap(String folder) {
43: return new ImapProtocolImpl(profile, auth, handler, folder);
44: }
45:
46: /**
47: *
48: * @param folder
49: * @return
50: */
51: public Protocol getProtocol(String folder) {
52: if (profile.getProtocol().equals(Constants.POP3)) {
53: return getPop3();
54: } else {
55: return getImap(folder);
56: }
57: }
58: }
|