code: private void registerSessionListener() {
          ISessionLifecycle sessionTracker = new ISessionLifecycle() {
              
              @Override
              public void onSessionCreate(Session session) {
                  try {
                      AppContextFinder.createAppContext(session.getPage());
                  } catch (Exception e) {
                      throw new SessionInitException(e);
                  }
              }
              
              @Override
              public void onSessionDestroy(Session session) {
                  AppContextFinder.destroyAppContext(session.getPage());
              }
              
          };
  
          Sessions.getInstance().addLifecycleListener(sessionTracker);
      }
docs: Manages creation/destruction of child contexts.