Author: rmannibucau
Date: Mon Sep 5 14:40:09 2011
New Revision: 1165302
URL: http://svn.apache.org/viewvc?rev=1165302&view=rev
Log:
some refactoring about myfaces properties to avoid too much logging for default
values
Modified:
openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
Modified:
openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java?rev=1165302&r1=1165301&r2=1165302&view=diff
==============================================================================
---
openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java
(original)
+++
openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java
Mon Sep 5 14:40:09 2011
@@ -95,6 +95,7 @@ import static org.apache.openejb.tomcat.
public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener {
public static final String OPENEJB_CROSSCONTEXT_PROPERTY =
"openejb.crosscontext";
public static final String OPENEJB_JSESSION_ID_SUPPORT =
"openejb.jsessionid-support";
+ public static final String OPENEJB_MYFACES_DISABLE_DEFAULT_VALUES =
"openejb.myfaces.disable-default-values";
/**
* Flag for ignore context
@@ -259,6 +260,46 @@ public class TomcatWebAppBuilder impleme
}
/**
+ * just to avoid a lot of log lines which are often useless.
+ *
+ * @param context the servlet context to init.
+ */
+ private static void addMyFacesDefaultParameters(ClassLoader classLoader,
ServletContext context) {
+ if (!Boolean.getBoolean(OPENEJB_MYFACES_DISABLE_DEFAULT_VALUES)) {
+ if (classLoader != null) {
+ try { // if myfaces is not here we doesn't need any trick
+
classLoader.loadClass("org.apache.myfaces.shared.config.MyfacesConfig");
+ } catch (ClassNotFoundException cnfe) {
+ return;
+ }
+ }
+
+ setInitParameter(context, "org.apache.myfaces.PRETTY_HTML",
"true");
+ setInitParameter(context, "org.apache.myfaces.ALLOW_JAVASCRIPT",
"true");
+ setInitParameter(context,
"org.apache.myfaces.RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON", "false");
+ setInitParameter(context,
"org.apache.myfaces.RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS", "false");
+ setInitParameter(context,
"org.apache.myfaces.SAVE_FORM_SUBMIT_LINK_IE", "false");
+ setInitParameter(context,
"org.apache.myfaces.READONLY_AS_DISABLED_FOR_SELECTS", "true");
+ setInitParameter(context,
"org.apache.myfaces.RENDER_VIEWSTATE_ID", "true");
+ setInitParameter(context, "org.apache.myfaces.STRICT_XHTML_LINKS",
"true");
+ setInitParameter(context,
"org.apache.myfaces.RENDER_FORM_SUBMIT_SCRIPT_INLINE", "false");
+ setInitParameter(context,
"org.apache.myfaces.CONFIG_REFRESH_PERIOD", "2");
+ setInitParameter(context,
"org.apache.myfaces.VIEWSTATE_JAVASCRIPT", "false");
+ setInitParameter(context,
"org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS", "auto");
+ setInitParameter(context,
"org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE", "false");
+ setInitParameter(context, "org.apache.myfaces.VALIDATE_XML",
"false");
+ setInitParameter(context,
"org.apache.myfaces.WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG", "true");
+ setInitParameter(context,
"org.apache.myfaces.DEBUG_PHASE_LISTENER", "false");
+ }
+ }
+
+ private static void setInitParameter(ServletContext context, String key,
String value) {
+ if (context.getInitParameter(key) == null) {
+ context.setInitParameter(key, value);
+ }
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -330,6 +371,7 @@ public class TomcatWebAppBuilder impleme
standardContext.getNamingResources().setTransaction(contextTransaction);
startInternal(standardContext);
}
+
addMyFacesDefaultParameters(standardContext.getLoader().getClassLoader(),
standardContext.getServletContext());
}
/**
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java?rev=1165302&r1=1165301&r2=1165302&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
Mon Sep 5 14:40:09 2011
@@ -834,35 +834,32 @@ public class DeploymentLoader implements
File warFile = new File(webModule.getJarLocation());
WebApp webApp = webModule.getWebApp();
if (webApp != null) {
- List<ParamValue> contextParam = webApp.getContextParam();
- for (ParamValue value : contextParam) {
- boolean foundContextParam =
value.getParamName().trim().equals("javax.faces.CONFIG_FILES");
- if (foundContextParam) {
- // the value is a comma separated list of config files
- String commaDelimitedListOfFiles =
value.getParamValue().trim();
- String[] configFiles =
commaDelimitedListOfFiles.split(",");
- // trim any extra spaces in each file
- String[] trimmedConfigFiles = new
String[configFiles.length];
- for (int i = 0; i < configFiles.length; i++) {
- trimmedConfigFiles[i] = configFiles[i].trim();
- }
- // convert each file to a URL and add it to
facesConfigLocations
- for (String location : trimmedConfigFiles) {
- if (!location.startsWith("/"))
- logger.error("A faces configuration file should be
context relative when specified in web.xml. Please fix the value of context
parameter javax.faces.CONFIG_FILES for the file " + location);
- try {
- File file = new File(warFile,
location).getCanonicalFile().getAbsoluteFile();
- URL url = file.toURI().toURL();
- facesConfigLocations.add(url);
+ String foundContextParam =
webApp.contextParamsAsMap().get("javax.faces.CONFIG_FILES");
+ if (foundContextParam != null && foundContextParam != null) {
+ // the value is a comma separated list of config files
+ String commaDelimitedListOfFiles = foundContextParam.trim();
+ String[] configFiles = commaDelimitedListOfFiles.split(",");
+ // trim any extra spaces in each file
+ String[] trimmedConfigFiles = new String[configFiles.length];
+ for (int i = 0; i < configFiles.length; i++) {
+ trimmedConfigFiles[i] = configFiles[i].trim();
+ }
+ // convert each file to a URL and add it to
facesConfigLocations
+ for (String location : trimmedConfigFiles) {
+ if (!location.startsWith("/"))
+ logger.error("A faces configuration file should be
context relative when specified in web.xml. Please fix the value of context
parameter javax.faces.CONFIG_FILES for the file " + location);
+ try {
+ File file = new File(warFile,
location).getCanonicalFile().getAbsoluteFile();
+ URL url = file.toURI().toURL();
+ facesConfigLocations.add(url);
- } catch (IOException e) {
- logger.error("Faces configuration file location
bad: " + location, e);
- }
+ } catch (IOException e) {
+ logger.error("Faces configuration file location bad: "
+ location, e);
}
- break;
}
+ } else if (foundContextParam == null) {
+ logger.error("faces config file is null");
}
-
}
// Search for WEB-INF/faces-config.xml