Skip to content

Commit 09c1535

Browse files
committed
catch up act-ebean fix to #33: create new mechanism for app to configure ServerConfig
1 parent 1f6501a commit 09c1535

File tree

4 files changed

+79
-1
lines changed

4 files changed

+79
-1
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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.ServerConfig;
25+
26+
/**
27+
* Application to implement this interface to do further
28+
* configuration to {@link ServerConfig Ebean ServerConfig}.
29+
*/
30+
public interface EbeanConfigurator {
31+
/**
32+
* Configure the Ebean {@link ServerConfig}.
33+
* @param ebeanConfig the Ebean config instance
34+
*/
35+
void configure(ServerConfig ebeanConfig);
36+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
import com.avaje.ebean.config.ServerConfig;
24+
25+
import javax.inject.Inject;
26+
import java.util.List;
27+
28+
public class EbeanConfiguratorManager {
29+
30+
@Inject
31+
private List<EbeanConfigurator> configurators;
32+
33+
void callConfigurators(ServerConfig config) {
34+
for (EbeanConfigurator configurator : configurators) {
35+
configurator.configure(config);
36+
}
37+
}
38+
39+
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ protected void dataSourceProvided(DataSource dataSource, DataSourceConfig dsConf
105105
}
106106
IdGeneratorRegister rg = Act.getInstance(IdGeneratorRegister.class);
107107
rg.registerTo(ebeanConfig);
108-
app().eventBus().trigger(new EbeanConfigLoaded(ebeanConfig));
108+
EbeanConfiguratorManager configuratorManager = Act.getInstance(EbeanConfiguratorManager.class);
109+
configuratorManager.callConfigurators(ebeanConfig);
110+
//app().eventBus().trigger(new EbeanConfigLoaded(ebeanConfig));
109111
if (readonly) {
110112
ebeanConfig.setDdlGenerate(false);
111113
ebeanConfig.setDdlRun(false);

src/main/resources/act.scan.list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
act.db.ebean.EbeanModule
22
act.db.ebean.IdGeneratorRegister
3+
act.db.ebean.EbeanConfiguratorManager

0 commit comments

Comments
 (0)