Skip to content

Commit 62b75d8

Browse files
Perform plugin loading only once all plugins have been "initialized"
1 parent c6c7aeb commit 62b75d8

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

ng-appserver/src/main/java/ng/appserver/NGApplication.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,14 @@ public static <E extends NGApplication> E runAndReturn( final String[] args, fin
175175
// We add the application plugin after all the other plugins
176176
application.plugins.add( application );
177177

178+
// We start by initializing all the located plugins...
178179
for( final NGPlugin plugin : application.plugins ) {
179-
application.loadPlugin( plugin );
180+
application.initPlugin( plugin );
181+
}
182+
183+
// Once all plugins have been initialized, we load them
184+
for( final NGPlugin plugin : application.plugins ) {
185+
plugin.load( application );
180186
}
181187

182188
logger.info( "===== All properties =====\n" + properties._propertiesMapAsString() );
@@ -266,8 +272,11 @@ private void locatePlugins() {
266272
} );
267273
}
268274

269-
private void loadPlugin( NGPlugin plugin ) {
270-
logger.info( "Loading plugin {}", plugin.getClass().getName() );
275+
/**
276+
* Initializes the given plugin, adding routes, properties and elements provided by it
277+
*/
278+
private void initPlugin( final NGPlugin plugin ) {
279+
logger.info( "Initializing plugin {}", plugin.getClass().getName() );
271280
addDefaultResourcesourcesForNamespace( resourceManager().resourceLoader(), plugin.namespace() );
272281
properties().addAndReadSource( new PropertiesSourceResource( plugin.namespace(), "Properties" ) );
273282

@@ -298,8 +307,6 @@ private void loadPlugin( NGPlugin plugin ) {
298307
// The new route table is added at the front, corresponding with the load order of the plugins
299308
_routeTables.add( 0, routeTable );
300309
}
301-
302-
plugin.load( this );
303310
}
304311

305312
/**

0 commit comments

Comments
 (0)