Skip to content

Commit 2dec4b7

Browse files
Updated comments on plugin route table registration
1 parent 60ce666 commit 2dec4b7

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,24 +270,26 @@ private void loadPlugin( NGPlugin plugin ) {
270270
elementManager().registerElementProvider( elementProvider );
271271
}
272272

273-
// Obtain all the routes generated by the given plugin
273+
// Check if the plugin is providing routes
274274
final List<Route> routeList = plugin._createRouteList();
275275

276276
if( !routeList.isEmpty() ) {
277277

278278
// 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;
279+
final NGRouteTable routeTable;
280280

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
281+
// If we're in development mode, we 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 by reading the route list once directly, maintaining performance in production.
283+
// FIXME: Whether or not the route list is cached should be configurable. It should even be configurable for each table, since some lists will rarely change (including ng's own routes) // Hugi 2025-04-19
283284
if( isDevelopmentMode() ) {
284-
pluginRouteTable = new NGRouteTable( plugin.namespace(), plugin::_createRouteList );
285+
routeTable = new NGRouteTable( plugin.namespace(), plugin::_createRouteList );
285286
}
286287
else {
287-
pluginRouteTable = new NGRouteTable( plugin.namespace(), plugin._createRouteList() );
288+
routeTable = new NGRouteTable( plugin.namespace(), plugin._createRouteList() );
288289
}
289290

290-
_routeTables.add( 0, pluginRouteTable );
291+
// The new route table is added at the front, corresponding with the load order of the plugins
292+
_routeTables.add( 0, routeTable );
291293
}
292294

293295
plugin.load( this );

ng-control/src/main/java/ng/control/NGControlPlugin.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ public Elements elements() {
3333
// @Override
3434
// public Routes routes() {
3535
// return Routes
36-
// .map( "/home", context -> new NGResponse( "You're home", 200 ) )
37-
// .mapComponent( "/home/user", NGUserDetailPage.class );
38-
// }
39-
// @Override
40-
// public Routes routes() {
41-
// return Routes
42-
// .map( "/home", context -> new NGResponse( "You're home", 200 ) )
43-
// .mapComponent( "/home/user", NGUserDetailPage.class );
36+
// .map( "/home", request -> new NGResponse( "You're home", 200 ) )
37+
// .map( "/home/user", NGUserDetailPage.class )
38+
// .map( "/some/page", request -> {
39+
// String someValue = request.formValueForKey( "someValue" );
40+
// SomePage page = request.context().pageWithName( SomePage.class );
41+
// page.someValue = someValue;
42+
// return page;
43+
// }
4444
// }
4545
//
4646
// /**

0 commit comments

Comments
 (0)