Skip to content

Commit 2030364

Browse files
committed
1 parent b002b6e commit 2030364

6 files changed

Lines changed: 27 additions & 11 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@
256256
<jline.version>2.14.3</jline.version>
257257
<joda-time.version>2.9.9</joda-time.version>
258258
<okhttp.version>3.8.0</okhttp.version>
259-
<osgl-tool.version>1.1.0</osgl-tool.version>
259+
<osgl-tool.version>1.2.0</osgl-tool.version>
260260
<osgl-genie.version>1.1.2</osgl-genie.version>
261261
<osgl-mvc.version>1.1.1</osgl-mvc.version>
262262
<osgl-storage.version>1.2.0</osgl-storage.version>

src/main/java/act/app/App.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ public synchronized void refresh() {
606606
emit(DEPENDENCY_INJECTOR_PROVISIONED);
607607
emit(SINGLETON_PROVISIONED);
608608
config().preloadConfigurations();
609-
jobManager().on(AppEventId.DB_SVC_LOADED, new Runnable() {
609+
Runnable runnable = new Runnable() {
610610
@Override
611611
public void run() {
612612
if (null != blockIssueCause) {
@@ -619,7 +619,12 @@ public void run() {
619619
LOGGER.info("App[%s] loaded in %sms", name(), $.ms() - ms);
620620
emit(POST_START);
621621
}
622-
}, true);
622+
};
623+
if (!dbServiceManager().hasDbService() || eventEmitted(DB_SVC_LOADED)) {
624+
runnable.run();
625+
} else {
626+
jobManager().on(DB_SVC_LOADED, runnable, true);
627+
}
623628
} catch (BlockIssueSignal e) {
624629
// ignore
625630
}
@@ -1028,7 +1033,7 @@ private void initServiceResourceManager() {
10281033

10291034
private void clearServiceResourceManager() {
10301035
if (null != appServiceRegistry) {
1031-
eventBus().emit(STOP);
1036+
emit(STOP);
10321037
appServiceRegistry.destroy();
10331038
dependencyInjector = null;
10341039
if (null != cache) {

src/main/java/act/app/DbServiceManager.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public void visit(ClassNode classNode) throws $.Break {
112112
@Override
113113
public void on(EventObject event) throws Exception {
114114
daoInitializer.run();
115-
eventBus.emit(AppEventId.DB_SVC_LOADED);
115+
app.emit(AppEventId.DB_SVC_LOADED);
116116
}
117117
});
118118
} else {
@@ -122,13 +122,17 @@ public void on(DbServiceInitialized event) throws Exception {
122122
asyncInitializers.remove(event.source());
123123
if (asyncInitializers.isEmpty()) {
124124
daoInitializer.run();
125-
eventBus.emit(AppEventId.DB_SVC_LOADED);
125+
app.emit(AppEventId.DB_SVC_LOADED);
126126
}
127127
}
128128
});
129129
}
130130
}
131131

132+
boolean hasDbService() {
133+
return serviceMap.isEmpty();
134+
}
135+
132136
private void configureSequenceGenerator(final App app) {
133137
app.jobManager().on(AppEventId.DEPENDENCY_INJECTOR_PROVISIONED, new Runnable() {
134138
@Override

src/main/java/act/app/conf/AutoConfigPlugin.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ void load() {
146146
void loadClass(Class<?> c, String ns) {
147147
Class[] ca = c.getClasses();
148148
for (Class c0 : ca) {
149+
if (c0 == c) {
150+
continue;
151+
}
149152
int mod = c0.getModifiers();
150153
if (Modifier.isStatic(mod)) {
151154
loadClass(c0, ns + "." + c0.getSimpleName());

src/main/java/act/conf/AppConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2575,7 +2575,7 @@ private void loadJarProperties(Properties p) {
25752575
* @param conf the application configurator
25762576
*/
25772577
public void _merge(AppConfigurator conf) {
2578-
app.eventBus().trigger(AppEventId.CONFIG_PREMERGE);
2578+
app.emit(AppEventId.CONFIG_PREMERGE);
25792579
if (mergeTracker.contains(conf)) {
25802580
return;
25812581
}

src/main/java/act/event/EventBus.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,18 @@ private void callOn(ActEvent event, Map<Class<? extends EventObject>, List<ActEv
283283
callOn(event, list, async);
284284
}
285285

286+
/**
287+
* Emit an internal event.
288+
*
289+
* Not to be used by app developer
290+
*
291+
* @param eventId the app event ID
292+
* @return this event bus
293+
*/
286294
public synchronized EventBus emit(AppEventId eventId) {
287295
return emit(appEventLookup.get(eventId));
288296
}
289297

290-
public synchronized EventBus trigger(AppEventId eventId) {
291-
return emit(eventId);
292-
}
293-
294298
public synchronized EventBus emit(final AppEvent event) {
295299
if (isDestroyed()) {
296300
return this;

0 commit comments

Comments
 (0)