// WARNING: This file was automatically generated. Do not edit it directly, // or you will lose your changes. /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * 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 org.apache.myfaces.webapp; import java.util.logging.Level; import java.util.logging.Logger; import javax.faces.application.ProjectStage; import javax.faces.context.FacesContext; import org.apache.myfaces.shared.config.MyfacesConfig; import org.apache.myfaces.shared.util.StringUtils; import org.apache.myfaces.shared.util.WebConfigParamUtils; public class WebConfigParamsLogger { private static final Logger log = Logger.getLogger(WebConfigParamsLogger.class.getName()); public static void logWebContextParams(FacesContext facesContext) { String logCommand = WebConfigParamUtils.getStringInitParameter( facesContext.getExternalContext(), AbstractFacesInitializer.INIT_PARAM_LOG_WEB_CONTEXT_PARAMS, AbstractFacesInitializer.INIT_PARAM_LOG_WEB_CONTEXT_PARAMS_DEFAULT); if ( logCommand.equals("false") || (logCommand.equals("auto") && !facesContext.isProjectStage(ProjectStage.Development) && !facesContext.isProjectStage(ProjectStage.Production) ) ) { //No log if is disabled or is in auto mode and project stage is UnitTest or SystemTest return; } MyfacesConfig myfacesConfig = MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()); if (myfacesConfig.isTomahawkAvailable()) { if(myfacesConfig.isMyfacesImplAvailable()) { if(log.isLoggable(Level.INFO)) { log.info("Starting up Tomahawk on the MyFaces-JSF-Implementation"); } } if(myfacesConfig.isRiImplAvailable()) { if(log.isLoggable(Level.INFO)) { log.info("Starting up Tomahawk on the RI-JSF-Implementation."); } } } else { if (log.isLoggable(Level.INFO)) { log.info("Tomahawk jar not available. Autoscrolling, DetectJavascript, AddResourceClass and CheckExtensionsFilter are disabled now."); } } if(myfacesConfig.isRiImplAvailable() && myfacesConfig.isMyfacesImplAvailable()) { log.severe("Both MyFaces and the RI are on your classpath. Please make sure to use only one of the two JSF-implementations."); } ## ----------------------------- PROPERTY MACROS ----------------------------- ## ## ------------------------------- ## writePropertyCheck ## ------------------------------- ## #macro (writePropertyCheck $webConfigParam) paramValue = facesContext.getExternalContext().getInitParameter("$webConfigParam.name"); if (paramValue == null) { log.info("No context init parameter '$webConfigParam.name' found#if($webConfigParam.defaultValue), using default value '$webConfigParam.defaultValue'#end."); } #if (!$webConfigParam.isDeprecated()) #if ($webConfigParam.expectedValues) else { boolean found = false; String[] expectedValues = StringUtils.trim(StringUtils.splitShortString("$webConfigParam.expectedValues",',')); for (int i = 0; i < expectedValues.length; i++) { #if ($webConfigParam.isIgnoreUpperLowerCase()) if (paramValue.equalsIgnoreCase(expectedValues[i])) #else if (paramValue.equals(expectedValues[i])) #end { found = true; break; } } if (!found) { if (log.isLoggable(Level.WARNING)) { log.warning("Wrong value in context init parameter '$webConfigParam.name' (='" + paramValue + "'), using default value #if($webConfigParam.defaultValue)'$webConfigParam.defaultValue'#else'null'#end"); } } } #elseif ($webConfigParam.classType) else { try { ${webConfigParam.classType}.valueOf(paramValue); } catch(Exception e) { if (log.isLoggable(Level.WARNING)) { log.warning("Wrong value in context init parameter '$webConfigParam.name' (='" + paramValue + "'), using default value #if($webConfigParam.defaultValue)'$webConfigParam.defaultValue'#else'null'#end"); } } } #end #end #end ## ## ----------------------------- END PROPERTY MACROS ------------------------- ## if (log.isLoggable(Level.INFO)) { log.info("Scanning for context init parameters not defined. It is not necessary to define them all into your web.xml, " + "they are just provided here for informative purposes. To disable this messages set " + AbstractFacesInitializer.INIT_PARAM_LOG_WEB_CONTEXT_PARAMS + " config param to 'false'"); String paramValue = null; #set ($webConfigList = ${model.getWebConfigs()}) #foreach( $webConfig in $webConfigList ) #if ($modelIds.contains($webConfig.modelId)) #set ($webConfigParamList = ${webConfig.getWebConfigParametersList()}) #foreach( $webConfigParam in $webConfigParamList ) #if (not $webConfigParam.containsTag('tomahawk')) #writePropertyCheck($webConfigParam) #end #end #end #end } ## if (log.isLoggable(Level.INFO) && myfacesConfig.isTomahawkAvailable()) { String paramValue = null; #foreach( $webConfig in $webConfigList ) #if ($modelIds.contains($webConfig.modelId)) #set ($webConfigParamList = ${webConfig.getWebConfigParametersList()}) #foreach( $webConfigParam in $webConfigParamList ) #if ($webConfigParam.containsTag('tomahawk')) #writePropertyCheck($webConfigParam) #end #end #end #end } } }