| .. | .. |
|---|
| 7 | 7 | import java.util.List; |
|---|
| 8 | 8 | import java.util.Properties; |
|---|
| 9 | 9 | |
|---|
| 10 | +import javax.enterprise.context.ApplicationScoped; |
|---|
| 10 | 11 | import javax.inject.Named; |
|---|
| 11 | | -import javax.inject.Singleton; |
|---|
| 12 | | -import javax.sql.DataSource; |
|---|
| 13 | 12 | import javax.ws.rs.core.UriBuilder; |
|---|
| 14 | 13 | import javax.ws.rs.core.UriBuilderException; |
|---|
| 15 | 14 | |
|---|
| 16 | 15 | import org.apache.logging.log4j.LogManager; |
|---|
| 17 | 16 | import org.apache.logging.log4j.Logger; |
|---|
| 18 | | -import org.h2.jdbcx.JdbcDataSource; |
|---|
| 19 | 17 | |
|---|
| 20 | 18 | import com.google.inject.AbstractModule; |
|---|
| 21 | 19 | import com.google.inject.Provides; |
|---|
| .. | .. |
|---|
| 46 | 44 | |
|---|
| 47 | 45 | @Named("base-uri") |
|---|
| 48 | 46 | @Provides |
|---|
| 49 | | - @Singleton |
|---|
| 47 | + @ApplicationScoped |
|---|
| 50 | 48 | public URI getBaseURI() { |
|---|
| 51 | 49 | // TODO Read from configuration, where? |
|---|
| 52 | 50 | try { |
|---|
| .. | .. |
|---|
| 81 | 79 | |
|---|
| 82 | 80 | @Named("temporary-dir") |
|---|
| 83 | 81 | @Provides |
|---|
| 84 | | - @Singleton |
|---|
| 82 | + @ApplicationScoped |
|---|
| 85 | 83 | public File getTemporaryDir() { |
|---|
| 86 | 84 | String tmp = getAppDir().getAbsolutePath(); |
|---|
| 87 | 85 | tmp += File.separator + ".TEMP"; |
|---|
| .. | .. |
|---|
| 98 | 96 | |
|---|
| 99 | 97 | @Named("app-dir") |
|---|
| 100 | 98 | @Provides |
|---|
| 101 | | - @Singleton |
|---|
| 99 | + @ApplicationScoped |
|---|
| 102 | 100 | public File getAppDir() { |
|---|
| 103 | 101 | String appDir = System.getProperty("user.home", System.getProperty("user.dir")); |
|---|
| 104 | 102 | if (appDir == null) { |
|---|
| .. | .. |
|---|
| 117 | 115 | |
|---|
| 118 | 116 | @Named("support-email") |
|---|
| 119 | 117 | @Provides |
|---|
| 120 | | - @Singleton |
|---|
| 118 | + @ApplicationScoped |
|---|
| 121 | 119 | public String getSupportEmail() { |
|---|
| 122 | | - return "integrity@curistec.com"; |
|---|
| 120 | + return "support@curisit.net"; |
|---|
| 123 | 121 | } |
|---|
| 124 | 122 | |
|---|
| 125 | 123 | @Named("hash-logo") |
|---|
| 126 | 124 | @Provides |
|---|
| 127 | | - @Singleton |
|---|
| 125 | + @ApplicationScoped |
|---|
| 128 | 126 | public String getHashLogo() { |
|---|
| 129 | 127 | return "1b42616809d4cd8ccf109e3c30d0ab25067f160b30b7354a08ddd563de0096ba"; |
|---|
| 130 | 128 | } |
|---|
| 131 | 129 | |
|---|
| 132 | | - @Provides |
|---|
| 133 | | - @Singleton |
|---|
| 134 | | - public DataSource getDataSource(@Named("app-dir") File appDir) { |
|---|
| 135 | | - |
|---|
| 136 | | - JdbcDataSource dataSource = new JdbcDataSource(); |
|---|
| 137 | | - dataSource.setURL(getUrl(appDir)); |
|---|
| 138 | | - dataSource.setUser("curis"); |
|---|
| 139 | | - dataSource.setPassword(getPassword()); |
|---|
| 140 | | - LOG.debug("JdbcDataSource: {}", dataSource); |
|---|
| 141 | | - return dataSource; |
|---|
| 142 | | - } |
|---|
| 143 | | - |
|---|
| 144 | 130 | @Named("db-files") |
|---|
| 145 | 131 | @Provides |
|---|
| 146 | | - @Singleton |
|---|
| 132 | + @ApplicationScoped |
|---|
| 147 | 133 | public List<String> getDbFiles() { |
|---|
| 148 | 134 | return getAppDbFiles(); |
|---|
| 149 | 135 | } |
|---|