5
5
import org .springframework .context .annotation .PropertySource ;
6
6
import org .springframework .context .annotation .PropertySources ;
7
7
import org .springframework .core .env .Environment ;
8
+ import org .springframework .jdbc .datasource .SimpleDriverDataSource ;
9
+ import ru .cti .verintsipbyehandler .controller .CallHandler ;
10
+ import ru .cti .verintsipbyehandler .controller .CallParser ;
11
+ import ru .cti .verintsipbyehandler .controller .Main ;
12
+ import ru .cti .verintsipbyehandler .controller .dao .DAOFacade ;
13
+ import ru .cti .verintsipbyehandler .controller .SipLayer ;
14
+ import ru .cti .verintsipbyehandler .model .factory .CallsFactory ;
8
15
9
16
import javax .sip .InvalidArgumentException ;
10
17
import javax .sip .ObjectInUseException ;
11
18
import javax .sip .PeerUnavailableException ;
12
19
import javax .sip .TransportNotSupportedException ;
20
+ import javax .sql .DataSource ;
13
21
import java .net .UnknownHostException ;
14
22
import java .util .TooManyListenersException ;
15
23
16
24
/**
17
25
* Spring Java configuration file
18
26
*/
19
27
@ org .springframework .context .annotation .Configuration
20
- @ PropertySources ({ @ PropertySource (value = "file:etc/config.properties" )})
28
+ @ PropertySources ({@ PropertySource (value = "file:etc/config.properties" )})
21
29
public class Configuration {
22
30
@ Autowired
23
31
Environment env ;
@@ -27,14 +35,6 @@ public Main main() {
27
35
return new Main (Integer .parseInt (env .getProperty ("applicationClosingTimer" )));
28
36
}
29
37
30
- @ Bean
31
- public ParseAndProcessCalls parseAndProcessCalls () throws Exception {
32
- return new ParseAndProcessCalls (env .getProperty ("regexp" ),
33
- env .getProperty ("risLogsFolderPath" ),
34
- Integer .parseInt (env .getProperty ("callTerminationTimeout" )),
35
- Integer .parseInt (env .getProperty ("completedCallDeletionTimer" )),
36
- Integer .parseInt (env .getProperty ("sipByeSenderPause" )));
37
- }
38
38
39
39
@ Bean
40
40
public SipLayer sipLayer () throws InvalidArgumentException , PeerUnavailableException , UnknownHostException ,
@@ -45,4 +45,35 @@ public SipLayer sipLayer() throws InvalidArgumentException, PeerUnavailableExcep
45
45
env .getProperty ("sip.destinationAddress" ),
46
46
env .getProperty ("sipLibraryLogLevel" ));
47
47
}
48
+
49
+ @ Bean
50
+ public CallsFactory callsFabric () {
51
+ return new CallsFactory ();
52
+ }
53
+
54
+ @ Bean
55
+ public DataSource dataSource () {
56
+ SimpleDriverDataSource dataSource = new SimpleDriverDataSource ();
57
+ dataSource .setDriverClass (org .sqlite .JDBC .class );
58
+ dataSource .setUrl ("jdbc:sqlite:db/sqlite.db" );
59
+ return dataSource ;
60
+ }
61
+
62
+ @ Bean
63
+ public DAOFacade daoFacade () {
64
+ return new DAOFacade (dataSource ());
65
+ }
66
+
67
+ @ Bean
68
+ public CallParser callParser () {
69
+ return new CallParser (env .getProperty ("risLogsFolderPath" ),
70
+ env .getProperty ("regexp" ));
71
+ }
72
+
73
+ @ Bean
74
+ public CallHandler callHandler () {
75
+ return new CallHandler (Long .parseLong (env .getProperty ("callTerminationTimeout" )),
76
+ Long .parseLong (env .getProperty ("completedCallDeletionTimer" )),
77
+ Integer .parseInt (env .getProperty ("sipByeSenderPause" )));
78
+ }
48
79
}
0 commit comments