01: package org.claros.mini.factory;
02:
03: import org.claros.commons.mail.models.ConnectionMetaHandler;
04: import org.claros.commons.mail.models.ConnectionProfile;
05: import org.claros.commons.mail.utility.Constants;
06: import org.claros.commons.models.AuthProfile;
07: import org.claros.mini.controllers.DbMailControllerImpl;
08: import org.claros.mini.controllers.ImapMailControllerImpl;
09: import org.claros.mini.controllers.MailController;
10:
11: /**
12: * @author Umut Gokbayrak
13: */
14: public class MailControllerFactory {
15: private AuthProfile auth;
16: private ConnectionProfile profile;
17: private ConnectionMetaHandler handler;
18: private String folder;
19:
20: /**
21: * used to disable default contstructor
22: */
23: private MailControllerFactory() {
24: super ();
25: }
26:
27: public MailControllerFactory(AuthProfile auth,
28: ConnectionProfile profile, ConnectionMetaHandler handler,
29: String folder) {
30: this .auth = auth;
31: this .profile = profile;
32: this .handler = handler;
33: this .folder = folder;
34: }
35:
36: public MailController getMailController() {
37: if (profile.getProtocol().equals(Constants.POP3)) {
38: return new DbMailControllerImpl(auth, profile, handler);
39: } else {
40: return new ImapMailControllerImpl(auth, profile, handler,
41: folder);
42: }
43: }
44:
45: }
|