Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2014-2015 Philip Helger ( philip[at]helger[dot]com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 package com.helger.webbasics.servlet;
 import java.util.Map;
Callbacks for the application server

<LECTYPE> Layout execution context type
Philip Helger
 public abstract class WebAppListenerMultiApp <LECTYPE extends ILayoutExecutionContextextends WebAppListenerWithStatistics
   public static final int DEFAULT_PASSWORD_MIN_LENGTH = 6;
   private static final Logger s_aLogger = LoggerFactory.getLogger (WebAppListenerMultiApp.class);
   protected abstract Map <StringIApplicationInitializer <LECTYPE>> getAllInitializers ();

Set global system properties, after the content was initialized but before the application specific init is started
   protected void initGlobals ()
     // Enable when ready
     WebScopeManager.setSessionPassivationAllowed (false);
     // UDO to data directory
     UserDataManager.setServletContextIO (false);
     // Define the password constrains
     // Global JS formatting stuff :(
     JSPrinter.setGenerateComments (false);
     JSPrinter.setGenerateTypeNames (false);
     JSPrinter.setIndentAndAlign (GlobalDebug.isDebugMode ());
   protected final void afterContextInitialized (@Nonnull final ServletContext aSC)
     // Global properties
     initGlobals ();
     // Determine all initializers
     final Map <StringIApplicationInitializer <LECTYPE>> aIniter = getAllInitializers ();
     if (ContainerHelper.isEmpty (aIniter))
       throw new IllegalStateException ("No application initializers provided!");
     // Invoke all initializers
     for (final Map.Entry <StringIApplicationInitializer <LECTYPE>> aEntry : aIniter.entrySet ())
      final String sAppID = aEntry.getKey ();
      WebScopeManager.onRequestBegin (sAppID,
                                      new OfflineHttpServletRequest (aSCfalse),
                                      new MockHttpServletResponse ());
        final IApplicationInitializer <LECTYPE> aInitializer = aEntry.getValue ();
        // Set per-application settings
        aInitializer.initApplicationSettings ();
        // Register application locales
        aInitializer.initLocales (ApplicationLocaleManager.getInstance ());
        // Create all menu items
        aInitializer.initMenu (ApplicationMenuTree.getTree ());
        // Create the application layouts - after the menus!
        aInitializer.initLayout (ApplicationLayoutManager.<LECTYPE> getInstance ());
        // Register all Ajax functions here
        aInitializer.initAjax (ApplicationAjaxManager.getInstance ());
        // Register all actions here
        aInitializer.initActions (ApplicationActionManager.getInstance ());
        // All other things come last
        aInitializer.initRest ();
      catch (final RuntimeException ex)
        // Log so that the failed application can easily be determined.
        .error ("Failed to init application '" + sAppID + "': " + ex.getMessage ());
        // re-throw
        throw ex;
        WebScopeManager.onRequestEnd ();
New to GrepCode? Check out our FAQ X