Skip to content

Commit 1f6501a

Browse files
committed
Allow app to define customised ebean IdGenerator #22
1 parent 3c7b06f commit 1f6501a

4 files changed

Lines changed: 50 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# act-ebean-java7 CHANGE LOG
22

3+
1.8.1
4+
* Allow app to define customised ebean IdGenerator #22
5+
36
1.8.0
47
* update to act-1.8.29
58
* update EbeanDao - add `processLikeValue` method

src/main/java/act/db/ebean/EbeanService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ protected void dataSourceProvided(DataSource dataSource, DataSourceConfig dsConf
103103
ebeanConfig = new EbeanConfigAdaptor().adaptFrom(this.config, dsConfig, this);
104104
ebeanConfig.setDataSource(dataSource);
105105
}
106+
IdGeneratorRegister rg = Act.getInstance(IdGeneratorRegister.class);
107+
rg.registerTo(ebeanConfig);
106108
app().eventBus().trigger(new EbeanConfigLoaded(ebeanConfig));
107109
if (readonly) {
108110
ebeanConfig.setDdlGenerate(false);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package act.db.ebean;
2+
3+
/*-
4+
* #%L
5+
* ACT Ebean
6+
* %%
7+
* Copyright (C) 2015 - 2020 ActFramework
8+
* %%
9+
* Licensed under the Apache License, Version 2.0 (the "License");
10+
* you may not use this file except in compliance with the License.
11+
* You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS,
17+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* See the License for the specific language governing permissions and
19+
* limitations under the License.
20+
* #L%
21+
*/
22+
23+
24+
import com.avaje.ebean.config.IdGenerator;
25+
import com.avaje.ebean.config.ServerConfig;
26+
27+
import javax.inject.Inject;
28+
import javax.inject.Singleton;
29+
import java.util.ArrayList;
30+
import java.util.List;
31+
32+
@Singleton
33+
public class IdGeneratorRegister {
34+
35+
@Inject
36+
private List<IdGenerator> idGenerators = new ArrayList<>();
37+
38+
void registerTo(ServerConfig config) {
39+
for (IdGenerator generator : idGenerators) {
40+
config.add(generator);
41+
}
42+
}
43+
44+
}

src/main/resources/act.scan.list

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
act.db.ebean.EbeanModule
2-
act.db.jpa.EntityFinder
2+
act.db.ebean.IdGeneratorRegister

0 commit comments

Comments
 (0)