diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2012-12-23 23:55:05 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2012-12-23 23:55:05 +0100 |
commit | 70595c41ce404ca68aaa6d1b531c6a858492553b (patch) | |
tree | 6644c653d49c344ca2d005b8fb82b1630a54bb95 /src/main/java/io/trygvis/esper | |
parent | 0cd76a4f295a9b1f833763bcaaf91141f704b5f5 (diff) | |
download | esper-testing-70595c41ce404ca68aaa6d1b531c6a858492553b.tar.gz esper-testing-70595c41ce404ca68aaa6d1b531c6a858492553b.tar.bz2 esper-testing-70595c41ce404ca68aaa6d1b531c6a858492553b.tar.xz esper-testing-70595c41ce404ca68aaa6d1b531c6a858492553b.zip |
o Adding Apache Shiro for security.
Diffstat (limited to 'src/main/java/io/trygvis/esper')
4 files changed, 35 insertions, 4 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/Config.java b/src/main/java/io/trygvis/esper/testing/Config.java index 13ef1cd..5beb9bb 100644 --- a/src/main/java/io/trygvis/esper/testing/Config.java +++ b/src/main/java/io/trygvis/esper/testing/Config.java @@ -48,6 +48,8 @@ public class Config { public final String databaseUsername; public final String databasePassword; + private BoneCPDataSource dataSource; + public Config(GitoriousConfig gitorious, long nexusUpdateInterval, long jenkinsUpdateInterval, String databaseUrl, String databaseUsername, String databasePassword) { this.gitorious = gitorious; @@ -89,12 +91,16 @@ public class Config { } public BoneCPDataSource createBoneCp() throws SQLException { - return new BoneCPDataSource(new BoneCPConfig(){{ + if (dataSource != null) { + return dataSource; + } + + return dataSource = new BoneCPDataSource(new BoneCPConfig() {{ setJdbcUrl(databaseUrl); setUsername(databaseUsername); setPassword(databasePassword); setDefaultAutoCommit(false); - setCloseConnectionWatch(true); + setCloseConnectionWatch(false); setMaxConnectionsPerPartition(10); }}); } diff --git a/src/main/java/io/trygvis/esper/testing/web/JerseyApplication.java b/src/main/java/io/trygvis/esper/testing/web/JerseyApplication.java index 8d071a9..6937804 100644 --- a/src/main/java/io/trygvis/esper/testing/web/JerseyApplication.java +++ b/src/main/java/io/trygvis/esper/testing/web/JerseyApplication.java @@ -10,8 +10,7 @@ public class JerseyApplication extends Application { private final DatabaseAccess da; public JerseyApplication() throws Exception { - Config config = Config.loadFromDisk(); - this.da = new DatabaseAccess(config.createBoneCp()); + this.da = new DatabaseAccess(WebConfig.config.createBoneCp()); } @Override diff --git a/src/main/java/io/trygvis/esper/testing/web/MissingShiroJdbcRealm.java b/src/main/java/io/trygvis/esper/testing/web/MissingShiroJdbcRealm.java new file mode 100644 index 0000000..0aacf7f --- /dev/null +++ b/src/main/java/io/trygvis/esper/testing/web/MissingShiroJdbcRealm.java @@ -0,0 +1,9 @@ +package io.trygvis.esper.testing.web; + +import org.apache.shiro.realm.jdbc.*; + +public class MissingShiroJdbcRealm extends JdbcRealm { + public MissingShiroJdbcRealm() throws Exception { + setDataSource(WebConfig.config.createBoneCp()); + } +} diff --git a/src/main/java/io/trygvis/esper/testing/web/WebConfig.java b/src/main/java/io/trygvis/esper/testing/web/WebConfig.java new file mode 100644 index 0000000..02fb4ff --- /dev/null +++ b/src/main/java/io/trygvis/esper/testing/web/WebConfig.java @@ -0,0 +1,17 @@ +package io.trygvis.esper.testing.web; + +import io.trygvis.esper.testing.*; + +import java.io.*; + +public class WebConfig { + public static final Config config; + + static { + try { + config = Config.loadFromDisk(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} |