Source Code Cross Referenced for BaseVelocityEmailImpl.java in  » Project-Management » EmForce » ru » emdev » EmForge » email » velocity » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Project Management » EmForce » ru.emdev.EmForge.email.velocity 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package ru.emdev.EmForge.email.velocity;
002:
003:        import java.util.Map;
004:
005:        import org.apache.commons.logging.Log;
006:        import org.apache.commons.logging.LogFactory;
007:        import org.apache.velocity.app.VelocityEngine;
008:        import org.apache.velocity.exception.VelocityException;
009:        import org.springframework.ui.velocity.VelocityEngineUtils;
010:
011:        import ru.emdev.EmForge.email.Email;
012:
013:        /** base implementation of emails, based on the Velocity Engine
014:         * 
015:         * @author akakunin
016:         *
017:         */
018:        public abstract class BaseVelocityEmailImpl implements  Email {
019:            private final Log log = LogFactory.getLog(getClass());
020:
021:            private VelocityEngine velocityEngine;
022:            private String templateName;
023:            private String applicationPath;
024:
025:            /** Email part */
026:            private String toName;
027:            private String fromName;
028:            private String subject;
029:            private int priority;
030:            private String carbonCopy;
031:
032:            public void setVelocityEngine(VelocityEngine velocityEngine) {
033:                this .velocityEngine = velocityEngine;
034:            }
035:
036:            public VelocityEngine getVelocityEngine() {
037:                return velocityEngine;
038:            }
039:
040:            public String getTemplateName() {
041:                return templateName;
042:            }
043:
044:            public void setTemplateName(String templateName) {
045:                this .templateName = templateName;
046:            }
047:
048:            public String getApplicationPath() {
049:                return applicationPath;
050:            }
051:
052:            public void setApplicationPath(String applicationPath) {
053:                this .applicationPath = applicationPath;
054:            }
055:
056:            /** Returns Model for text generation */
057:            abstract public Map<String, Object> getModel();
058:
059:            /* Email Part Implementation */
060:            public String getCarbonCopy() {
061:                return carbonCopy;
062:            }
063:
064:            public void setCarbonCopy(String carbonCopy) {
065:                this .carbonCopy = carbonCopy;
066:            }
067:
068:            public String getFromName() {
069:                return fromName;
070:            }
071:
072:            public void setFromName(String fromName) {
073:                this .fromName = fromName;
074:            }
075:
076:            public int getPriority() {
077:                return priority;
078:            }
079:
080:            public void setPriority(int priority) {
081:                this .priority = priority;
082:            }
083:
084:            public String getSubject() {
085:                return subject;
086:            }
087:
088:            public void setSubject(String subject) {
089:                this .subject = subject;
090:            }
091:
092:            public String getToName() {
093:                return toName;
094:            }
095:
096:            public void setToName(String toName) {
097:                this .toName = toName;
098:            }
099:
100:            public String getContent() {
101:                String text = null;
102:                try {
103:                    Map model = getModel();
104:
105:                    text = VelocityEngineUtils.mergeTemplateIntoString(
106:                            velocityEngine, templateName + ".text", model);
107:                } catch (VelocityException ex) {
108:                    log.error("Cannot generate message text:", ex);
109:                }
110:
111:                return text;
112:
113:            }
114:
115:            /** HTML Messages is not supported yet */
116:            public String getHtmlContent() {
117:                String text = null;
118:                try {
119:                    Map model = getModel();
120:
121:                    text = VelocityEngineUtils.mergeTemplateIntoString(
122:                            velocityEngine, templateName + ".html", model);
123:                } catch (VelocityException ex) {
124:                    // html template may not be defined - just ignore it
125:                    //log.error("Cannot generate message text:", ex);
126:                }
127:
128:                return text;
129:            }
130:
131:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.