Skip to content

Commit 60ce666

Browse files
Move plugin loading to a method
1 parent 728b77a commit 60ce666

File tree

1 file changed

+32
-27
lines changed

1 file changed

+32
-27
lines changed

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

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -167,32 +167,7 @@ public static <E extends NGApplication> E runAndReturn( final String[] args, fin
167167
application.plugins.add( application );
168168

169169
for( final NGPlugin plugin : application.plugins ) {
170-
addDefaultResourcesourcesForNamespace( application.resourceManager().resourceLoader(), plugin.namespace() );
171-
properties.addAndReadSource( new PropertiesSourceResource( plugin.namespace(), "Properties" ) );
172-
173-
for( final ElementProvider elementProvider : plugin.elements().elementProviders() ) {
174-
application.elementManager().registerElementProvider( elementProvider );
175-
}
176-
177-
// Obtain all the routes generated by the given plugin
178-
final List<Route> routeList = plugin._createRouteList();
179-
180-
if( !routeList.isEmpty() ) {
181-
182-
// CHECKME: We generate a new route table. This is only so we can copy in the plugin's namespace. Should reeeaally happen in the plugin itself...
183-
final NGRouteTable pluginRouteTable;
184-
185-
// If we're in development mode, the create the route table, using the plugin as a "route supplier". This means the route list gets updated, every time the user makes a change.
186-
// In production, we just create the route table from a static list in instead, to maintain performance
187-
if( isDevelopmentMode ) {
188-
pluginRouteTable = new NGRouteTable( plugin.namespace(), plugin::_createRouteList );
189-
}
190-
else {
191-
pluginRouteTable = new NGRouteTable( plugin.namespace(), plugin._createRouteList() );
192-
}
193-
194-
application._routeTables.add( 0, pluginRouteTable );
195-
}
170+
application.loadPlugin( plugin );
196171
}
197172

198173
logger.info( "===== All properties =====\n" + properties._propertiesMapAsString() );
@@ -284,10 +259,40 @@ private void loadPlugins() {
284259
.forEach( plugin -> {
285260
logger.info( "Loading plugin {}", plugin.getClass().getName() );
286261
plugins.add( plugin );
287-
plugin.load( this );
288262
} );
289263
}
290264

265+
private void loadPlugin( NGPlugin plugin ) {
266+
addDefaultResourcesourcesForNamespace( resourceManager().resourceLoader(), plugin.namespace() );
267+
properties().addAndReadSource( new PropertiesSourceResource( plugin.namespace(), "Properties" ) );
268+
269+
for( final ElementProvider elementProvider : plugin.elements().elementProviders() ) {
270+
elementManager().registerElementProvider( elementProvider );
271+
}
272+
273+
// Obtain all the routes generated by the given plugin
274+
final List<Route> routeList = plugin._createRouteList();
275+
276+
if( !routeList.isEmpty() ) {
277+
278+
// CHECKME: We generate a new route table. This is only so we can copy in the plugin's namespace. Should reeeaally happen in the plugin itself...
279+
final NGRouteTable pluginRouteTable;
280+
281+
// If we're in development mode, the create the route table, using the plugin as a "route supplier". This means the route list gets updated, every time the user makes a change.
282+
// In production, we just create the route table from a static list in instead, to maintain performance
283+
if( isDevelopmentMode() ) {
284+
pluginRouteTable = new NGRouteTable( plugin.namespace(), plugin::_createRouteList );
285+
}
286+
else {
287+
pluginRouteTable = new NGRouteTable( plugin.namespace(), plugin._createRouteList() );
288+
}
289+
290+
_routeTables.add( 0, pluginRouteTable );
291+
}
292+
293+
plugin.load( this );
294+
}
295+
291296
/**
292297
* @return The class to use when constructing a new session. By default we look for a class named "Session" in the same package as the application class
293298
*/

0 commit comments

Comments
 (0)