1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.data.platform;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.springframework.beans.factory.FactoryBean;
20 import org.springframework.beans.factory.InitializingBean;
21 import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;
22
23 import javax.sql.DataSource;
24
25
26
27
28
29
30 public class MaxValueIncrementerFactoryBean implements FactoryBean<DataFieldMaxValueIncrementer>, InitializingBean {
31
32 private DataSource dataSource;
33 private String incrementerName;
34
35
36
37
38 @Override
39 public DataFieldMaxValueIncrementer getObject() throws Exception {
40 return MaxValueIncrementerFactory.getIncrementer(dataSource, incrementerName);
41 }
42
43
44
45
46 @Override
47 public Class<DataFieldMaxValueIncrementer> getObjectType() {
48 return DataFieldMaxValueIncrementer.class;
49 }
50
51
52
53
54 @Override
55 public boolean isSingleton() {
56 return false;
57 }
58
59
60
61
62 @Override
63 public void afterPropertiesSet() throws Exception {
64 if (dataSource == null) {
65 throw new IllegalStateException("Property 'dataSource' is required");
66 }
67
68 if (StringUtils.isBlank(incrementerName)) {
69 throw new IllegalStateException("Property 'incrementerName' is required");
70 }
71 }
72
73
74
75
76
77
78 public DataSource getDataSource() {
79 return dataSource;
80 }
81
82
83
84
85
86
87 public void setDataSource(DataSource dataSource) {
88 this.dataSource = dataSource;
89 }
90
91
92
93
94
95
96 public String getIncrementerName() {
97 return incrementerName;
98 }
99
100
101
102
103
104
105 public void setIncrementerName(String incrementerName) {
106 this.incrementerName = incrementerName;
107 }
108 }