2bd1433dbbe48eb92cf406844f137f372dd205d0
[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 in this way annotations like @Service, @Endpoint, etc, etc)  -->
19     <context:component-scan base-package="de.spring.emails"/>
20     
21     
22     <!--  Enable Asynchronous Spring Tasks -->
23         <task:annotation-driven />
24         <task:executor id="asyncEmailSender" pool-size="0-2" keep-alive="60" queue-capacity="2" rejection-policy="CALLER_RUNS" />
25         
26
27         <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
28                 <property name="host" value="smtp.gumartinm.name"/>
29                 <property name="port" value="25"/>
30                 <property name="defaultEncoding" value="UTF-8"/>
31         </bean>
32
33         <bean id="mailVelocityEngine"
34                 class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
35                 <property name="velocityProperties">                    
36                         <props>
37                     <prop key="resource.loader">class</prop>
38                     <prop key="class.resource.loader.class">
39                         org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
40                     </prop>
41                     <prop key="velocimacro.library">email/macro.vm</prop>            
42                 </props>        
43                 </property>
44         </bean>
45
46         <bean name="mailMessageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> 
47             <property name="basename"> 
48                 <value>email.email-messages</value> 
49             </property> 
50             <property name="defaultEncoding" value="UTF-8"/>
51         </bean>
52         
53         <bean id="emailService"
54                 class="de.spring.emails.services.impl.EmailServiceImpl">
55                 <constructor-arg ref="mailSender" />
56         </bean>
57         
58         <bean id="emailMakerService"
59                 class="de.spring.emails.services.impl.EmailMakerServiceImpl">
60                 <constructor-arg ref="mailVelocityEngine" />
61                 <constructor-arg ref="mailMessageSource" />
62         </bean>
63         
64 </beans>