5bd90eccffc928f015610d2cf016ace807b2678d
[JavaForFun] /
1 <?xml version="1.0" encoding="UTF-8"?>
2 <beans xmlns="http://www.springframework.org/schema/beans"
3   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4   xmlns:context="http://www.springframework.org/schema/context"
5   xmlns:util="http://www.springframework.org/schema/util"
6   xmlns:task="http://www.springframework.org/schema/task"
7
8   xsi:schemaLocation="http://www.springframework.org/schema/beans 
9                       http://www.springframework.org/schema/beans/spring-beans.xsd
10                       http://www.springframework.org/schema/context 
11                       http://www.springframework.org/schema/context/spring-context.xsd
12                       http://www.springframework.org/schema/util 
13                       http://www.springframework.org/schema/util/spring-util.xsd
14                       http://www.springframework.org/schema/task
15                                   http://www.springframework.org/schema/task/spring-task-3.0.xsd">
16
17     <!--
18         Searches for beans in packages (instead of XML configuration we can use
19         in this way annotations like @Service, @Endpoint, etc, etc)
20     -->
21     <context:component-scan base-package="de.spring.emails"/>
22     
23     
24     <!--  Enable Asynchronous Spring Tasks -->
25         <task:annotation-driven />
26         <task:executor id="asyncEmailSender" pool-size="0-2" keep-alive="60"
27                 queue-capacity="2" rejection-policy="CALLER_RUNS" />
28         
29
30         <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
31                 <property name="host" value="smtp.gumartinm.name"/>
32                 <property name="port" value="25"/>
33                 <property name="defaultEncoding" value="UTF-8"/>
34         </bean>
35
36
37         <bean name="mailMessageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> 
38             <property name="basename"> 
39                 <value>email.email-messages</value> 
40             </property> 
41             <property name="defaultEncoding" value="UTF-8"/>
42         </bean>
43         
44         <bean id="emailService"
45                 class="de.spring.emails.services.impl.EmailServiceImpl">
46                 <constructor-arg ref="mailSender" />
47         </bean>
48         
49         <!-- Using Velocity instead of Thymeleaf -->
50         <bean id="mailVelocityEngine"
51                 class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
52                 <property name="velocityProperties">                    
53                         <props>
54                     <prop key="resource.loader">class</prop>
55                     <prop key="class.resource.loader.class">
56                         org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
57                     </prop>
58                     <prop key="velocimacro.library">email/macro.vm</prop>            
59                 </props>        
60                 </property>
61         </bean>
62         <bean id="emailMakerVelocityService"
63                 class="de.spring.emails.services.impl.EmailMakerVelocityServiceImpl">
64                 <constructor-arg ref="mailVelocityEngine" />
65                 <constructor-arg ref="mailMessageSource" />
66         </bean>
67
68
69
70         <!-- Using Thymeleaf instead of Velocity -->
71         <bean id="thymeleafTemplateResolver"
72                 class="org.thymeleaf.templateresolver.ClassLoaderTemplateResolver">
73                 <property name="prefix" value="/email/" />
74                 <property name="suffix" value=".html" />
75                 <property name="templateMode" value="HTML" />
76         </bean>
77         <bean id="thymeleafTemplateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine">
78                 <property name="templateResolver" ref="thymeleafTemplateResolver" />
79         </bean>
80         <bean id="emailMakerThymeleafService"
81                 class="de.spring.emails.services.impl.EmailMakerThymeleafServiceImpl">
82                 <constructor-arg ref="thymeleafTemplateEngine" />
83                 <constructor-arg ref="mailMessageSource" />
84         </bean>
85
86 </beans>