diff --git a/CHANGELOG.md b/CHANGELOG.md index b7c0094..7d2c190 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # 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 + +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..f5c1956 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ act-ebean-java7 jar - 1.7.9-SNAPSHOT + 1.8.1-SNAPSHOT ACT Ebean Provides SQL database access through Ebean ORM library (java 7+) @@ -35,7 +35,7 @@ org.actframework parent - 1.8.25 + 1.8.29 @@ -45,7 +45,7 @@ 8.1.1 2.1.2 - 1.5.0 + 1.6.0 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); 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/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 + "%"; + } } diff --git a/src/main/java/act/db/ebean/EbeanService.java b/src/main/java/act/db/ebean/EbeanService.java index 86ddedd..9ddd466 100644 --- a/src/main/java/act/db/ebean/EbeanService.java +++ b/src/main/java/act/db/ebean/EbeanService.java @@ -103,7 +103,11 @@ protected void dataSourceProvided(DataSource dataSource, DataSourceConfig dsConf ebeanConfig = new EbeanConfigAdaptor().adaptFrom(this.config, dsConfig, this); ebeanConfig.setDataSource(dataSource); } - app().eventBus().trigger(new EbeanConfigLoaded(ebeanConfig)); + IdGeneratorRegister rg = Act.getInstance(IdGeneratorRegister.class); + rg.registerTo(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/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..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.jpa.EntityFinder \ No newline at end of file +act.db.ebean.IdGeneratorRegister +act.db.ebean.EbeanConfiguratorManager \ No newline at end of file