- 자, 이제 공포의 XML을 만들어보자.
- data-source-context.xml (데이터베이스 연결 관리, 트랜잭션관리등을 선언해놓았다.)
01 | <? xml version = "1.0" encoding = "UTF-8" ?> |
02 | <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" |
04 | < beans > |
05 | < bean id = "placeholderProperties" |
06 | class = "org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" > |
07 | < property name = "location" value = "classpath:postman.properties" /> |
08 | </ bean > |
09 | |
10 | < bean id = "dataSource" class = "org.apache.commons.dbcp.BasicDataSource" > |
11 | < property name = "driverClassName" value = "${batch.jdbc.driver}" /> |
12 | < property name = "url" value = "${batch.jdbc.url}" /> |
13 | < property name = "username" value = "${batch.jdbc.user}" /> |
14 | < property name = "password" value = "${batch.jdbc.password}" /> |
15 | </ bean > |
16 | < bean id = "transactionManager" |
17 | class = "org.springframework.jdbc.datasource.DataSourceTransactionManager" > |
18 | < property name = "dataSource" ref = "dataSource" /> |
19 | </ bean > |
20 | < bean id = "sqlMapClient" class = "org.springframework.orm.ibatis.SqlMapClientFactoryBean" > |
21 | < property name = "dataSource" ref = "dataSource" /> |
22 | < property name = "configLocation" value = "classpath:ibatis-config.xml" /> |
23 | </ bean > |
24 | < bean id = "baseTransactionProxy" |
25 | class = "org.springframework.transaction.interceptor.TransactionProxyFactoryBean" |
26 | lazy-init = "true" > |
27 | < property name = "transactionManager" > |
28 | < ref local = "transactionManager" /> |
29 | </ property > |
30 | < property name = "transactionAttributes" > |
31 | < props > |
32 | < prop key = "add*" >PROPAGATION_REQUIRED</ prop > |
33 | < prop key = "insert*" >PROPAGATION_REQUIRED</ prop > |
34 | < prop key = "update*" >PROPAGATION_REQUIRED</ prop > |
35 | < prop key = "delete*" >PROPAGATION_REQUIRED</ prop > |
36 | < prop key = "save*" >PROPAGATION_REQUIRED</ prop > |
37 | < prop key = "get*" >PROPAGATION_SUPPORTS</ prop > |
38 | < prop key = "getList*" >PROPAGATION_SUPPORTS</ prop > |
39 | < prop key = "count*" >PROPAGATION_SUPPORTS</ prop > |
40 | < prop key = "*" >PROPAGATION_SUPPORTS</ prop > |
41 | </ props > |
42 | </ property > |
43 | </ bean > |
44 | </ beans > |
- ibatis-config.xml (iBatis 설정 정보이다.)
1 | <? xml version = "1.0" encoding = "UTF-8" ?> |
2 | <!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" |
4 | < sqlMapConfig > |
5 | < settings |
6 | useStatementNamespaces = "true" /> |
7 | < sqlMap resource = "kr/kangwoo/postman/repository/ibatis/MailDaoSqlMap.xml" /> |
8 | < sqlMap resource = "kr/kangwoo/postman/repository/ibatis/MailTemplateDaoSqlMap.xml" /> |
9 | </ sqlMapConfig > |
- post-man-context.xml
01 | <? xml version = "1.0" encoding = "UTF-8" ?> |
02 | <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" |
04 | < beans > |
05 |
06 | <!-- B:Data Access Object --> |
07 | < bean id = "mailDao" class = "kr.kangwoo.postman.repository.ibatis.MailDaoSqlMap" > |
08 | < property name = "sqlMapClient" > |
09 | < ref bean = "sqlMapClient" /> |
10 | </ property > |
11 | </ bean > |
12 | < bean id = "mailTemplateDao" class = "kr.kangwoo.postman.repository.ibatis.MailTemplateDaoSqlMap" > |
13 | < property name = "sqlMapClient" > |
14 | < ref bean = "sqlMapClient" /> |
15 | </ property > |
16 | </ bean > |
17 | <!-- E:Data Access Object --> |
18 | |
19 | <!-- B:Service --> |
20 | < bean id = "mailManager" parent = "baseTransactionProxy" > |
21 | < property name = "proxyInterfaces" value = "kr.kangwoo.postman.service.MailManager" /> |
22 | < property name = "target" > |
23 | < bean class = "kr.kangwoo.postman.service.SimpleMailManager" > |
24 | < property name = "mailDao" > |
25 | < ref bean = "mailDao" /> |
26 | </ property > |
27 | </ bean > |
28 | </ property > |
29 | </ bean > |
30 | |
31 | < bean id = "mailSendManager" parent = "baseTransactionProxy" > |
32 | < property name = "proxyInterfaces" value = "kr.kangwoo.postman.service.MailSendManager" /> |
33 | < property name = "target" > |
34 | < bean class = "kr.kangwoo.postman.service.SMTPMailSendManager" > |
35 | < property name = "host" value = "${smtp.host}" /> |
36 | < property name = "port" value = "${smtp.port}" /> |
37 | < property name = "starttlsEnable" value = "${smtp.starttlsEnable}" /> |
38 | < property name = "userName" value = "${smtp.userName}" /> |
39 | < property name = "password" value = "${smtp.password}" /> |
40 | </ bean > |
41 | </ property > |
42 | </ bean > |
43 | |
44 | < bean id = "mailTemplateManager" parent = "baseTransactionProxy" > |
45 | < property name = "proxyInterfaces" value = "kr.kangwoo.postman.service.MailTemplateManager" /> |
46 | < property name = "target" > |
47 | < bean class = "kr.kangwoo.postman.service.FreemarkerMailTemplateManager" > |
48 | < property name = "mailTemplateDao" > |
49 | < ref bean = "mailTemplateDao" /> |
50 | </ property > |
51 | </ bean > |
52 | </ property > |
53 | </ bean > |
54 | <!-- E:Service --> |
55 | |
56 | </ beans > |
- post-man-scheduler.xml (quartz를 이용한 스케줄 설정 파일이다.)
- MethodInvokingJobDetailFactoryBean 를 이용해서 POJO인 PostManJob의 run()메소드를 실행시킨다.
- CronTriggerBean을 이용해서, 30초다(사실은 0초, 30초인 시점이지만 ^^;)마다 메일을 조회해서 발송한다.
댓글 없음:
댓글 쓰기