From 502462b744043df3e2444a2afd58aa54a7176285 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Thu, 9 Mar 2017 11:51:42 +1100 Subject: [PATCH 001/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8328d1c..dec8551 100755 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ org.actframework act-ebean jar - 1.0.0 + 1.1.0-SNAPSHOT ACT Ebean The Ebean Plugin for Actframework SQL database access From 1202719a7adebcdd578b0a1649f45a0ecece262a Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 28 Mar 2017 15:40:15 +1100 Subject: [PATCH 002/114] fix #7 It reports XXX table not found when start app in dev mode #7 --- src/main/java/act/db/ebean/EbeanService.java | 29 ++++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/main/java/act/db/ebean/EbeanService.java b/src/main/java/act/db/ebean/EbeanService.java index 7a02df3..a926710 100644 --- a/src/main/java/act/db/ebean/EbeanService.java +++ b/src/main/java/act/db/ebean/EbeanService.java @@ -146,23 +146,22 @@ private ServerConfig serverConfig(String id, Map conf) { properties.putAll(conf); sc.loadFromProperties(properties); + Object o = conf.get("url"); + if (null == o) { + o = conf.get("jdbcUrl"); + } + E.invalidConfigurationIf(null == o, "JDBC URL required"); + // We need to check h2 db file existence before loading HikariDatasource + // otherwise it will generate the h2 db file if it does not exist + boolean noddl = h2DbFileExists(S.string(o)); HikariDataSource dataSource = dataSource(conf); sc.setDataSource(dataSource); ds = dataSource; - boolean noddl = false; String ddlGenerate = (String) conf.get("ddl.generate"); if (null != ddlGenerate) { sc.setDdlGenerate(Boolean.parseBoolean(ddlGenerate)); } else if (Act.isDev()) { - String url = dataSource.getJdbcUrl(); - if (url.startsWith("jdbc:h2:")) { - String file = url.substring("jdbc:h2:".length()) + ".mv.db"; - File _file = new File(file); - if (_file.exists()) { - noddl = true; - } - } sc.setDdlGenerate(!noddl); } @@ -187,6 +186,18 @@ private ServerConfig serverConfig(String id, Map conf) { return sc; } + private boolean h2DbFileExists(String jdbcUrl) { + if (Act.isProd()) { + return true; + } + if (jdbcUrl.startsWith("jdbc:h2:")) { + String file = jdbcUrl.substring("jdbc:h2:".length()) + ".mv.db"; + File _file = new File(file); + return (_file.exists()); + } + return false; + } + private HikariDataSource dataSource(Map conf) { HikariConfig hc = new HikariConfig(); for (Map.Entry entry : conf.entrySet()) { From 2014f8028b2fb8cb36446e51b02c68a2a049ec69 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 28 Mar 2017 15:40:41 +1100 Subject: [PATCH 003/114] [maven-release-plugin] prepare release act-ebean-1.0.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e560f00..7984bb1 100755 --- a/pom.xml +++ b/pom.xml @@ -48,7 +48,7 @@ org.actframework act-ebean jar - 1.0.5-SNAPSHOT + 1.0.5 ACT Ebean The Ebean Plugin for Actframework SQL database access From d1ccc31ebba460bb81bb71e16f70078ca7a93a93 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 28 Mar 2017 15:40:54 +1100 Subject: [PATCH 004/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7984bb1..bf97e3d 100755 --- a/pom.xml +++ b/pom.xml @@ -48,7 +48,7 @@ org.actframework act-ebean jar - 1.0.5 + 1.0.6-SNAPSHOT ACT Ebean The Ebean Plugin for Actframework SQL database access From 65da904d9851b32fd2764fe28be8e49f66fa62eb Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 2 Apr 2017 10:56:50 +1000 Subject: [PATCH 005/114] #6, #9, #8 --- pom.xml | 20 +- .../java/act/db/ebean/DataSourceProvider.java | 28 +++ src/main/java/act/db/ebean/EbeanService.java | 182 ++++++++---------- .../datasource/DruidDataSourceProvider.java | 91 +++++++++ .../datasource/HikariDataSourceProvider.java | 68 +++++++ 5 files changed, 283 insertions(+), 106 deletions(-) create mode 100644 src/main/java/act/db/ebean/DataSourceProvider.java create mode 100644 src/main/java/act/db/ebean/datasource/DruidDataSourceProvider.java create mode 100644 src/main/java/act/db/ebean/datasource/HikariDataSourceProvider.java diff --git a/pom.xml b/pom.xml index bf97e3d..c7bc335 100755 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,12 @@ ******************************************** * version history ******************************************** +1.1.0 +- #9 Support plugin different datasource solution +- #8 change mysql jdbc driver class name +- #6 Support Druid database +1.0.5 +- fix #7 It reports XXX table not found when start app in dev mode 1.0.4 - take out version range from pom.xml. See https://issues.apache.org/jira/browse/MNG-3092 1.0.3 @@ -48,7 +54,7 @@ org.actframework act-ebean jar - 1.0.6-SNAPSHOT + 1.1.0-SNAPSHOT ACT Ebean The Ebean Plugin for Actframework SQL database access @@ -58,12 +64,13 @@ UTF-8 UTF-8 git@github.com:actframework/act-ebean.git - 1.0.5 + 1.0.6 8.8.1 8.1.1 2.1.2 2.7.0 2.6.1 + 1.0.29 @@ -186,7 +193,14 @@ com.zaxxer HikariCP ${HikariCP.version} - compile + provided + + + + com.alibaba + druid + ${druid.version} + provided diff --git a/src/main/java/act/db/ebean/DataSourceProvider.java b/src/main/java/act/db/ebean/DataSourceProvider.java new file mode 100644 index 0000000..dbed44c --- /dev/null +++ b/src/main/java/act/db/ebean/DataSourceProvider.java @@ -0,0 +1,28 @@ +package act.db.ebean; + +import org.avaje.datasource.DataSourceConfig; +import org.osgl.logging.LogManager; +import org.osgl.logging.Logger; + +import javax.sql.DataSource; +import java.util.Map; + +public abstract class DataSourceProvider { + + protected final Logger logger = LogManager.get(getClass()); + + /** + * Create datasource from configuration map + * @param conf the data source configuration + * @return a DataSource instance + */ + public abstract DataSource createDataSource(DataSourceConfig conf); + + /** + * Provide a mapping to bridge the default configuration into solution specific + * configuration. E.g. HikariCP use `jdbcUrl` instead of `url` + * @return the conf key mapping + */ + public abstract Map confKeyMapping(); + +} diff --git a/src/main/java/act/db/ebean/EbeanService.java b/src/main/java/act/db/ebean/EbeanService.java index a926710..0d9291d 100644 --- a/src/main/java/act/db/ebean/EbeanService.java +++ b/src/main/java/act/db/ebean/EbeanService.java @@ -11,8 +11,6 @@ import com.avaje.ebean.EbeanServer; import com.avaje.ebean.EbeanServerFactory; import com.avaje.ebean.config.ServerConfig; -import com.zaxxer.hikari.HikariConfig; -import com.zaxxer.hikari.HikariDataSource; import org.avaje.datasource.DataSourceConfig; import org.osgl.$; import org.osgl.logging.LogManager; @@ -140,100 +138,77 @@ public DataSource ds() { } private ServerConfig serverConfig(String id, Map conf) { - ServerConfig sc = new ServerConfig(); - sc.setName(id); + ServerConfig serverConfig = new ServerConfig(); + serverConfig.setName(id); Properties properties = new Properties(); properties.putAll(conf); - sc.loadFromProperties(properties); + serverConfig.loadFromProperties(properties); Object o = conf.get("url"); if (null == o) { o = conf.get("jdbcUrl"); } E.invalidConfigurationIf(null == o, "JDBC URL required"); + // We need to check h2 db file existence before loading HikariDatasource // otherwise it will generate the h2 db file if it does not exist boolean noddl = h2DbFileExists(S.string(o)); - HikariDataSource dataSource = dataSource(conf); - sc.setDataSource(dataSource); - ds = dataSource; + + DataSourceProvider dataSourceProvider = dataSourceProvider(conf); + if (null != dataSourceProvider) { + // process conf mapping + Map confMapping = dataSourceProvider.confKeyMapping(); + for (Map.Entry entry : confMapping.entrySet()) { + String solutionKey = entry.getKey(); + String commonKey = entry.getValue(); + if (conf.containsKey(solutionKey)) { + conf.put(commonKey, conf.get(solutionKey)); + } + } + serverConfig.setDataSource(dataSourceProvider.createDataSource(datasourceConfig(conf))); + } else { + serverConfig.setDataSourceConfig(datasourceConfig(conf)); + } String ddlGenerate = (String) conf.get("ddl.generate"); if (null != ddlGenerate) { - sc.setDdlGenerate(Boolean.parseBoolean(ddlGenerate)); + serverConfig.setDdlGenerate(Boolean.parseBoolean(ddlGenerate)); } else if (Act.isDev()) { - sc.setDdlGenerate(!noddl); + serverConfig.setDdlGenerate(!noddl); } String ddlRun = (String) conf.get("ddl.run"); if (null != ddlRun) { - sc.setDdlRun(Boolean.parseBoolean(ddlRun)); + serverConfig.setDdlRun(Boolean.parseBoolean(ddlRun)); } else if (Act.isDev()) { - sc.setDdlRun(!noddl); + serverConfig.setDdlRun(!noddl); } String ddlCreateOnly = (String) conf.get("ddl.createOnly"); if (null != ddlCreateOnly) { - sc.setDdlCreateOnly(Boolean.parseBoolean(ddlCreateOnly)); + serverConfig.setDdlCreateOnly(Boolean.parseBoolean(ddlCreateOnly)); } else if (Act.isDev()) { - sc.setDdlCreateOnly(!noddl); + serverConfig.setDdlCreateOnly(!noddl); } for (Class c : modelTypes) { - sc.addClass(c); + serverConfig.addClass(c); } - return sc; - } - - private boolean h2DbFileExists(String jdbcUrl) { - if (Act.isProd()) { - return true; - } - if (jdbcUrl.startsWith("jdbc:h2:")) { - String file = jdbcUrl.substring("jdbc:h2:".length()) + ".mv.db"; - File _file = new File(file); - return (_file.exists()); - } - return false; + return serverConfig; } - private HikariDataSource dataSource(Map conf) { - HikariConfig hc = new HikariConfig(); - for (Map.Entry entry : conf.entrySet()) { - String key = entry.getKey(); - Object val = entry.getValue(); - if ("username".equals(key)) { - hc.setUsername(S.string(val)); - } else if ("password".equals(key)) { - hc.setPassword(S.string(val)); - } else if ("url".equals(key) || "jdbcUrl".equals(key)) { - hc.setJdbcUrl(S.string(val)); - } else if ("maximumPoolSize".equals(key)) { - hc.setMaximumPoolSize(Integer.parseInt(S.string(val))); - } else if ("autoCommit".equals(key)) { - hc.setAutoCommit(Boolean.valueOf(S.string(val))); - } else if ("idleTimeout".equals(key)) { - hc.setIdleTimeout(Long.parseLong(S.string(val))); - } else if ("maxLifetime".equals(key)) { - hc.setMaxLifetime(Long.parseLong(S.string(val))); - } else if ("connectionTimeout".equals(key)) { - hc.setConnectionTimeout(Long.parseLong(S.string(val))); - } else if ("minimumIdle".equals(key)) { - hc.setMinimumIdle(Integer.parseInt(S.string(val))); - } else if ("poolName".equals(key)) { - hc.setPoolName(S.string(val)); - } else if ("driverClassName".equals(key)) { - hc.setDriverClassName(S.string(val)); - } else { - hc.addDataSourceProperty(entry.getKey(), entry.getValue()); - } - } - ensureDefaultDatasourceConfig(hc); - return new HikariDataSource(hc); + private DataSourceConfig datasourceConfig(Map conf) { + Properties properties = new Properties(); + properties.putAll(conf); + DataSourceConfig dsc = new DataSourceConfig(); + dsc.loadSettings(properties, ""); + ensureDefaultDatasourceConfig(dsc); + dsc.setCustomProperties((Map)properties); + return dsc; } - private void ensureDefaultDatasourceConfig(HikariConfig dsc) { + private void ensureDefaultDatasourceConfig(DataSourceConfig dsc) { String username = dsc.getUsername(); if (null == username) { logger.warn("No data source user configuration specified. Will use the default 'sa' user"); @@ -247,15 +222,14 @@ private void ensureDefaultDatasourceConfig(HikariConfig dsc) { } dsc.setPassword(password); - String url = dsc.getJdbcUrl(); + String url = dsc.getUrl(); if (null == url) { logger.warn("No database URL configuration specified. Will use the default h2 inmemory test database"); url = "jdbc:h2:mem:tests"; } - dsc.setJdbcUrl(url); - + dsc.setUrl(url); - String driver = dsc.getDriverClassName(); + String driver = dsc.getDriver(); if (null == driver) { if (url.contains("mysql")) { driver = "com.mysql.jdbc.Driver"; @@ -274,50 +248,52 @@ private void ensureDefaultDatasourceConfig(HikariConfig dsc) { } logger.warn("JDBC driver not configured, system automatically set to: " + driver); } - dsc.setDriverClassName(driver); + dsc.setDriver(driver); } - private void ensureDefaultDatasourceConfig(DataSourceConfig dsc) { - String username = dsc.getUsername(); - if (null == username) { - logger.warn("No data source user configuration specified. Will use the default 'sa' user"); - username = "sa"; - } - dsc.setUsername(username); + private static final String DRUID_PROVDER = "act.db.ebean.datasource.DruidDataSourceProvider"; + private static final String HIKARI_PROVIDER = "act.db.ebean.datasource.HikariDataSourceProvider"; + private DataSourceProvider dataSourceProvider(Map conf) { + String dsProvider = (String) conf.get("datasource.provider"); - String password = dsc.getPassword(); - if (null == password) { - password = ""; + if (null != dsProvider) { + if (dsProvider.toLowerCase().contains("hikari")) { + dsProvider = HIKARI_PROVIDER; + } else if (dsProvider.toLowerCase().contains("druid")) { + dsProvider = DRUID_PROVDER; + } } - dsc.setPassword(password); - - String url = dsc.getUrl(); - if (null == url) { - logger.warn("No database URL configuration specified. Will use the default h2 inmemory test database"); - url = "jdbc:h2:mem:tests"; + DataSourceProvider provider; + if (null != dsProvider) { + provider = app().getInstance(dsProvider); + } else { + // try HikariCP first + try { + Class.forName("com.zaxxer.hikari.HikariConfig"); + provider = app().getInstance(HIKARI_PROVIDER); + } catch (Exception e) { + try { + Class.forName("com.alibaba.druid.pool.DruidDataSource"); + provider = app().getInstance(DRUID_PROVDER); + } catch (Exception e1) { + // ignore + return null; + } + } } - dsc.setUrl(url); + return provider; + } - String driver = dsc.getDriver(); - if (null == driver) { - if (url.contains("mysql")) { - driver = "com.mysql.jdbc.Driver"; - } else if (url.contains("postgresql")) { - driver = "org.postgresql.Driver"; - } else if (url.contains("jdbc:h2:")) { - driver = "org.h2.Driver"; - } else if (url.contains("jdbc:oracle")) { - driver = "oracle.jdbc.OracleDriver"; - } else if (url.contains("sqlserver")) { - driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; - } else if (url.contains("jdbc:db2")) { - driver = "com.ibm.db2.jcc.DB2Driver"; - } else { - throw E.invalidConfiguration("JDBC driver needs to be configured for datasource: %s", id()); - } - logger.warn("JDBC driver not configured, system automatically set to: " + driver); + private boolean h2DbFileExists(String jdbcUrl) { + if (Act.isProd()) { + return true; } - dsc.setDriver(driver); + if (jdbcUrl.startsWith("jdbc:h2:")) { + String file = jdbcUrl.substring("jdbc:h2:".length()) + ".mv.db"; + File _file = new File(file); + return (_file.exists()); + } + return false; } public static void registerModelType(Class modelType) { diff --git a/src/main/java/act/db/ebean/datasource/DruidDataSourceProvider.java b/src/main/java/act/db/ebean/datasource/DruidDataSourceProvider.java new file mode 100644 index 0000000..7c4e402 --- /dev/null +++ b/src/main/java/act/db/ebean/datasource/DruidDataSourceProvider.java @@ -0,0 +1,91 @@ +package act.db.ebean.datasource; + +import act.db.ebean.DataSourceProvider; +import com.alibaba.druid.pool.DruidDataSource; +import org.avaje.datasource.DataSourceConfig; +import org.osgl.util.C; +import org.osgl.util.E; + +import javax.sql.DataSource; +import java.sql.SQLException; +import java.util.Map; + +/** + * Provide Druid datasource + */ +public class DruidDataSourceProvider extends DataSourceProvider { + + @Override + public DataSource createDataSource(DataSourceConfig conf) { + DruidDataSource source = new DruidDataSource(); + source.setUrl(conf.getUrl()); + source.setUsername(conf.getUsername()); + source.setPassword(conf.getPassword()); + source.setDriverClassName(conf.getDriver()); + source.setMaxActive(conf.getMaxConnections()); + source.setMinIdle(conf.getMinConnections()); + source.setMaxWait(conf.getWaitTimeoutMillis()); + source.setValidationQuery(conf.getHeartbeatSql()); + source.setMaxPoolPreparedStatementPerConnectionSize(conf.getPstmtCacheSize()); + + Map miscConf = conf.getCustomProperties(); + String s = miscConf.get("initialSize"); + if (null != s) { + source.setInitialSize(Integer.parseInt(s)); + } else { + source.setInitialSize(source.getMinIdle()); + } + + s = miscConf.get("timeBetweenEvictionRunsMillis"); + if (null != s) { + source.setTimeBetweenEvictionRunsMillis(Long.parseLong(s)); + } + + s = miscConf.get("minEvictableIdleTimeMillis"); + if (null != s) { + source.setMinEvictableIdleTimeMillis(Long.parseLong(s)); + } + + s = miscConf.get("testWhileIdle"); + if (null != s) { + source.setTestWhileIdle(Boolean.parseBoolean(s)); + } + + s = miscConf.get("testOnBorrow"); + if (null != s) { + source.setTestOnBorrow(Boolean.parseBoolean(s)); + } + + s = miscConf.get("testOnReturn"); + if (null != s) { + source.setTestOnReturn(Boolean.parseBoolean(s)); + } + + s = miscConf.get("filters"); + if (null != s) { + try { + source.setFilters(s); + } catch (SQLException e) { + throw E.unexpected(e); + } + } + + s = miscConf.get("poolPreparedStatements"); + if (null != s) { + source.setPoolPreparedStatements(Boolean.parseBoolean(s)); + } + + return source; + } + + @Override + public Map confKeyMapping() { + return C.map("minIdle", "minConnections", + "maxActive", "maxConnections", + "maxWait", "connectionTimeout", + "validationQuery", "heartbeatSql", + "pstmtCacheSize", "maxPoolPreparedStatementPerConnectionSize" + ); + } + +} diff --git a/src/main/java/act/db/ebean/datasource/HikariDataSourceProvider.java b/src/main/java/act/db/ebean/datasource/HikariDataSourceProvider.java new file mode 100644 index 0000000..3448ea0 --- /dev/null +++ b/src/main/java/act/db/ebean/datasource/HikariDataSourceProvider.java @@ -0,0 +1,68 @@ +package act.db.ebean.datasource; + +import act.db.ebean.DataSourceProvider; +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; +import org.avaje.datasource.DataSourceConfig; +import org.osgl.util.C; + +import javax.sql.DataSource; +import java.util.Map; + +/** + * Provide HikariCP data source + */ +public class HikariDataSourceProvider extends DataSourceProvider { + + @Override + public DataSource createDataSource(DataSourceConfig conf) { + HikariConfig hc = new HikariConfig(); + hc.setJdbcUrl(conf.getUrl()); + hc.setUsername(conf.getUsername()); + hc.setPassword(conf.getPassword()); + hc.setDriverClassName(conf.getDriver()); + hc.setMaximumPoolSize(conf.getMaxConnections()); + int minConn = conf.getMinConnections(); + if (minConn != new DataSourceConfig().getMinConnections()) { + // Only set min connection when it is not the default value + // because HikariCP recommend not to set this value by default + hc.setMinimumIdle(conf.getMinConnections()); + } + hc.setConnectionTimeout(conf.getWaitTimeoutMillis()); + hc.setAutoCommit(conf.isAutoCommit()); + hc.setConnectionTestQuery(conf.getHeartbeatSql()); + + Map miscConf = conf.getCustomProperties(); + String s = miscConf.get("idleTimeout"); + if (null != s) { + int n = Integer.parseInt(s); + hc.setIdleTimeout(n); + } else { + hc.setIdleTimeout(conf.getMaxInactiveTimeSecs() * 1000); + } + + s = miscConf.get("maxLifetime"); + if (null != s) { + long n = Long.parseLong(s); + hc.setMaxLifetime(n); + } else { + hc.setMaxLifetime(conf.getMaxAgeMinutes() * 60 * 1000L); + } + + s = miscConf.get("poolName"); + if (null != s) { + hc.setPoolName(s); + } + + return new HikariDataSource(hc); + } + + @Override + public Map confKeyMapping() { + return C.map("url", "jdbcUrl", + "maxConnections", "maximumPoolSize", + "minimumIdle", "minConnections", + "waitTimeout", "connectionTimeout" + ); + } +} From 3ab2a21f4679607025c30c05c82754384a8b5f9e Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 2 Apr 2017 10:57:15 +1000 Subject: [PATCH 006/114] [maven-release-plugin] prepare release act-ebean-1.1.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c7bc335..3cebcae 100755 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ org.actframework act-ebean jar - 1.1.0-SNAPSHOT + 1.1.0 ACT Ebean The Ebean Plugin for Actframework SQL database access From 79ae1d00152e44cd5edfbb2a17bf684211f06c94 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 2 Apr 2017 10:58:01 +1000 Subject: [PATCH 007/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3cebcae..1b06934 100755 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ org.actframework act-ebean jar - 1.1.0 + 1.1.1-SNAPSHOT ACT Ebean The Ebean Plugin for Actframework SQL database access From 706861243a375f852b8f998140c3cafc4bdf6cde Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Mon, 3 Apr 2017 13:55:47 +1000 Subject: [PATCH 008/114] fix #10 and #11 --- src/main/java/act/db/ebean/EbeanPlugin.java | 2 -- src/main/java/act/db/ebean/EntityFinder.java | 2 -- .../act/db/ebean/datasource/DruidDataSourceProvider.java | 5 ++--- .../act/db/ebean/datasource/HikariDataSourceProvider.java | 6 +++--- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/main/java/act/db/ebean/EbeanPlugin.java b/src/main/java/act/db/ebean/EbeanPlugin.java index 069ab24..da0de5e 100644 --- a/src/main/java/act/db/ebean/EbeanPlugin.java +++ b/src/main/java/act/db/ebean/EbeanPlugin.java @@ -1,6 +1,5 @@ package act.db.ebean; -import act.ActComponent; import act.app.App; import act.db.DbPlugin; import act.db.DbService; @@ -8,7 +7,6 @@ import java.util.Map; -@ActComponent public class EbeanPlugin extends DbPlugin { @Override public DbService initDbService(String id, App app, Map conf) { diff --git a/src/main/java/act/db/ebean/EntityFinder.java b/src/main/java/act/db/ebean/EntityFinder.java index 8e0258e..8796de2 100644 --- a/src/main/java/act/db/ebean/EntityFinder.java +++ b/src/main/java/act/db/ebean/EntityFinder.java @@ -1,6 +1,5 @@ package act.db.ebean; -import act.ActComponent; import act.app.App; import act.app.AppByteCodeScanner; import act.util.AnnotatedTypeFinder; @@ -11,7 +10,6 @@ import java.util.Map; import java.util.Set; -@ActComponent public class EntityFinder extends AnnotatedTypeFinder { public EntityFinder() { super(true, false, Entity.class, new $.F2, Set>>() { diff --git a/src/main/java/act/db/ebean/datasource/DruidDataSourceProvider.java b/src/main/java/act/db/ebean/datasource/DruidDataSourceProvider.java index 7c4e402..0ba8558 100644 --- a/src/main/java/act/db/ebean/datasource/DruidDataSourceProvider.java +++ b/src/main/java/act/db/ebean/datasource/DruidDataSourceProvider.java @@ -82,10 +82,9 @@ public DataSource createDataSource(DataSourceConfig conf) { public Map confKeyMapping() { return C.map("minIdle", "minConnections", "maxActive", "maxConnections", - "maxWait", "connectionTimeout", + "maxWait", "waitTimeout", "validationQuery", "heartbeatSql", - "pstmtCacheSize", "maxPoolPreparedStatementPerConnectionSize" + "maxPoolPreparedStatementPerConnectionSize", "pstmtCacheSize" ); } - } diff --git a/src/main/java/act/db/ebean/datasource/HikariDataSourceProvider.java b/src/main/java/act/db/ebean/datasource/HikariDataSourceProvider.java index 3448ea0..b13c0af 100644 --- a/src/main/java/act/db/ebean/datasource/HikariDataSourceProvider.java +++ b/src/main/java/act/db/ebean/datasource/HikariDataSourceProvider.java @@ -59,10 +59,10 @@ public DataSource createDataSource(DataSourceConfig conf) { @Override public Map confKeyMapping() { - return C.map("url", "jdbcUrl", - "maxConnections", "maximumPoolSize", + return C.map("jdbcUrl", "url", + "maximumPoolSize", "maxConnections", "minimumIdle", "minConnections", - "waitTimeout", "connectionTimeout" + "connectionTimeout", "waitTimeout" ); } } From 2a5351281dc8743c8b19b4aa796071c131170916 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Mon, 3 Apr 2017 13:56:26 +1000 Subject: [PATCH 009/114] [maven-release-plugin] prepare release act-ebean-1.1.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1b06934..9f9422b 100755 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ org.actframework act-ebean jar - 1.1.1-SNAPSHOT + 1.1.1 ACT Ebean The Ebean Plugin for Actframework SQL database access From 41c2203f57ba396e34bc98e9a3a6a1fce24662f8 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Mon, 3 Apr 2017 13:56:38 +1000 Subject: [PATCH 010/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9f9422b..c727f63 100755 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ org.actframework act-ebean jar - 1.1.1 + 1.1.2-SNAPSHOT ACT Ebean The Ebean Plugin for Actframework SQL database access From beaa1932c5ec82a13a55f1139906cd6a33244b93 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Mon, 10 Apr 2017 22:23:19 +1000 Subject: [PATCH 011/114] migrate to act-1.1.0 and new DB architecture --- pom.xml | 14 +- .../java/act/db/ebean/DataSourceProvider.java | 28 -- .../java/act/db/ebean/EbeanConfigLoaded.java | 17 ++ src/main/java/act/db/ebean/EbeanDao.java | 4 +- src/main/java/act/db/ebean/EbeanPlugin.java | 2 +- src/main/java/act/db/ebean/EbeanService.java | 259 +++--------------- src/main/java/act/db/ebean/EntityFinder.java | 23 -- .../datasource/DruidDataSourceProvider.java | 90 ------ .../datasource/HikariDataSourceProvider.java | 68 ----- .../act/db/ebean/util/EbeanConfigAdaptor.java | 90 ++++++ src/main/java/act/db/jpa/EntityFinder.java | 32 +++ src/main/resources/act.scan.list | 3 +- 12 files changed, 190 insertions(+), 440 deletions(-) delete mode 100644 src/main/java/act/db/ebean/DataSourceProvider.java create mode 100644 src/main/java/act/db/ebean/EbeanConfigLoaded.java delete mode 100644 src/main/java/act/db/ebean/EntityFinder.java delete mode 100644 src/main/java/act/db/ebean/datasource/DruidDataSourceProvider.java delete mode 100644 src/main/java/act/db/ebean/datasource/HikariDataSourceProvider.java create mode 100644 src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java create mode 100644 src/main/java/act/db/jpa/EntityFinder.java diff --git a/pom.xml b/pom.xml index c727f63..974686b 100755 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,11 @@ ******************************************** * version history ******************************************** +1.1.2 +- #12 Migrate to act-1.1.0 new DB architecture +1.1.1 +- #10 HikariDataSourceProvider.confKeyMapping error +- #11 DruidDataSourceProvider.confKeyMapping() error 1.1.0 - #9 Support plugin different datasource solution - #8 change mysql jdbc driver class name @@ -64,7 +69,8 @@ UTF-8 UTF-8 git@github.com:actframework/act-ebean.git - 1.0.6 + 1.1.0 + 1.0.0 8.8.1 8.1.1 2.1.2 @@ -189,6 +195,12 @@ provided + + org.actframework + act-sql-common + ${act-sql-common.version} + + com.zaxxer HikariCP diff --git a/src/main/java/act/db/ebean/DataSourceProvider.java b/src/main/java/act/db/ebean/DataSourceProvider.java deleted file mode 100644 index dbed44c..0000000 --- a/src/main/java/act/db/ebean/DataSourceProvider.java +++ /dev/null @@ -1,28 +0,0 @@ -package act.db.ebean; - -import org.avaje.datasource.DataSourceConfig; -import org.osgl.logging.LogManager; -import org.osgl.logging.Logger; - -import javax.sql.DataSource; -import java.util.Map; - -public abstract class DataSourceProvider { - - protected final Logger logger = LogManager.get(getClass()); - - /** - * Create datasource from configuration map - * @param conf the data source configuration - * @return a DataSource instance - */ - public abstract DataSource createDataSource(DataSourceConfig conf); - - /** - * Provide a mapping to bridge the default configuration into solution specific - * configuration. E.g. HikariCP use `jdbcUrl` instead of `url` - * @return the conf key mapping - */ - public abstract Map confKeyMapping(); - -} diff --git a/src/main/java/act/db/ebean/EbeanConfigLoaded.java b/src/main/java/act/db/ebean/EbeanConfigLoaded.java new file mode 100644 index 0000000..7c761dc --- /dev/null +++ b/src/main/java/act/db/ebean/EbeanConfigLoaded.java @@ -0,0 +1,17 @@ +package act.db.ebean; + +import act.event.ActEvent; +import com.avaje.ebean.config.ServerConfig; + +/** + * The event get triggered when {@link ServerConfig} is loaded and + * before the {@link com.avaje.ebean.EbeanServer} is created. + * + * Application can use this event to do further configuration on + * {@link ServerConfig} + */ +public class EbeanConfigLoaded extends ActEvent { + public EbeanConfigLoaded(ServerConfig source) { + super(source); + } +} diff --git a/src/main/java/act/db/ebean/EbeanDao.java b/src/main/java/act/db/ebean/EbeanDao.java index 92acf60..387e4f7 100644 --- a/src/main/java/act/db/ebean/EbeanDao.java +++ b/src/main/java/act/db/ebean/EbeanDao.java @@ -47,7 +47,7 @@ public class EbeanDao extends DaoBase id_type, Class modelType) { @@ -130,7 +130,7 @@ public DataSource ds() { String dbId = null == db ? DbServiceManager.DEFAULT : db.value(); EbeanService dbService = getService(dbId, app().dbServiceManager()); E.NPE(dbService); - ds = dbService.ds(); + ds = dbService.dataSource(); } } return ds; diff --git a/src/main/java/act/db/ebean/EbeanPlugin.java b/src/main/java/act/db/ebean/EbeanPlugin.java index da0de5e..1c5de21 100644 --- a/src/main/java/act/db/ebean/EbeanPlugin.java +++ b/src/main/java/act/db/ebean/EbeanPlugin.java @@ -9,7 +9,7 @@ public class EbeanPlugin extends DbPlugin { @Override - public DbService initDbService(String id, App app, Map conf) { + public DbService initDbService(String id, App app, Map conf) { ParamValueLoaderService.waiveFields("_ebean_intercept", "_ebean_identity"); return new EbeanService(id, app, conf); diff --git a/src/main/java/act/db/ebean/EbeanService.java b/src/main/java/act/db/ebean/EbeanService.java index 0d9291d..484eeb4 100644 --- a/src/main/java/act/db/ebean/EbeanService.java +++ b/src/main/java/act/db/ebean/EbeanService.java @@ -2,104 +2,81 @@ import act.Act; import act.app.App; -import act.app.DbServiceManager; import act.conf.AppConfigKey; import act.db.Dao; -import act.db.DbService; +import act.db.ebean.util.EbeanConfigAdaptor; +import act.db.sql.SqlDbService; import act.event.AppEventListenerBase; -import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; import com.avaje.ebean.EbeanServerFactory; import com.avaje.ebean.config.ServerConfig; -import org.avaje.datasource.DataSourceConfig; import org.osgl.$; -import org.osgl.logging.LogManager; -import org.osgl.logging.Logger; -import org.osgl.util.C; import org.osgl.util.E; import org.osgl.util.S; import javax.persistence.Entity; import javax.persistence.Id; -import javax.persistence.PersistenceException; import javax.sql.DataSource; -import java.io.File; import java.lang.annotation.Annotation; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.EventObject; import java.util.Map; -import java.util.Properties; -import java.util.Set; -import static act.app.event.AppEventId.CLASS_LOADED; import static act.app.event.AppEventId.PRE_LOAD_CLASSES; -public final class EbeanService extends DbService { - - private static Logger logger = LogManager.get(EbeanService.class); +public final class EbeanService extends SqlDbService { // the ebean service instance private EbeanServer ebean; - private Map conf; - - private ServerConfig serverConfig; - - // the datasource for low level JDBC API usage - private DataSource ds; - - private static Set> modelTypes = C.newSet(); + private ServerConfig ebeanConfig; - public EbeanService(final String dbId, final App app, final Map config) { - super(dbId, app); - this.conf = config; - Object o = conf.get("agentPackage"); - final String agentPackage = null == o ? S.string(app().config().get(AppConfigKey.SCAN_PACKAGE)) : S.string(o).trim(); + public EbeanService(final String dbId, final App app, final Map config) { + super(dbId, app, config); + String s = config.get("agentPackage"); + final String agentPackage = null == s ? S.string(app().config().get(AppConfigKey.SCAN_PACKAGE)) : S.string(s).trim(); E.invalidConfigurationIf(S.blank(agentPackage), "\"agentPackage\" not configured"); - logger.info("\"agentPackage\" configured: %s", agentPackage); - final EbeanService svc = this; - app.eventBus().bind(CLASS_LOADED, new AppEventListenerBase(S.builder(dbId).append("-ebean-prestart")) { - @Override - public void on(EventObject event) { - svc.serverConfig = serverConfig(dbId, conf); - app().eventBus().emit(new PreEbeanCreation(serverConfig)); - try { - ebean = EbeanServerFactory.create(serverConfig); - } catch (PersistenceException e) { - // try disable ddlRun - // see http://stackoverflow.com/questions/35676651/ebean-run-ddl-only-if-the-database-does-not-exist/36253846 - if (Act.isDev()) { - serverConfig.setDdlRun(false); - ebean = EbeanServerFactory.create(serverConfig); - } else { - throw e; - } - } - Ebean.register(ebean, S.eq(DbServiceManager.DEFAULT, dbId)); - } - }).bind(PRE_LOAD_CLASSES, new AppEventListenerBase(S.builder(dbId).append("-ebean-pre-cl")) { + _logger.info("\"agentPackage\" configured: %s", agentPackage); + app.eventBus().bind(PRE_LOAD_CLASSES, new AppEventListenerBase(S.concat(dbId, "-ebean-pre-cl")) { @Override public void on(EventObject event) { - String s = S.builder("debug=").append(Act.isDev() ? "1" : "0") + String s = S.buffer("debug=").append(Act.isDev() ? "1" : "0") .append(";packages=") - //.append("act.db.ebean.*,") .append(agentPackage) .toString(); if (!EbeanAgentLoader.loadAgentFromClasspath("ebean-agent", s)) { - logger.warn("ebean-agent not found in classpath - not dynamically loaded"); + _logger.warn("ebean-agent not found in classpath - not dynamically loaded"); } } }); } + @Override + protected boolean supportDdl() { + return true; + } + + @Override + protected void configured() { + ebeanConfig = new EbeanConfigAdaptor().adaptFrom(this.config, this); + app().eventBus().trigger(new EbeanConfigLoaded(ebeanConfig)); + ebean = EbeanServerFactory.create(ebeanConfig); + } + + @Override + protected DataSource createDataSource() { + // Ebean has set the datasource to config while creating ebean server + return ebeanConfig.getDataSource(); + } + @Override protected void releaseResources() { if (null != ebean) { ebean.shutdown(true, false); + ebean = null; + ebeanConfig = null; } - modelTypes.clear(); - conf.clear(); } @Override @@ -108,7 +85,7 @@ public DAO defaultDao(Class modelType) { if (EbeanModelBase.class.isAssignableFrom(modelType)) { Type type = modelType.getGenericSuperclass(); if (type instanceof ParameterizedType) { - return $.cast(new EbeanDao((Class)((ParameterizedType) type).getActualTypeArguments()[0], modelType, this)); + return $.cast(new EbeanDao((Class) ((ParameterizedType) type).getActualTypeArguments()[0], modelType, this)); } } Class idType = findModelIdTypeByAnnotation(modelType, Id.class); @@ -133,174 +110,4 @@ public EbeanServer ebean() { return ebean; } - public DataSource ds() { - return ds; - } - - private ServerConfig serverConfig(String id, Map conf) { - ServerConfig serverConfig = new ServerConfig(); - serverConfig.setName(id); - Properties properties = new Properties(); - properties.putAll(conf); - serverConfig.loadFromProperties(properties); - - Object o = conf.get("url"); - if (null == o) { - o = conf.get("jdbcUrl"); - } - E.invalidConfigurationIf(null == o, "JDBC URL required"); - - // We need to check h2 db file existence before loading HikariDatasource - // otherwise it will generate the h2 db file if it does not exist - boolean noddl = h2DbFileExists(S.string(o)); - - DataSourceProvider dataSourceProvider = dataSourceProvider(conf); - if (null != dataSourceProvider) { - // process conf mapping - Map confMapping = dataSourceProvider.confKeyMapping(); - for (Map.Entry entry : confMapping.entrySet()) { - String solutionKey = entry.getKey(); - String commonKey = entry.getValue(); - if (conf.containsKey(solutionKey)) { - conf.put(commonKey, conf.get(solutionKey)); - } - } - serverConfig.setDataSource(dataSourceProvider.createDataSource(datasourceConfig(conf))); - } else { - serverConfig.setDataSourceConfig(datasourceConfig(conf)); - } - - String ddlGenerate = (String) conf.get("ddl.generate"); - if (null != ddlGenerate) { - serverConfig.setDdlGenerate(Boolean.parseBoolean(ddlGenerate)); - } else if (Act.isDev()) { - serverConfig.setDdlGenerate(!noddl); - } - - String ddlRun = (String) conf.get("ddl.run"); - if (null != ddlRun) { - serverConfig.setDdlRun(Boolean.parseBoolean(ddlRun)); - } else if (Act.isDev()) { - serverConfig.setDdlRun(!noddl); - } - - String ddlCreateOnly = (String) conf.get("ddl.createOnly"); - if (null != ddlCreateOnly) { - serverConfig.setDdlCreateOnly(Boolean.parseBoolean(ddlCreateOnly)); - } else if (Act.isDev()) { - serverConfig.setDdlCreateOnly(!noddl); - } - - for (Class c : modelTypes) { - serverConfig.addClass(c); - } - - return serverConfig; - } - - private DataSourceConfig datasourceConfig(Map conf) { - Properties properties = new Properties(); - properties.putAll(conf); - DataSourceConfig dsc = new DataSourceConfig(); - dsc.loadSettings(properties, ""); - ensureDefaultDatasourceConfig(dsc); - dsc.setCustomProperties((Map)properties); - return dsc; - } - - private void ensureDefaultDatasourceConfig(DataSourceConfig dsc) { - String username = dsc.getUsername(); - if (null == username) { - logger.warn("No data source user configuration specified. Will use the default 'sa' user"); - username = "sa"; - } - dsc.setUsername(username); - - String password = dsc.getPassword(); - if (null == password) { - password = ""; - } - dsc.setPassword(password); - - String url = dsc.getUrl(); - if (null == url) { - logger.warn("No database URL configuration specified. Will use the default h2 inmemory test database"); - url = "jdbc:h2:mem:tests"; - } - dsc.setUrl(url); - - String driver = dsc.getDriver(); - if (null == driver) { - if (url.contains("mysql")) { - driver = "com.mysql.jdbc.Driver"; - } else if (url.contains("postgresql")) { - driver = "org.postgresql.Driver"; - } else if (url.contains("jdbc:h2:")) { - driver = "org.h2.Driver"; - } else if (url.contains("jdbc:oracle")) { - driver = "oracle.jdbc.OracleDriver"; - } else if (url.contains("sqlserver")) { - driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; - } else if (url.contains("jdbc:db2")) { - driver = "com.ibm.db2.jcc.DB2Driver"; - } else { - throw E.invalidConfiguration("JDBC driver needs to be configured for datasource: %s", id()); - } - logger.warn("JDBC driver not configured, system automatically set to: " + driver); - } - dsc.setDriver(driver); - } - - private static final String DRUID_PROVDER = "act.db.ebean.datasource.DruidDataSourceProvider"; - private static final String HIKARI_PROVIDER = "act.db.ebean.datasource.HikariDataSourceProvider"; - private DataSourceProvider dataSourceProvider(Map conf) { - String dsProvider = (String) conf.get("datasource.provider"); - - if (null != dsProvider) { - if (dsProvider.toLowerCase().contains("hikari")) { - dsProvider = HIKARI_PROVIDER; - } else if (dsProvider.toLowerCase().contains("druid")) { - dsProvider = DRUID_PROVDER; - } - } - DataSourceProvider provider; - if (null != dsProvider) { - provider = app().getInstance(dsProvider); - } else { - // try HikariCP first - try { - Class.forName("com.zaxxer.hikari.HikariConfig"); - provider = app().getInstance(HIKARI_PROVIDER); - } catch (Exception e) { - try { - Class.forName("com.alibaba.druid.pool.DruidDataSource"); - provider = app().getInstance(DRUID_PROVDER); - } catch (Exception e1) { - // ignore - return null; - } - } - } - return provider; - } - - private boolean h2DbFileExists(String jdbcUrl) { - if (Act.isProd()) { - return true; - } - if (jdbcUrl.startsWith("jdbc:h2:")) { - String file = jdbcUrl.substring("jdbc:h2:".length()) + ".mv.db"; - File _file = new File(file); - return (_file.exists()); - } - return false; - } - - public static void registerModelType(Class modelType) { - modelTypes.add(modelType); - Class superType = modelType.getSuperclass(); - if (!Object.class.equals(superType)) { - registerModelType(superType); - } - } } diff --git a/src/main/java/act/db/ebean/EntityFinder.java b/src/main/java/act/db/ebean/EntityFinder.java deleted file mode 100644 index 8796de2..0000000 --- a/src/main/java/act/db/ebean/EntityFinder.java +++ /dev/null @@ -1,23 +0,0 @@ -package act.db.ebean; - -import act.app.App; -import act.app.AppByteCodeScanner; -import act.util.AnnotatedTypeFinder; -import org.osgl.$; -import org.osgl.exception.NotAppliedException; - -import javax.persistence.Entity; -import java.util.Map; -import java.util.Set; - -public class EntityFinder extends AnnotatedTypeFinder { - public EntityFinder() { - super(true, false, Entity.class, new $.F2, Set>>() { - @Override - public Map, Set> apply(App app, String className) throws NotAppliedException, $.Break { - EbeanService.registerModelType($.classForName(className, app.classLoader())); - return null; - } - }); - } -} diff --git a/src/main/java/act/db/ebean/datasource/DruidDataSourceProvider.java b/src/main/java/act/db/ebean/datasource/DruidDataSourceProvider.java deleted file mode 100644 index 0ba8558..0000000 --- a/src/main/java/act/db/ebean/datasource/DruidDataSourceProvider.java +++ /dev/null @@ -1,90 +0,0 @@ -package act.db.ebean.datasource; - -import act.db.ebean.DataSourceProvider; -import com.alibaba.druid.pool.DruidDataSource; -import org.avaje.datasource.DataSourceConfig; -import org.osgl.util.C; -import org.osgl.util.E; - -import javax.sql.DataSource; -import java.sql.SQLException; -import java.util.Map; - -/** - * Provide Druid datasource - */ -public class DruidDataSourceProvider extends DataSourceProvider { - - @Override - public DataSource createDataSource(DataSourceConfig conf) { - DruidDataSource source = new DruidDataSource(); - source.setUrl(conf.getUrl()); - source.setUsername(conf.getUsername()); - source.setPassword(conf.getPassword()); - source.setDriverClassName(conf.getDriver()); - source.setMaxActive(conf.getMaxConnections()); - source.setMinIdle(conf.getMinConnections()); - source.setMaxWait(conf.getWaitTimeoutMillis()); - source.setValidationQuery(conf.getHeartbeatSql()); - source.setMaxPoolPreparedStatementPerConnectionSize(conf.getPstmtCacheSize()); - - Map miscConf = conf.getCustomProperties(); - String s = miscConf.get("initialSize"); - if (null != s) { - source.setInitialSize(Integer.parseInt(s)); - } else { - source.setInitialSize(source.getMinIdle()); - } - - s = miscConf.get("timeBetweenEvictionRunsMillis"); - if (null != s) { - source.setTimeBetweenEvictionRunsMillis(Long.parseLong(s)); - } - - s = miscConf.get("minEvictableIdleTimeMillis"); - if (null != s) { - source.setMinEvictableIdleTimeMillis(Long.parseLong(s)); - } - - s = miscConf.get("testWhileIdle"); - if (null != s) { - source.setTestWhileIdle(Boolean.parseBoolean(s)); - } - - s = miscConf.get("testOnBorrow"); - if (null != s) { - source.setTestOnBorrow(Boolean.parseBoolean(s)); - } - - s = miscConf.get("testOnReturn"); - if (null != s) { - source.setTestOnReturn(Boolean.parseBoolean(s)); - } - - s = miscConf.get("filters"); - if (null != s) { - try { - source.setFilters(s); - } catch (SQLException e) { - throw E.unexpected(e); - } - } - - s = miscConf.get("poolPreparedStatements"); - if (null != s) { - source.setPoolPreparedStatements(Boolean.parseBoolean(s)); - } - - return source; - } - - @Override - public Map confKeyMapping() { - return C.map("minIdle", "minConnections", - "maxActive", "maxConnections", - "maxWait", "waitTimeout", - "validationQuery", "heartbeatSql", - "maxPoolPreparedStatementPerConnectionSize", "pstmtCacheSize" - ); - } -} diff --git a/src/main/java/act/db/ebean/datasource/HikariDataSourceProvider.java b/src/main/java/act/db/ebean/datasource/HikariDataSourceProvider.java deleted file mode 100644 index b13c0af..0000000 --- a/src/main/java/act/db/ebean/datasource/HikariDataSourceProvider.java +++ /dev/null @@ -1,68 +0,0 @@ -package act.db.ebean.datasource; - -import act.db.ebean.DataSourceProvider; -import com.zaxxer.hikari.HikariConfig; -import com.zaxxer.hikari.HikariDataSource; -import org.avaje.datasource.DataSourceConfig; -import org.osgl.util.C; - -import javax.sql.DataSource; -import java.util.Map; - -/** - * Provide HikariCP data source - */ -public class HikariDataSourceProvider extends DataSourceProvider { - - @Override - public DataSource createDataSource(DataSourceConfig conf) { - HikariConfig hc = new HikariConfig(); - hc.setJdbcUrl(conf.getUrl()); - hc.setUsername(conf.getUsername()); - hc.setPassword(conf.getPassword()); - hc.setDriverClassName(conf.getDriver()); - hc.setMaximumPoolSize(conf.getMaxConnections()); - int minConn = conf.getMinConnections(); - if (minConn != new DataSourceConfig().getMinConnections()) { - // Only set min connection when it is not the default value - // because HikariCP recommend not to set this value by default - hc.setMinimumIdle(conf.getMinConnections()); - } - hc.setConnectionTimeout(conf.getWaitTimeoutMillis()); - hc.setAutoCommit(conf.isAutoCommit()); - hc.setConnectionTestQuery(conf.getHeartbeatSql()); - - Map miscConf = conf.getCustomProperties(); - String s = miscConf.get("idleTimeout"); - if (null != s) { - int n = Integer.parseInt(s); - hc.setIdleTimeout(n); - } else { - hc.setIdleTimeout(conf.getMaxInactiveTimeSecs() * 1000); - } - - s = miscConf.get("maxLifetime"); - if (null != s) { - long n = Long.parseLong(s); - hc.setMaxLifetime(n); - } else { - hc.setMaxLifetime(conf.getMaxAgeMinutes() * 60 * 1000L); - } - - s = miscConf.get("poolName"); - if (null != s) { - hc.setPoolName(s); - } - - return new HikariDataSource(hc); - } - - @Override - public Map confKeyMapping() { - return C.map("jdbcUrl", "url", - "maximumPoolSize", "maxConnections", - "minimumIdle", "minConnections", - "connectionTimeout", "waitTimeout" - ); - } -} diff --git a/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java b/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java new file mode 100644 index 0000000..619e5af --- /dev/null +++ b/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java @@ -0,0 +1,90 @@ +package act.db.ebean.util; + +import act.db.sql.SqlDbService; +import act.db.sql.SqlDbServiceConfig; +import com.avaje.ebean.config.MatchingNamingConvention; +import com.avaje.ebean.config.NamingConvention; +import com.avaje.ebean.config.ServerConfig; +import com.avaje.ebean.config.UnderscoreNamingConvention; +import org.avaje.datasource.DataSourceConfig; + +import javax.inject.Singleton; +import javax.sql.DataSource; +import java.util.Properties; +import java.util.Set; + +import static act.db.sql.util.NamingConvention.Default.MATCHING; + +/** + * Adapt {@link act.db.sql.SqlDbServiceConfig} to {@link ServerConfig} + */ +@Singleton +public class EbeanConfigAdaptor { + + public ServerConfig adaptFrom(SqlDbServiceConfig actConfig, SqlDbService svc) { + ServerConfig config = new ServerConfig(); + + config.setName(svc.id()); + DataSource dataSource = svc.dataSource(); + if (null == dataSource) { + config.setDataSourceConfig(adaptFrom(actConfig.dataSourceConfig, svc)); + } else { + config.setDataSource(svc.dataSource()); + } + + config.setDdlGenerate(actConfig.ddlGeneratorConfig.create); + config.setDdlRun(actConfig.ddlGeneratorConfig.create); + config.setDdlCreateOnly(!actConfig.ddlGeneratorConfig.drop); + + config.setNamingConvention(namingConvention(actConfig)); + + Set modelClasses = svc.modelClasses(); + if (null != modelClasses && !modelClasses.isEmpty()) { + for (Class modelClass : modelClasses) { + config.addClass(modelClass); + } + } + + return config; + } + + public DataSourceConfig adaptFrom(act.db.sql.DataSourceConfig actConfig, SqlDbService svc) { + Properties properties = new Properties(); + properties.putAll(actConfig.customProperties); + DataSourceConfig config = new DataSourceConfig(); + config.loadSettings(properties, svc.id()); + + config.setUrl(actConfig.url); + config.setDriver(actConfig.driver); + config.setUsername(actConfig.username); + config.setPassword(actConfig.password); + config.setAutoCommit(actConfig.autoCommit); + + config.setMinConnections(actConfig.minConnections); + config.setMaxConnections(actConfig.maxConnections); + config.setHeartbeatSql(actConfig.heartbeatSql); + config.setIsolationLevel(actConfig.isolationLevel); + config.setMaxAgeMinutes(actConfig.maxAgeMinutes); + config.setMaxInactiveTimeSecs(actConfig.maxInactiveTimeSecs); + config.setHeartbeatFreqSecs(actConfig.heartbeatFreqSecs); + config.setCstmtCacheSize(actConfig.cstmtCacheSize); + config.setPstmtCacheSize(actConfig.pstmtCacheSize); + config.setTrimPoolFreqSecs(actConfig.trimPoolFreqSecs); + config.setWaitTimeoutMillis(actConfig.waitTimeoutMillis); + config.setLeakTimeMinutes(actConfig.leakTimeMinutes); + config.setPoolListener(actConfig.poolListener); + config.setOffline(actConfig.offline); + config.setCaptureStackTrace(actConfig.captureStackTrace); + + return config; + } + + private NamingConvention namingConvention(SqlDbServiceConfig svcConfig) { + //TODO provide more actuate naming convention matching logic + if (MATCHING == svcConfig.tableNamingConvention) { + return new MatchingNamingConvention(); + } + return new UnderscoreNamingConvention(); + } + +} diff --git a/src/main/java/act/db/jpa/EntityFinder.java b/src/main/java/act/db/jpa/EntityFinder.java new file mode 100644 index 0000000..2cb31fd --- /dev/null +++ b/src/main/java/act/db/jpa/EntityFinder.java @@ -0,0 +1,32 @@ +package act.db.jpa; + +import act.db.EntityClassRepository; +import act.util.AnnotatedClassFinder; +import org.osgl.$; + +import javax.inject.Inject; +import javax.inject.Singleton; +import javax.persistence.Entity; +import javax.persistence.Table; + +@Singleton +public final class EntityFinder { + + private final EntityClassRepository repo; + + @Inject + public EntityFinder(EntityClassRepository repo) { + this.repo = $.notNull(repo); + } + + @AnnotatedClassFinder(Entity.class) + public void foundEntity(Class entityClass) { + repo.registerModelClass(entityClass); + } + + @AnnotatedClassFinder(Table.class) + public void foundTable(Class tableClass) { + repo.registerModelClass(tableClass); + } + +} diff --git a/src/main/resources/act.scan.list b/src/main/resources/act.scan.list index 35bfda6..57e4589 100644 --- a/src/main/resources/act.scan.list +++ b/src/main/resources/act.scan.list @@ -1 +1,2 @@ -act.db.ebean.EbeanModule \ No newline at end of file +act.db.ebean.EbeanModule +act.db.jpa.EntityFinder \ No newline at end of file From 5385d780889e221d65683c95114408c185b552da Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Mon, 10 Apr 2017 22:23:50 +1000 Subject: [PATCH 012/114] [maven-release-plugin] prepare release act-ebean-1.1.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 974686b..90540c9 100755 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,7 @@ org.actframework act-ebean jar - 1.1.2-SNAPSHOT + 1.1.2 ACT Ebean The Ebean Plugin for Actframework SQL database access From 6f7537064a1dae822118753d317ead9734bc19c1 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Mon, 10 Apr 2017 22:24:03 +1000 Subject: [PATCH 013/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 90540c9..18919cd 100755 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,7 @@ org.actframework act-ebean jar - 1.1.2 + 1.1.3-SNAPSHOT ACT Ebean The Ebean Plugin for Actframework SQL database access From db20823074beca78eec83ca68bbb7d0a33321b92 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Wed, 12 Apr 2017 16:15:24 +1000 Subject: [PATCH 014/114] fix #13 --- src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java b/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java index 619e5af..20e1358 100644 --- a/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java +++ b/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java @@ -80,6 +80,10 @@ public DataSourceConfig adaptFrom(act.db.sql.DataSourceConfig actConfig, SqlDbSe } private NamingConvention namingConvention(SqlDbServiceConfig svcConfig) { + if (!svcConfig.rawConf.containsKey("naming.convention")) { + // https://github.com/actframework/act-ebean/issues/13 + return new UnderscoreNamingConvention(); + } //TODO provide more actuate naming convention matching logic if (MATCHING == svcConfig.tableNamingConvention) { return new MatchingNamingConvention(); From b915f67f875f0af61959f3178b5891664602969c Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Wed, 12 Apr 2017 16:15:53 +1000 Subject: [PATCH 015/114] [maven-release-plugin] prepare release act-ebean-1.1.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 18919cd..5159b6f 100755 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,7 @@ org.actframework act-ebean jar - 1.1.3-SNAPSHOT + 1.1.3 ACT Ebean The Ebean Plugin for Actframework SQL database access From caa188cd50bb8c07a05fc6559ac428ad9a995408 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Wed, 12 Apr 2017 16:16:06 +1000 Subject: [PATCH 016/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5159b6f..08e2620 100755 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,7 @@ org.actframework act-ebean jar - 1.1.3 + 1.1.4-SNAPSHOT ACT Ebean The Ebean Plugin for Actframework SQL database access From 46cd4cef7bd4299b02eef87f6ce91c4c6c944ef0 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Fri, 14 Apr 2017 21:25:26 +1000 Subject: [PATCH 017/114] update act-sql-common to 1.0.1; fix #14 and #15 --- README.md | 27 ++++++++++++++++++- pom.xml | 26 ++++++------------ .../java/act/db/ebean/EbeanAgentLoader.java | 2 +- src/main/java/act/db/ebean/EbeanService.java | 2 +- 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 782b4dd..72f048d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,28 @@ # act-ebean -Ebean plugin for ACT Framework +Ebean plugin for ACT Framework. + +## act-ebean vs act-ebean2 + +* act-ebean: support JDK7 and JDK8 +* act-ebean2: uses latest ebean version but can only run on JDK8 + +## Versions + +| ActFramework | act-ebean | +| ------------ | -------- | +| 1.0.x | 1.0.x, 1.1.0, 1.1.1 | +| 1.1.x | 1.1.2+ | + +## Configuration + +For configuration items, please refer to [act-sql-common](https://github.com/actframework/act-sql-common) + +If application needs to manipulate the loaded configuration before `EbeanServer` is created, try add the following method in any Class: + +```java +@OnEvent(beforeAppStart = true) +public static void configureEbean(ServerConfig config) { + // do whatever required on ebean's ServerConfig +} +``` diff --git a/pom.xml b/pom.xml index 08e2620..f731d5e 100755 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,12 @@ ******************************************** * version history ******************************************** +1.1.4 +- update to act-sql-common-1.0.1 +- #14 Ebean Agent loaded twice if there are two ebean db services +- #15 The datasource created in sql-common not used when creating ebean server +1.1.3 +- #13 It should use ebean's naming convention by default 1.1.2 - #12 Migrate to act-1.1.0 new DB architecture 1.1.1 @@ -69,14 +75,12 @@ UTF-8 UTF-8 git@github.com:actframework/act-ebean.git - 1.1.0 - 1.0.0 + 1.1.1 + 1.0.1 8.8.1 8.1.1 2.1.2 2.7.0 - 2.6.1 - 1.0.29 @@ -201,20 +205,6 @@ ${act-sql-common.version} - - com.zaxxer - HikariCP - ${HikariCP.version} - provided - - - - com.alibaba - druid - ${druid.version} - provided - - diff --git a/src/main/java/act/db/ebean/EbeanAgentLoader.java b/src/main/java/act/db/ebean/EbeanAgentLoader.java index 1d0eade..5262581 100644 --- a/src/main/java/act/db/ebean/EbeanAgentLoader.java +++ b/src/main/java/act/db/ebean/EbeanAgentLoader.java @@ -119,7 +119,7 @@ public synchronized static boolean loadAgentFromClasspath(String agentName, Stri fullName = fullName.substring(1); } loadAgent(fullName, params); - loaded.add(fullName); + loaded.add(agentName); return true; } } diff --git a/src/main/java/act/db/ebean/EbeanService.java b/src/main/java/act/db/ebean/EbeanService.java index 484eeb4..3b96744 100644 --- a/src/main/java/act/db/ebean/EbeanService.java +++ b/src/main/java/act/db/ebean/EbeanService.java @@ -58,7 +58,7 @@ protected boolean supportDdl() { } @Override - protected void configured() { + protected void dataSourceInitialized() { ebeanConfig = new EbeanConfigAdaptor().adaptFrom(this.config, this); app().eventBus().trigger(new EbeanConfigLoaded(ebeanConfig)); ebean = EbeanServerFactory.create(ebeanConfig); From 2d415720e24162b7b2fddf24d66871fb9c89ad2e Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Fri, 14 Apr 2017 21:25:57 +1000 Subject: [PATCH 018/114] [maven-release-plugin] prepare release act-ebean-1.1.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f731d5e..2b2c339 100755 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,7 @@ org.actframework act-ebean jar - 1.1.4-SNAPSHOT + 1.1.4 ACT Ebean The Ebean Plugin for Actframework SQL database access From 1e480d8263a467fe7ae08fffa83aa15687238044 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Fri, 14 Apr 2017 21:26:13 +1000 Subject: [PATCH 019/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2b2c339..951d16e 100755 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,7 @@ org.actframework act-ebean jar - 1.1.4 + 1.1.5-SNAPSHOT ACT Ebean The Ebean Plugin for Actframework SQL database access From 31a554adb773022fc705fcef609da7eef3adf16e Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Wed, 19 Apr 2017 09:45:49 +1000 Subject: [PATCH 020/114] fix #16 --- pom.xml | 8 ++++++-- src/main/java/act/db/ebean/EbeanService.java | 7 +++++-- src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java | 8 +------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 951d16e..cf921f5 100755 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,10 @@ ******************************************** * version history ******************************************** +1.1.5 +- #16 NPE when no third party datasource configured +- update sql-common to 1.0.2 + 1.1.4 - update to act-sql-common-1.0.1 - #14 Ebean Agent loaded twice if there are two ebean db services @@ -75,8 +79,8 @@ UTF-8 UTF-8 git@github.com:actframework/act-ebean.git - 1.1.1 - 1.0.1 + 1.1.2 + 1.0.2 8.8.1 8.1.1 2.1.2 diff --git a/src/main/java/act/db/ebean/EbeanService.java b/src/main/java/act/db/ebean/EbeanService.java index 3b96744..fee0214 100644 --- a/src/main/java/act/db/ebean/EbeanService.java +++ b/src/main/java/act/db/ebean/EbeanService.java @@ -58,15 +58,18 @@ protected boolean supportDdl() { } @Override - protected void dataSourceInitialized() { + protected void dataSourceProvided(DataSource dataSource) { ebeanConfig = new EbeanConfigAdaptor().adaptFrom(this.config, this); + ebeanConfig.setDataSource(dataSource); app().eventBus().trigger(new EbeanConfigLoaded(ebeanConfig)); ebean = EbeanServerFactory.create(ebeanConfig); } @Override protected DataSource createDataSource() { - // Ebean has set the datasource to config while creating ebean server + ebeanConfig = new EbeanConfigAdaptor().adaptFrom(this.config, this); + app().eventBus().trigger(new EbeanConfigLoaded(ebeanConfig)); + ebean = EbeanServerFactory.create(ebeanConfig); return ebeanConfig.getDataSource(); } diff --git a/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java b/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java index 20e1358..9d1df0a 100644 --- a/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java +++ b/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java @@ -9,7 +9,6 @@ import org.avaje.datasource.DataSourceConfig; import javax.inject.Singleton; -import javax.sql.DataSource; import java.util.Properties; import java.util.Set; @@ -25,12 +24,7 @@ public ServerConfig adaptFrom(SqlDbServiceConfig actConfig, SqlDbService svc) { ServerConfig config = new ServerConfig(); config.setName(svc.id()); - DataSource dataSource = svc.dataSource(); - if (null == dataSource) { - config.setDataSourceConfig(adaptFrom(actConfig.dataSourceConfig, svc)); - } else { - config.setDataSource(svc.dataSource()); - } + config.setDataSourceConfig(adaptFrom(actConfig.dataSourceConfig, svc)); config.setDdlGenerate(actConfig.ddlGeneratorConfig.create); config.setDdlRun(actConfig.ddlGeneratorConfig.create); From 345c4ff6571a3f344f0f6b67943cc945576098f9 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Wed, 19 Apr 2017 09:46:37 +1000 Subject: [PATCH 021/114] [maven-release-plugin] prepare release act-ebean-1.1.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cf921f5..dd7adf4 100755 --- a/pom.xml +++ b/pom.xml @@ -69,7 +69,7 @@ org.actframework act-ebean jar - 1.1.5-SNAPSHOT + 1.1.5 ACT Ebean The Ebean Plugin for Actframework SQL database access From 6739f710b8049b7aac61ee891b42182be08b1ccf Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Wed, 19 Apr 2017 09:46:47 +1000 Subject: [PATCH 022/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dd7adf4..f5dc5e4 100755 --- a/pom.xml +++ b/pom.xml @@ -69,7 +69,7 @@ org.actframework act-ebean jar - 1.1.5 + 1.1.6-SNAPSHOT ACT Ebean The Ebean Plugin for Actframework SQL database access From 3c0a0fcb19b7f86b97f2f3e266c64a565707582b Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 28 May 2017 21:57:00 +1000 Subject: [PATCH 023/114] update to act-1.4.0, sql-common-1.1.0 --- pom.xml | 19 +++++++++++++++++-- src/main/java/act/db/ebean/EbeanService.java | 11 ++++++++--- .../act/db/ebean/util/EbeanConfigAdaptor.java | 10 ++++++++-- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index f5dc5e4..06c29f9 100755 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,10 @@ ******************************************** * version history ******************************************** +1.2.0 +* catch up to act-1.4.0 +* catch up to act-sql-common to 1.1.0 + 1.1.5 - #16 NPE when no third party datasource configured - update sql-common to 1.0.2 @@ -26,31 +30,42 @@ - update to act-sql-common-1.0.1 - #14 Ebean Agent loaded twice if there are two ebean db services - #15 The datasource created in sql-common not used when creating ebean server + 1.1.3 - #13 It should use ebean's naming convention by default + 1.1.2 - #12 Migrate to act-1.1.0 new DB architecture + 1.1.1 - #10 HikariDataSourceProvider.confKeyMapping error - #11 DruidDataSourceProvider.confKeyMapping() error + 1.1.0 - #9 Support plugin different datasource solution - #8 change mysql jdbc driver class name - #6 Support Druid database + 1.0.5 - fix #7 It reports XXX table not found when start app in dev mode + 1.0.4 - take out version range from pom.xml. See https://issues.apache.org/jira/browse/MNG-3092 + 1.0.3 - version number of mistake + 1.0.2 - #4 use HikariCP for connection pool - #5 Make it easy to do low level JDBC logic + 1.0.1 - Fix #1 EbeanDao.drop() method cause JdbcSQLException - Fix #3 EbeanInjectionListener not effect on User defined Dao + 1.0.0 - the first formal release + 0.7.0 - update act to 0.7.0 0.6.0 - update act to 0.6.0 0.5.0 - upgrade to act 0.5.0 (to reserve 0.4.0 for techempower test) @@ -69,7 +84,7 @@ org.actframework act-ebean jar - 1.1.6-SNAPSHOT + 1.2.0-SNAPSHOT ACT Ebean The Ebean Plugin for Actframework SQL database access @@ -80,7 +95,7 @@ UTF-8 git@github.com:actframework/act-ebean.git 1.1.2 - 1.0.2 + 1.0.4-SNAPSHOT 8.8.1 8.1.1 2.1.2 diff --git a/src/main/java/act/db/ebean/EbeanService.java b/src/main/java/act/db/ebean/EbeanService.java index fee0214..22a7c58 100644 --- a/src/main/java/act/db/ebean/EbeanService.java +++ b/src/main/java/act/db/ebean/EbeanService.java @@ -5,6 +5,7 @@ import act.conf.AppConfigKey; import act.db.Dao; import act.db.ebean.util.EbeanConfigAdaptor; +import act.db.sql.DataSourceConfig; import act.db.sql.SqlDbService; import act.event.AppEventListenerBase; import com.avaje.ebean.EbeanServer; @@ -58,8 +59,8 @@ protected boolean supportDdl() { } @Override - protected void dataSourceProvided(DataSource dataSource) { - ebeanConfig = new EbeanConfigAdaptor().adaptFrom(this.config, this); + protected void dataSourceProvided(DataSource dataSource, DataSourceConfig dataSourceConfig) { + ebeanConfig = new EbeanConfigAdaptor().adaptFrom(this.config, dataSourceConfig, this); ebeanConfig.setDataSource(dataSource); app().eventBus().trigger(new EbeanConfigLoaded(ebeanConfig)); ebean = EbeanServerFactory.create(ebeanConfig); @@ -67,7 +68,7 @@ protected void dataSourceProvided(DataSource dataSource) { @Override protected DataSource createDataSource() { - ebeanConfig = new EbeanConfigAdaptor().adaptFrom(this.config, this); + ebeanConfig = new EbeanConfigAdaptor().adaptFrom(this.config, this.config.dataSourceConfig, this); app().eventBus().trigger(new EbeanConfigLoaded(ebeanConfig)); ebean = EbeanServerFactory.create(ebeanConfig); return ebeanConfig.getDataSource(); @@ -77,9 +78,13 @@ protected DataSource createDataSource() { protected void releaseResources() { if (null != ebean) { ebean.shutdown(true, false); + if (_logger.isDebugEnabled()) { + _logger.debug("ebean shutdown: %s", id()); + } ebean = null; ebeanConfig = null; } + super.releaseResources(); } @Override diff --git a/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java b/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java index 9d1df0a..3af7c17 100644 --- a/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java +++ b/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java @@ -7,11 +7,13 @@ import com.avaje.ebean.config.ServerConfig; import com.avaje.ebean.config.UnderscoreNamingConvention; import org.avaje.datasource.DataSourceConfig; +import org.osgl.util.S; import javax.inject.Singleton; import java.util.Properties; import java.util.Set; +import static act.app.App.LOGGER; import static act.db.sql.util.NamingConvention.Default.MATCHING; /** @@ -20,11 +22,11 @@ @Singleton public class EbeanConfigAdaptor { - public ServerConfig adaptFrom(SqlDbServiceConfig actConfig, SqlDbService svc) { + public ServerConfig adaptFrom(SqlDbServiceConfig actConfig, act.db.sql.DataSourceConfig dsConfig, SqlDbService svc) { ServerConfig config = new ServerConfig(); config.setName(svc.id()); - config.setDataSourceConfig(adaptFrom(actConfig.dataSourceConfig, svc)); + config.setDataSourceConfig(adaptFrom(dsConfig, svc)); config.setDdlGenerate(actConfig.ddlGeneratorConfig.create); config.setDdlRun(actConfig.ddlGeneratorConfig.create); @@ -35,6 +37,9 @@ public ServerConfig adaptFrom(SqlDbServiceConfig actConfig, SqlDbService svc) { Set modelClasses = svc.modelClasses(); if (null != modelClasses && !modelClasses.isEmpty()) { for (Class modelClass : modelClasses) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace(S.concat("add model class into Ebean config: ", modelClass.getName())); + } config.addClass(modelClass); } } @@ -42,6 +47,7 @@ public ServerConfig adaptFrom(SqlDbServiceConfig actConfig, SqlDbService svc) { return config; } + public DataSourceConfig adaptFrom(act.db.sql.DataSourceConfig actConfig, SqlDbService svc) { Properties properties = new Properties(); properties.putAll(actConfig.customProperties); From 8bd833b8c3e5287195345f32440bcd192e99c859 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 28 May 2017 21:58:55 +1000 Subject: [PATCH 024/114] update to act-1.4.0, sql-common-1.1.0 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 06c29f9..45db58a 100755 --- a/pom.xml +++ b/pom.xml @@ -94,8 +94,8 @@ UTF-8 UTF-8 git@github.com:actframework/act-ebean.git - 1.1.2 - 1.0.4-SNAPSHOT + 1.4.0-SNAPSHOT + 1.1.0-SNAPSHOT 8.8.1 8.1.1 2.1.2 From e323737a184f421bee12513684af03bd13f53209 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 13 Jun 2017 22:05:01 +1000 Subject: [PATCH 025/114] upgrade to act-1.4.0 --- .../java/act/db/ebean/EbeanAgentLoader.java | 50 +++++++++++++------ src/main/java/act/db/ebean/EbeanDao.java | 15 +++--- .../db/ebean/EbeanDaoInjectionListener.java | 18 +++++-- .../java/act/db/ebean/EbeanModelBase.java | 1 - src/main/java/act/db/ebean/EbeanQuery.java | 20 ++++---- src/main/java/act/db/ebean/EbeanService.java | 14 ++++-- .../act/db/ebean/util/EbeanConfigAdaptor.java | 5 +- 7 files changed, 79 insertions(+), 44 deletions(-) diff --git a/src/main/java/act/db/ebean/EbeanAgentLoader.java b/src/main/java/act/db/ebean/EbeanAgentLoader.java index 5262581..51f3e6e 100644 --- a/src/main/java/act/db/ebean/EbeanAgentLoader.java +++ b/src/main/java/act/db/ebean/EbeanAgentLoader.java @@ -1,38 +1,35 @@ package act.db.ebean; +import act.Act; +import act.app.event.AppEventId; +import act.sys.Env; import com.sun.tools.attach.AttachNotSupportedException; import com.sun.tools.attach.VirtualMachine; import com.sun.tools.attach.VirtualMachineDescriptor; import com.sun.tools.attach.spi.AttachProvider; import org.avaje.agentloader.AgentLoader; +import org.osgl.logging.LogManager; +import org.osgl.logging.Logger; +import org.osgl.util.S; import sun.tools.attach.BsdVirtualMachine; import sun.tools.attach.LinuxVirtualMachine; import sun.tools.attach.SolarisVirtualMachine; import sun.tools.attach.WindowsVirtualMachine; -import java.io.File; -import java.io.IOException; -import java.lang.management.ManagementFactory; +import java.io.*; import java.net.URISyntaxException; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; import java.util.List; -import java.util.logging.Logger; public class EbeanAgentLoader extends AgentLoader { - private static final Logger log = Logger.getLogger(AgentLoader.class.getName()); + private static final Logger LOGGER = LogManager.get(EbeanAgentLoader.class.getName()); private static final List loaded = new ArrayList(); - private static final String discoverPid() { - String nameOfRunningVM = ManagementFactory.getRuntimeMXBean().getName(); - int p = nameOfRunningVM.indexOf('@'); - return nameOfRunningVM.substring(0, p); - } - private static final AttachProvider ATTACH_PROVIDER = new AttachProvider() { @Override public String name() { @@ -66,11 +63,9 @@ public static void loadAgent(String jarFilePath) { * Load an agent providing the full file path with parameters. */ public static void loadAgent(String jarFilePath, String params) { - - log.info("dynamically loading javaagent for " + jarFilePath); try { - String pid = discoverPid(); + String pid = Env.PID.get(); VirtualMachine vm; if (AttachProvider.providers().isEmpty()) { @@ -79,7 +74,22 @@ public static void loadAgent(String jarFilePath, String params) { vm = VirtualMachine.attach(pid); } - vm.loadAgent(jarFilePath, params); + final PrintStream ps = System.out; + try { + System.setOut(new PrintStream(new FileOutputStream(".ebean_agent.log"))); + vm.loadAgent(jarFilePath, params); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("javaagent loaded: " + jarFilePath); + } + } finally { + // ensure ebean2 EnhanceContext logout set to dump output + Act.jobManager().on(AppEventId.CLASS_LOADER_INITIALIZED, new Runnable() { + @Override + public void run() { + System.setOut(ps); + } + }); + } vm.detach(); } catch (Exception e) { @@ -98,8 +108,10 @@ public static void loadAgentFromClasspath(String agentName) { * Load the agent from the classpath using its name and passing params. */ public synchronized static boolean loadAgentFromClasspath(String agentName, String params) { - if (loaded.contains(agentName)) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug(S.concat("agent already loaded: ", agentName)); + } // the agent is already loaded return true; } @@ -118,6 +130,9 @@ public synchronized static boolean loadAgentFromClasspath(String agentName, Stri if (fullName.startsWith("/") && isWindows()) { fullName = fullName.substring(1); } + if (LOGGER.isTraceEnabled()) { + LOGGER.trace(S.concat("loading agent: ", fullName)); + } loadAgent(fullName, params); loaded.add(agentName); return true; @@ -126,6 +141,9 @@ public synchronized static boolean loadAgentFromClasspath(String agentName, Stri } // Agent not found and not loaded + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("agent not found"); + } return false; } catch (URISyntaxException use) { diff --git a/src/main/java/act/db/ebean/EbeanDao.java b/src/main/java/act/db/ebean/EbeanDao.java index 387e4f7..6c64b87 100644 --- a/src/main/java/act/db/ebean/EbeanDao.java +++ b/src/main/java/act/db/ebean/EbeanDao.java @@ -46,7 +46,7 @@ public class EbeanDao extends DaoBase idType, Class modelType, EbeanService service) { super(idType, modelType); init(modelType); - this.ebean(service.ebean()); + this.setEbean(service.ebean()); this.ds = service.dataSource(); } @@ -60,8 +60,7 @@ public EbeanDao() { } public void ebean(EbeanServer ebean) { - this.ebean = $.notNull(ebean); - this.tableName = ((SpiEbeanServer) ebean).getBeanDescriptor(modelType()).getBaseTable(); + setEbean($.notNull(ebean)); } public void modelType(Class type) { @@ -92,9 +91,11 @@ private void init(Class modelType) { break; } } - if (null != ebean) { - this.tableName = ((SpiEbeanServer) ebean).getBeanDescriptor(modelType()).getBaseTable(); - } + } + + private void setEbean(EbeanServer ebean) { + this.ebean = ebean; + this.tableName = ((SpiEbeanServer) ebean).getBeanDescriptor(modelType()).getBaseTable(); } private EbeanService getService(String dbId, DbServiceManager mgr) { @@ -114,7 +115,7 @@ public EbeanServer ebean() { String dbId = null == db ? DbServiceManager.DEFAULT : db.value(); EbeanService dbService = getService(dbId, app().dbServiceManager()); E.NPE(dbService); - ebean = dbService.ebean(); + setEbean(dbService.ebean()); } } return ebean; diff --git a/src/main/java/act/db/ebean/EbeanDaoInjectionListener.java b/src/main/java/act/db/ebean/EbeanDaoInjectionListener.java index e246255..a281623 100644 --- a/src/main/java/act/db/ebean/EbeanDaoInjectionListener.java +++ b/src/main/java/act/db/ebean/EbeanDaoInjectionListener.java @@ -1,11 +1,14 @@ package act.db.ebean; +import act.Act; import act.app.App; +import act.app.event.AppEventId; import act.db.DbService; import act.db.di.DaoInjectionListenerBase; import org.osgl.$; import org.osgl.inject.BeanSpec; import org.osgl.util.Generics; +import org.osgl.util.S; import java.lang.reflect.Type; import java.util.List; @@ -27,13 +30,18 @@ public void onInjection(Object injectee, BeanSpec spec) { logger.warn("No type parameter information provided"); return; } - $.T2 resolved = resolve(typeParameters); + final $.T2 resolved = resolve(typeParameters); DbService dbService = App.instance().dbServiceManager().dbService(resolved._2); if (dbService instanceof EbeanService) { - EbeanService service = $.cast(dbService); - EbeanDao dao = $.cast(injectee); - dao.ebean(service.ebean()); - dao.modelType(resolved._1); + final EbeanService service = $.cast(dbService); + final EbeanDao dao = $.cast(injectee); + Act.jobManager().on(AppEventId.DB_SVC_LOADED, S.concat(resolved._2, "-ebean-on-dao-injection"), new Runnable() { + @Override + public void run() { + dao.ebean(service.ebean()); + dao.modelType(resolved._1); + } + }, true); } } } diff --git a/src/main/java/act/db/ebean/EbeanModelBase.java b/src/main/java/act/db/ebean/EbeanModelBase.java index 9c105df..a11cf7b 100644 --- a/src/main/java/act/db/ebean/EbeanModelBase.java +++ b/src/main/java/act/db/ebean/EbeanModelBase.java @@ -6,7 +6,6 @@ import org.osgl.$; import javax.persistence.MappedSuperclass; - @MappedSuperclass public abstract class EbeanModelBase implements Model { diff --git a/src/main/java/act/db/ebean/EbeanQuery.java b/src/main/java/act/db/ebean/EbeanQuery.java index 26c0a93..0f9adbb 100644 --- a/src/main/java/act/db/ebean/EbeanQuery.java +++ b/src/main/java/act/db/ebean/EbeanQuery.java @@ -289,16 +289,6 @@ public void consume($.Visitor visitor) { } } - @Override - public void findEach(QueryEachConsumer consumer) { - q.findEach(consumer); - } - - @Override - public void findEachWhile(QueryEachWhileConsumer consumer) { - q.findEachWhile(consumer); - } - @Override public List findList() { return q.findList(); @@ -344,6 +334,16 @@ public FutureList findFutureList() { return q.findFutureList(); } + @Override + public void findEach(QueryEachConsumer consumer) { + q.findEach(consumer); + } + + @Override + public void findEachWhile(QueryEachWhileConsumer consumer) { + q.findEachWhile(consumer); + } + @Override public EbeanQuery setParameter(String name, Object value) { q.setParameter(name, value); diff --git a/src/main/java/act/db/ebean/EbeanService.java b/src/main/java/act/db/ebean/EbeanService.java index 22a7c58..bf00a3e 100644 --- a/src/main/java/act/db/ebean/EbeanService.java +++ b/src/main/java/act/db/ebean/EbeanService.java @@ -12,6 +12,8 @@ import com.avaje.ebean.EbeanServerFactory; import com.avaje.ebean.config.ServerConfig; import org.osgl.$; +import org.osgl.logging.LogManager; +import org.osgl.logging.Logger; import org.osgl.util.E; import org.osgl.util.S; @@ -28,6 +30,8 @@ public final class EbeanService extends SqlDbService { + private final Logger LOGGER = LogManager.get(EbeanService.class); + // the ebean service instance private EbeanServer ebean; @@ -38,7 +42,9 @@ public EbeanService(final String dbId, final App app, final Map String s = config.get("agentPackage"); final String agentPackage = null == s ? S.string(app().config().get(AppConfigKey.SCAN_PACKAGE)) : S.string(s).trim(); E.invalidConfigurationIf(S.blank(agentPackage), "\"agentPackage\" not configured"); - _logger.info("\"agentPackage\" configured: %s", agentPackage); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("\"agentPackage\" configured: %s", agentPackage); + } app.eventBus().bind(PRE_LOAD_CLASSES, new AppEventListenerBase(S.concat(dbId, "-ebean-pre-cl")) { @Override public void on(EventObject event) { @@ -47,7 +53,7 @@ public void on(EventObject event) { .append(agentPackage) .toString(); if (!EbeanAgentLoader.loadAgentFromClasspath("ebean-agent", s)) { - _logger.warn("ebean-agent not found in classpath - not dynamically loaded"); + LOGGER.warn("ebean-agent not found in classpath - not dynamically loaded"); } } }); @@ -59,8 +65,8 @@ protected boolean supportDdl() { } @Override - protected void dataSourceProvided(DataSource dataSource, DataSourceConfig dataSourceConfig) { - ebeanConfig = new EbeanConfigAdaptor().adaptFrom(this.config, dataSourceConfig, this); + protected void dataSourceProvided(DataSource dataSource, DataSourceConfig dsConfig) { + ebeanConfig = new EbeanConfigAdaptor().adaptFrom(this.config, dsConfig, this); ebeanConfig.setDataSource(dataSource); app().eventBus().trigger(new EbeanConfigLoaded(ebeanConfig)); ebean = EbeanServerFactory.create(ebeanConfig); diff --git a/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java b/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java index 3af7c17..7b9c164 100644 --- a/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java +++ b/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java @@ -7,13 +7,14 @@ import com.avaje.ebean.config.ServerConfig; import com.avaje.ebean.config.UnderscoreNamingConvention; import org.avaje.datasource.DataSourceConfig; +import org.osgl.logging.LogManager; +import org.osgl.logging.Logger; import org.osgl.util.S; import javax.inject.Singleton; import java.util.Properties; import java.util.Set; -import static act.app.App.LOGGER; import static act.db.sql.util.NamingConvention.Default.MATCHING; /** @@ -22,6 +23,8 @@ @Singleton public class EbeanConfigAdaptor { + private static final Logger LOGGER = LogManager.get(EbeanConfigAdaptor.class); + public ServerConfig adaptFrom(SqlDbServiceConfig actConfig, act.db.sql.DataSourceConfig dsConfig, SqlDbService svc) { ServerConfig config = new ServerConfig(); From e19b9916c7a20b8bdba16a60e8ef05d97a5f9f49 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 13 Jun 2017 22:05:53 +1000 Subject: [PATCH 026/114] [maven-release-plugin] prepare release act-ebean-1.2.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 45db58a..dad14f2 100755 --- a/pom.xml +++ b/pom.xml @@ -84,7 +84,7 @@ org.actframework act-ebean jar - 1.2.0-SNAPSHOT + 1.2.0 ACT Ebean The Ebean Plugin for Actframework SQL database access @@ -94,8 +94,8 @@ UTF-8 UTF-8 git@github.com:actframework/act-ebean.git - 1.4.0-SNAPSHOT - 1.1.0-SNAPSHOT + 1.4.0 + 1.1.0 8.8.1 8.1.1 2.1.2 From 9edfcbcf624c4603ce44d5e87daee0149aa50442 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 13 Jun 2017 22:06:04 +1000 Subject: [PATCH 027/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dad14f2..60bbc32 100755 --- a/pom.xml +++ b/pom.xml @@ -84,7 +84,7 @@ org.actframework act-ebean jar - 1.2.0 + 1.2.1-SNAPSHOT ACT Ebean The Ebean Plugin for Actframework SQL database access From 557900a595d7f97088d8e6aa2b130b8cb9d96efb Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Wed, 14 Jun 2017 21:14:48 +1000 Subject: [PATCH 028/114] catch up to act-ebean2-1.1.1 --- pom.xml | 3 +++ src/main/java/act/db/ebean/EbeanDao.java | 4 ++++ .../act/db/ebean/EbeanDaoInjectionListener.java | 14 +++++++++----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 60bbc32..8146b2a 100755 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,9 @@ ******************************************** * version history ******************************************** +1.2.1 +* catch up to ebean2-1.1.1 + 1.2.0 * catch up to act-1.4.0 * catch up to act-sql-common to 1.1.0 diff --git a/src/main/java/act/db/ebean/EbeanDao.java b/src/main/java/act/db/ebean/EbeanDao.java index 6c64b87..122f2f2 100644 --- a/src/main/java/act/db/ebean/EbeanDao.java +++ b/src/main/java/act/db/ebean/EbeanDao.java @@ -316,6 +316,10 @@ public EbeanQuery createQuery() { return q(); } + boolean ebeanServerProvided() { + return null != ebean; + } + private enum R2 { betweenProperties() { @Override diff --git a/src/main/java/act/db/ebean/EbeanDaoInjectionListener.java b/src/main/java/act/db/ebean/EbeanDaoInjectionListener.java index a281623..d56e881 100644 --- a/src/main/java/act/db/ebean/EbeanDaoInjectionListener.java +++ b/src/main/java/act/db/ebean/EbeanDaoInjectionListener.java @@ -5,12 +5,13 @@ import act.app.event.AppEventId; import act.db.DbService; import act.db.di.DaoInjectionListenerBase; +import act.event.AppEventListenerBase; import org.osgl.$; import org.osgl.inject.BeanSpec; import org.osgl.util.Generics; -import org.osgl.util.S; import java.lang.reflect.Type; +import java.util.EventObject; import java.util.List; public class EbeanDaoInjectionListener extends DaoInjectionListenerBase { @@ -22,6 +23,10 @@ public Class[] listenTo() { @Override public void onInjection(Object injectee, BeanSpec spec) { + final EbeanDao dao = $.cast(injectee); + if (dao.ebeanServerProvided()) { + return; + } List typeParameters = spec.typeParams(); if (typeParameters.isEmpty()) { typeParameters = Generics.typeParamImplementations(spec.rawType(), EbeanDao.class); @@ -34,14 +39,13 @@ public void onInjection(Object injectee, BeanSpec spec) { DbService dbService = App.instance().dbServiceManager().dbService(resolved._2); if (dbService instanceof EbeanService) { final EbeanService service = $.cast(dbService); - final EbeanDao dao = $.cast(injectee); - Act.jobManager().on(AppEventId.DB_SVC_LOADED, S.concat(resolved._2, "-ebean-on-dao-injection"), new Runnable() { + Act.eventBus().bind(AppEventId.DB_SVC_LOADED, new AppEventListenerBase() { @Override - public void run() { + public void on(EventObject eventObject) throws Exception { dao.ebean(service.ebean()); dao.modelType(resolved._1); } - }, true); + }); } } } From 85c114b9fac5c4d499de28068e7876caf9a58333 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Wed, 14 Jun 2017 21:15:56 +1000 Subject: [PATCH 029/114] [maven-release-plugin] prepare release act-ebean-1.2.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8146b2a..9f97839 100755 --- a/pom.xml +++ b/pom.xml @@ -87,7 +87,7 @@ org.actframework act-ebean jar - 1.2.1-SNAPSHOT + 1.2.1 ACT Ebean The Ebean Plugin for Actframework SQL database access From 8193a94854b84e15ddb2069af99bcd0f1e69ac4f Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Wed, 14 Jun 2017 21:16:07 +1000 Subject: [PATCH 030/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9f97839..05ac859 100755 --- a/pom.xml +++ b/pom.xml @@ -87,7 +87,7 @@ org.actframework act-ebean jar - 1.2.1 + 1.2.2-SNAPSHOT ACT Ebean The Ebean Plugin for Actframework SQL database access From ad39daf7c8f16c26f0cbc8779c0a4b0029a40fe0 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 25 Jun 2017 17:35:13 +1000 Subject: [PATCH 031/114] [maven-release-plugin] prepare release act-ebean-1.2.2 --- pom.xml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 05ac859..1004605 100755 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,9 @@ ******************************************** * version history ******************************************** +1.2.2 +* catch up to sql-common-1.1.1 + 1.2.1 * catch up to ebean2-1.1.1 @@ -87,7 +90,7 @@ org.actframework act-ebean jar - 1.2.2-SNAPSHOT + 1.2.2 ACT Ebean The Ebean Plugin for Actframework SQL database access @@ -97,8 +100,8 @@ UTF-8 UTF-8 git@github.com:actframework/act-ebean.git - 1.4.0 - 1.1.0 + 1.4.1 + 1.1.1 8.8.1 8.1.1 2.1.2 From f9e6961bb0e9bef44f81715abe740ec8367aa2fe Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 25 Jun 2017 17:35:27 +1000 Subject: [PATCH 032/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1004605..f7c2c5b 100755 --- a/pom.xml +++ b/pom.xml @@ -90,7 +90,7 @@ org.actframework act-ebean jar - 1.2.2 + 1.2.3-SNAPSHOT ACT Ebean The Ebean Plugin for Actframework SQL database access From 36e2ff1c52fa1d084c0eebef46e1581404881e58 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 10 Sep 2017 19:27:40 +1000 Subject: [PATCH 033/114] improve build process; update to act-1.4.11, act-sql-common-1.1.2; apply new javadoc style; apply osgl-bootstrap version --- .travis.yml | 7 + CHANGELOG.md | 71 ++ README.md | 7 + checkstyle.xml | 209 ++++++ pom.xml | 364 +++++----- src/etc/javadoc.css | 622 ++++++++++++++++++ .../java/act/db/ebean/EbeanAgentLoader.java | 20 + .../java/act/db/ebean/EbeanConfigLoaded.java | 20 + src/main/java/act/db/ebean/EbeanDao.java | 29 +- .../db/ebean/EbeanDaoInjectionListener.java | 20 + .../java/act/db/ebean/EbeanModelBase.java | 20 + src/main/java/act/db/ebean/EbeanModule.java | 20 + src/main/java/act/db/ebean/EbeanPlugin.java | 24 + src/main/java/act/db/ebean/EbeanQuery.java | 24 +- src/main/java/act/db/ebean/EbeanService.java | 45 +- .../java/act/db/ebean/ModelBaseEnhancer.java | 20 + .../java/act/db/ebean/PreEbeanCreation.java | 20 + .../act/db/ebean/util/EbeanConfigAdaptor.java | 20 + .../act/db/ebean/util/EbeanDaoLoader.java | 20 + src/main/java/act/db/jpa/EntityFinder.java | 20 + src/main/resources/act/db/ebean/.version | 3 + src/test/java/act/db/ebean/VersionTest.java | 13 + src/test/java/playground/Contact.java | 20 + src/test/java/playground/ContactService.java | 20 + 24 files changed, 1466 insertions(+), 192 deletions(-) create mode 100644 .travis.yml create mode 100644 CHANGELOG.md create mode 100644 checkstyle.xml create mode 100644 src/etc/javadoc.css create mode 100644 src/main/resources/act/db/ebean/.version create mode 100644 src/test/java/act/db/ebean/VersionTest.java diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..13c782f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: java +sudo: false # faster builds + +#script: "mvn cobertura:cobertura" +# +#after_success: +# - bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..af66719 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,71 @@ +# act-ebean CHANGE LOG + +1.2.3 +* update to act-1.4.11, act-sql-common-1.1.1 +* apply oslg-bootstrap version mechanism +* improve maven build process + +1.2.2 +* catch up to sql-common-1.1.1 + +1.2.1 +* catch up to ebean2-1.1.1 + +1.2.0 +* catch up to act-1.4.0 +* catch up to act-sql-common to 1.1.0 + +1.1.5 +- NPE when no third party datasource configured #16 +- update sql-common to 1.0.2 + +1.1.4 +- update to act-sql-common-1.0.1 +- Ebean Agent loaded twice if there are two ebean db services #14 +- The datasource created in sql-common not used when creating ebean server #15 + +1.1.3 +- It should use ebean's naming convention by default #13 + +1.1.2 +- Migrate to act-1.1.0 new DB architecture #12 + +1.1.1 +- HikariDataSourceProvider.confKeyMapping error #10 +- DruidDataSourceProvider.confKeyMapping() error #11 + +1.1.0 +- Support plugin different datasource solution #9 +- change mysql jdbc driver class name #8 +- Support Druid database #6 + +1.0.5 +- It reports XXX table not found when start app in dev mode #7 + +1.0.4 +- take out version range from pom.xml. See https://issues.apache.org/jira/browse/MNG-3092 + +1.0.3 +- version number of mistake + +1.0.2 +- use HikariCP for connection pool #4 +- Make it easy to do low level JDBC logic #5 + +1.0.1 +- EbeanDao.drop() method cause JdbcSQLException #1 +- EbeanInjectionListener not effect on User defined Dao #3 + +1.0.0 +- the first formal release + +0.7.0 - update act to 0.7.0 +0.6.0 - update act to 0.6.0 +0.5.0 - upgrade to act 0.5.0 (to reserve 0.4.0 for techempower test) +0.4.0 - upgrade to act 0.4.0 +0.3.1 - upgrade to act 0.3.1 +0.3.0 - upgrade to act 0.3.0 +0.2.0 - upgrade to act 0.2.0 + - upgrade to ebean-8 +0.1.2 - upgrade to act 0.1.2 +0.1.1 - baseline version diff --git a/README.md b/README.md index 72f048d..c1596e7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,12 @@ # act-ebean +[![APL v2](https://img.shields.io/badge/license-Apache%202-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html) +[![Maven Central](https://img.shields.io/maven-central/v/org.actframework/act-ebean.svg)](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22act-ebean%22) +[![Build Status](https://travis-ci.org/actframework/act-ebean.svg?branch=master)](https://travis-ci.org/actframework/act-ebean) +[![codecov](https://codecov.io/gh/actframework/act-ebean/branch/master/graph/badge.svg)](https://codecov.io/gh/actframework/act-ebean) +[![Javadocs](http://www.javadoc.io/badge/org.actframework/act-ebean.svg?color=blue)](http://www.javadoc.io/doc/org.actframework/act-ebean) + + Ebean plugin for ACT Framework. ## act-ebean vs act-ebean2 diff --git a/checkstyle.xml b/checkstyle.xml new file mode 100644 index 0000000..5bd34d5 --- /dev/null +++ b/checkstyle.xml @@ -0,0 +1,209 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index f7c2c5b..2e3c137 100755 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 @@ -93,31 +24,57 @@ 1.2.3-SNAPSHOT ACT Ebean - The Ebean Plugin for Actframework SQL database access + Provides SQL database access through Ebean ORM library (Java 8+) http://actframework.org/plugin/ebean + 2015 + + + ActFramework + http://actframework.org + + + + org.sonatype.oss + oss-parent + 7 + UTF-8 UTF-8 - git@github.com:actframework/act-ebean.git - 1.4.1 - 1.1.1 + 1.7 + 1.7 + git@github.com:actframework/act-ebean.git + + 2.17 + 3.7.0 + 3.0.0-M1 + 3.0.1 + + 1.4 + 8.1 + 2.7 + 2.1.1 + 1.13 + 1.4 + 2.8.2 + + 1.0.0-BETA-7 + 1.0.0-BETA-4 + 8.8.1 8.1.1 2.1.2 - 2.7.0 - - - org.sonatype.oss - oss-parent - 7 - + 1.4.11 + 1.1.2 + + - scm:git:${git.url} - scm:git:${git.url} - ${git.url} + scm:git:${scm.url} + scm:git:${scm.url} + ${scm.url} @@ -136,66 +93,137 @@ - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.3 - - 1.7 - 1.7 - - - - org.apache.maven.plugins - maven-source-plugin - 2.1.2 - - true - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9 - - src/etc/javadoc.css - - - - - gen-javadoc - prepare-package - - javadoc - - - - attach-javadocs - - jar - - - - - - + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + javac-with-errorprone + true + + + + org.codehaus.plexus + plexus-compiler-javac-errorprone + ${plexus-compiler-javac-errorprone.version} + + + + com.google.errorprone + error_prone_core + ${errorpone-core.version} + + + + + org.codehaus.mojo + cobertura-maven-plugin + ${cobertura-maven-plugin.version} + + + html + xml + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven-checkstyle-plugin.version} + + + com.puppycrawl.tools + checkstyle + ${checkstyle.version} + + + + true + checkstyle.xml + UTF-8 + true + true + + + + checkstyle + validate + + check + + + + + + org.codehaus.mojo + license-maven-plugin + ${license-maven-plugin.version} + + apache_v2 + false + + + + first + + update-file-header + + process-sources + + + src/main/java + src/test/java + + + **/README + src/test/resources/** + src/main/resources/** + + + + + + + org.codehaus.mojo + buildnumber-maven-plugin + ${buildnumber-maven-plugin.version} + + + validate + + create + + + + + 4 + + + + org.apache.maven.plugins + maven-source-plugin + ${maven-source-plugin.version} + + + attach-sources + + jar-no-fork + + + + + - junit - junit - 4.10 - test - - - - org.mockito - mockito-core - ${mockito-core.version} + org.osgl + osgl-ut + ${osgl-ut.version} test @@ -219,68 +247,58 @@ org.actframework - act - ${act.version} - provided + act-sql-common + ${act-sql-common.version} org.actframework - act-sql-common - ${act-sql-common.version} + act + ${act.version} + provided - dist + release org.apache.maven.plugins - maven-assembly-plugin - 2.2 + maven-javadoc-plugin + ${maven-javadoc-plugin.version} - - ${basedir}/assembly-dist.xml - - gnu + src/etc/javadoc.css + ch.raffael.mddoclet.MarkdownDoclet + + ch.raffael.markdown-doclet + markdown-doclet + ${markdown-doclet.version} + + true + + http://javax-inject.github.io/javax-inject/api/ + https://docs.oracle.com/javaee/7/api/ + - make-assembly - package + gen-javadoc + prepare-package - single + javadoc - - - ${basedir}/assembly-dist.xml - - - - - - org.apache.maven.plugins - maven-source-plugin - - attach-sources + attach-javadocs jar - - com.mycila.maven-license-plugin - maven-license-plugin - -
src/etc/header.txt
-
-
diff --git a/src/etc/javadoc.css b/src/etc/javadoc.css new file mode 100644 index 0000000..e951d01 --- /dev/null +++ b/src/etc/javadoc.css @@ -0,0 +1,622 @@ +@import url(highlight.css); + +body { + background-color:#222222; + color:#D2DECA; + font-family:'Roboto', 'San Francisco Text', 'Noto Sans', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif; + font-size:16px; + margin:0; +} +a:link, a:visited { + text-decoration:none; + color:#999; +} +a:hover, a:focus { + text-decoration:underline; +} +a:active { + text-decoration:none; + color:#999; +} +a[name] { + color:#D2DECA; +} +a[name]:hover { + text-decoration:none; + color:#D2DECA; +} +/*[MOD] +pre { + font-family:'Roboto Mono', 'Envy Code R', Consolas, Menlo, Monaco,monospace; + font-size:14px; +}*/ +h1 { + font-size:20px; +} +h2 { + font-size:18px; +} +h3 { + font-size:16px; + font-style:italic; +} +h4 { + font-size:13px; +} +h5 { + font-size:12px; +} +h6 { + font-size:11px; +} +ul { + list-style-type:disc; +} + +code, tt { + font-family:'Roboto Mono', 'Envy Code R', Consolas, Menlo, Monaco,monospace; + font-size:14px; + padding-top:4px; + margin-top:8px; + line-height:1.4em; +} +dt code { + font-family:'Roboto Mono', 'Envy Code R', Consolas, Menlo, Monaco,monospace; + font-size:14px; + padding-top:4px; +} +table tr td dt code { + font-family:'Roboto Mono', 'Envy Code R', Consolas, Menlo, Monaco,monospace; + font-size:14px; + vertical-align:top; + padding-top:4px; +} +sup { + font-size:8px; +} +/* +Document title and Copyright styles +*/ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:.8em; + z-index:200; + margin-top:-7px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#222222; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#999; +} +.tab { + background-color:#004F66; + color:#D0D0D0; + padding:8px; + width:5em; + font-weight:bold; +} +/* +Navigation bar styles +*/ +.bar { + background-color:#818487; + color:#080707; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:11px; + margin:0; +} +.topNav { + background-color:#818487; + color:#222222; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.bottomNav { + margin-top:10px; + background-color:#818487; + color:#222222; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.subNav { + background-color:#47494C; + float:left; + width:100%; + overflow:hidden; + font-size:12px; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; + text-transform:uppercase;/*???*/ +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding: 5px 6px; + text-transform:uppercase;/*???*/ +} +ul.subNavList li{ + list-style:none; + float:left; + font-size:90%;/*???*/ +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#222222; + text-decoration:none; + text-transform:uppercase;/*???*/ +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#999; + text-transform:uppercase;/*???*/ +} +.navBarCell1Rev { + background-color:#C2C2C2; + color:#253441; + margin: auto 5px; +} +.skipNav { + position:absolute; + top:auto; + left:-9999px; + overflow:hidden; +} +/* +Page header and footer styles +*/ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader span{ + margin-right:15px; +} +.indexHeader h1 { + font-size:13px; +} +.title { + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 15px 0; + padding:0; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:13px; +} +/* +Heading styles +*/ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#47494C; + border:none; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#47494C; + border:none; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:10px 0 10px 0; +} +/* +Page layout container styles +*/ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:14px; +} +.indexContainer h2 { + font-size:15px; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; + padding-top:2px; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:14px; + font-weight:bold; + margin:10px 0 0 0; + color:#e4e4e4; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:5px 0 10px 0px; + font-size:14px; + font-family:'DejaVu Sans Mono',monospace; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* +List styles +*/ +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:15px; + line-height:1.4; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #545454; + background-color:#282828; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#222222; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* +Table styles +*/ +.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary { + width:100%; + border-left:1px solid #333; + border-right:1px solid #333; + border-bottom:1px solid #333; +} +.overviewSummary, .memberSummary { + padding:0px; +} +.overviewSummary caption, .memberSummary caption, .typeSummary caption, +.useSummary caption, .constantsSummary caption, .deprecatedSummary caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#253441; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + padding-top:10px; + padding-left:1px; + margin:0px; + white-space:pre; +} +.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, +.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link, +.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, +.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover, +.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, +.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active, +.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, +.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited { + color:#222222; +} +.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, +.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + padding-bottom:7px; + display:inline-block; + float:left; + background-color:#C2C2C2; + border: none; + height:16px; +} +.memberSummary caption span.activeTableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#C2C2C2; + height:16px; +} +.memberSummary caption span.tableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#818487; + height:16px; +} +.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab { + padding-top:0px; + padding-left:0px; + padding-right:0px; + background-image:none; + float:none; + display:inline; +} +.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, +.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd { + display:none; + width:5px; + position:relative; + float:left; + background-color:#C2C2C2; +} +.memberSummary .activeTableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + float:left; + background-color:#C2C2C2; +} +.memberSummary .tableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + background-color:#818487; + float:left; + +} +.overviewSummary td, .memberSummary td, .typeSummary td, +.useSummary td, .constantsSummary td, .deprecatedSummary td { + text-align:left; + padding:0px 0px 12px 10px; + width:100%; +} +th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, +td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ + vertical-align:top; + padding-right:0px; + padding-top:8px; + padding-bottom:3px; +} +th.colFirst, th.colLast, th.colOne, .constantsSummary th { + background:#47494C; + text-align:left; + padding:8px 3px 3px 7px; +} +td.colFirst, th.colFirst { + white-space:nowrap; + font-size:13px; +} +td.colLast, th.colLast { + font-size:13px; +} +td.colOne, th.colOne { + font-size:13px; +} +.overviewSummary td.colFirst, .overviewSummary th.colFirst, +.overviewSummary td.colOne, .overviewSummary th.colOne, +.memberSummary td.colFirst, .memberSummary th.colFirst, +.memberSummary td.colOne, .memberSummary th.colOne, +.typeSummary td.colFirst{ + width:25%; + vertical-align:top; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +.tableSubHeadingColor { + background-color:#2F3131; +} +.altColor { + background-color:#222222; +} +.rowColor { + background-color:#2F3131; +} +/* +Content styles +*/ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} + +ul.blockList ul.blockList ul.blockList li.blockList h3 { + font-style:normal; +} + +div.block { + font-size:16px; + font-family:'Roboto', 'San Francisco Text', 'Noto Sans', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif; +} + +td.colLast div { + padding-top:0px; +} + + +td.colLast a { + padding-bottom:3px; +} +/* +Formatting effect styles +*/ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:10px; +} +.block { + display:block; + margin:3px 10px 2px 0px; + color:#E9E9e9; +} +.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink, +.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel, +.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink { + font-weight:bold; +} +.deprecationComment, .emphasizedPhrase, .interfaceName { + font-style:italic; +} + +div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase, +div.block div.block span.interfaceName { + font-style:normal; +} + +/* code block tweaks */ +code, tt { + font-size: 14px; +} +pre { + /* inspired by GitHub */ + padding: 0 5px; + border: solid 1px #888; + background: #888; + border-radius: none; +} +pre code { + background: none; +} +li.blockList > pre { + font-size: 16px; + padding: 0; + margin: 0; + background: 0; + border: 0; +} +div.summary code { + background: none; + border: 0; + padding: 0; +} + +/* @todo tag */ +div.todo { + display: block; + margin: 1em; + border: solid 1px black; + border-radius: 3px; +} +div.todoTitle { + display: block; + background: #f6f30d; + padding: 5px; + border-bottom: solid 1px black; +} +span.todoTitle { + font-weight: bold; +} +span.todoCounter { + float: right; + font-size: .8em; +} +div.todoText { + display: block; + padding: 5px; +} + +pre .comment, pre .annotation, pre .template_comment, pre .diff .header, pre .chunk, pre .markdown .blockquote { + color: #333 +} \ No newline at end of file diff --git a/src/main/java/act/db/ebean/EbeanAgentLoader.java b/src/main/java/act/db/ebean/EbeanAgentLoader.java index 51f3e6e..0f5361c 100644 --- a/src/main/java/act/db/ebean/EbeanAgentLoader.java +++ b/src/main/java/act/db/ebean/EbeanAgentLoader.java @@ -1,5 +1,25 @@ package act.db.ebean; +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2017 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import act.Act; import act.app.event.AppEventId; import act.sys.Env; diff --git a/src/main/java/act/db/ebean/EbeanConfigLoaded.java b/src/main/java/act/db/ebean/EbeanConfigLoaded.java index 7c761dc..8cb202d 100644 --- a/src/main/java/act/db/ebean/EbeanConfigLoaded.java +++ b/src/main/java/act/db/ebean/EbeanConfigLoaded.java @@ -1,5 +1,25 @@ package act.db.ebean; +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2017 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import act.event.ActEvent; import com.avaje.ebean.config.ServerConfig; diff --git a/src/main/java/act/db/ebean/EbeanDao.java b/src/main/java/act/db/ebean/EbeanDao.java index 122f2f2..76388b6 100644 --- a/src/main/java/act/db/ebean/EbeanDao.java +++ b/src/main/java/act/db/ebean/EbeanDao.java @@ -1,5 +1,27 @@ package act.db.ebean; +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2017 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + +import static act.Act.app; + import act.app.DbServiceManager; import act.db.DB; import act.db.DaoBase; @@ -16,15 +38,13 @@ import org.osgl.util.E; import org.osgl.util.S; -import javax.persistence.Id; -import javax.sql.DataSource; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.util.Collection; import java.util.Iterator; import java.util.List; - -import static act.Act.app; +import javax.persistence.Id; +import javax.sql.DataSource; @General @NoBind @@ -511,6 +531,7 @@ private void buildWhere(ExpressionList where, String key, Object val break; case 3: R2.valueOf(sa[2]).applyTo(where, sa[0], sa[1], val); + break; default: throw E.unexpected("Unknown where expression: %s", key); } diff --git a/src/main/java/act/db/ebean/EbeanDaoInjectionListener.java b/src/main/java/act/db/ebean/EbeanDaoInjectionListener.java index d56e881..ec72a79 100644 --- a/src/main/java/act/db/ebean/EbeanDaoInjectionListener.java +++ b/src/main/java/act/db/ebean/EbeanDaoInjectionListener.java @@ -1,5 +1,25 @@ package act.db.ebean; +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2017 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import act.Act; import act.app.App; import act.app.event.AppEventId; diff --git a/src/main/java/act/db/ebean/EbeanModelBase.java b/src/main/java/act/db/ebean/EbeanModelBase.java index a11cf7b..ce61b8b 100644 --- a/src/main/java/act/db/ebean/EbeanModelBase.java +++ b/src/main/java/act/db/ebean/EbeanModelBase.java @@ -1,5 +1,25 @@ package act.db.ebean; +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2017 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import act.app.App; import act.db.Dao; import act.db.Model; diff --git a/src/main/java/act/db/ebean/EbeanModule.java b/src/main/java/act/db/ebean/EbeanModule.java index 827cf6b..4e0e0ca 100644 --- a/src/main/java/act/db/ebean/EbeanModule.java +++ b/src/main/java/act/db/ebean/EbeanModule.java @@ -1,5 +1,25 @@ package act.db.ebean; +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2017 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import act.db.ebean.util.EbeanDaoLoader; import org.osgl.inject.Module; diff --git a/src/main/java/act/db/ebean/EbeanPlugin.java b/src/main/java/act/db/ebean/EbeanPlugin.java index 1c5de21..8576607 100644 --- a/src/main/java/act/db/ebean/EbeanPlugin.java +++ b/src/main/java/act/db/ebean/EbeanPlugin.java @@ -1,13 +1,37 @@ package act.db.ebean; +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2017 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import act.app.App; import act.db.DbPlugin; import act.db.DbService; import act.inject.param.ParamValueLoaderService; +import org.osgl.bootstrap.Version; import java.util.Map; public class EbeanPlugin extends DbPlugin { + + public static final Version VERSION = Version.of(EbeanPlugin.class); + @Override public DbService initDbService(String id, App app, Map conf) { ParamValueLoaderService.waiveFields("_ebean_intercept", "_ebean_identity"); diff --git a/src/main/java/act/db/ebean/EbeanQuery.java b/src/main/java/act/db/ebean/EbeanQuery.java index 0f9adbb..fb0fc69 100644 --- a/src/main/java/act/db/ebean/EbeanQuery.java +++ b/src/main/java/act/db/ebean/EbeanQuery.java @@ -1,5 +1,25 @@ package act.db.ebean; +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2017 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import act.db.Dao; import com.avaje.ebean.*; import org.osgl.$; @@ -136,12 +156,12 @@ public Query fetchLazy(String path, String fetchProperties) { @Override public Query fetchQuery(String path) { - return fetchQuery(path); + return q.fetchQuery(path); } @Override public Query fetchLazy(String path) { - return fetchLazy(path); + return q.fetchLazy(path); } @Override diff --git a/src/main/java/act/db/ebean/EbeanService.java b/src/main/java/act/db/ebean/EbeanService.java index bf00a3e..f7d2258 100644 --- a/src/main/java/act/db/ebean/EbeanService.java +++ b/src/main/java/act/db/ebean/EbeanService.java @@ -1,5 +1,27 @@ package act.db.ebean; +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2017 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + +import static act.app.event.AppEventId.PRE_LOAD_CLASSES; + import act.Act; import act.app.App; import act.conf.AppConfigKey; @@ -12,25 +34,22 @@ import com.avaje.ebean.EbeanServerFactory; import com.avaje.ebean.config.ServerConfig; import org.osgl.$; -import org.osgl.logging.LogManager; -import org.osgl.logging.Logger; +import org.osgl.bootstrap.Version; import org.osgl.util.E; import org.osgl.util.S; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.sql.DataSource; import java.lang.annotation.Annotation; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.EventObject; import java.util.Map; - -import static act.app.event.AppEventId.PRE_LOAD_CLASSES; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.sql.DataSource; public final class EbeanService extends SqlDbService { - private final Logger LOGGER = LogManager.get(EbeanService.class); + public static final Version VERSION = EbeanPlugin.VERSION; // the ebean service instance private EbeanServer ebean; @@ -42,8 +61,8 @@ public EbeanService(final String dbId, final App app, final Map String s = config.get("agentPackage"); final String agentPackage = null == s ? S.string(app().config().get(AppConfigKey.SCAN_PACKAGE)) : S.string(s).trim(); E.invalidConfigurationIf(S.blank(agentPackage), "\"agentPackage\" not configured"); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("\"agentPackage\" configured: %s", agentPackage); + if (isTraceEnabled()) { + trace("\"agentPackage\" configured: %s", agentPackage); } app.eventBus().bind(PRE_LOAD_CLASSES, new AppEventListenerBase(S.concat(dbId, "-ebean-pre-cl")) { @Override @@ -53,7 +72,7 @@ public void on(EventObject event) { .append(agentPackage) .toString(); if (!EbeanAgentLoader.loadAgentFromClasspath("ebean-agent", s)) { - LOGGER.warn("ebean-agent not found in classpath - not dynamically loaded"); + warn("ebean-agent not found in classpath - not dynamically loaded"); } } }); @@ -84,8 +103,8 @@ protected DataSource createDataSource() { protected void releaseResources() { if (null != ebean) { ebean.shutdown(true, false); - if (_logger.isDebugEnabled()) { - _logger.debug("ebean shutdown: %s", id()); + if (isDebugEnabled()) { + debug("ebean shutdown: %s", id()); } ebean = null; ebeanConfig = null; diff --git a/src/main/java/act/db/ebean/ModelBaseEnhancer.java b/src/main/java/act/db/ebean/ModelBaseEnhancer.java index a7b96e1..dceeafc 100644 --- a/src/main/java/act/db/ebean/ModelBaseEnhancer.java +++ b/src/main/java/act/db/ebean/ModelBaseEnhancer.java @@ -1,5 +1,25 @@ package act.db.ebean; +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2017 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import act.asm.AnnotationVisitor; import act.asm.Type; import act.util.AppByteCodeEnhancer; diff --git a/src/main/java/act/db/ebean/PreEbeanCreation.java b/src/main/java/act/db/ebean/PreEbeanCreation.java index e9b5a3d..5e2dcf3 100644 --- a/src/main/java/act/db/ebean/PreEbeanCreation.java +++ b/src/main/java/act/db/ebean/PreEbeanCreation.java @@ -1,5 +1,25 @@ package act.db.ebean; +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2017 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import act.event.ActEvent; import com.avaje.ebean.config.ServerConfig; diff --git a/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java b/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java index 7b9c164..e16c85b 100644 --- a/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java +++ b/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java @@ -1,5 +1,25 @@ package act.db.ebean.util; +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2017 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import act.db.sql.SqlDbService; import act.db.sql.SqlDbServiceConfig; import com.avaje.ebean.config.MatchingNamingConvention; diff --git a/src/main/java/act/db/ebean/util/EbeanDaoLoader.java b/src/main/java/act/db/ebean/util/EbeanDaoLoader.java index 1e5575c..11e88e7 100644 --- a/src/main/java/act/db/ebean/util/EbeanDaoLoader.java +++ b/src/main/java/act/db/ebean/util/EbeanDaoLoader.java @@ -1,5 +1,25 @@ package act.db.ebean.util; +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2017 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import act.app.App; import act.app.DbServiceManager; import act.db.ebean.EbeanDao; diff --git a/src/main/java/act/db/jpa/EntityFinder.java b/src/main/java/act/db/jpa/EntityFinder.java index 2cb31fd..7036c07 100644 --- a/src/main/java/act/db/jpa/EntityFinder.java +++ b/src/main/java/act/db/jpa/EntityFinder.java @@ -1,5 +1,25 @@ package act.db.jpa; +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2017 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import act.db.EntityClassRepository; import act.util.AnnotatedClassFinder; import org.osgl.$; diff --git a/src/main/resources/act/db/ebean/.version b/src/main/resources/act/db/ebean/.version new file mode 100644 index 0000000..ea0c261 --- /dev/null +++ b/src/main/resources/act/db/ebean/.version @@ -0,0 +1,3 @@ +artifact=${project.artifactId} +version=${project.version} +build=${buildNumber} \ No newline at end of file diff --git a/src/test/java/act/db/ebean/VersionTest.java b/src/test/java/act/db/ebean/VersionTest.java new file mode 100644 index 0000000..70f83b0 --- /dev/null +++ b/src/test/java/act/db/ebean/VersionTest.java @@ -0,0 +1,13 @@ +package act.db.ebean; + +import org.junit.Test; +import org.osgl.ut.TestBase; + +public class VersionTest extends TestBase { + + @Test + public void versionShallContainsEbean() { + yes(EbeanPlugin.VERSION.toString().contains("ebean")); + } + +} diff --git a/src/test/java/playground/Contact.java b/src/test/java/playground/Contact.java index 8486ccd..16b065f 100644 --- a/src/test/java/playground/Contact.java +++ b/src/test/java/playground/Contact.java @@ -1,5 +1,25 @@ package playground; +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2017 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import javax.persistence.Entity; import javax.persistence.Id; diff --git a/src/test/java/playground/ContactService.java b/src/test/java/playground/ContactService.java index 33a4fa2..d221d6f 100644 --- a/src/test/java/playground/ContactService.java +++ b/src/test/java/playground/ContactService.java @@ -1,5 +1,25 @@ package playground; +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2017 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import act.db.ebean.EbeanDao; import java.lang.reflect.Field; From d0bc61f6bfcb7b4e6d232104cf92e9c472b7cf49 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 10 Sep 2017 19:29:15 +1000 Subject: [PATCH 034/114] enable codecov --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 13c782f..76497e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: java sudo: false # faster builds -#script: "mvn cobertura:cobertura" -# -#after_success: -# - bash <(curl -s https://codecov.io/bash) \ No newline at end of file +script: "mvn cobertura:cobertura" + +after_success: + - bash <(curl -s https://codecov.io/bash) \ No newline at end of file From c9de23d460dc08df4e66c86ffabd123ea9479675 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 10 Sep 2017 19:30:11 +1000 Subject: [PATCH 035/114] minor update in pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2e3c137..0924f8a 100755 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ 1.2.3-SNAPSHOT ACT Ebean - Provides SQL database access through Ebean ORM library (Java 8+) + Provides SQL database access through Ebean ORM library (java 7+) http://actframework.org/plugin/ebean 2015 From a9144b98368e0bf6eb68f0df5c376be4989bcdc2 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 10 Sep 2017 19:30:53 +1000 Subject: [PATCH 036/114] [maven-release-plugin] prepare release act-ebean-1.2.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0924f8a..ab268ab 100755 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.actframework act-ebean jar - 1.2.3-SNAPSHOT + 1.2.3 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 02ff3b11e35c9c9abf50489fd873ee30a67f93f1 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 10 Sep 2017 19:31:03 +1000 Subject: [PATCH 037/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ab268ab..cdfc7fe 100755 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.actframework act-ebean jar - 1.2.3 + 1.2.4-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From da2d03dd18252b3f12a8c72d6f3900a945c48fee Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 17 Dec 2017 22:26:08 +1100 Subject: [PATCH 038/114] update to act-1.6 --- pom.xml | 6 +++--- src/main/java/act/db/ebean/EbeanDao.java | 10 ++++++++++ src/main/java/act/db/ebean/EbeanService.java | 2 +- src/test/java/act/db/ebean/VersionTest.java | 20 ++++++++++++++++++++ 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index cdfc7fe..4775aab 100755 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.actframework act-ebean jar - 1.2.4-SNAPSHOT + 1.3.0-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) @@ -66,8 +66,8 @@ 8.1.1 2.1.2 - 1.4.11 - 1.1.2 + 1.6.0-SNAPSHOT + 1.2.0-SNAPSHOT diff --git a/src/main/java/act/db/ebean/EbeanDao.java b/src/main/java/act/db/ebean/EbeanDao.java index 76388b6..daa3394 100644 --- a/src/main/java/act/db/ebean/EbeanDao.java +++ b/src/main/java/act/db/ebean/EbeanDao.java @@ -195,6 +195,16 @@ public List findAllAsList() { return q().findList(); } + @Override + public MODEL_TYPE findLatest() { + throw E.unsupport(); + } + + @Override + public MODEL_TYPE findLastModified() { + throw E.unsupport(); + } + @Override public MODEL_TYPE reload(MODEL_TYPE entity) { ebean().refresh(entity); diff --git a/src/main/java/act/db/ebean/EbeanService.java b/src/main/java/act/db/ebean/EbeanService.java index f7d2258..35d43da 100644 --- a/src/main/java/act/db/ebean/EbeanService.java +++ b/src/main/java/act/db/ebean/EbeanService.java @@ -59,7 +59,7 @@ public final class EbeanService extends SqlDbService { public EbeanService(final String dbId, final App app, final Map config) { super(dbId, app, config); String s = config.get("agentPackage"); - final String agentPackage = null == s ? S.string(app().config().get(AppConfigKey.SCAN_PACKAGE)) : S.string(s).trim(); + final String agentPackage = null == s ? S.string(app().config().get(AppConfigKey.SCAN_PACKAGE, null)) : S.string(s).trim(); E.invalidConfigurationIf(S.blank(agentPackage), "\"agentPackage\" not configured"); if (isTraceEnabled()) { trace("\"agentPackage\" configured: %s", agentPackage); diff --git a/src/test/java/act/db/ebean/VersionTest.java b/src/test/java/act/db/ebean/VersionTest.java index 70f83b0..95f2c29 100644 --- a/src/test/java/act/db/ebean/VersionTest.java +++ b/src/test/java/act/db/ebean/VersionTest.java @@ -1,5 +1,25 @@ package act.db.ebean; +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2017 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import org.junit.Test; import org.osgl.ut.TestBase; From f8ec2aaa6668a4dd131b560cadeadc70dbc66190 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Wed, 20 Dec 2017 13:39:57 +1100 Subject: [PATCH 039/114] apply new build system --- pom.xml | 221 +------------------ src/main/java/act/db/ebean/EbeanPlugin.java | 2 +- src/main/java/act/db/ebean/EbeanService.java | 2 +- src/test/java/act/db/ebean/VersionTest.java | 2 +- 4 files changed, 7 insertions(+), 220 deletions(-) diff --git a/pom.xml b/pom.xml index 4775aab..06c9499 100755 --- a/pom.xml +++ b/pom.xml @@ -34,40 +34,19 @@ - org.sonatype.oss - oss-parent - 7 + org.actframework + parent + 1.6.0-RC1 - UTF-8 - UTF-8 - 1.7 - 1.7 git@github.com:actframework/act-ebean.git - 2.17 - 3.7.0 - 3.0.0-M1 - 3.0.1 - - 1.4 - 8.1 - 2.7 - 2.1.1 - 1.13 - 1.4 - 2.8.2 - - 1.0.0-BETA-7 - 1.0.0-BETA-4 - 8.8.1 8.1.1 2.1.2 - 1.6.0-SNAPSHOT - 1.2.0-SNAPSHOT + 1.2.0-RC1 @@ -77,156 +56,8 @@ ${scm.url} - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - - - src/main/resources - true - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - javac-with-errorprone - true - - - - org.codehaus.plexus - plexus-compiler-javac-errorprone - ${plexus-compiler-javac-errorprone.version} - - - - com.google.errorprone - error_prone_core - ${errorpone-core.version} - - - - - org.codehaus.mojo - cobertura-maven-plugin - ${cobertura-maven-plugin.version} - - - html - xml - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - ${maven-checkstyle-plugin.version} - - - com.puppycrawl.tools - checkstyle - ${checkstyle.version} - - - - true - checkstyle.xml - UTF-8 - true - true - - - - checkstyle - validate - - check - - - - - - org.codehaus.mojo - license-maven-plugin - ${license-maven-plugin.version} - - apache_v2 - false - - - - first - - update-file-header - - process-sources - - - src/main/java - src/test/java - - - **/README - src/test/resources/** - src/main/resources/** - - - - - - - org.codehaus.mojo - buildnumber-maven-plugin - ${buildnumber-maven-plugin.version} - - - validate - - create - - - - - 4 - - - - org.apache.maven.plugins - maven-source-plugin - ${maven-source-plugin.version} - - - attach-sources - - jar-no-fork - - - - - - - - - org.osgl - osgl-ut - ${osgl-ut.version} - test - - org.avaje.ebean ebean @@ -260,48 +91,4 @@ - - - release - - - - org.apache.maven.plugins - maven-javadoc-plugin - ${maven-javadoc-plugin.version} - - src/etc/javadoc.css - ch.raffael.mddoclet.MarkdownDoclet - - ch.raffael.markdown-doclet - markdown-doclet - ${markdown-doclet.version} - - true - - http://javax-inject.github.io/javax-inject/api/ - https://docs.oracle.com/javaee/7/api/ - - - - - gen-javadoc - prepare-package - - javadoc - - - - attach-javadocs - - jar - - - - - - - - -
diff --git a/src/main/java/act/db/ebean/EbeanPlugin.java b/src/main/java/act/db/ebean/EbeanPlugin.java index 8576607..2f6540f 100644 --- a/src/main/java/act/db/ebean/EbeanPlugin.java +++ b/src/main/java/act/db/ebean/EbeanPlugin.java @@ -24,7 +24,7 @@ import act.db.DbPlugin; import act.db.DbService; import act.inject.param.ParamValueLoaderService; -import org.osgl.bootstrap.Version; +import osgl.version.Version; import java.util.Map; diff --git a/src/main/java/act/db/ebean/EbeanService.java b/src/main/java/act/db/ebean/EbeanService.java index 35d43da..65cf81d 100644 --- a/src/main/java/act/db/ebean/EbeanService.java +++ b/src/main/java/act/db/ebean/EbeanService.java @@ -34,9 +34,9 @@ import com.avaje.ebean.EbeanServerFactory; import com.avaje.ebean.config.ServerConfig; import org.osgl.$; -import org.osgl.bootstrap.Version; import org.osgl.util.E; import org.osgl.util.S; +import osgl.version.Version; import java.lang.annotation.Annotation; import java.lang.reflect.ParameterizedType; diff --git a/src/test/java/act/db/ebean/VersionTest.java b/src/test/java/act/db/ebean/VersionTest.java index 95f2c29..6902457 100644 --- a/src/test/java/act/db/ebean/VersionTest.java +++ b/src/test/java/act/db/ebean/VersionTest.java @@ -21,7 +21,7 @@ */ import org.junit.Test; -import org.osgl.ut.TestBase; +import osgl.ut.TestBase; public class VersionTest extends TestBase { From b69a731d89149952de3a49ebc45197b02fad2fcb Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Wed, 20 Dec 2017 13:43:45 +1100 Subject: [PATCH 040/114] [maven-release-plugin] prepare release act-ebean-1.3.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 06c9499..09430a5 100755 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.actframework act-ebean jar - 1.3.0-SNAPSHOT + 1.3.0 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From ef14f49451b68606b7e598778a6ab04d3d5fba41 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Wed, 20 Dec 2017 13:43:54 +1100 Subject: [PATCH 041/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 09430a5..2e7a0c8 100755 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.actframework act-ebean jar - 1.3.0 + 1.3.1-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 43c9108367d4d0ad25fda806bcfe67c317a4734a Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Thu, 11 Jan 2018 19:45:03 +1100 Subject: [PATCH 042/114] update to act-1.6.2; add BindOn annotation to EbeanConfigLoaded to allow early binding of event listeners --- CHANGELOG.md | 7 +++++++ pom.xml | 4 ++-- src/main/java/act/db/ebean/EbeanConfigLoaded.java | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af66719..82eaf8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # act-ebean CHANGE LOG +1.3.1 - 11/Jan/2018 +* update to act-1.6.2 +* add `@BindOn` annotation to `EbeanConfigLoaded` event class to allow early bind of event listeners + +1.3.0 - 28/Dec/2017 +* update to act-1.6.0 + 1.2.3 * update to act-1.4.11, act-sql-common-1.1.1 * apply oslg-bootstrap version mechanism diff --git a/pom.xml b/pom.xml index 2e7a0c8..5a96e7f 100755 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ org.actframework parent - 1.6.0-RC1 + 1.6.2 @@ -46,7 +46,7 @@ 8.1.1 2.1.2 - 1.2.0-RC1 + 1.2.0 diff --git a/src/main/java/act/db/ebean/EbeanConfigLoaded.java b/src/main/java/act/db/ebean/EbeanConfigLoaded.java index 8cb202d..ab83976 100644 --- a/src/main/java/act/db/ebean/EbeanConfigLoaded.java +++ b/src/main/java/act/db/ebean/EbeanConfigLoaded.java @@ -20,7 +20,10 @@ * #L% */ +import static act.app.event.AppEventId.DEPENDENCY_INJECTOR_PROVISIONED; + import act.event.ActEvent; +import act.event.BindOn; import com.avaje.ebean.config.ServerConfig; /** @@ -30,6 +33,7 @@ * Application can use this event to do further configuration on * {@link ServerConfig} */ +@BindOn(DEPENDENCY_INJECTOR_PROVISIONED) public class EbeanConfigLoaded extends ActEvent { public EbeanConfigLoaded(ServerConfig source) { super(source); From a924e0d648101f90348abb713fd2a96ca53dccf6 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Thu, 11 Jan 2018 19:45:32 +1100 Subject: [PATCH 043/114] [maven-release-plugin] prepare release act-ebean-1.3.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5a96e7f..5fc5e30 100755 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.actframework act-ebean jar - 1.3.1-SNAPSHOT + 1.3.1 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 3dcbe9686c1e8212ce95765df288aa9e6b47a4a2 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Thu, 11 Jan 2018 19:45:42 +1100 Subject: [PATCH 044/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5fc5e30..240f2aa 100755 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.actframework act-ebean jar - 1.3.1 + 1.3.2-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 96a54462e2dd7b4591dd9d363d7bf308a250290f Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 23 Jan 2018 11:26:58 +1100 Subject: [PATCH 045/114] update to act-1.6.5; update to act-sql-common-1.2.1 --- CHANGELOG.md | 4 ++++ pom.xml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82eaf8c..d63b870 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # act-ebean CHANGE LOG +1.3.2 - 23/Jan/2018 +* update to act-1.6.5 +* update act-sql-common to 1.2.1 + 1.3.1 - 11/Jan/2018 * update to act-1.6.2 * add `@BindOn` annotation to `EbeanConfigLoaded` event class to allow early bind of event listeners diff --git a/pom.xml b/pom.xml index 240f2aa..8a641cb 100755 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ org.actframework parent - 1.6.2 + 1.6.5 @@ -46,7 +46,7 @@ 8.1.1 2.1.2 - 1.2.0 + 1.2.1 From 6fae761c1daa5f8098088c6f7b2acacf17cb7345 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 23 Jan 2018 11:27:28 +1100 Subject: [PATCH 046/114] [maven-release-plugin] prepare release act-ebean-1.3.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8a641cb..b671644 100755 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.actframework act-ebean jar - 1.3.2-SNAPSHOT + 1.3.2 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From c13724051b6f16b60b119281f9c1b666bd037023 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 23 Jan 2018 11:27:38 +1100 Subject: [PATCH 047/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b671644..164faae 100755 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.actframework act-ebean jar - 1.3.2 + 1.3.3-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From df7f2ece24870afb71bfff85fb236c677060e957 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Mon, 19 Feb 2018 22:08:57 +1100 Subject: [PATCH 048/114] update to act-1.7.0, act-sql-common-1.3.0; support act Tx framework --- CHANGELOG.md | 4 ++ pom.xml | 7 ++- .../java/act/db/ebean/EbeanAgentLoader.java | 4 +- .../java/act/db/ebean/EbeanConfigLoaded.java | 2 +- .../db/ebean/EbeanDaoInjectionListener.java | 6 +-- src/main/java/act/db/ebean/EbeanPlugin.java | 45 ++++++++++++++++ src/main/java/act/db/ebean/EbeanService.java | 8 +-- .../act/db/ebean/util/EbeanConfigAdaptor.java | 8 +-- src/main/java/act/db/jpa/EntityFinder.java | 52 ------------------- 9 files changed, 67 insertions(+), 69 deletions(-) delete mode 100644 src/main/java/act/db/jpa/EntityFinder.java diff --git a/CHANGELOG.md b/CHANGELOG.md index d63b870..07c4171 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # act-ebean CHANGE LOG +1.4.0 - 19/Feb/2018 +* update to act-1.7.0 +* update to act-sql-common-1.3.0 + 1.3.2 - 23/Jan/2018 * update to act-1.6.5 * update act-sql-common to 1.2.1 diff --git a/pom.xml b/pom.xml index 164faae..dc88fab 100755 --- a/pom.xml +++ b/pom.xml @@ -18,10 +18,9 @@ 4.0.0 - org.actframework act-ebean jar - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) @@ -36,7 +35,7 @@ org.actframework parent - 1.6.5 + 1.7.0 @@ -46,7 +45,7 @@ 8.1.1 2.1.2 - 1.2.1 + 1.3.0 diff --git a/src/main/java/act/db/ebean/EbeanAgentLoader.java b/src/main/java/act/db/ebean/EbeanAgentLoader.java index 0f5361c..24ef773 100644 --- a/src/main/java/act/db/ebean/EbeanAgentLoader.java +++ b/src/main/java/act/db/ebean/EbeanAgentLoader.java @@ -21,7 +21,7 @@ */ import act.Act; -import act.app.event.AppEventId; +import act.app.event.SysEventId; import act.sys.Env; import com.sun.tools.attach.AttachNotSupportedException; import com.sun.tools.attach.VirtualMachine; @@ -103,7 +103,7 @@ public static void loadAgent(String jarFilePath, String params) { } } finally { // ensure ebean2 EnhanceContext logout set to dump output - Act.jobManager().on(AppEventId.CLASS_LOADER_INITIALIZED, new Runnable() { + Act.jobManager().on(SysEventId.CLASS_LOADER_INITIALIZED, new Runnable() { @Override public void run() { System.setOut(ps); diff --git a/src/main/java/act/db/ebean/EbeanConfigLoaded.java b/src/main/java/act/db/ebean/EbeanConfigLoaded.java index ab83976..24d36c2 100644 --- a/src/main/java/act/db/ebean/EbeanConfigLoaded.java +++ b/src/main/java/act/db/ebean/EbeanConfigLoaded.java @@ -20,7 +20,7 @@ * #L% */ -import static act.app.event.AppEventId.DEPENDENCY_INJECTOR_PROVISIONED; +import static act.app.event.SysEventId.DEPENDENCY_INJECTOR_PROVISIONED; import act.event.ActEvent; import act.event.BindOn; diff --git a/src/main/java/act/db/ebean/EbeanDaoInjectionListener.java b/src/main/java/act/db/ebean/EbeanDaoInjectionListener.java index ec72a79..66d14fa 100644 --- a/src/main/java/act/db/ebean/EbeanDaoInjectionListener.java +++ b/src/main/java/act/db/ebean/EbeanDaoInjectionListener.java @@ -22,10 +22,10 @@ import act.Act; import act.app.App; -import act.app.event.AppEventId; +import act.app.event.SysEventId; import act.db.DbService; import act.db.di.DaoInjectionListenerBase; -import act.event.AppEventListenerBase; +import act.event.SysEventListenerBase; import org.osgl.$; import org.osgl.inject.BeanSpec; import org.osgl.util.Generics; @@ -59,7 +59,7 @@ public void onInjection(Object injectee, BeanSpec spec) { DbService dbService = App.instance().dbServiceManager().dbService(resolved._2); if (dbService instanceof EbeanService) { final EbeanService service = $.cast(dbService); - Act.eventBus().bind(AppEventId.DB_SVC_LOADED, new AppEventListenerBase() { + Act.eventBus().bind(SysEventId.DB_SVC_LOADED, new SysEventListenerBase() { @Override public void on(EventObject eventObject) throws Exception { dao.ebean(service.ebean()); diff --git a/src/main/java/act/db/ebean/EbeanPlugin.java b/src/main/java/act/db/ebean/EbeanPlugin.java index 2f6540f..845545f 100644 --- a/src/main/java/act/db/ebean/EbeanPlugin.java +++ b/src/main/java/act/db/ebean/EbeanPlugin.java @@ -21,17 +21,62 @@ */ import act.app.App; +import act.asm.Opcodes; import act.db.DbPlugin; import act.db.DbService; +import act.db.sql.tx.TxError; +import act.db.sql.tx.TxInfo; +import act.db.sql.tx.TxStart; +import act.db.sql.tx.TxStop; +import act.event.ActEventListenerBase; import act.inject.param.ParamValueLoaderService; +import com.avaje.ebean.TxScope; +import com.avaje.ebeaninternal.api.HelpScopeTrans; +import com.avaje.ebeaninternal.api.ScopeTrans; import osgl.version.Version; +import java.util.EventObject; import java.util.Map; public class EbeanPlugin extends DbPlugin { public static final Version VERSION = Version.of(EbeanPlugin.class); + private static final ThreadLocal txHolder = new ThreadLocal<>(); + + @Override + protected void applyTo(App app) { + super.applyTo(app); + app.eventBus().bind(TxStart.class, new ActEventListenerBase() { + @Override + public void on(TxStart eventObject) { + TxInfo info = eventObject.source(); + TxScope scope = new TxScope(); + scope.setReadOnly(info.readOnly()); + ScopeTrans tx = HelpScopeTrans.createScopeTrans(scope); + txHolder.set(tx); + } + }).bind(TxStop.class, new ActEventListenerBase() { + @Override + public void on(EventObject eventObject) throws Exception { + ScopeTrans tx = txHolder.get(); + if (null != tx) { + tx.onExit(null, 1); + } + } + }).bind(TxError.class, new ActEventListenerBase() { + @Override + public void on(TxError eventObject) throws Exception { + ScopeTrans tx = txHolder.get(); + if (null != tx) { + Throwable cause = eventObject.source(); + tx.onExit(cause, Opcodes.ATHROW); + } + } + }); + + } + @Override public DbService initDbService(String id, App app, Map conf) { ParamValueLoaderService.waiveFields("_ebean_intercept", "_ebean_identity"); diff --git a/src/main/java/act/db/ebean/EbeanService.java b/src/main/java/act/db/ebean/EbeanService.java index 65cf81d..8beea60 100644 --- a/src/main/java/act/db/ebean/EbeanService.java +++ b/src/main/java/act/db/ebean/EbeanService.java @@ -20,7 +20,7 @@ * #L% */ -import static act.app.event.AppEventId.PRE_LOAD_CLASSES; +import static act.app.event.SysEventId.PRE_LOAD_CLASSES; import act.Act; import act.app.App; @@ -29,7 +29,7 @@ import act.db.ebean.util.EbeanConfigAdaptor; import act.db.sql.DataSourceConfig; import act.db.sql.SqlDbService; -import act.event.AppEventListenerBase; +import act.event.SysEventListenerBase; import com.avaje.ebean.EbeanServer; import com.avaje.ebean.EbeanServerFactory; import com.avaje.ebean.config.ServerConfig; @@ -37,6 +37,7 @@ import org.osgl.util.E; import org.osgl.util.S; import osgl.version.Version; +import osgl.version.Versioned; import java.lang.annotation.Annotation; import java.lang.reflect.ParameterizedType; @@ -47,6 +48,7 @@ import javax.persistence.Id; import javax.sql.DataSource; +@Versioned public final class EbeanService extends SqlDbService { public static final Version VERSION = EbeanPlugin.VERSION; @@ -64,7 +66,7 @@ public EbeanService(final String dbId, final App app, final Map if (isTraceEnabled()) { trace("\"agentPackage\" configured: %s", agentPackage); } - app.eventBus().bind(PRE_LOAD_CLASSES, new AppEventListenerBase(S.concat(dbId, "-ebean-pre-cl")) { + app.eventBus().bind(PRE_LOAD_CLASSES, new SysEventListenerBase(S.concat(dbId, "-ebean-pre-cl")) { @Override public void on(EventObject event) { String s = S.buffer("debug=").append(Act.isDev() ? "1" : "0") diff --git a/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java b/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java index e16c85b..2026830 100644 --- a/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java +++ b/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java @@ -20,6 +20,8 @@ * #L% */ +import static act.db.sql.util.NamingConvention.Default.MATCHING; + import act.db.sql.SqlDbService; import act.db.sql.SqlDbServiceConfig; import com.avaje.ebean.config.MatchingNamingConvention; @@ -31,11 +33,9 @@ import org.osgl.logging.Logger; import org.osgl.util.S; -import javax.inject.Singleton; import java.util.Properties; import java.util.Set; - -import static act.db.sql.util.NamingConvention.Default.MATCHING; +import javax.inject.Singleton; /** * Adapt {@link act.db.sql.SqlDbServiceConfig} to {@link ServerConfig} @@ -57,7 +57,7 @@ public ServerConfig adaptFrom(SqlDbServiceConfig actConfig, act.db.sql.DataSourc config.setNamingConvention(namingConvention(actConfig)); - Set modelClasses = svc.modelClasses(); + Set modelClasses = svc.entityClasses(); if (null != modelClasses && !modelClasses.isEmpty()) { for (Class modelClass : modelClasses) { if (LOGGER.isTraceEnabled()) { diff --git a/src/main/java/act/db/jpa/EntityFinder.java b/src/main/java/act/db/jpa/EntityFinder.java deleted file mode 100644 index 7036c07..0000000 --- a/src/main/java/act/db/jpa/EntityFinder.java +++ /dev/null @@ -1,52 +0,0 @@ -package act.db.jpa; - -/*- - * #%L - * ACT Ebean - * %% - * Copyright (C) 2015 - 2017 ActFramework - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - -import act.db.EntityClassRepository; -import act.util.AnnotatedClassFinder; -import org.osgl.$; - -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.persistence.Entity; -import javax.persistence.Table; - -@Singleton -public final class EntityFinder { - - private final EntityClassRepository repo; - - @Inject - public EntityFinder(EntityClassRepository repo) { - this.repo = $.notNull(repo); - } - - @AnnotatedClassFinder(Entity.class) - public void foundEntity(Class entityClass) { - repo.registerModelClass(entityClass); - } - - @AnnotatedClassFinder(Table.class) - public void foundTable(Class tableClass) { - repo.registerModelClass(tableClass); - } - -} From cca304bb7a3a18bdd6d925f84de91736e3003974 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Mon, 19 Feb 2018 22:09:30 +1100 Subject: [PATCH 049/114] [maven-release-plugin] prepare release act-ebean-1.4.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dc88fab..7cfc0a9 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean jar - 1.4.0-SNAPSHOT + 1.4.0 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From adec8e9111ae58f6a2e48d08fb6ebee42a7237f6 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Mon, 19 Feb 2018 22:09:42 +1100 Subject: [PATCH 050/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7cfc0a9..0ec8ddb 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean jar - 1.4.0 + 1.4.1-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From f6cfa7e982109ff6e44cf47792a779f6c8b1580d Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 4 Mar 2018 21:07:03 +1100 Subject: [PATCH 051/114] update to act-1.8;catch ebean2 change: Support act timestamp annotation #19 --- CHANGELOG.md | 4 + pom.xml | 4 +- .../ebean/util/TimestampAuditorEnhancer.java | 99 +++++++++++++++++++ 3 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 src/main/java/act/db/ebean/util/TimestampAuditorEnhancer.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 07c4171..721e631 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # act-ebean CHANGE LOG +1.5.0 +* update to act-1.8.0 +* catch ebean2 change: Support act timestamp annotation #19 + 1.4.0 - 19/Feb/2018 * update to act-1.7.0 * update to act-sql-common-1.3.0 diff --git a/pom.xml b/pom.xml index 0ec8ddb..6081e31 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean jar - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) @@ -35,7 +35,7 @@ org.actframework parent - 1.7.0 + 1.8.0 diff --git a/src/main/java/act/db/ebean/util/TimestampAuditorEnhancer.java b/src/main/java/act/db/ebean/util/TimestampAuditorEnhancer.java new file mode 100644 index 0000000..e18dfc4 --- /dev/null +++ b/src/main/java/act/db/ebean/util/TimestampAuditorEnhancer.java @@ -0,0 +1,99 @@ +package act.db.ebean.util; + +/*- + * #%L + * ACT Ebean2 + * %% + * Copyright (C) 2015 - 2018 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + +import act.app.App; +import act.asm.AnnotationVisitor; +import act.asm.FieldVisitor; +import act.asm.Type; +import act.db.meta.EntityClassMetaInfo; +import act.db.meta.EntityFieldMetaInfo; +import act.db.meta.EntityMetaInfoRepo; +import act.util.AppByteCodeEnhancer; +import org.osgl.util.S; + +// Adapt act timestamp annotation to ebean timestamp annotation +public class TimestampAuditorEnhancer extends AppByteCodeEnhancer { + + private EntityMetaInfoRepo metaInfoRepo; + private String className; + private String createdAt; + private String lastModifiedAt; + + public TimestampAuditorEnhancer() { + super(S.F.startsWith("act.").negate()); + } + + @Override + protected Class subClass() { + return TimestampAuditorEnhancer.class; + } + + @Override + public AppByteCodeEnhancer app(App app) { + metaInfoRepo = app.entityMetaInfoRepo(); + return super.app(app); + } + + @Override + public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { + String classDesc = "L" + name + ";"; + className = Type.getType(classDesc).getClassName(); + EntityClassMetaInfo classMetaInfo = metaInfoRepo.classMetaInfo(className); + if (null != classMetaInfo) { + EntityFieldMetaInfo fieldMetaInfo = classMetaInfo.createdAtField(); + if (null != fieldMetaInfo) { + createdAt = fieldMetaInfo.fieldName(); + } + fieldMetaInfo = classMetaInfo.lastModifiedAtField(); + if (null != fieldMetaInfo) { + lastModifiedAt = fieldMetaInfo.fieldName(); + } + } + super.visit(version, access, name, signature, superName, interfaces); + } + + @Override + public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { + FieldVisitor fv = super.visitField(access, name, desc, signature, value); + if (null == createdAt && null == lastModifiedAt) { + return fv; + } + final boolean isCreatedAt = name.equals(createdAt); + final boolean isLastModified = !isCreatedAt && name.equals(lastModifiedAt); + if (!isCreatedAt && !isLastModified) { + return fv; + } + return new FieldVisitor(ASM5, fv) { + @Override + public void visitEnd() { + AnnotationVisitor av; + if (isCreatedAt) { + av = fv.visitAnnotation("Lcom/avaje/ebean/annotation/WhenCreated;", true); + } else { + av = fv.visitAnnotation("Lcom/avaje/ebean/annotation/WhenModified;", true); + } + av.visitEnd(); + super.visitEnd(); + } + }; + } +} From 51c046654774db89c7ad0246b07622bc3fe4a1a4 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 4 Mar 2018 21:15:25 +1100 Subject: [PATCH 052/114] update CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 721e631..8516aed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # act-ebean CHANGE LOG -1.5.0 +1.5.0 - 4/Mar/2018 * update to act-1.8.0 * catch ebean2 change: Support act timestamp annotation #19 From 376c366f289b5b711cf9aae42184782b6cf56ca2 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 4 Mar 2018 21:15:59 +1100 Subject: [PATCH 053/114] [maven-release-plugin] prepare release act-ebean-1.5.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6081e31..3ac5b38 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean jar - 1.5.0-SNAPSHOT + 1.5.0 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 5b01379e385c82e6a6ffb5ffe88bf3a0abecd09b Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 4 Mar 2018 21:16:10 +1100 Subject: [PATCH 054/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3ac5b38..27292af 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean jar - 1.5.0 + 1.5.1-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 86fd40fbb1327a23435b7bcfdc3b7bd86bd85807 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 11 Mar 2018 21:13:25 +1100 Subject: [PATCH 055/114] update to act-1.8.1, act-sql-common-1.3.1 --- CHANGELOG.md | 4 ++++ pom.xml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8516aed..40e939c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # act-ebean CHANGE LOG +1.5.1 - 11/Mar/2018 +* update to act-1.8.1 +* update to act-sql-common-1.3.1 + 1.5.0 - 4/Mar/2018 * update to act-1.8.0 * catch ebean2 change: Support act timestamp annotation #19 diff --git a/pom.xml b/pom.xml index 27292af..41a5ff8 100755 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ org.actframework parent - 1.8.0 + 1.8.1 @@ -45,7 +45,7 @@ 8.1.1 2.1.2 - 1.3.0 + 1.3.1 From 720a0d33b04abfd60780744dbfdc8a14d16b71c3 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 11 Mar 2018 21:13:44 +1100 Subject: [PATCH 056/114] [maven-release-plugin] prepare release act-ebean-1.5.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 41a5ff8..eec6a8c 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean jar - 1.5.1-SNAPSHOT + 1.5.1 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From c6ffbcad1d01675503d2974ccd085e4612e04caf Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 11 Mar 2018 21:14:00 +1100 Subject: [PATCH 057/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eec6a8c..bd7a12d 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean jar - 1.5.1 + 1.5.2-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 71992d9a5787a525f51ccbf7cd7f11156b20bbf1 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 25 Mar 2018 19:05:53 +1100 Subject: [PATCH 058/114] rename to act-ebean-java7, update act to 1.8.2, act-sql-common to 1.3.2 --- CHANGELOG.md | 11 ++++++++++- pom.xml | 6 +++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40e939c..44bc687 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,13 @@ -# act-ebean CHANGE LOG +# act-ebean-java7 CHANGE LOG + +1.5.2 - 25/Mar/2018 +* rename to act-ebean-java7 +* update act to 1.8.2 +* update act-sql-common to 1.3.2 + +------------------------------------ + +Previous named act-ebean 1.5.1 - 11/Mar/2018 * update to act-1.8.1 diff --git a/pom.xml b/pom.xml index bd7a12d..443e29e 100755 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ 4.0.0 - act-ebean + act-ebean-java7 jar 1.5.2-SNAPSHOT @@ -35,7 +35,7 @@ org.actframework parent - 1.8.1 + 1.8.2 @@ -45,7 +45,7 @@ 8.1.1 2.1.2 - 1.3.1 + 1.3.2 From 783fb9596f958479af93aa9eae65afaa922b4316 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 25 Mar 2018 19:06:27 +1100 Subject: [PATCH 059/114] [maven-release-plugin] prepare release act-ebean-java7-1.5.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 443e29e..04f6929 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.5.2-SNAPSHOT + 1.5.2 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 314a5d25fb283b74069e59227d892a61054e8da3 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 25 Mar 2018 19:06:42 +1100 Subject: [PATCH 060/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 04f6929..3be4389 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.5.2 + 1.5.3-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 3df0e604ed1cd71c2fb12649b6d8573b123e2cc9 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Mon, 2 Apr 2018 22:25:50 +1000 Subject: [PATCH 061/114] update act to 1.8.5 --- CHANGELOG.md | 4 ++++ pom.xml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44bc687..5d73ac0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # act-ebean-java7 CHANGE LOG +1.5.3 - 02/Apr/2018 +* update act to 1.8.5 +* update act-sql-common to 1.3.3 + 1.5.2 - 25/Mar/2018 * rename to act-ebean-java7 * update act to 1.8.2 diff --git a/pom.xml b/pom.xml index 3be4389..ec26f43 100755 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ org.actframework parent - 1.8.2 + 1.8.5 @@ -45,7 +45,7 @@ 8.1.1 2.1.2 - 1.3.2 + 1.3.3 From 2e9a48e43e9245dbd0b730c34dadcdd67c922db8 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Mon, 2 Apr 2018 22:29:24 +1000 Subject: [PATCH 062/114] [maven-release-plugin] prepare release act-ebean-java7-1.5.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ec26f43..830b09a 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.5.3-SNAPSHOT + 1.5.3 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 2510a8008a28db1ae2d5f3aa7339b8f737aa31d8 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Mon, 2 Apr 2018 22:29:40 +1000 Subject: [PATCH 063/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 830b09a..f17ce1c 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.5.3 + 1.5.4-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 5d25ba6d8d8f726765d82c8d0b33776cfea2329f Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 13 May 2018 14:40:14 +1000 Subject: [PATCH 064/114] update to act-1.8.8-RC4; bump version to 1.6.0 --- CHANGELOG.md | 6 ++++++ pom.xml | 4 ++-- src/main/java/act/db/ebean/EbeanPlugin.java | 12 ++++++++++++ .../java/act/db/ebean/util/EbeanConfigAdaptor.java | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d73ac0..45455ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # act-ebean-java7 CHANGE LOG +1.6.0 - 13/May/2018 +* update act to 1.8.8-RC4 +* Disable Ebean classpath search #21 +* Register global mapping filter to avoid copying ebean enhanced fields #20 + + 1.5.3 - 02/Apr/2018 * update act to 1.8.5 * update act-sql-common to 1.3.3 diff --git a/pom.xml b/pom.xml index f17ce1c..7b19c6f 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.5.4-SNAPSHOT + 1.6.0-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) @@ -35,7 +35,7 @@ org.actframework parent - 1.8.5 + 1.8.8-RC4 diff --git a/src/main/java/act/db/ebean/EbeanPlugin.java b/src/main/java/act/db/ebean/EbeanPlugin.java index 845545f..63bbe27 100644 --- a/src/main/java/act/db/ebean/EbeanPlugin.java +++ b/src/main/java/act/db/ebean/EbeanPlugin.java @@ -33,6 +33,7 @@ import com.avaje.ebean.TxScope; import com.avaje.ebeaninternal.api.HelpScopeTrans; import com.avaje.ebeaninternal.api.ScopeTrans; +import org.osgl.OsglConfig; import osgl.version.Version; import java.util.EventObject; @@ -44,6 +45,12 @@ public class EbeanPlugin extends DbPlugin { private static final ThreadLocal txHolder = new ThreadLocal<>(); + @Override + public void register() { + super.register(); + registerGlobalMappingFilter(); + } + @Override protected void applyTo(App app) { super.applyTo(app); @@ -83,4 +90,9 @@ public DbService initDbService(String id, App app, Map conf) { return new EbeanService(id, app, conf); } + + private void registerGlobalMappingFilter() { + OsglConfig.addGlobalMappingFilter("starts:_ebean_"); + } + } diff --git a/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java b/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java index 2026830..75bd0d2 100644 --- a/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java +++ b/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java @@ -67,6 +67,7 @@ public ServerConfig adaptFrom(SqlDbServiceConfig actConfig, act.db.sql.DataSourc } } + config.setDisableClasspathSearch(true); return config; } From 41f2fff6043ee99f0745637bbfafa3514cb5c2f9 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 13 May 2018 14:41:47 +1000 Subject: [PATCH 065/114] [maven-release-plugin] prepare release act-ebean-java7-1.6.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7b19c6f..d362af3 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.6.0-SNAPSHOT + 1.6.0 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From d0055bad59b3ad5d3df6ed9f7f67a46e79c4a8e0 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 13 May 2018 14:42:05 +1000 Subject: [PATCH 066/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d362af3..dc2a56e 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.6.0 + 1.6.1-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From bfd3d0093f6849d7b0cbbd0953c0b7bff8f50567 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Mon, 14 May 2018 11:00:09 +1000 Subject: [PATCH 067/114] catch up act-ebean-1.6.4 change --- CHANGELOG.md | 3 +++ src/main/java/act/db/ebean/EbeanService.java | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45455ba..f26e328 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # act-ebean-java7 CHANGE LOG +1.6.1 - 14/May/2018 +* java.lang.ClassCastException: java.lang.String cannot be cast to [C #22 + 1.6.0 - 13/May/2018 * update act to 1.8.8-RC4 * Disable Ebean classpath search #21 diff --git a/src/main/java/act/db/ebean/EbeanService.java b/src/main/java/act/db/ebean/EbeanService.java index 8beea60..09a7b57 100644 --- a/src/main/java/act/db/ebean/EbeanService.java +++ b/src/main/java/act/db/ebean/EbeanService.java @@ -61,7 +61,8 @@ public final class EbeanService extends SqlDbService { public EbeanService(final String dbId, final App app, final Map config) { super(dbId, app, config); String s = config.get("agentPackage"); - final String agentPackage = null == s ? S.string(app().config().get(AppConfigKey.SCAN_PACKAGE, null)) : S.string(s).trim(); + String scanPackage = app().config().get(AppConfigKey.SCAN_PACKAGE, null); + final String agentPackage = null == s ? scanPackage : S.string(s).trim(); E.invalidConfigurationIf(S.blank(agentPackage), "\"agentPackage\" not configured"); if (isTraceEnabled()) { trace("\"agentPackage\" configured: %s", agentPackage); From b274212aa1438efcd05edb47cf60689b9c5a432f Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Mon, 14 May 2018 11:00:58 +1000 Subject: [PATCH 068/114] [maven-release-plugin] prepare release act-ebean-java7-1.6.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dc2a56e..9769ad6 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.6.1-SNAPSHOT + 1.6.1 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From cf7e1198694ffdc018657426fdc93cfc7d6d1344 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Mon, 14 May 2018 11:01:17 +1000 Subject: [PATCH 069/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9769ad6..7c82878 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.6.1 + 1.6.2-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From b21ec81cd53818bba77ac75e689e99860db2979c Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 15 May 2018 20:54:26 +1000 Subject: [PATCH 070/114] update act-sql-common to 1.3.4-SNAPSHOT --- CHANGELOG.md | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f26e328..4dfdc6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # act-ebean-java7 CHANGE LOG 1.6.1 - 14/May/2018 -* java.lang.ClassCastException: java.lang.String cannot be cast to [C #22 +* catch act-ebean 1.6.5 changes 1.6.0 - 13/May/2018 * update act to 1.8.8-RC4 diff --git a/pom.xml b/pom.xml index 7c82878..88c7188 100755 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ 8.1.1 2.1.2 - 1.3.3 + 1.3.4-SNAPSHOT From 8c570c6377204e83d030b25e97778a3a03ef8b8f Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sat, 19 May 2018 13:46:21 +1000 Subject: [PATCH 071/114] update parent to 1.8.8-RC5-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 88c7188..d379042 100755 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ org.actframework parent - 1.8.8-RC4 + 1.8.8-RC5-SNAPSHOT From 0cfeb18c2c30c24b331d8b5a82a44d50e5972121 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sat, 19 May 2018 21:29:58 +1000 Subject: [PATCH 072/114] update act to 1.8.8-RC5, act-sql-common to 1.3.4 --- CHANGELOG.md | 5 ++++- pom.xml | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dfdc6d..759c099 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ # act-ebean-java7 CHANGE LOG +1.6.2 - 19/May/2018 +* catch up act-ebean 1.6.5 changes + 1.6.1 - 14/May/2018 -* catch act-ebean 1.6.5 changes +* catch act-ebean 1.6.4 changes 1.6.0 - 13/May/2018 * update act to 1.8.8-RC4 diff --git a/pom.xml b/pom.xml index d379042..e385fde 100755 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ org.actframework parent - 1.8.8-RC5-SNAPSHOT + 1.8.8-RC5 @@ -45,7 +45,7 @@ 8.1.1 2.1.2 - 1.3.4-SNAPSHOT + 1.3.4 From ddce7d0ce3c4677825ef3c3e8725f81a02898bd0 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sat, 19 May 2018 21:31:08 +1000 Subject: [PATCH 073/114] [maven-release-plugin] prepare release act-ebean-java7-1.6.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e385fde..bebc5c0 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.6.2-SNAPSHOT + 1.6.2 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From ba4660543d996edcd0bd4d28ca8090fa7a19edc6 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sat, 19 May 2018 21:31:26 +1000 Subject: [PATCH 074/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bebc5c0..14eb565 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.6.2 + 1.6.3-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From f9198105a69dc40385984c4caa9c1c91bf3a3913 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 29 May 2018 13:13:36 +1000 Subject: [PATCH 075/114] update act to 1.8.8-RC8; act-sql-common to 1.4.0 --- pom.xml | 6 +- src/main/java/act/db/ebean/EbeanDao.java | 117 +++++---- .../db/ebean/EbeanDaoInjectionListener.java | 2 +- src/main/java/act/db/ebean/EbeanPlugin.java | 42 ---- src/main/java/act/db/ebean/EbeanQuery.java | 234 ++++++++++++------ src/main/java/act/db/ebean/EbeanService.java | 96 +++++-- .../act/db/ebean/util/EbeanConfigAdaptor.java | 43 ++-- .../ebean/util/EbeanDataSourceProvider.java | 77 ++++++ .../db/ebean/util/EbeanDataSourceWrapper.java | 88 +++++++ 9 files changed, 500 insertions(+), 205 deletions(-) create mode 100644 src/main/java/act/db/ebean/util/EbeanDataSourceProvider.java create mode 100644 src/main/java/act/db/ebean/util/EbeanDataSourceWrapper.java diff --git a/pom.xml b/pom.xml index 14eb565..e06ddfe 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.6.3-SNAPSHOT + 1.7.0-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) @@ -35,7 +35,7 @@ org.actframework parent - 1.8.8-RC5 + 1.8.8-RC8 @@ -45,7 +45,7 @@ 8.1.1 2.1.2 - 1.3.4 + 1.4.0 diff --git a/src/main/java/act/db/ebean/EbeanDao.java b/src/main/java/act/db/ebean/EbeanDao.java index daa3394..4398731 100644 --- a/src/main/java/act/db/ebean/EbeanDao.java +++ b/src/main/java/act/db/ebean/EbeanDao.java @@ -27,6 +27,7 @@ import act.db.DaoBase; import act.db.DbService; import act.db.Model; +import act.db.sql.tx.TxContext; import act.inject.param.NoBind; import act.util.General; import com.avaje.ebean.*; @@ -53,21 +54,25 @@ public class EbeanDao extends DaoBase queryIterators = C.newList(); EbeanDao(EbeanService service) { init(modelType()); - this.ebean(service.ebean()); + this.dbService(service); } EbeanDao(Class idType, Class modelType, EbeanService service) { super(idType, modelType); init(modelType); - this.setEbean(service.ebean()); + this.dbService(service); this.ds = service.dataSource(); + this.dsReadOnly = service.dataSourceReadOnly(); } public EbeanDao(Class id_type, Class modelType) { @@ -79,8 +84,14 @@ public EbeanDao() { init(modelType()); } - public void ebean(EbeanServer ebean) { - setEbean($.notNull(ebean)); + public void ebean(EbeanServer ebean, boolean readonly) { + setEbean($.requireNotNull(ebean), readonly); + } + + public void dbService(EbeanService service) { + this.dbSvc = service; + this.ebean(service.ebean(true), true); + this.ebean(service.ebean(false), false); } public void modelType(Class type) { @@ -113,7 +124,11 @@ private void init(Class modelType) { } } - private void setEbean(EbeanServer ebean) { + private void setEbean(EbeanServer ebean, boolean readonly) { + if (readonly) { + this.ebeanReadOnly = ebean; + return; + } this.ebean = ebean; this.tableName = ((SpiEbeanServer) ebean).getBeanDescriptor(modelType()).getBaseTable(); } @@ -125,20 +140,27 @@ private EbeanService getService(String dbId, DbServiceManager mgr) { return $.cast(svc); } - public EbeanServer ebean() { - if (null != ebean) { + private EbeanServer ebean_(boolean defaultReadOnly) { + boolean ctxReadOnly = TxContext.readOnly(defaultReadOnly); + E.illegalStateIf(!defaultReadOnly && ctxReadOnly, "Cannot do write operation within readonly transaction"); + return ebean(ctxReadOnly); + } + + public EbeanServer ebean(boolean readonly) { + dbSvc.beginTxIfRequired(null); + if (!readonly && null != ebean) { return ebean; } + if (readonly && null != ebeanReadOnly) { + return ebeanReadOnly; + } synchronized (this) { - if (null == ebean) { - DB db = modelType().getAnnotation(DB.class); - String dbId = null == db ? DbServiceManager.DEFAULT : db.value(); - EbeanService dbService = getService(dbId, app().dbServiceManager()); - E.NPE(dbService); - setEbean(dbService.ebean()); - } + DB db = modelType().getAnnotation(DB.class); + String dbId = null == db ? DbServiceManager.DEFAULT : db.value(); + EbeanService dbService = getService(dbId, app().dbServiceManager()); + dbService(dbService); + return readonly ? ebeanReadOnly : ebean; } - return ebean; } public DataSource ds() { @@ -163,7 +185,17 @@ void registerQueryIterator(QueryIterator i) { @Override public MODEL_TYPE findById(ID_TYPE id) { - return ebean().find(modelType(), id); + return ebean_(true).find(modelType(), id); + } + + @Override + public MODEL_TYPE findLatest() { + throw E.unsupport(); + } + + @Override + public MODEL_TYPE findLastModified() { + throw E.unsupport(); } @Override @@ -195,19 +227,9 @@ public List findAllAsList() { return q().findList(); } - @Override - public MODEL_TYPE findLatest() { - throw E.unsupport(); - } - - @Override - public MODEL_TYPE findLastModified() { - throw E.unsupport(); - } - @Override public MODEL_TYPE reload(MODEL_TYPE entity) { - ebean().refresh(entity); + ebean_(true).refresh(entity); return entity; } @@ -239,12 +261,12 @@ public long countBy(String fields, Object... values) throws IllegalArgumentExcep @Override public MODEL_TYPE save(MODEL_TYPE entity) { - ebean().save(entity); + ebean_(false).save(entity); return entity; } public MODEL_TYPE save(Transaction tx, MODEL_TYPE entity) { - ebean().save(entity, tx); + ebean_(false).save(entity, tx); return entity; } @@ -254,61 +276,50 @@ public List save(Iterable iterable) { if (list.isEmpty()) { return list; } - Transaction transaction = ebean().createTransaction(TxIsolation.READ_COMMITED); - transaction.setBatchMode(true); - transaction.setBatchSize(list.size()); - try { - ebean().saveAll(list); - transaction.commit(); - } catch (RuntimeException e) { - transaction.rollback(); - throw e; - } finally { - transaction.end(); - } + ebean_(false).saveAll(list); return list; } public List save(Transaction tx, Iterable iterable) { List list = C.list(iterable); - ebean().saveAll(list, tx); + ebean_(false).saveAll(list, tx); return list; } @Override public void save(MODEL_TYPE entity, String fields, Object... values) throws IllegalArgumentException { - ebean().update(entity); + ebean_(false).update(entity); } public void save(Transaction tx, MODEL_TYPE entity, String fields, Object... values) throws IllegalArgumentException { - ebean().update(entity, tx); + ebean_(false).update(entity, tx); } @Override public void delete(MODEL_TYPE entity) { - ebean().delete(entity); + ebean_(false).delete(entity); } public void delete(Transaction tx, MODEL_TYPE entity) { - ebean().delete(entity, tx); + ebean_(false).delete(entity, tx); } @Override public void delete(EbeanQuery query) { - ebean().delete(query.rawQuery(), null); + ebean_(false).delete(query.rawQuery(), null); } public void delete(Transaction tx, EbeanQuery query) { - ebean().delete(query.rawQuery(), tx); + ebean_(false).delete(query.rawQuery(), tx); } @Override public void deleteById(ID_TYPE id) { - ebean().delete(modelType(), id); + ebean_(false).delete(modelType(), id); } public void deleteById(Transaction tx, ID_TYPE id) { - ebean().delete(modelType(), id, tx); + ebean_(false).delete(modelType(), id, tx); } @Override @@ -332,13 +343,13 @@ public void deleteAll(Transaction tx) { @Override public void drop() { String sql = "DELETE from " + tableName; - SqlUpdate sqlUpdate = ebean().createSqlUpdate(sql); - ebean().execute(sqlUpdate); + SqlUpdate sqlUpdate = ebean_(false).createSqlUpdate(sql); + ebean_(false).execute(sqlUpdate); } @Override public EbeanQuery q() { - return new EbeanQuery(this, modelType()); + return new EbeanQuery<>(this, modelType()); } @Override diff --git a/src/main/java/act/db/ebean/EbeanDaoInjectionListener.java b/src/main/java/act/db/ebean/EbeanDaoInjectionListener.java index 66d14fa..9cff1b4 100644 --- a/src/main/java/act/db/ebean/EbeanDaoInjectionListener.java +++ b/src/main/java/act/db/ebean/EbeanDaoInjectionListener.java @@ -62,7 +62,7 @@ public void onInjection(Object injectee, BeanSpec spec) { Act.eventBus().bind(SysEventId.DB_SVC_LOADED, new SysEventListenerBase() { @Override public void on(EventObject eventObject) throws Exception { - dao.ebean(service.ebean()); + dao.dbService(service); dao.modelType(resolved._1); } }); diff --git a/src/main/java/act/db/ebean/EbeanPlugin.java b/src/main/java/act/db/ebean/EbeanPlugin.java index 63bbe27..916201d 100644 --- a/src/main/java/act/db/ebean/EbeanPlugin.java +++ b/src/main/java/act/db/ebean/EbeanPlugin.java @@ -21,22 +21,13 @@ */ import act.app.App; -import act.asm.Opcodes; import act.db.DbPlugin; import act.db.DbService; -import act.db.sql.tx.TxError; -import act.db.sql.tx.TxInfo; -import act.db.sql.tx.TxStart; -import act.db.sql.tx.TxStop; -import act.event.ActEventListenerBase; import act.inject.param.ParamValueLoaderService; -import com.avaje.ebean.TxScope; -import com.avaje.ebeaninternal.api.HelpScopeTrans; import com.avaje.ebeaninternal.api.ScopeTrans; import org.osgl.OsglConfig; import osgl.version.Version; -import java.util.EventObject; import java.util.Map; public class EbeanPlugin extends DbPlugin { @@ -51,39 +42,6 @@ public void register() { registerGlobalMappingFilter(); } - @Override - protected void applyTo(App app) { - super.applyTo(app); - app.eventBus().bind(TxStart.class, new ActEventListenerBase() { - @Override - public void on(TxStart eventObject) { - TxInfo info = eventObject.source(); - TxScope scope = new TxScope(); - scope.setReadOnly(info.readOnly()); - ScopeTrans tx = HelpScopeTrans.createScopeTrans(scope); - txHolder.set(tx); - } - }).bind(TxStop.class, new ActEventListenerBase() { - @Override - public void on(EventObject eventObject) throws Exception { - ScopeTrans tx = txHolder.get(); - if (null != tx) { - tx.onExit(null, 1); - } - } - }).bind(TxError.class, new ActEventListenerBase() { - @Override - public void on(TxError eventObject) throws Exception { - ScopeTrans tx = txHolder.get(); - if (null != tx) { - Throwable cause = eventObject.source(); - tx.onExit(cause, Opcodes.ATHROW); - } - } - }); - - } - @Override public DbService initDbService(String id, App app, Map conf) { ParamValueLoaderService.waiveFields("_ebean_intercept", "_ebean_identity"); diff --git a/src/main/java/act/db/ebean/EbeanQuery.java b/src/main/java/act/db/ebean/EbeanQuery.java index fb0fc69..0c89807 100644 --- a/src/main/java/act/db/ebean/EbeanQuery.java +++ b/src/main/java/act/db/ebean/EbeanQuery.java @@ -22,6 +22,7 @@ import act.db.Dao; import com.avaje.ebean.*; +import org.jetbrains.annotations.Nullable; import org.osgl.$; import org.osgl.util.C; import org.osgl.util.E; @@ -39,6 +40,7 @@ public class EbeanQuery implements Query, Dao.Query modelType; Query q; + Query qReadOnly; EbeanDao dao; public EbeanQuery() { @@ -54,34 +56,83 @@ public EbeanQuery() { public EbeanQuery(EbeanDao dao, Class modelType) { this.modelType = modelType; - EbeanServer ebean = dao.ebean(); - E.NPE(ebean); - q = ebean.createQuery(modelType); + + q = dao.ebean(false).createQuery(modelType); + qReadOnly = dao.ebean(true).createQuery(modelType); + syncEbeanQueries(); + this.dao = dao; } + private void syncEbeanQueries() { + + _sync("detail"); + + q.orderBy(); + _sync("orderBy"); + + q.text(); + _sync("textExpressions"); + + q.where(); + _sync("whereExpressions"); + + q.having(); + _sync("havingExpressions"); + + } + + private void _sync(String property) { + $.setProperty(qReadOnly, $.getProperty(q, property), property); + } + public Query rawQuery() { return q; } @Override - public Query asOf(Timestamp timestamp) { - return q.asOf(timestamp); + public EbeanQuery asOf(Timestamp timestamp) { + q.asOf(timestamp); + qReadOnly.asOf(timestamp); + return this; } @Override public List> findVersions() { - return q.findVersions(); + return qReadOnly.findVersions(); } @Override public List> findVersionsBetween(Timestamp timestamp, Timestamp timestamp1) { - return q.findVersionsBetween(timestamp, timestamp1); + return qReadOnly.findVersionsBetween(timestamp, timestamp1); } @Override - public Query apply(FetchPath fetchPath) { - return q.apply(fetchPath); + public RawSql getRawSql() { + return q.getRawSql(); + } + + @Override + public void findEach(QueryEachConsumer consumer) { + qReadOnly.findEach(consumer); + } + + @Override + public void findEachWhile(QueryEachWhileConsumer consumer) { + qReadOnly.findEachWhile(consumer); + } + + @Nullable + @Override + public MODEL_TYPE findUnique() { + return qReadOnly.findUnique(); + } + + @Override + public EbeanQuery apply(FetchPath fetchPath) { + q.apply(fetchPath); + qReadOnly.apply(fetchPath); + return this; } @Override @@ -90,8 +141,9 @@ public ExpressionList text() { } @Override - public Query setUseDocStore(boolean b) { + public EbeanQuery setUseDocStore(boolean b) { q.setUseDocStore(b); + qReadOnly.setUseDocStore(b); return this; } @@ -107,28 +159,32 @@ public int delete() { @Override public Object getId() { - return q.getId(); + return qReadOnly.getId(); } @Override public Class getBeanType() { - return q.getBeanType(); + return qReadOnly.getBeanType(); } @Override - public Query setDisableLazyLoading(boolean b) { - return q.setDisableLazyLoading(b); + public EbeanQuery setDisableLazyLoading(boolean b) { + q.setDisableLazyLoading(b); + qReadOnly.setDisableLazyLoading(b); + return this; } @Override public EbeanQuery offset(int pos) { q.setFirstRow(pos); + qReadOnly.setFirstRow(pos); return this; } @Override public EbeanQuery limit(int limit) { q.setMaxRows(limit); + qReadOnly.setMaxRows(limit); return this; } @@ -136,32 +192,41 @@ public EbeanQuery limit(int limit) { public EbeanQuery orderBy(String... fieldList) { E.illegalArgumentIf(fieldList.length == 0); q.order(S.join(" ", fieldList)); + qReadOnly.order(S.join(" ", fieldList)); return this; } @Override public MODEL_TYPE first() { - return q.findUnique(); + return qReadOnly.findUnique(); } @Override - public Query fetchQuery(String path, String fetchProperties) { - return q.fetchQuery(path, fetchProperties); + public EbeanQuery fetchQuery(String path, String fetchProperties) { + q.fetchQuery(path, fetchProperties); + qReadOnly.fetchQuery(path, fetchProperties); + return this; } @Override - public Query fetchLazy(String path, String fetchProperties) { - return q.fetchLazy(path, fetchProperties); + public EbeanQuery fetchLazy(String path, String fetchProperties) { + q.fetchLazy(path, fetchProperties); + qReadOnly.fetchLazy(path, fetchProperties); + return this; } @Override - public Query fetchQuery(String path) { - return q.fetchQuery(path); + public EbeanQuery fetchQuery(String path) { + q.fetchQuery(path); + qReadOnly.fetchQuery(path); + return this; } @Override - public Query fetchLazy(String path) { - return q.fetchLazy(path); + public EbeanQuery fetchLazy(String path) { + q.fetchLazy(path); + qReadOnly.fetchLazy(path); + return this; } @Override @@ -173,7 +238,7 @@ public Iterable fetch() { } qi.close(); return list; -// we need to close the query iterable right now otherwise it hold the data connection forever +// we need to close the query iterable right now otherwise it holds the data connection forever // return new Iterable() { // @Override // public Iterator iterator() { @@ -184,121 +249,137 @@ public Iterable fetch() { @Override public long count() { - return q.findCount(); + return qReadOnly.findCount(); } // --- Ebean Query methods: delegate to q @Override - public Query setIncludeSoftDeletes() { + public EbeanQuery setIncludeSoftDeletes() { q.setIncludeSoftDeletes(); + qReadOnly.setIncludeSoftDeletes(); return this; } @Override - public Query asDraft() { - return q.asDraft(); + public EbeanQuery asDraft() { + q.asDraft(); + qReadOnly.asDraft(); + return this; } @Override public boolean isAutoTuned() { - return q.isAutoTuned(); + return qReadOnly.isAutoTuned(); } @Override - public Query setAutoTune(boolean b) { - return q.setAutoTune(b); - } - - @Override - public Query setDisableReadAuditing() { - return q.setDisableReadAuditing(); + public EbeanQuery setAutoTune(boolean b) { + q.setAutoTune(b); + qReadOnly.setAutoTune(b); + return this; } @Override - public RawSql getRawSql() { - return q.getRawSql(); + public EbeanQuery setDisableReadAuditing() { + q.setDisableReadAuditing(); + qReadOnly.setDisableReadAuditing(); + return this; } @Override public EbeanQuery setRawSql(RawSql rawSql) { q.setRawSql(rawSql); + qReadOnly.setRawSql(rawSql); return this; } + public void setDefaultRawSqlIfRequired() { + } + @Override public void cancel() { q.cancel(); + qReadOnly.cancel(); } @Override public EbeanQuery copy() { - q.copy(); - return this; + EbeanQuery copy = new EbeanQuery<>(); + copy.q = q.copy(); + copy.qReadOnly = qReadOnly.copy(); + return copy; } @Override public EbeanQuery setPersistenceContextScope(PersistenceContextScope scope) { q.setPersistenceContextScope(scope); + qReadOnly.setPersistenceContextScope(scope); return this; } @Override public ExpressionFactory getExpressionFactory() { - return q.getExpressionFactory(); + return qReadOnly.getExpressionFactory(); } @Override public EbeanQuery setLazyLoadBatchSize(int lazyLoadBatchSize) { q.setLazyLoadBatchSize(lazyLoadBatchSize); + qReadOnly.setLazyLoadBatchSize(lazyLoadBatchSize); return this; } @Override public EbeanQuery select(String fetchProperties) { q.select(fetchProperties); + qReadOnly.select(fetchProperties); return this; } @Override public EbeanQuery fetch(String path, String fetchProperties) { q.fetch(path, fetchProperties); + qReadOnly.fetch(path, fetchProperties); return this; } @Override public EbeanQuery fetch(String assocProperty, String fetchProperties, FetchConfig fetchConfig) { q.fetch(assocProperty, fetchProperties, fetchConfig); + qReadOnly.fetch(assocProperty, fetchProperties, fetchConfig); return this; } @Override public EbeanQuery fetch(String path) { q.fetch(path); + qReadOnly.fetch(path); return this; } @Override public EbeanQuery fetch(String path, FetchConfig joinConfig) { q.fetch(path, joinConfig); + qReadOnly.fetch(path, joinConfig); return this; } @Override - public List findIds() { - return q.findIds(); + public List findIds() { + return qReadOnly.findIds(); } @Override public QueryIterator findIterate() { - QueryIterator i = q.findIterate(); + QueryIterator i = qReadOnly.findIterate(); dao.registerQueryIterator(i); return i; } public void consume($.Visitor visitor) { - QueryIterator i = q.findIterate(); + QueryIterator i = qReadOnly.findIterate(); try { while (i.hasNext()) { MODEL_TYPE entity = i.next(); @@ -311,91 +392,84 @@ public void consume($.Visitor visitor) { @Override public List findList() { - return q.findList(); + return qReadOnly.findList(); } @Override public Set findSet() { - return q.findSet(); + return qReadOnly.findSet(); } @Override public Map findMap() { - return q.findMap(); + return qReadOnly.findMap(); } @Override public List findSingleAttributeList() { - return q.findSingleAttributeList(); + return qReadOnly.findSingleAttributeList(); } @Override - public MODEL_TYPE findUnique() { - return q.findUnique(); + public int findCount() { + return qReadOnly.findCount(); } - @Override - public int findCount() { - return q.findCount(); + public MODEL_TYPE findOne() { + return qReadOnly.findUnique(); } @Override public FutureRowCount findFutureCount() { - return q.findFutureCount(); + return qReadOnly.findFutureCount(); } @Override public FutureIds findFutureIds() { - return q.findFutureIds(); + return qReadOnly.findFutureIds(); } @Override public FutureList findFutureList() { - return q.findFutureList(); - } - - @Override - public void findEach(QueryEachConsumer consumer) { - q.findEach(consumer); - } - - @Override - public void findEachWhile(QueryEachWhileConsumer consumer) { - q.findEachWhile(consumer); + return qReadOnly.findFutureList(); } @Override public EbeanQuery setParameter(String name, Object value) { q.setParameter(name, value); + qReadOnly.setParameter(name, value); return this; } @Override public EbeanQuery setParameter(int position, Object value) { q.setParameter(position, value); + qReadOnly.setParameter(position, value); return this; } @Override public EbeanQuery setId(Object id) { q.setId(id); + qReadOnly.setId(id); return this; } @Override public EbeanQuery where(Expression expression) { q.where(expression); + qReadOnly.where(expression); return this; } @Override public ExpressionList where() { - return q.where(); + return qReadOnly.where(); } @Override public ExpressionList filterMany(String propertyName) { - return q.filterMany(propertyName); + return qReadOnly.filterMany(propertyName); } @Override @@ -406,18 +480,24 @@ public ExpressionList having() { @Override public EbeanQuery having(Expression addExpressionToHaving) { q.having(addExpressionToHaving); + qReadOnly.having(addExpressionToHaving); return this; } @Override public EbeanQuery orderBy(String orderByClause) { + if (S.blank(orderByClause)) { + return this; + } q.orderBy(orderByClause); + qReadOnly.orderBy(orderByClause); return this; } @Override public EbeanQuery order(String orderByClause) { q.order(orderByClause); + qReadOnly.order(orderByClause); return this; } @@ -434,18 +514,21 @@ public OrderBy orderBy() { @Override public EbeanQuery setOrder(OrderBy orderBy) { q.setOrder(orderBy); + qReadOnly.setOrder(orderBy); return this; } @Override public EbeanQuery setOrderBy(OrderBy orderBy) { q.setOrderBy(orderBy); + qReadOnly.setOrderBy(orderBy); return this; } @Override public EbeanQuery setDistinct(boolean isDistinct) { q.setDistinct(isDistinct); + qReadOnly.setDistinct(isDistinct); return this; } @@ -457,6 +540,7 @@ public int getFirstRow() { @Override public EbeanQuery setFirstRow(int firstRow) { q.setFirstRow(firstRow); + qReadOnly.setFirstRow(firstRow); return this; } @@ -468,24 +552,28 @@ public int getMaxRows() { @Override public EbeanQuery setMaxRows(int maxRows) { q.setMaxRows(maxRows); + qReadOnly.setMaxRows(maxRows); return this; } @Override public EbeanQuery setMapKey(String mapKey) { q.setMapKey(mapKey); + qReadOnly.setMapKey(mapKey); return this; } @Override public EbeanQuery setUseCache(boolean useBeanCache) { q.setUseCache(useBeanCache); + qReadOnly.setUseCache(useBeanCache); return this; } @Override public EbeanQuery setUseQueryCache(boolean useQueryCache) { q.setUseQueryCache(useQueryCache); + qReadOnly.setUseQueryCache(useQueryCache); return this; } @@ -498,18 +586,21 @@ public EbeanQuery setReadOnly(boolean readOnly) { @Override public EbeanQuery setLoadBeanCache(boolean loadBeanCache) { q.setLoadBeanCache(loadBeanCache); + qReadOnly.setLoadBeanCache(loadBeanCache); return this; } @Override public EbeanQuery setTimeout(int secs) { q.setTimeout(secs); + qReadOnly.setTimeout(secs); return this; } @Override public EbeanQuery setBufferFetchSizeHint(int fetchSize) { q.setBufferFetchSizeHint(fetchSize); + qReadOnly.setBufferFetchSizeHint(fetchSize); return this; } @@ -519,6 +610,7 @@ public String getGeneratedSql() { } @Override + @Deprecated public EbeanQuery setForUpdate(boolean forUpdate) { q.setForUpdate(forUpdate); return this; @@ -532,16 +624,18 @@ public boolean isForUpdate() { @Override public EbeanQuery alias(String alias) { q.alias(alias); + qReadOnly.alias(alias); return this; } @Override public PagedList findPagedList() { - return q.findPagedList(); + return qReadOnly.findPagedList(); } @Override public Set validate() { return q.validate(); } + } diff --git a/src/main/java/act/db/ebean/EbeanService.java b/src/main/java/act/db/ebean/EbeanService.java index 09a7b57..77c6a25 100644 --- a/src/main/java/act/db/ebean/EbeanService.java +++ b/src/main/java/act/db/ebean/EbeanService.java @@ -27,11 +27,17 @@ import act.conf.AppConfigKey; import act.db.Dao; import act.db.ebean.util.EbeanConfigAdaptor; +import act.db.ebean.util.EbeanDataSourceProvider; +import act.db.ebean.util.EbeanDataSourceWrapper; import act.db.sql.DataSourceConfig; +import act.db.sql.DataSourceProvider; import act.db.sql.SqlDbService; +import act.db.sql.tx.TxContext; import act.event.SysEventListenerBase; import com.avaje.ebean.EbeanServer; import com.avaje.ebean.EbeanServerFactory; +import com.avaje.ebean.Transaction; +import com.avaje.ebean.TxScope; import com.avaje.ebean.config.ServerConfig; import org.osgl.$; import org.osgl.util.E; @@ -56,7 +62,8 @@ public final class EbeanService extends SqlDbService { // the ebean service instance private EbeanServer ebean; - private ServerConfig ebeanConfig; + // the ebean service instance for readonly operations + private EbeanServer ebeanReadOnly; public EbeanService(final String dbId, final App app, final Map config) { super(dbId, app, config); @@ -87,30 +94,46 @@ protected boolean supportDdl() { } @Override - protected void dataSourceProvided(DataSource dataSource, DataSourceConfig dsConfig) { - ebeanConfig = new EbeanConfigAdaptor().adaptFrom(this.config, dsConfig, this); - ebeanConfig.setDataSource(dataSource); + protected void dataSourceProvided(DataSource dataSource, DataSourceConfig dsConfig, boolean readonly) { + ServerConfig ebeanConfig; + if (dataSource instanceof EbeanDataSourceWrapper) { + EbeanDataSourceWrapper wrapper = (EbeanDataSourceWrapper) dataSource; + ebeanConfig = wrapper.ebeanConfig; + } else { + ebeanConfig = new EbeanConfigAdaptor().adaptFrom(this.config, dsConfig, this); + ebeanConfig.setDataSource(dataSource); + } app().eventBus().trigger(new EbeanConfigLoaded(ebeanConfig)); - ebean = EbeanServerFactory.create(ebeanConfig); + if (readonly) { + ebeanReadOnly = EbeanServerFactory.create(ebeanConfig); + } else { + ebean = EbeanServerFactory.create(ebeanConfig); + if (null == ebeanReadOnly) { + ebeanReadOnly = ebean; + } + } } @Override - protected DataSource createDataSource() { - ebeanConfig = new EbeanConfigAdaptor().adaptFrom(this.config, this.config.dataSourceConfig, this); - app().eventBus().trigger(new EbeanConfigLoaded(ebeanConfig)); - ebean = EbeanServerFactory.create(ebeanConfig); - return ebeanConfig.getDataSource(); + protected DataSourceProvider builtInDataSourceProvider() { + return new EbeanDataSourceProvider(config, this); } @Override protected void releaseResources() { if (null != ebean) { ebean.shutdown(true, false); - if (isDebugEnabled()) { - debug("ebean shutdown: %s", id()); + if (logger.isDebugEnabled()) { + logger.debug("ebean shutdown: %s", id()); } ebean = null; - ebeanConfig = null; + } + if (null != ebeanReadOnly) { + ebeanReadOnly.shutdown(true, false); + if (logger.isDebugEnabled()) { + logger.debug("ebean readonly shutdown: %s", id()); + } + ebeanReadOnly = null; } super.releaseResources(); } @@ -133,7 +156,7 @@ public DAO defaultDao(Class modelType) { public DAO newDaoInstance(Class daoType) { E.illegalArgumentIf(!EbeanDao.class.isAssignableFrom(daoType), "expected EbeanDao, found: %s", daoType); EbeanDao dao = $.cast(app().getInstance(daoType)); - dao.ebean(this.ebean()); + dao.dbService(this); return (DAO) dao; } @@ -142,8 +165,53 @@ public Class entityAnnotationType() { return Entity.class; } + @Override + protected void doStartTx(Object delegate, boolean readOnly) { + if (readOnly) { + TxScope scope = TxScope.required().setReadOnly(true); + ebeanReadOnly.beginTransaction(scope); + } else { + ebean.beginTransaction(); + } + } + + @Override + protected void doRollbackTx(Object delegate, Throwable cause) { + Transaction tx = ebean.currentTransaction(); + if (null == tx) { + return; + } + if (TxContext.readOnly()) { + ebeanReadOnly.endTransaction(); + } else { + logger.warn(cause, "Roll back transaction"); + ebean.rollbackTransaction(); + } + } + + @Override + protected void doEndTxIfActive(Object delegate) { + Transaction tx = ebean.currentTransaction(); + if (null == tx) { + return; + } + if (TxContext.readOnly()) { + ebeanReadOnly.endTransaction(); + } else { + ebean.commitTransaction(); + } + } + + public EbeanServer ebean(boolean readOnly) { + return readOnly ? ebeanReadOnly : ebean; + } + public EbeanServer ebean() { return ebean; } + public EbeanServer ebeanReadOnly() { + return ebeanReadOnly; + } + } diff --git a/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java b/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java index 75bd0d2..a0c2b9c 100644 --- a/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java +++ b/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java @@ -24,15 +24,15 @@ import act.db.sql.SqlDbService; import act.db.sql.SqlDbServiceConfig; +import act.util.LogSupport; import com.avaje.ebean.config.MatchingNamingConvention; import com.avaje.ebean.config.NamingConvention; import com.avaje.ebean.config.ServerConfig; import com.avaje.ebean.config.UnderscoreNamingConvention; import org.avaje.datasource.DataSourceConfig; -import org.osgl.logging.LogManager; -import org.osgl.logging.Logger; import org.osgl.util.S; +import java.sql.Connection; import java.util.Properties; import java.util.Set; import javax.inject.Singleton; @@ -41,9 +41,7 @@ * Adapt {@link act.db.sql.SqlDbServiceConfig} to {@link ServerConfig} */ @Singleton -public class EbeanConfigAdaptor { - - private static final Logger LOGGER = LogManager.get(EbeanConfigAdaptor.class); +public class EbeanConfigAdaptor extends LogSupport { public ServerConfig adaptFrom(SqlDbServiceConfig actConfig, act.db.sql.DataSourceConfig dsConfig, SqlDbService svc) { ServerConfig config = new ServerConfig(); @@ -60,8 +58,8 @@ public ServerConfig adaptFrom(SqlDbServiceConfig actConfig, act.db.sql.DataSourc Set modelClasses = svc.entityClasses(); if (null != modelClasses && !modelClasses.isEmpty()) { for (Class modelClass : modelClasses) { - if (LOGGER.isTraceEnabled()) { - LOGGER.trace(S.concat("add model class into Ebean config: ", modelClass.getName())); + if (isTraceEnabled()) { + trace(S.concat("add model class into Ebean config: ", modelClass.getName())); } config.addClass(modelClass); } @@ -71,10 +69,11 @@ public ServerConfig adaptFrom(SqlDbServiceConfig actConfig, act.db.sql.DataSourc return config; } - public DataSourceConfig adaptFrom(act.db.sql.DataSourceConfig actConfig, SqlDbService svc) { Properties properties = new Properties(); properties.putAll(actConfig.customProperties); + properties.put("isolationLevel", adaptIsolationLevel(actConfig.isolationLevel)); + DataSourceConfig config = new DataSourceConfig(); config.loadSettings(properties, svc.id()); @@ -83,29 +82,17 @@ public DataSourceConfig adaptFrom(act.db.sql.DataSourceConfig actConfig, SqlDbSe config.setUsername(actConfig.username); config.setPassword(actConfig.password); config.setAutoCommit(actConfig.autoCommit); + config.setIsolationLevel(actConfig.isolationLevel); config.setMinConnections(actConfig.minConnections); config.setMaxConnections(actConfig.maxConnections); - config.setHeartbeatSql(actConfig.heartbeatSql); - config.setIsolationLevel(actConfig.isolationLevel); - config.setMaxAgeMinutes(actConfig.maxAgeMinutes); - config.setMaxInactiveTimeSecs(actConfig.maxInactiveTimeSecs); - config.setHeartbeatFreqSecs(actConfig.heartbeatFreqSecs); - config.setCstmtCacheSize(actConfig.cstmtCacheSize); - config.setPstmtCacheSize(actConfig.pstmtCacheSize); - config.setTrimPoolFreqSecs(actConfig.trimPoolFreqSecs); - config.setWaitTimeoutMillis(actConfig.waitTimeoutMillis); - config.setLeakTimeMinutes(actConfig.leakTimeMinutes); - config.setPoolListener(actConfig.poolListener); - config.setOffline(actConfig.offline); - config.setCaptureStackTrace(actConfig.captureStackTrace); return config; } private NamingConvention namingConvention(SqlDbServiceConfig svcConfig) { if (!svcConfig.rawConf.containsKey("naming.convention")) { - // https://github.com/actframework/act-ebean/issues/13 + // https://github.com/actframework/act-ebean2/issues/1 return new UnderscoreNamingConvention(); } //TODO provide more actuate naming convention matching logic @@ -115,4 +102,16 @@ private NamingConvention namingConvention(SqlDbServiceConfig svcConfig) { return new UnderscoreNamingConvention(); } + private String adaptIsolationLevel(int level) { + switch (level) { + case Connection.TRANSACTION_NONE : return "NONE"; + case Connection.TRANSACTION_READ_COMMITTED : return "READ_COMMITTED"; + case Connection.TRANSACTION_READ_UNCOMMITTED : return "READ_UNCOMMITTED"; + case Connection.TRANSACTION_REPEATABLE_READ : return "REPEATABLE_READ"; + case Connection.TRANSACTION_SERIALIZABLE : return "SERIALIZABLE"; + default: + warn("Unknown isolationLevel found: %s; will use default level: REPEATABLE_READ"); + return "REPEATABLE_READ"; + } + } } diff --git a/src/main/java/act/db/ebean/util/EbeanDataSourceProvider.java b/src/main/java/act/db/ebean/util/EbeanDataSourceProvider.java new file mode 100644 index 0000000..b8d9570 --- /dev/null +++ b/src/main/java/act/db/ebean/util/EbeanDataSourceProvider.java @@ -0,0 +1,77 @@ +package act.db.ebean.util; + +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2018 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + +import act.db.sql.DataSourceConfig; +import act.db.sql.DataSourceProvider; +import act.db.sql.SqlDbService; +import act.db.sql.SqlDbServiceConfig; +import act.db.sql.monitor.DataSourceStatus; +import com.avaje.ebean.config.ServerConfig; +import org.avaje.datasource.DataSourceAlertFactory; +import org.avaje.datasource.DataSourceFactory; + +import java.util.Map; +import javax.sql.DataSource; + +public class EbeanDataSourceProvider extends DataSourceProvider { + + private SqlDbServiceConfig actConfig; + private SqlDbService svc; + + public EbeanDataSourceProvider(SqlDbServiceConfig actConfig, SqlDbService svc) { + this.actConfig = actConfig; + this.svc = svc; + } + + @Override + public DataSource createDataSource(DataSourceConfig conf) { + ServerConfig ebeanConfig = new EbeanConfigAdaptor().adaptFrom(actConfig, conf, svc); + DataSourceFactory factory = ebeanConfig.service(DataSourceFactory.class); + if (factory == null) { + throw new IllegalStateException("No DataSourceFactory service implementation found in class path." + + " Probably missing dependency to avaje-datasource?"); + } + + DataSourceAlertFactory alertFactory = ebeanConfig.service(DataSourceAlertFactory.class); + org.avaje.datasource.DataSourceConfig dsConfig = ebeanConfig.getDataSourceConfig(); + if (alertFactory != null) { + dsConfig.setAlert(alertFactory.createAlert()); + } + + if (conf.readOnly) { + // setup to use AutoCommit such that we skip explicit commit + dsConfig.setAutoCommit(true); + } + String poolName = ebeanConfig.getName() + (conf.readOnly ? "-ro" : ""); + return new EbeanDataSourceWrapper(ebeanConfig, factory.createPool(poolName, dsConfig)); + } + + @Override + public Map confKeyMapping() { + return null; + } + + @Override + public DataSourceStatus getStatus(DataSource ds) { + return null; + } +} diff --git a/src/main/java/act/db/ebean/util/EbeanDataSourceWrapper.java b/src/main/java/act/db/ebean/util/EbeanDataSourceWrapper.java new file mode 100644 index 0000000..efd0c7b --- /dev/null +++ b/src/main/java/act/db/ebean/util/EbeanDataSourceWrapper.java @@ -0,0 +1,88 @@ +package act.db.ebean.util; + +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2018 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + +import com.avaje.ebean.config.ServerConfig; +import org.avaje.datasource.DataSourcePool; + +import java.io.PrintWriter; +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.util.logging.Logger; +import javax.sql.DataSource; + +public class EbeanDataSourceWrapper implements DataSource { + + public ServerConfig ebeanConfig; + public DataSourcePool ebeanDs; + + public EbeanDataSourceWrapper(ServerConfig ebeanConfig, DataSourcePool ebeanDs) { + ebeanConfig.setDataSource(ebeanDs); + this.ebeanConfig = ebeanConfig; + this.ebeanDs = ebeanDs; + } + + @Override + public Connection getConnection() throws SQLException { + return ebeanDs.getConnection(); + } + + @Override + public Connection getConnection(String username, String password) throws SQLException { + return ebeanDs.getConnection(username, password); + } + + @Override + public T unwrap(Class iface) throws SQLException { + return ebeanDs.unwrap(iface); + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return ebeanDs.isWrapperFor(iface); + } + + @Override + public PrintWriter getLogWriter() throws SQLException { + return ebeanDs.getLogWriter(); + } + + @Override + public void setLogWriter(PrintWriter out) throws SQLException { + ebeanDs.setLogWriter(out); + } + + @Override + public void setLoginTimeout(int seconds) throws SQLException { + ebeanDs.setLoginTimeout(seconds); + } + + @Override + public int getLoginTimeout() throws SQLException { + return ebeanDs.getLoginTimeout(); + } + + @Override + public Logger getParentLogger() throws SQLFeatureNotSupportedException { + return ebeanDs.getParentLogger(); + } +} From c22b0e14a18d8500a1924ee8ec866c17f22cab32 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 29 May 2018 13:14:20 +1000 Subject: [PATCH 076/114] update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 759c099..617bcb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # act-ebean-java7 CHANGE LOG +1.7.0 - 29/May/2018 +* update act to 1.8.8-RC8 +* update act-sql-common to 1.4.0 + 1.6.2 - 19/May/2018 * catch up act-ebean 1.6.5 changes From 6d656bba9a4b7258fd25c745b0846c619b3a8669 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 29 May 2018 13:15:12 +1000 Subject: [PATCH 077/114] [maven-release-plugin] prepare release act-ebean-java7-1.7.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e06ddfe..554711a 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.0-SNAPSHOT + 1.7.0 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 9d8d51a90b25a32370a055609e804d8931718476 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 29 May 2018 13:15:27 +1000 Subject: [PATCH 078/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 554711a..7ac5426 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.0 + 1.7.1-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 3d18398c168f267b0d0bd6716edd10d5c0cefec4 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Thu, 7 Jun 2018 17:23:58 +1000 Subject: [PATCH 079/114] update act to 1.8.8-RC9, act-sql-common to 1.4.1; catch up to act-ebean-1.7.1 updates --- CHANGELOG.md | 5 +++++ pom.xml | 4 ++-- src/main/java/act/db/ebean/EbeanDao.java | 16 +++++++++++++++- src/main/java/act/db/ebean/EbeanService.java | 2 ++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 617bcb4..43b8ade 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # act-ebean-java7 CHANGE LOG +1.7.1 - 7/Jun/2018 +* update act to 1.8.8-RC9 +* update act-sql-common to 1.4.1 +* catch up act-ebean-1.7.1 updates + 1.7.0 - 29/May/2018 * update act to 1.8.8-RC8 * update act-sql-common to 1.4.0 diff --git a/pom.xml b/pom.xml index 7ac5426..57d1d7f 100755 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ org.actframework parent - 1.8.8-RC8 + 1.8.8-RC9 @@ -45,7 +45,7 @@ 8.1.1 2.1.2 - 1.4.0 + 1.4.1 diff --git a/src/main/java/act/db/ebean/EbeanDao.java b/src/main/java/act/db/ebean/EbeanDao.java index 4398731..5fd02ab 100644 --- a/src/main/java/act/db/ebean/EbeanDao.java +++ b/src/main/java/act/db/ebean/EbeanDao.java @@ -548,7 +548,21 @@ private void buildWhere(ExpressionList where, String key, Object val where.eq(sa[0], val); break; case 2: - R1.valueOf(sa[1]).applyTo(where, sa[0], val); + String op = sa[1]; + if ("!=".equalsIgnoreCase(op)) { + op = "ne"; + } else if ("==".equalsIgnoreCase(op)) { + op = "eq"; + } else if (">".equalsIgnoreCase(op)) { + op = "gt"; + } else if (">=".equals(op)) { + op = "ge"; + } else if ("<".equals(op)) { + op = "lt"; + } else if ("<=".equals(op)) { + op = "le"; + } + R1.valueOf(op).applyTo(where, sa[0], val); break; case 3: R2.valueOf(sa[2]).applyTo(where, sa[0], sa[1], val); diff --git a/src/main/java/act/db/ebean/EbeanService.java b/src/main/java/act/db/ebean/EbeanService.java index 77c6a25..86ddedd 100644 --- a/src/main/java/act/db/ebean/EbeanService.java +++ b/src/main/java/act/db/ebean/EbeanService.java @@ -105,6 +105,8 @@ protected void dataSourceProvided(DataSource dataSource, DataSourceConfig dsConf } app().eventBus().trigger(new EbeanConfigLoaded(ebeanConfig)); if (readonly) { + ebeanConfig.setDdlGenerate(false); + ebeanConfig.setDdlRun(false); ebeanReadOnly = EbeanServerFactory.create(ebeanConfig); } else { ebean = EbeanServerFactory.create(ebeanConfig); From 54dad7e2923b24d34c2d466bda238fa8e39ac2bf Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Thu, 7 Jun 2018 17:24:31 +1000 Subject: [PATCH 080/114] [maven-release-plugin] prepare release act-ebean-java7-1.7.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 57d1d7f..a2b8e1e 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.1-SNAPSHOT + 1.7.1 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 05c7c11f175116019ea8554c260aec999931a35a Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Thu, 7 Jun 2018 17:24:47 +1000 Subject: [PATCH 081/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a2b8e1e..0040b6e 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.1 + 1.7.2-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From e8cd6c216eee416d616ef83c6ed086b5e21909d3 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 19 Jun 2018 21:31:44 +1000 Subject: [PATCH 082/114] update to act-1.8.8-RC10, act-sql-common-1.4.2 --- CHANGELOG.md | 4 ++++ pom.xml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43b8ade..ab1f6f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # act-ebean-java7 CHANGE LOG +1.7.2 - 19/Jun/2018 +* update to act-1.8.8-RC10 +* update act-sql-common to 1.4.2 + 1.7.1 - 7/Jun/2018 * update act to 1.8.8-RC9 * update act-sql-common to 1.4.1 diff --git a/pom.xml b/pom.xml index 0040b6e..459f06a 100755 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ org.actframework parent - 1.8.8-RC9 + 1.8.8-RC10 @@ -45,7 +45,7 @@ 8.1.1 2.1.2 - 1.4.1 + 1.4.2 From 9a2998031be866aeda77120db98c3447fe0e38e1 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 19 Jun 2018 21:32:06 +1000 Subject: [PATCH 083/114] [maven-release-plugin] prepare release act-ebean-java7-1.7.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 459f06a..9871bd2 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.2-SNAPSHOT + 1.7.2 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From c31eef50af1e2e0861cc2400b0ffb4c5ba01f11d Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 19 Jun 2018 21:32:22 +1000 Subject: [PATCH 084/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9871bd2..877d620 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.2 + 1.7.3-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 3904be739ac47a96fab25417ae2bb6f077acdd0b Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Wed, 31 Oct 2018 00:26:26 +1100 Subject: [PATCH 085/114] prepare for 1.7.3 release --- CHANGELOG.md | 4 ++++ pom.xml | 4 ++-- src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab1f6f2..4ee6f90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # act-ebean-java7 CHANGE LOG +1.7.3 - 30/Oct/2018 +* update to act-1.8.8 +* update to act-sql-common 1.4.3 + 1.7.2 - 19/Jun/2018 * update to act-1.8.8-RC10 * update act-sql-common to 1.4.2 diff --git a/pom.xml b/pom.xml index 877d620..fbae80f 100755 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ org.actframework parent - 1.8.8-RC10 + 1.8.9 @@ -45,7 +45,7 @@ 8.1.1 2.1.2 - 1.4.2 + 1.4.3 diff --git a/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java b/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java index a0c2b9c..02e64a0 100644 --- a/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java +++ b/src/main/java/act/db/ebean/util/EbeanConfigAdaptor.java @@ -54,6 +54,7 @@ public ServerConfig adaptFrom(SqlDbServiceConfig actConfig, act.db.sql.DataSourc config.setDdlCreateOnly(!actConfig.ddlGeneratorConfig.drop); config.setNamingConvention(namingConvention(actConfig)); + config.setDatabasePlatformName(dsConfig.customProperties.get("databasePlatformName")); Set modelClasses = svc.entityClasses(); if (null != modelClasses && !modelClasses.isEmpty()) { From dea7ab33b881fad49e259f7f9a77daf32f208c9a Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Wed, 31 Oct 2018 00:26:50 +1100 Subject: [PATCH 086/114] [maven-release-plugin] prepare release act-ebean-java7-1.7.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fbae80f..da0179b 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.3-SNAPSHOT + 1.7.3 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From a0d2c0f1ef5ddd3cd779ad590911bccc9193e5bf Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Wed, 31 Oct 2018 00:30:39 +1100 Subject: [PATCH 087/114] revert to prepare release --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 pom.xml diff --git a/pom.xml b/pom.xml old mode 100755 new mode 100644 index da0179b..fbae80f --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.3 + 1.7.3-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 08457fd21e0c98cf96f85a4f294cae5e0e7970e9 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Wed, 31 Oct 2018 00:31:10 +1100 Subject: [PATCH 088/114] [maven-release-plugin] prepare release act-ebean-java7-1.7.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fbae80f..da0179b 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.3-SNAPSHOT + 1.7.3 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From b247958444556db3eb69b292f974b107b221183a Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Wed, 31 Oct 2018 00:31:26 +1100 Subject: [PATCH 089/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index da0179b..278dc65 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.3 + 1.7.4-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 777eb4583d8dc5ee8d09e2026c3c3305e3cf9352 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sat, 3 Nov 2018 22:22:25 +1100 Subject: [PATCH 090/114] make all fields on EbeanDao be stateless --- src/main/java/act/db/ebean/EbeanDao.java | 31 +++++++++--------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/main/java/act/db/ebean/EbeanDao.java b/src/main/java/act/db/ebean/EbeanDao.java index 5fd02ab..290298f 100644 --- a/src/main/java/act/db/ebean/EbeanDao.java +++ b/src/main/java/act/db/ebean/EbeanDao.java @@ -23,44 +23,37 @@ import static act.Act.app; import act.app.DbServiceManager; -import act.db.DB; -import act.db.DaoBase; -import act.db.DbService; +import act.db.*; import act.db.Model; import act.db.sql.tx.TxContext; -import act.inject.param.NoBind; import act.util.General; +import act.util.Stateless; import com.avaje.ebean.*; import com.avaje.ebeaninternal.api.SpiEbeanServer; import org.osgl.$; import org.osgl.logging.L; import org.osgl.logging.Logger; -import org.osgl.util.C; -import org.osgl.util.E; -import org.osgl.util.S; +import org.osgl.util.*; import java.lang.reflect.Array; import java.lang.reflect.Field; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; +import java.util.*; import javax.persistence.Id; import javax.sql.DataSource; @General -@NoBind public class EbeanDao extends DaoBase> { private static final Logger logger = L.get(EbeanDao.class); - private volatile EbeanServer ebean; - private volatile EbeanServer ebeanReadOnly; - private volatile EbeanService dbSvc; - private volatile DataSource ds; - private volatile DataSource dsReadOnly; - private String tableName; - private Field idField = null; - private List queryIterators = C.newList(); + @Stateless private volatile EbeanServer ebean; + @Stateless private volatile EbeanServer ebeanReadOnly; + @Stateless private volatile EbeanService dbSvc; + @Stateless private volatile DataSource ds; + @Stateless private volatile DataSource dsReadOnly; + @Stateless private String tableName; + @Stateless private Field idField = null; + @Stateless private List queryIterators = C.newList(); EbeanDao(EbeanService service) { init(modelType()); From 8b0d8a799797b422017eb30602a06b26a1750b7b Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 4 Nov 2018 22:08:10 +1100 Subject: [PATCH 091/114] update to act-1.8.9;act-sql-common to 1.4.4;bump version to 1.7.4 --- CHANGELOG.md | 4 ++++ pom.xml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ee6f90..db1a05f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # act-ebean-java7 CHANGE LOG +1.7.4 - 04/Nov/2018 +* update to act-1.8.9 +* update to act-sql-common to 1.4.4 + 1.7.3 - 30/Oct/2018 * update to act-1.8.8 * update to act-sql-common 1.4.3 diff --git a/pom.xml b/pom.xml index 278dc65..558ad7d 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ org.actframework parent - 1.8.9 + 1.8.10 @@ -45,7 +45,7 @@ 8.1.1 2.1.2 - 1.4.3 + 1.4.4 From 318461a6fb5f943141af63a3ddbe05743f7975c1 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 4 Nov 2018 22:09:20 +1100 Subject: [PATCH 092/114] [maven-release-plugin] prepare release act-ebean-java7-1.7.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 558ad7d..f535dd8 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.4-SNAPSHOT + 1.7.4 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From c4d2abe62af3161f51229aa7205b7b813b7edad5 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 4 Nov 2018 22:09:34 +1100 Subject: [PATCH 093/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f535dd8..3e76f13 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.4 + 1.7.5-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From f71ed19d97fe47c9f9d2fd761d381ab64d2d856e Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 18 Nov 2018 12:26:46 +1100 Subject: [PATCH 094/114] catch up ebean2 fix to GH28 --- CHANGELOG.md | 4 ++++ src/main/java/act/db/ebean/EbeanQuery.java | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db1a05f..fe09c84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # act-ebean-java7 CHANGE LOG +1.7.5 +* Catch up Ebean2 fix on GH28 + + 1.7.4 - 04/Nov/2018 * update to act-1.8.9 * update to act-sql-common to 1.4.4 diff --git a/src/main/java/act/db/ebean/EbeanQuery.java b/src/main/java/act/db/ebean/EbeanQuery.java index 0c89807..687ec7a 100644 --- a/src/main/java/act/db/ebean/EbeanQuery.java +++ b/src/main/java/act/db/ebean/EbeanQuery.java @@ -198,7 +198,8 @@ public EbeanQuery orderBy(String... fieldList) { @Override public MODEL_TYPE first() { - return qReadOnly.findUnique(); + List list = qReadOnly.setMaxRows(1).findList(); + return list.isEmpty() ? null : list.get(0); } @Override From ded2cdda6eb65a52d573aa8444cbf54bac48708a Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 20 Nov 2018 10:40:19 +1100 Subject: [PATCH 095/114] update act to 1.8.12 --- CHANGELOG.md | 4 ++-- pom.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe09c84..9ad590a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ # act-ebean-java7 CHANGE LOG -1.7.5 +1.7.5 - 20/Nov/2018 * Catch up Ebean2 fix on GH28 - +* update act to 1.8.12 1.7.4 - 04/Nov/2018 * update to act-1.8.9 diff --git a/pom.xml b/pom.xml index 3e76f13..9e6b395 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ org.actframework parent - 1.8.10 + 1.8.12 From 45a336105d70db3c0a4f901bac692c01671dea96 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 20 Nov 2018 10:41:14 +1100 Subject: [PATCH 096/114] [maven-release-plugin] prepare release act-ebean-java7-1.7.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9e6b395..cd0824d 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.5-SNAPSHOT + 1.7.5 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 87fa62f3b6ea6bc0dfbcc3b37f4a5fe59ada96c3 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 20 Nov 2018 10:41:27 +1100 Subject: [PATCH 097/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cd0824d..107a406 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.5 + 1.7.6-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From fdc019723aaeed2ce0be85179153652b4319205d Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sat, 20 Apr 2019 15:44:12 +1000 Subject: [PATCH 098/114] update to act-1.8.20 --- CHANGELOG.md | 3 +++ pom.xml | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ad590a..3325821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # act-ebean-java7 CHANGE LOG +1.7.6 - 20/Apr/2019 +* Update to act-1.8.20 + 1.7.5 - 20/Nov/2018 * Catch up Ebean2 fix on GH28 * update act to 1.8.12 diff --git a/pom.xml b/pom.xml index 107a406..e00d142 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ org.actframework parent - 1.8.12 + 1.8.20 @@ -45,7 +45,7 @@ 8.1.1 2.1.2 - 1.4.4 + 1.4.5 From ca31f394f32cbb077b9e6389abb849fb56ef79ec Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sat, 20 Apr 2019 15:45:03 +1000 Subject: [PATCH 099/114] [maven-release-plugin] prepare release act-ebean-java7-1.7.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e00d142..76ba8e7 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.6-SNAPSHOT + 1.7.6 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From e08e45e9b5c0a1bedf5132cd79bb8125d1625537 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sat, 20 Apr 2019 15:45:22 +1000 Subject: [PATCH 100/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 76ba8e7..5190336 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.6 + 1.7.7-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From a0bd81ad0a7940d1e9cc2efe46d9b22b9aedb2a6 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 16 Jun 2019 23:45:34 +1000 Subject: [PATCH 101/114] update to act-1.8.23, act-sql-common-1.4.6 --- CHANGELOG.md | 4 ++++ pom.xml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3325821..8322f67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # act-ebean-java7 CHANGE LOG +1.7.7 - 16/Jun/2019 +* update to act-1.8.23 +* update to act-sql-common-1.4.6 + 1.7.6 - 20/Apr/2019 * Update to act-1.8.20 diff --git a/pom.xml b/pom.xml index 5190336..76522b1 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ org.actframework parent - 1.8.20 + 1.8.23 @@ -45,7 +45,7 @@ 8.1.1 2.1.2 - 1.4.5 + 1.4.6 From df6bb5022e0f66f1901f72a7a332e11d369b7ef6 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 16 Jun 2019 23:46:04 +1000 Subject: [PATCH 102/114] [maven-release-plugin] prepare release act-ebean-java7-1.7.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 76522b1..6273721 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.7-SNAPSHOT + 1.7.7 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 0c59dc472bd359c22722d2805f1f6cf5b58b133e Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 16 Jun 2019 23:46:15 +1000 Subject: [PATCH 103/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6273721..9e6b365 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.7 + 1.7.8-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 3fe35c97e57f3bd17096847a0ecf6bad2cb03587 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 2 Jul 2019 23:52:08 +1000 Subject: [PATCH 104/114] update to act-1.8.25, sql-common-1.5.0 --- CHANGELOG.md | 4 ++++ pom.xml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8322f67..b7c0094 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # act-ebean-java7 CHANGE LOG +1.7.8 - 03/Jul/2019 +* update to act-1.8.25 +* update to act-sql-common-1.5.0 + 1.7.7 - 16/Jun/2019 * update to act-1.8.23 * update to act-sql-common-1.4.6 diff --git a/pom.xml b/pom.xml index 9e6b365..ae257a0 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ org.actframework parent - 1.8.23 + 1.8.25 @@ -45,7 +45,7 @@ 8.1.1 2.1.2 - 1.4.6 + 1.5.0 From 739bd127b95443f5bd5d3992c1eb174625ae44bc Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Wed, 3 Jul 2019 07:32:52 +1000 Subject: [PATCH 105/114] [maven-release-plugin] prepare release act-ebean-java7-1.7.8 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ae257a0..14ec8c6 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.8-SNAPSHOT + 1.7.8 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 1ffcfea07bcf2a2f7e3de7e7ae0371d5b262fad5 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Wed, 3 Jul 2019 07:33:04 +1000 Subject: [PATCH 106/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 14ec8c6..80b0b96 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.8 + 1.7.9-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From b7175bee1843e2329fb2ec1c97dc552d0a575af9 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Mon, 30 Sep 2019 21:46:30 +1000 Subject: [PATCH 107/114] update act to 1.8.28; act-sql-common to 1.5.1; tune jobId for all jobs --- CHANGELOG.md | 5 +++++ pom.xml | 4 ++-- src/main/java/act/db/ebean/EbeanAgentLoader.java | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7c0094..8f69ae6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # act-ebean-java7 CHANGE LOG +1.7.9 - 30/Sep/2019 +* update to act-1.8.28 +* update to act-sql-common-1.5.1 + + 1.7.8 - 03/Jul/2019 * update to act-1.8.25 * update to act-sql-common-1.5.0 diff --git a/pom.xml b/pom.xml index 80b0b96..d4af03a 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ org.actframework parent - 1.8.25 + 1.8.28 @@ -45,7 +45,7 @@ 8.1.1 2.1.2 - 1.5.0 + 1.5.1 diff --git a/src/main/java/act/db/ebean/EbeanAgentLoader.java b/src/main/java/act/db/ebean/EbeanAgentLoader.java index 24ef773..1894cd8 100644 --- a/src/main/java/act/db/ebean/EbeanAgentLoader.java +++ b/src/main/java/act/db/ebean/EbeanAgentLoader.java @@ -103,7 +103,9 @@ public static void loadAgent(String jarFilePath, String params) { } } finally { // ensure ebean2 EnhanceContext logout set to dump output - Act.jobManager().on(SysEventId.CLASS_LOADER_INITIALIZED, new Runnable() { + Act.jobManager().on(SysEventId.CLASS_LOADER_INITIALIZED, + S.buffer("EbeanAgentLoader - clean up for ").append(jarFilePath).toString(), + new Runnable() { @Override public void run() { System.setOut(ps); From e73cde7fc3e80db2d950ecc924b5634d3965ac4f Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Mon, 30 Sep 2019 21:47:26 +1000 Subject: [PATCH 108/114] [maven-release-plugin] prepare release act-ebean-java7-1.7.9 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d4af03a..87c7923 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.9-SNAPSHOT + 1.7.9 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 256cf73093beaa1e1161110f2a5161e674cc1708 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Mon, 30 Sep 2019 21:47:36 +1000 Subject: [PATCH 109/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 87c7923..43ea479 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.9 + 1.7.10-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From ab5de823aee18ce975d7a3645edec2f123b021e4 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 3 Nov 2019 20:55:39 +1100 Subject: [PATCH 110/114] update to act-1.8.29 --- CHANGELOG.md | 5 ++++- pom.xml | 6 +++--- src/main/java/act/db/ebean/EbeanDao.java | 5 +++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f69ae6..b3b3ca1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,13 @@ # act-ebean-java7 CHANGE LOG +1.8.0 +* update to act-1.8.29 +* update EbeanDao - add `processLikeValue` method + 1.7.9 - 30/Sep/2019 * update to act-1.8.28 * update to act-sql-common-1.5.1 - 1.7.8 - 03/Jul/2019 * update to act-1.8.25 * update to act-sql-common-1.5.0 diff --git a/pom.xml b/pom.xml index 43ea479..a9dc97f 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.10-SNAPSHOT + 1.8.0-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) @@ -35,7 +35,7 @@ org.actframework parent - 1.8.28 + 1.8.29 @@ -45,7 +45,7 @@ 8.1.1 2.1.2 - 1.5.1 + 1.6.0 diff --git a/src/main/java/act/db/ebean/EbeanDao.java b/src/main/java/act/db/ebean/EbeanDao.java index 290298f..9e0ce5c 100644 --- a/src/main/java/act/db/ebean/EbeanDao.java +++ b/src/main/java/act/db/ebean/EbeanDao.java @@ -583,4 +583,9 @@ public EbeanQuery q(String keys, Object... values) { public EbeanQuery createQuery(String s, Object... objects) { return q(s, objects); } + + @Override + public Object processLikeValue(String v) { + return v.contains("%") ? v : "%" + v + "%"; + } } From 32f107668115b14d021bd90fc570017eddb7a64d Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 3 Nov 2019 20:56:14 +1100 Subject: [PATCH 111/114] [maven-release-plugin] prepare release act-ebean-java7-1.8.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a9dc97f..b032ecf 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.8.0-SNAPSHOT + 1.8.0 ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 3c7b06f141e8054671c311775cacad0e264346bd Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Sun, 3 Nov 2019 20:56:26 +1100 Subject: [PATCH 112/114] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b032ecf..f5c1956 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.8.0 + 1.8.1-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) From 1f6501a4c7dfd973db371c7672195da93b53f974 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Mon, 23 Mar 2020 22:02:24 +1100 Subject: [PATCH 113/114] Allow app to define customised ebean IdGenerator #22 --- CHANGELOG.md | 3 ++ src/main/java/act/db/ebean/EbeanService.java | 2 + .../act/db/ebean/IdGeneratorRegister.java | 44 +++++++++++++++++++ src/main/resources/act.scan.list | 2 +- 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/main/java/act/db/ebean/IdGeneratorRegister.java diff --git a/CHANGELOG.md b/CHANGELOG.md index b3b3ca1..7d2c190 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # act-ebean-java7 CHANGE LOG +1.8.1 +* Allow app to define customised ebean IdGenerator #22 + 1.8.0 * update to act-1.8.29 * update EbeanDao - add `processLikeValue` method diff --git a/src/main/java/act/db/ebean/EbeanService.java b/src/main/java/act/db/ebean/EbeanService.java index 86ddedd..dd40d60 100644 --- a/src/main/java/act/db/ebean/EbeanService.java +++ b/src/main/java/act/db/ebean/EbeanService.java @@ -103,6 +103,8 @@ protected void dataSourceProvided(DataSource dataSource, DataSourceConfig dsConf ebeanConfig = new EbeanConfigAdaptor().adaptFrom(this.config, dsConfig, this); ebeanConfig.setDataSource(dataSource); } + IdGeneratorRegister rg = Act.getInstance(IdGeneratorRegister.class); + rg.registerTo(ebeanConfig); app().eventBus().trigger(new EbeanConfigLoaded(ebeanConfig)); if (readonly) { ebeanConfig.setDdlGenerate(false); diff --git a/src/main/java/act/db/ebean/IdGeneratorRegister.java b/src/main/java/act/db/ebean/IdGeneratorRegister.java new file mode 100644 index 0000000..cc6b397 --- /dev/null +++ b/src/main/java/act/db/ebean/IdGeneratorRegister.java @@ -0,0 +1,44 @@ +package act.db.ebean; + +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2020 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + + +import com.avaje.ebean.config.IdGenerator; +import com.avaje.ebean.config.ServerConfig; + +import javax.inject.Inject; +import javax.inject.Singleton; +import java.util.ArrayList; +import java.util.List; + +@Singleton +public class IdGeneratorRegister { + + @Inject + private List idGenerators = new ArrayList<>(); + + void registerTo(ServerConfig config) { + for (IdGenerator generator : idGenerators) { + config.add(generator); + } + } + +} diff --git a/src/main/resources/act.scan.list b/src/main/resources/act.scan.list index 57e4589..2ab6d2c 100644 --- a/src/main/resources/act.scan.list +++ b/src/main/resources/act.scan.list @@ -1,2 +1,2 @@ act.db.ebean.EbeanModule -act.db.jpa.EntityFinder \ No newline at end of file +act.db.ebean.IdGeneratorRegister From 09c15353be4b343106e2eb9bd99197671516b4a8 Mon Sep 17 00:00:00 2001 From: Gelin Luo Date: Tue, 24 Mar 2020 21:01:42 +1100 Subject: [PATCH 114/114] catch up act-ebean fix to #33: create new mechanism for app to configure ServerConfig --- .../java/act/db/ebean/EbeanConfigurator.java | 36 +++++++++++++++++ .../db/ebean/EbeanConfiguratorManager.java | 39 +++++++++++++++++++ src/main/java/act/db/ebean/EbeanService.java | 4 +- src/main/resources/act.scan.list | 1 + 4 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 src/main/java/act/db/ebean/EbeanConfigurator.java create mode 100644 src/main/java/act/db/ebean/EbeanConfiguratorManager.java diff --git a/src/main/java/act/db/ebean/EbeanConfigurator.java b/src/main/java/act/db/ebean/EbeanConfigurator.java new file mode 100644 index 0000000..d7b8ef3 --- /dev/null +++ b/src/main/java/act/db/ebean/EbeanConfigurator.java @@ -0,0 +1,36 @@ +package act.db.ebean; + +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2020 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + + +import com.avaje.ebean.config.ServerConfig; + +/** + * Application to implement this interface to do further + * configuration to {@link ServerConfig Ebean ServerConfig}. + */ +public interface EbeanConfigurator { + /** + * Configure the Ebean {@link ServerConfig}. + * @param ebeanConfig the Ebean config instance + */ + void configure(ServerConfig ebeanConfig); +} diff --git a/src/main/java/act/db/ebean/EbeanConfiguratorManager.java b/src/main/java/act/db/ebean/EbeanConfiguratorManager.java new file mode 100644 index 0000000..922aedb --- /dev/null +++ b/src/main/java/act/db/ebean/EbeanConfiguratorManager.java @@ -0,0 +1,39 @@ +package act.db.ebean; + +/*- + * #%L + * ACT Ebean + * %% + * Copyright (C) 2015 - 2020 ActFramework + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + +import com.avaje.ebean.config.ServerConfig; + +import javax.inject.Inject; +import java.util.List; + +public class EbeanConfiguratorManager { + + @Inject + private List configurators; + + void callConfigurators(ServerConfig config) { + for (EbeanConfigurator configurator : configurators) { + configurator.configure(config); + } + } + +} diff --git a/src/main/java/act/db/ebean/EbeanService.java b/src/main/java/act/db/ebean/EbeanService.java index dd40d60..9ddd466 100644 --- a/src/main/java/act/db/ebean/EbeanService.java +++ b/src/main/java/act/db/ebean/EbeanService.java @@ -105,7 +105,9 @@ protected void dataSourceProvided(DataSource dataSource, DataSourceConfig dsConf } IdGeneratorRegister rg = Act.getInstance(IdGeneratorRegister.class); rg.registerTo(ebeanConfig); - app().eventBus().trigger(new EbeanConfigLoaded(ebeanConfig)); + EbeanConfiguratorManager configuratorManager = Act.getInstance(EbeanConfiguratorManager.class); + configuratorManager.callConfigurators(ebeanConfig); + //app().eventBus().trigger(new EbeanConfigLoaded(ebeanConfig)); if (readonly) { ebeanConfig.setDdlGenerate(false); ebeanConfig.setDdlRun(false); diff --git a/src/main/resources/act.scan.list b/src/main/resources/act.scan.list index 2ab6d2c..698965d 100644 --- a/src/main/resources/act.scan.list +++ b/src/main/resources/act.scan.list @@ -1,2 +1,3 @@ act.db.ebean.EbeanModule act.db.ebean.IdGeneratorRegister +act.db.ebean.EbeanConfiguratorManager \ No newline at end of file