-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathHsqlDbServerConfig.java
More file actions
50 lines (37 loc) · 1.47 KB
/
Copy pathHsqlDbServerConfig.java
File metadata and controls
50 lines (37 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import org.hsqldb.persist.HsqlProperties;
import org.hsqldb.server.Server;
import org.hsqldb.server.ServerAcl;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.io.IOException;
import java.util.Properties;
/*
References:
---------
1. How to start HSQL DB web server: https://stackoverflow.com/questions/40114231/how-to-start-hsqldb-in-server-mode-from-spring-boot-application
*/
/*
Point of interest:
-----------------
This configuration can be used to run an embedded web server to explore HSQL database
used by the original DDDSample. It should be added to the scan path of the application.
*/
@Configuration
public class HsqlDbServerConfig {
@Bean(initMethod = "start", destroyMethod = "stop")
public Server hsqldbServer() {
final Server server = new Server();
final Properties props = new Properties();
props.setProperty("server.database.0", "mem:dddsample");
props.setProperty("server.dbname.0", "dddsample");
props.setProperty("server.no_system_exit", "true");
props.setProperty("server.port", "9001");
try {
server.setProperties(new HsqlProperties(props));
} catch (IOException | ServerAcl.AclFormatException e) {
throw new BeanInitializationException(e.getMessage(), e);
}
return server;
}
}