01: /*
02: * Copyright (c) Mateusz Prokopowicz. All Rights Reserved.
03: */
04:
05: package com.technoetic.xplanner.mail;
06:
07: import com.technoetic.xplanner.domain.repository.ObjectRepository;
08:
09: public class EmailMessageFactory {
10: private ObjectRepository personRepository;
11: private Class emailMessageClass;
12: public EmailMessage emailMessage;
13:
14: public EmailMessageFactory(ObjectRepository objectRepository) {
15: this .personRepository = objectRepository;
16: }
17:
18: public EmailMessage createMessage() throws Exception {
19: if (emailMessageClass == null) {
20: emailMessageClass = EmailMessageImpl.class;
21: }
22:
23: if (emailMessage == null) {
24: EmailMessage emailMessage = (EmailMessage) emailMessageClass
25: .newInstance();
26: emailMessage.setObjectRepository(personRepository);
27: return emailMessage;
28: } else {
29: return emailMessage;
30: }
31:
32: }
33:
34: public void setEmailMessageClass(Class emailMessageClass) {
35: this .emailMessageClass = emailMessageClass;
36: }
37:
38: public void setEmailMessage(EmailMessage newEmailMessage)
39: throws java.lang.InstantiationException,
40: java.lang.IllegalAccessException {
41: emailMessage = newEmailMessage;
42: }
43: }
|