While thinking about the JAXB transition I performed some minor cleanup work
on ConfigureListener.
SECTION: Modified Files
--------------------------------
M src/com/sun/faces/RIConstants.java
- Moved constants from RIConstants to ConfigureListener as
these were only used by ConfigureListener
- Removed static methods for setting configuration of
HTML TLV (the methods seemed to go against what
RIConstants was all about). Variable is now public member.
M src/com/sun/faces/config/ConfigureListener.java
- added generic method 'isFeatureEnabled' for
handling of true/false type of context init param
configuration - removed old related methods.
- changed relevant single byte Strings to char
- Moved the repetitious exception processing logic
from contextInitialized method into the parse() method.
- Use Util.loadClass() to load classes
M src/com/sun/faces/taglib/html_basic/HtmlBasicValidator.java
- Changes based on modifications in RIConstants.java
M src/com/sun/faces/util/Util.java
- Added new messages based on changes in ConfigureListener
M src/javax/faces/Messages.properties
M src/javax/faces/Messages_de.properties
M src/javax/faces/Messages_es.properties
M src/javax/faces/Messages_fr.properties
- Clarified the existing message regarding invalid context parameter
values.
Since this was only used in the true/false config options, state the
value received, the option name, and the valid values.
M test/com/sun/faces/config/ConfigFileTestCase.java
- Updated based on changes above.
M test/com/sun/faces/util/TestUtil_messages.java
- Added new message to test list
SECTION: Diffs
----------------------------
SEE ATTACHED FILE
? diff.txt
? patch.txt
? testresults
? systest-per-webapp/build
? systest-per-webapp/command-link-redirect/build
? systest-per-webapp/el-performance/build
? systest-per-webapp/nested-datatables/build
? systest-per-webapp/replace-application/build
? systest-per-webapp/unique-view-id/build
Index: src/com/sun/faces/RIConstants.java
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/RIConstants.java,v
retrieving revision 1.66
diff -u -r1.66 RIConstants.java
--- src/com/sun/faces/RIConstants.java 8 Jun 2004 13:47:27 -0000 1.66
+++ src/com/sun/faces/RIConstants.java 26 Jul 2004 18:53:16 -0000
@@ -51,15 +51,6 @@
public static final String SAVESTATE_FIELD_MARKER = FACES_PREFIX +
"saveStateFieldMarker";
- public static final String JSF_RI_CONFIG =
- "com/sun/faces/jsf-ri-config.xml";
-
- public static final String JSF_RI_STANDARD =
- "com/sun/faces/standard-html-renderkit.xml";
-
- public final static String FORM_NUMBER_ATTR = FACES_PREFIX +
- "FormNumber";
-
/**
* <p>Parser implementation for processing JSF reference expressions.</p>
*/
@@ -86,10 +77,6 @@
public static final String IMMUTABLE_MARKER =
FACES_PREFIX + "IMMUTABLE";
- public static final String VALIDATE_XML = FACES_PREFIX + "validateXml";
-
- public static final String VERIFY_OBJECTS = FACES_PREFIX + "verifyObjects";
-
public static final String ONE_TIME_INITIALIZATION_ATTR =
FACES_PREFIX + "OneTimeInitialization";
@@ -119,18 +106,7 @@
public static final Object NO_VALUE = new String();
- private static boolean htmlTLVActive = false;
-
- public static final String ENABLE_HTML_TLV = FACES_PREFIX +
- "enableHtmlTagLibValidator";
-
- public static boolean isHtmlTagLibValidatorActive() {
- return htmlTLVActive;
- }
-
- public static void setHtmlTagLibValidatorActive(boolean state) {
- htmlTLVActive = state;
- }
+ public static boolean HTML_TLV_ACTIVE = false;
//
// Constructors and Initializers
Index: src/com/sun/faces/config/ConfigureListener.java
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/config/ConfigureListener.java,v
retrieving revision 1.23
diff -u -r1.23 ConfigureListener.java
--- src/com/sun/faces/config/ConfigureListener.java 20 Jul 2004 21:54:48 -0000 1.23
+++ src/com/sun/faces/config/ConfigureListener.java 26 Jul 2004 18:53:17 -0000
@@ -11,7 +11,6 @@
import com.sun.faces.RIConstants;
import com.sun.faces.application.ApplicationAssociate;
import com.sun.faces.application.ConfigNavigationCase;
-import com.sun.faces.application.ViewHandlerImpl;
import com.sun.faces.config.beans.ApplicationBean;
import com.sun.faces.config.beans.ComponentBean;
import com.sun.faces.config.beans.ConverterBean;
@@ -31,7 +30,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
import javax.faces.FacesException;
import javax.faces.FactoryFinder;
@@ -40,6 +38,7 @@
import javax.faces.application.NavigationHandler;
import javax.faces.application.StateManager;
import javax.faces.application.ViewHandler;
+import javax.faces.context.ExternalContext;
import javax.faces.el.PropertyResolver;
import javax.faces.el.VariableResolver;
import javax.faces.event.ActionListener;
@@ -53,10 +52,7 @@
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
-import javax.faces.context.ExternalContext;
-import java.util.Locale;
-import java.util.Map;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
@@ -68,7 +64,10 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.Locale;
+import java.util.Map;
import java.util.Set;
+import java.util.StringTokenizer;
/**
@@ -81,8 +80,110 @@
// -------------------------------------------------------- Static Variables
- protected static String FACES_CONFIG_BEAN_KEY = RIConstants.FACES_PREFIX +
- "FACES_CONFIG_BEAN";
+ /**
+ * <p><code>ServletContext</code> attribute key.</p>
+ */
+ protected static String FACES_CONFIG_BEAN_KEY =
+ RIConstants.FACES_PREFIX + "FACES_CONFIG_BEAN";
+
+ /**
+ * <p>The path to the RI main configuration file.</p>
+ */
+ protected static final String JSF_RI_CONFIG =
+ "com/sun/faces/jsf-ri-config.xml";
+
+
+ /**
+ * <p>The path to the RI standard HTML renderkit configuration file.</p>
+ */
+ protected static final String JSF_RI_STANDARD =
+ "com/sun/faces/standard-html-renderkit.xml";
+
+ /**
+ * <p>The resource path for faces-config files included in the
+ * <code>META-INF</code> directory of JAR files.</p>
+ */
+ protected static final String META_INF_RESOURCES =
+ "META-INF/faces-config.xml";
+
+ /**
+ * <p>The resource path for the faces configuration in the
+ * <code>WEB-INF</code> directory of an application.</p>
+ */
+ protected static final String WEB_INF_RESOURCE =
+ "/WEB-INF/faces-config.xml";
+
+ /**
+ * <p>The context initialization parameter that determines whether
+ * or not the config files will be validated against their respective
+ * DTD.</p>
+ */
+ protected static final String VALIDATE_XML =
+ RIConstants.FACES_PREFIX + "validateXml";
+
+ /**
+ * <p>The context initialization parameter that determines whether
+ * or not the RI will attempt to validate that all defined objects
+ * can be created.</p>
+ */
+ protected static final String VERIFY_OBJECTS =
+ RIConstants.FACES_PREFIX + "verifyObjects";
+
+
+ /**
+ * <p>The context initialization parameter that determines whether
+ * or not the RI will enable HTML TLV processing.</p>
+ */
+ protected static final String ENABLE_HTML_TLV =
+ RIConstants.FACES_PREFIX + "enableHtmlTagLibValidator";
+
+ /*
+ * The first element is the path, the second is the public ID.
+ */
+ private static String[][] DTD_INFO = {
+ { "/com/sun/faces/web-facesconfig_1_0.dtd",
+ "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN" },
+ { "/com/sun/faces/web-facesconfig_1_1.dtd",
+ "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" }
+ };
+
+ /**
+ * <p>All known factory names.</p>
+ */
+ private static final String[] FACTORY_NAMES = {
+ FactoryFinder.APPLICATION_FACTORY,
+ FactoryFinder.FACES_CONTEXT_FACTORY,
+ FactoryFinder.LIFECYCLE_FACTORY,
+ FactoryFinder.RENDER_KIT_FACTORY
+ };
+
+ /**
+ * <p>Array of known primitive types.</p>
+ */
+ private static final Class PRIM_CLASSES_TO_CONVERT[] = {
+ java.lang.Boolean.TYPE,
+ java.lang.Byte.TYPE,
+ java.lang.Character.TYPE,
+ java.lang.Double.TYPE,
+ java.lang.Float.TYPE,
+ java.lang.Integer.TYPE,
+ java.lang.Long.TYPE,
+ java.lang.Short.TYPE
+ };
+
+ /**
+ * <p>Array of known converters for primitive types.</p>
+ */
+ private static final String CONVERTERS_FOR_PRIMS[] = {
+ "javax.faces.convert.BooleanConverter",
+ "javax.faces.convert.ByteConverter",
+ "javax.faces.convert.CharacterConverter",
+ "javax.faces.convert.DoubleConverter",
+ "javax.faces.convert.FloatConverter",
+ "javax.faces.convert.IntegerConverter",
+ "javax.faces.convert.LongConverter",
+ "javax.faces.convert.ShortConverter"
+ };
/**
@@ -157,14 +258,10 @@
}
}
- // see if we need to disable our TLValidator
- String enableHtmlTLValidator = null;
- if (null != (enableHtmlTLValidator =
- context.getInitParameter(RIConstants.ENABLE_HTML_TLV))) {
- if (enableHtmlTLValidator.toString().equals("true")) {
- RIConstants.setHtmlTagLibValidatorActive(true);
- }
- }
+ // see if we need to disable our TLValidator
+ RIConstants.HTML_TLV_ACTIVE =
+ isFeatureEnabled(context, ENABLE_HTML_TLV);
+
URL url = null;
if (log.isDebugEnabled()) {
log.debug("contextInitialized(" + context.getServletContextName()
@@ -172,62 +269,27 @@
}
// Ensure that we initialize a particular application ony once
- if (initialized(context)) {
+ if (initialized()) {
return;
}
// Step 1, configure a Digester instance we can use
- try {
- boolean validateXml = validateTheXml(context);
- digester = digester(validateXml);
- } catch (MalformedURLException e) {
- throw new FacesException(e); // PENDING - add message
- }
+ digester = digester(isFeatureEnabled(context, VALIDATE_XML));
// Step 2, parse the RI configuration resource
- try {
- url = Util.getCurrentLoader(this).getResource
- (RIConstants.JSF_RI_CONFIG);
- parse(digester, url, fcb);
- } catch (Exception e) {
- String message = null;
- try {
- message = Util.getExceptionMessageString
- (Util.CANT_PARSE_FILE_ERROR_MESSAGE_ID,
- new Object[]{url.toExternalForm()});
- } catch (Exception ee) {
- message = "Can't parse configuration file:" +
- url.toExternalForm();
- }
- log.warn(message, e);
- throw new FacesException(message, e);
- }
+ url = Util.getCurrentLoader(this).getResource(JSF_RI_CONFIG);
+ parse(digester, url, fcb);
// Step 3, parse the Standard HTML RenderKit
- try {
- url = Util.getCurrentLoader(this).getResource
- (RIConstants.JSF_RI_STANDARD);
- parse(digester, url, fcb);
- } catch (Exception e) {
- String message = null;
- try {
- message = Util.getExceptionMessageString
- (Util.CANT_PARSE_FILE_ERROR_MESSAGE_ID,
- new Object[]{url.toExternalForm()});
- } catch (Exception ee) {
- message = "Can't parse configuration file:" +
- url.toExternalForm();
- }
- log.warn(message, e);
- throw new FacesException(message, e);
- }
+ url = Util.getCurrentLoader(this).getResource(JSF_RI_STANDARD);
+ parse(digester, url, fcb);
// Step 4, parse any "/META-INF/faces-config.xml" resources
Iterator resources;
try {
List list = new LinkedList();
- Enumeration items = Util.getCurrentLoader(this).getResources
- ("META-INF/faces-config.xml");
+ Enumeration items = Util.getCurrentLoader(this).
+ getResources(META_INF_RESOURCES);
while (items.hasMoreElements()) {
list.add(0, items.nextElement());
}
@@ -237,31 +299,17 @@
try {
message = Util.getExceptionMessageString
(Util.CANT_PARSE_FILE_ERROR_MESSAGE_ID,
- new Object[]{"/META-INF/faces-config.xml"});
+ new Object[]{ META_INF_RESOURCES });
} catch (Exception ee) {
message = "Can't parse configuration file:" +
- "/META-INF/faces-config.xml";
+ META_INF_RESOURCES;
}
log.warn(message, e);
throw new FacesException(message, e);
}
while (resources.hasNext()) {
url = (URL) resources.next();
- try {
- parse(digester, url, fcb);
- } catch (Exception e) {
- String message = null;
- try {
- message = Util.getExceptionMessageString
- (Util.CANT_PARSE_FILE_ERROR_MESSAGE_ID,
- new Object[]{url.toExternalForm()});
- } catch (Exception ee) {
- message = "Can't parse configuration file:" +
- url.toExternalForm();
- }
- log.warn(message, e);
- throw new FacesException(message, e);
- }
+ parse(digester, url, fcb);
}
// Step 5, parse any context-relative resources specified in
@@ -269,59 +317,21 @@
String paths =
context.getInitParameter(FacesServlet.CONFIG_FILES_ATTR);
if (paths != null) {
- paths = paths.trim();
- String path;
- while (paths.length() > 0) {
-
- // Identify the next resource path to load
- int comma = paths.indexOf(",");
- if (comma >= 0) {
- path = paths.substring(0, comma).trim();
- paths = paths.substring(comma + 1).trim();
- } else {
- path = paths.trim();
- paths = "";
- }
- if (path.length() < 1) {
- break;
- }
+ for (StringTokenizer t = new StringTokenizer(paths.trim(), ",");
+ t.hasMoreTokens(); ) {
- try {
- url = context.getResource(path);
+ url = getContextURLForPath(context, t.nextToken().trim());
+ if (url != null) {
parse(digester, url, fcb);
- } catch (Exception e) {
- String message = null;
- try {
- message = Util.getExceptionMessageString
- (Util.CANT_PARSE_FILE_ERROR_MESSAGE_ID,
- new Object[]{path});
- } catch (Exception ee) {
- message = "Can't parse configuration file:" + path;
- }
- log.warn(message, e);
- throw new FacesException(message, e);
}
+
}
}
// Step 6, parse "/WEB-INF/faces-config.xml" if it exists
- try {
- url = context.getResource("/WEB-INF/faces-config.xml");
- if (url != null) {
- parse(digester, url, fcb);
- }
- } catch (Exception e) {
- String message = null;
- try {
- message = Util.getExceptionMessageString
- (Util.CANT_PARSE_FILE_ERROR_MESSAGE_ID,
- new Object[]{url.toExternalForm()});
- } catch (Exception ee) {
- message = "Can't parse configuration file:" +
- url.toExternalForm();
- }
- log.warn(message, e);
- throw new FacesException(message, e);
+ url = getContextURLForPath(context, WEB_INF_RESOURCE);
+ if (url != null) {
+ parse(digester, url, fcb);
}
// Step 7, use the accumulated configuration beans to configure the RI
@@ -339,7 +349,7 @@
// Step 8, verify that all the configured factories are available
// and optionall that configured objects can be created
verifyFactories();
- if (shouldVerifyObjects(context)) {
+ if (isFeatureEnabled(context, VERIFY_OBJECTS)) {
verifyObjects(context, fcb);
}
@@ -352,7 +362,7 @@
ServletContext context = sce.getServletContext();
if (log.isDebugEnabled()) {
log.debug("contextDestroyed(" + context.getServletContextName()
- + ")");
+ + ')');
}
// Release any allocated application resources
@@ -362,7 +372,7 @@
tlsExternalContext.set(null);
// Release the initialization mark on this web application
- release(context);
+ release();
}
@@ -434,7 +444,7 @@
value = config.getMessageBundle();
if (value != null) {
if (log.isTraceEnabled()) {
- log.trace("setMessageBundle(" + value + ")");
+ log.trace("setMessageBundle(" + value + ')');
}
application.setMessageBundle(value);
}
@@ -442,7 +452,7 @@
value = config.getDefaultRenderKitId();
if (value != null) {
if (log.isTraceEnabled()) {
- log.trace("setDefaultRenderKitId(" + value + ")");
+ log.trace("setDefaultRenderKitId(" + value + ')');
}
application.setDefaultRenderKitId(value);
}
@@ -453,7 +463,7 @@
if ((values != null) && (values.length > 0)) {
for (int i = 0; i < values.length; i++) {
if (log.isTraceEnabled()) {
- log.trace("setActionListener(" + values[i] + ")");
+ log.trace("setActionListener(" + values[i] + ')');
}
instance = Util.createInstance
(values[i], ActionListener.class,
@@ -468,7 +478,7 @@
if ((values != null) && (values.length > 0)) {
for (int i = 0; i < values.length; i++) {
if (log.isTraceEnabled()) {
- log.trace("setNavigationHandler(" + values[i] + ")");
+ log.trace("setNavigationHandler(" + values[i] + ')');
}
instance = Util.createInstance
(values[i], NavigationHandler.class,
@@ -484,7 +494,7 @@
if ((values != null) && (values.length > 0)) {
for (int i = 0; i < values.length; i++) {
if (log.isTraceEnabled()) {
- log.trace("setPropertyResolver(" + values[i] + ")");
+ log.trace("setPropertyResolver(" + values[i] + ')');
}
instance = Util.createInstance
(values[i], PropertyResolver.class,
@@ -500,7 +510,7 @@
if ((values != null) && (values.length > 0)) {
for (int i = 0; i < values.length; i++) {
if (log.isTraceEnabled()) {
- log.trace("setStateManager(" + values[i] + ")");
+ log.trace("setStateManager(" + values[i] + ')');
}
instance = Util.createInstance
(values[i], StateManager.class,
@@ -516,7 +526,7 @@
if ((values != null) && (values.length > 0)) {
for (int i = 0; i < values.length; i++) {
if (log.isTraceEnabled()) {
- log.trace("setVariableResolver(" + values[i] + ")");
+ log.trace("setVariableResolver(" + values[i] + ')');
}
instance = Util.createInstance
(values[i], VariableResolver.class,
@@ -532,7 +542,7 @@
if ((values != null) && (values.length > 0)) {
for (int i = 0; i < values.length; i++) {
if (log.isTraceEnabled()) {
- log.trace("setViewHandler(" + values[i] + ")");
+ log.trace("setViewHandler(" + values[i] + ')');
}
instance = Util.createInstance
(values[i], ViewHandler.class,
@@ -563,8 +573,8 @@
for (int i = 0; i < config.length; i++) {
if (log.isTraceEnabled()) {
log.trace("addComponent(" +
- config[i].getComponentType() + "," +
- config[i].getComponentClass() + ")");
+ config[i].getComponentType() + ',' +
+ config[i].getComponentClass() + ')');
}
application.addComponent(config[i].getComponentType(),
config[i].getComponentClass());
@@ -573,29 +583,6 @@
}
- private static Class primitiveClassesToConvert[] = {
- java.lang.Boolean.TYPE,
- java.lang.Byte.TYPE,
- java.lang.Character.TYPE,
- java.lang.Double.TYPE,
- java.lang.Float.TYPE,
- java.lang.Integer.TYPE,
- java.lang.Long.TYPE,
- java.lang.Short.TYPE
- };
-
- private static String convertersForPrimitives[] = {
- "javax.faces.convert.BooleanConverter",
- "javax.faces.convert.ByteConverter",
- "javax.faces.convert.CharacterConverter",
- "javax.faces.convert.DoubleConverter",
- "javax.faces.convert.FloatConverter",
- "javax.faces.convert.IntegerConverter",
- "javax.faces.convert.LongConverter",
- "javax.faces.convert.ShortConverter"
- };
-
-
/**
* <p>Configure all registered converters.</p>
*
@@ -607,14 +594,14 @@
Application application = application();
// at a minimum, configure the primitive converters
- for (i = 0, len = primitiveClassesToConvert.length; i < len; i++) {
+ for (i = 0, len = PRIM_CLASSES_TO_CONVERT.length; i < len; i++) {
if (log.isTraceEnabled()) {
log.trace("addConverterByClass(" +
- primitiveClassesToConvert[i].toString() + "," +
- convertersForPrimitives[i].toString() + ")");
+ PRIM_CLASSES_TO_CONVERT[i] + ',' +
+ CONVERTERS_FOR_PRIMS[i] + ')');
}
- application.addConverter(primitiveClassesToConvert[i],
- convertersForPrimitives[i]);
+ application.addConverter(PRIM_CLASSES_TO_CONVERT[i],
+ CONVERTERS_FOR_PRIMS[i]);
}
if (config == null) {
@@ -625,16 +612,16 @@
if (config[i].getConverterId() != null) {
if (log.isTraceEnabled()) {
log.trace("addConverterById(" +
- config[i].getConverterId() + "," +
- config[i].getConverterClass() + ")");
+ config[i].getConverterId() + ',' +
+ config[i].getConverterClass() + ')');
}
application.addConverter(config[i].getConverterId(),
config[i].getConverterClass());
} else {
if (log.isTraceEnabled()) {
log.trace("addConverterByClass(" +
- config[i].getConverterForClass() + "," +
- config[i].getConverterClass() + ")");
+ config[i].getConverterForClass() + ',' +
+ config[i].getConverterClass() + ')');
}
Class clazz = Util.getCurrentLoader(this).loadClass
(config[i].getConverterForClass());
@@ -665,7 +652,7 @@
value = (String) iter.next();
if (value != null) {
if (log.isTraceEnabled()) {
- log.trace("setApplicationFactory(" + value + ")");
+ log.trace("setApplicationFactory(" + value + ')');
}
FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
value);
@@ -677,7 +664,7 @@
value = (String) iter.next();
if (value != null) {
if (log.isTraceEnabled()) {
- log.trace("setFacesContextFactory(" + value + ")");
+ log.trace("setFacesContextFactory(" + value + ')');
}
FactoryFinder.setFactory(FactoryFinder.FACES_CONTEXT_FACTORY,
value);
@@ -689,7 +676,7 @@
value = (String) iter.next();
if (value != null) {
if (log.isTraceEnabled()) {
- log.trace("setLifecycleFactory(" + value + ")");
+ log.trace("setLifecycleFactory(" + value + ')');
}
FactoryFinder.setFactory(FactoryFinder.LIFECYCLE_FACTORY,
value);
@@ -701,7 +688,7 @@
value = (String) iter.next();
if (value != null) {
if (log.isTraceEnabled()) {
- log.trace("setRenderKitFactory(" + value + ")");
+ log.trace("setRenderKitFactory(" + value + ')');
}
FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
value);
@@ -729,10 +716,9 @@
factory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
for (int i = 0; i < listeners.length; i++) {
if (log.isTraceEnabled()) {
- log.trace("addPhaseListener(" + listeners[i] + ")");
+ log.trace("addPhaseListener(" + listeners[i] + ')');
}
- ClassLoader cl = Util.getCurrentLoader(this);
- Class clazz = cl.loadClass(listeners[i]);
+ Class clazz = Util.loadClass(listeners[i], this);
lifecycle.addPhaseListener((PhaseListener) clazz.newInstance());
}
@@ -757,7 +743,7 @@
value = config.getDefaultLocale();
if (value != null) {
if (log.isTraceEnabled()) {
- log.trace("setDefaultLocale(" + value + ")");
+ log.trace("setDefaultLocale(" + value + ')');
}
application.setDefaultLocale
(Util.getLocaleFromString(value));
@@ -768,7 +754,7 @@
List locales = new ArrayList();
for (int i = 0; i < values.length; i++) {
if (log.isTraceEnabled()) {
- log.trace("addSupportedLocale(" + values[i] + ")");
+ log.trace("addSupportedLocale(" + values[i] + ')');
}
locales.add(Util.getLocaleFromString(values[i]));
}
@@ -791,7 +777,6 @@
if (config == null) {
return;
}
- Application application = application();
ApplicationAssociate associate =
ApplicationAssociate.getInstance(getExternalContextDuringInitialize());
@@ -802,8 +787,8 @@
for (int i = 0; i < config.length; i++) {
if (log.isTraceEnabled()) {
log.trace("addManagedBean(" +
- config[i].getManagedBeanName() + "," +
- config[i].getManagedBeanClass() + ")");
+ config[i].getManagedBeanName() + ',' +
+ config[i].getManagedBeanClass() + ')');
}
ManagedBeanFactory mbf = new ManagedBeanFactory(config[i]);
associate.addManagedBeanFactory(config[i].getManagedBeanName(),
@@ -818,12 +803,11 @@
* @param config Array of <code>NavigationRuleBean</code> that contains
* our configuration information
*/
- private void configure(NavigationRuleBean config[]) throws Exception {
+ private void configure(NavigationRuleBean config[]) {
if (config == null) {
return;
}
- Application application = application();
ApplicationAssociate associate =
ApplicationAssociate.getInstance(getExternalContextDuringInitialize());
@@ -834,16 +818,16 @@
for (int i = 0; i < config.length; i++) {
if (log.isTraceEnabled()) {
log.trace("addNavigationRule(" +
- config[i].getFromViewId() + ")");
+ config[i].getFromViewId() + ')');
}
NavigationCaseBean ncb[] = config[i].getNavigationCases();
for (int j = 0; j < ncb.length; j++) {
if (log.isTraceEnabled()) {
log.trace("addNavigationCase(" +
- ncb[j].getFromAction() + "," +
- ncb[j].getFromOutcome() + "," +
- ncb[j].isRedirect() + "," +
- ncb[j].getToViewId() + ")");
+ ncb[j].getFromAction() + ',' +
+ ncb[j].getFromOutcome() + ',' +
+ ncb[j].isRedirect() + ',' +
+ ncb[j].getToViewId() + ')');
}
ConfigNavigationCase cnc = new ConfigNavigationCase();
if (config[i].getFromViewId() == null) {
@@ -896,14 +880,13 @@
for (int i = 0; i < config.length; i++) {
if (log.isTraceEnabled()) {
log.trace("addRenderer(" +
- config[i].getComponentFamily() + "," +
- config[i].getRendererType() + "," +
- config[i].getRendererClass() + ")");
+ config[i].getComponentFamily() + ',' +
+ config[i].getRendererType() + ',' +
+ config[i].getRendererClass() + ')');
}
Renderer r = (Renderer)
- Util.getCurrentLoader(this).
- loadClass(config[i].getRendererClass()).
- newInstance();
+ Util.loadClass(
+ config[i].getRendererClass(), this).newInstance();
rk.addRenderer(config[i].getComponentFamily(),
config[i].getRendererType(),
r);
@@ -932,8 +915,8 @@
if (rk == null) {
if (log.isTraceEnabled()) {
log.trace("createRenderKit(" +
- config[i].getRenderKitId() + "," +
- config[i].getRenderKitClass() + ")");
+ config[i].getRenderKitId() + ',' +
+ config[i].getRenderKitClass() + ')');
}
if (config[i].getRenderKitClass() == null) {
throw new IllegalArgumentException// PENDING - i18n
@@ -941,14 +924,13 @@
config[i].getRenderKitId());
}
rk = (RenderKit)
- Util.getCurrentLoader(this).
- loadClass(config[i].getRenderKitClass()).
- newInstance();
+ Util.loadClass(
+ config[i].getRenderKitClass(), this).newInstance();
rkFactory.addRenderKit(config[i].getRenderKitId(), rk);
} else {
if (log.isTraceEnabled()) {
log.trace("getRenderKit(" +
- config[i].getRenderKitId() + ")");
+ config[i].getRenderKitId() + ')');
}
}
configure(config[i].getRenderers(), rk);
@@ -973,8 +955,8 @@
for (int i = 0; i < config.length; i++) {
if (log.isTraceEnabled()) {
log.trace("addValidator(" +
- config[i].getValidatorId() + "," +
- config[i].getValidatorClass() + ")");
+ config[i].getValidatorId() + ',' +
+ config[i].getValidatorClass() + ')');
}
application.addValidator(config[i].getValidatorId(),
config[i].getValidatorClass());
@@ -988,10 +970,8 @@
* parsing the runtime configuration information we need.</p>
*
* @param validateXml if true, validation is turned on during parsing.
- * @throws MalformedURLException if a URL cannot be formed correctly
*/
- protected Digester digester(boolean validateXml)
- throws MalformedURLException {
+ protected Digester digester(boolean validateXml) {
Digester digester = new Digester();
// Configure basic properties
@@ -1003,17 +983,17 @@
// PENDING - Read from file?
digester.addRuleSet(new FacesConfigRuleSet(false, false, true));
- // Configure preregistered entities
- URL url = this.getClass().getResource
- ("/com/sun/faces/web-facesconfig_1_1.dtd");
- digester.register
- ("-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN",
- url.toString());
- url = this.getClass().getResource
- ("/com/sun/faces/web-facesconfig_1_0.dtd");
- digester.register
- ("-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN",
- url.toString());
+ // Register known entities
+ for (int i = 0; i < DTD_INFO.length; i++) {
+ URL url = this.getClass().getResource(DTD_INFO[i][0]);
+ if (url != null) {
+ digester.register(DTD_INFO[i][1], url.toString());
+ } else {
+ throw new FacesException(
+ Util.getExceptionMessageString(Util.NO_DTD_FOUND_ERROR_ID,
+ new Object[]{ DTD_INFO[i][1], DTD_INFO[i][0] }));
+ }
+ }
// Push an initial FacesConfigBean onto the stack
digester.push(new FacesConfigBean());
@@ -1022,16 +1002,6 @@
}
-
- private String factoryNames[] =
- {
- FactoryFinder.APPLICATION_FACTORY,
- FactoryFinder.FACES_CONTEXT_FACTORY,
- FactoryFinder.LIFECYCLE_FACTORY,
- FactoryFinder.RENDER_KIT_FACTORY
- };
-
-
/**
* <p>Verify that all of the required factory objects are available.</p>
*
@@ -1039,9 +1009,9 @@
*/
private void verifyFactories() throws FacesException {
- for (int i = 0, len = factoryNames.length; i < len; i++) {
+ for (int i = 0, len = FACTORY_NAMES.length; i < len; i++) {
try {
- Object factory = FactoryFinder.getFactory(factoryNames[i]);
+ FactoryFinder.getFactory(FACTORY_NAMES[i]);
} catch (Exception e) {
throw new FacesException(e);
}
@@ -1055,10 +1025,8 @@
* been initialized. If it has not been initialized, also record
* the initialization of this application until removed by a call to
* <code>release()</code>.</p>
- *
- * @param context <code>ServletContext</code> for this web application
*/
- private boolean initialized(ServletContext context) {
+ private boolean initialized() {
// Initialize at most once per web application class loader
ClassLoader cl = Util.getCurrentLoader(this);
@@ -1189,7 +1157,9 @@
"cannot be created. See your web application logs " +
"for details.";
}
- log.warn(message);
+ if (log.isErrorEnabled()) {
+ log.error(message);
+ }
throw new FacesException(message);
} else {
if (log.isInfoEnabled()) {
@@ -1208,14 +1178,11 @@
* @param digester Digester to use for parsing
* @param url URL of the configuration resource to be parsed
* @param fcb FacesConfigBean to accumulate results
- * @throws IOException if an input/output error occurs
- * @throws SAXException if an XML parsing error occurs
*/
- protected void parse(Digester digester, URL url, FacesConfigBean fcb)
- throws IOException, SAXException {
+ protected void parse(Digester digester, URL url, FacesConfigBean fcb) {
if (log.isDebugEnabled()) {
- log.debug("parse(" + url.toExternalForm() + ")");
+ log.debug("parse(" + url.toExternalForm() + ')');
}
URLConnection conn = null;
@@ -1232,6 +1199,20 @@
digester.parse(source);
stream.close();
stream = null;
+ } catch (Exception e) {
+ String message = null;
+ try {
+ message = Util.getExceptionMessageString
+ (Util.CANT_PARSE_FILE_ERROR_MESSAGE_ID,
+ new Object[]{url.toExternalForm()});
+ } catch (Exception ee) {
+ message = "Can't parse configuration file:" +
+ url.toExternalForm();
+ }
+ if (log.isErrorEnabled()) {
+ log.error(message, e);
+ }
+ throw new FacesException(message, e);
} finally {
if (stream != null) {
try {
@@ -1245,57 +1226,54 @@
}
-
/**
- * <p>Determine if we will turn on validation during parsing.
+ * <p>Determines if a particular feature, configured via the web
+ * deployment descriptor as a <code>true/false</code> value, is
+ * enabled or not.</p>
+ * @param context the <code>ServletContext</code> of the application
+ * @param paramName the name of the context init paramName to check
*
- * @param sc the servlet context
+ * @return <code>true</code> if the feature in question is enabled, otherwise
+ * <code>false</code>
*/
- protected boolean validateTheXml(ServletContext sc) {
- String validateXml = sc.getInitParameter(RIConstants.VALIDATE_XML);
- if (validateXml != null) {
- if (!(validateXml.equals("true")) &&
- !(validateXml.equals("false"))) {
- Object[] obj = new Object[1];
- obj[0] = "validateXml";
- throw new FacesException(Util.getExceptionMessageString(
- Util.INVALID_INIT_PARAM_ERROR_MESSAGE_ID, obj));
+ protected boolean isFeatureEnabled(ServletContext context, String paramName) {
+ String paramValue = context.getInitParameter(paramName);
+ if (paramValue != null) {
+ paramValue = paramValue.trim();
+ if (!(paramValue.equals("true")) &&
+ !(paramValue.equals("false"))) {
+
+ if (log.isWarnEnabled()) {
+ log.warn(Util.getExceptionMessageString(
+ Util.INVALID_INIT_PARAM_ERROR_MESSAGE_ID,
+ new Object[] { paramValue, "validateXml" }));
+ }
}
- } else {
- validateXml = "false";
}
- return new Boolean(validateXml).booleanValue();
+
+ return Boolean.valueOf(paramValue).booleanValue();
}
/**
- * <p>Determine if we will verify objects after configuration.
- *
- * @param sc the servlet context
+ * <p>Return the URL for the given path.</p>
+ * @param context the <code>ServletContext</code> of the current application
+ * @param path the resource path
+ * @return the URL for the given resource or <code>null</code>
*/
- private boolean shouldVerifyObjects(ServletContext sc) {
- String validateXml = sc.getInitParameter(RIConstants.VERIFY_OBJECTS);
- if (validateXml != null) {
- if (!(validateXml.equals("true")) &&
- !(validateXml.equals("false"))) {
- Object[] obj = new Object[1];
- obj[0] = "validateXml";
- throw new FacesException(Util.getExceptionMessageString(
- Util.INVALID_INIT_PARAM_ERROR_MESSAGE_ID, obj));
- }
- } else {
- validateXml = "false";
+ private URL getContextURLForPath(ServletContext context, String path) {
+ try {
+ return context.getResource(path);
+ } catch (MalformedURLException mue) {
+ throw new FacesException(mue);
}
- return new Boolean(validateXml).booleanValue();
}
/**
* <p>Release the mark that this web application has been initialized.</p>
- *
- * @param context <code>ServletContext</code> for this web application
*/
- private void release(ServletContext context) {
+ private void release() {
ClassLoader cl = Util.getCurrentLoader(this);
synchronized (loaders) {
@@ -1303,7 +1281,8 @@
}
}
-
+
+
public class ServletContextAdapter extends ExternalContext {
private ServletContext servletContext = null;
Index: src/com/sun/faces/taglib/html_basic/HtmlBasicValidator.java
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/taglib/html_basic/HtmlBasicValidator.java,v
retrieving revision 1.9
diff -u -r1.9 HtmlBasicValidator.java
--- src/com/sun/faces/taglib/html_basic/HtmlBasicValidator.java 20 Apr 2004 18:27:25 -0000 1.9
+++ src/com/sun/faces/taglib/html_basic/HtmlBasicValidator.java 26 Jul 2004 18:53:17 -0000
@@ -62,7 +62,7 @@
// says not to.
if (java.beans.Beans.isDesignTime() ||
- !RIConstants.isHtmlTagLibValidatorActive()) {
+ !RIConstants.HTML_TLV_ACTIVE) {
return null;
}
Index: src/com/sun/faces/util/Util.java
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/util/Util.java,v
retrieving revision 1.141
diff -u -r1.141 Util.java
--- src/com/sun/faces/util/Util.java 17 Jul 2004 01:37:13 -0000 1.141
+++ src/com/sun/faces/util/Util.java 26 Jul 2004 18:53:17 -0000
@@ -287,6 +287,9 @@
public static final String CYCLIC_REFERENCE_ERROR_ID =
"com.sun.faces.CYCLIC_REFERENCE_ERROR";
+ public static final String NO_DTD_FOUND_ERROR_ID =
+ "com.sun.faces.NO_DTD_FOUND_ERROR";
+
// README - make sure to add the message identifier constant
// (ex: Util.CONVERSION_ERROR_MESSAGE_ID) and the number of substitution
Index: src/javax/faces/Messages.properties
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/javax/faces/Messages.properties,v
retrieving revision 1.16
diff -u -r1.16 Messages.properties
--- src/javax/faces/Messages.properties 23 Jul 2004 19:23:23 -0000 1.16
+++ src/javax/faces/Messages.properties 26 Jul 2004 18:53:17 -0000
@@ -100,7 +100,7 @@
com.sun.faces.ILLEGAL_MODEL_REFERENCE=Illegal Model Reference in this context for expression ''{0}''.
com.sun.faces.ILLEGAL_VIEW_ID=Illegal view ID ''{0}''. The ID must begin with ''/''
com.sun.faces.INVALID_EXPRESSION=Invalid expression: ''{0}''.
-com.sun.faces.INVALID_INIT_PARAM=Invalid initialization parameter: ''{0}''.
+com.sun.faces.INVALID_INIT_PARAM=Invalid value: ''{0}'', for initialization parameter: ''{1}''. Acceptable values are 'true' or 'false'. Defaulting to 'false'.
com.sun.faces.INVALID_MESSAGE_SEVERITY_IN_CONFIG=Invalid Message severity ''{0}'' defined in configuration.
com.sun.faces.INVALID_SCOPE_LIFESPAN=The scope of the referenced object: ''{0}'' is shorter than the referring object
com.sun.faces.LIFECYCLE_ID_ALREADY_ADDED=LifecycleId already added for id: ''{0}''.
@@ -111,6 +111,7 @@
com.sun.faces.MODELUPDATE_ERROR=Model Update failure for value ''{0}'' in model''{1}''.
com.sun.faces.NAMED_OBJECT_NOT_FOUND_ERROR=Expression Error: Named Object: ''{0}'' not found.
com.sun.faces.NOT_NESTED_IN_FACES_TAG_ERROR=Not nested in a UIComponentTag Error for tag with handler class: ''{0}''.
+com.sun.faces.NO_DTD_FOUND_ERROR=Unable to locate DTD with PUBLIC ID ''{0}'' at path ''{1}''.
com.sun.faces.NULL_BODY_CONTENT_ERROR=BodyContent is null for tag with handler class: ''{0}''.
com.sun.faces.NULL_COMPONENT_ERROR=Construction Error: Component argument is null.
com.sun.faces.NULL_CONFIGURATION=No Configuration loaded for the application.
Index: src/javax/faces/Messages_de.properties
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/javax/faces/Messages_de.properties,v
retrieving revision 1.15
diff -u -r1.15 Messages_de.properties
--- src/javax/faces/Messages_de.properties 23 Jul 2004 19:23:23 -0000 1.15
+++ src/javax/faces/Messages_de.properties 26 Jul 2004 18:53:17 -0000
@@ -82,6 +82,7 @@
com.sun.faces.CANT_INSTANTIATE_CLASS=Can''t instantiate class: ''{0}''.
com.sun.faces.ILLEGAL_CHARACTERS_ERROR=Characters not allowed.
com.sun.faces.NOT_NESTED_IN_FACES_TAG_ERROR=Not nested in a FacesTag Error for tag with handler class: ''{0}''.
+com.sun.faces.NO_DTD_FOUND_ERROR=Unable to locate DTD with PUBLIC ID ''{0}'' at path ''{1}''.
com.sun.faces.NULL_BODY_CONTENT_ERROR=BodyContent is null for tag with handler class: ''{0}''.
com.sun.faces.SAVING_STATE_ERROR=Error while saving state in ''{0}'': ''{1}''.
com.sun.faces.RENDERER_NOT_FOUND=Renderer not found for Renderer type: ''{0}''.
@@ -89,7 +90,7 @@
com.sun.faces.NULL_CONFIGURATION=No Configuration loaded for the application.
com.sun.faces.ERROR_OPENING_FILE=Can''t open configuration file: ''{0}''.
com.sun.faces.ERROR_REGISTERING_DTD=Can''t register DTD: ''{0}''.
-com.sun.faces.INVALID_INIT_PARAM=Invalid initialization parameter: ''{0}''.
+com.sun.faces.INVALID_INIT_PARAM=Invalid value: ''{0}'', for initialization parameter: ''{1}''. Acceptable values are 'true' or 'false'. Defaulting to 'false'.
com.sun.faces.ERROR_SETTING_BEAN_PROPERTY=Can''t set managed bean property: ''{0}''.
com.sun.faces.ERROR_GETTING_VALUE_BINDING=Can''t get ValueBinding for value: ''{0}''.
com.sun.faces.ERROR_GETTING_VALUEREF_VALUE=Can''t get value from value reference expression: ''{0}''.
Index: src/javax/faces/Messages_es.properties
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/javax/faces/Messages_es.properties,v
retrieving revision 1.15
diff -u -r1.15 Messages_es.properties
--- src/javax/faces/Messages_es.properties 23 Jul 2004 19:23:24 -0000 1.15
+++ src/javax/faces/Messages_es.properties 26 Jul 2004 18:53:17 -0000
@@ -83,6 +83,7 @@
com.sun.faces.CANT_INSTANTIATE_CLASS=Can''t instantiate class: ''{0}''.
com.sun.faces.ILLEGAL_CHARACTERS_ERROR=Characters not allowed.
com.sun.faces.NOT_NESTED_IN_FACES_TAG_ERROR=Not nested in a FacesTag Error for tag with handler class: ''{0}''.
+com.sun.faces.NO_DTD_FOUND_ERROR=Unable to locate DTD with PUBLIC ID ''{0}'' at path ''{1}''.
com.sun.faces.NULL_BODY_CONTENT_ERROR=BodyContent is null for tag with handler class: ''{0}''.
com.sun.faces.SAVING_STATE_ERROR=Error while saving state in ''{0}'': ''{1}''.
com.sun.faces.RENDERER_NOT_FOUND=Renderer not found for Renderer type: ''{0}''.
@@ -90,7 +91,7 @@
com.sun.faces.NULL_CONFIGURATION=No Configuration loaded for the application.
com.sun.faces.ERROR_OPENING_FILE=Can''t open configuration file: ''{0}''.
com.sun.faces.ERROR_REGISTERING_DTD=Can''t register DTD: ''{0}''.
-com.sun.faces.INVALID_INIT_PARAM=Invalid initialization parameter: ''{0}''.
+com.sun.faces.INVALID_INIT_PARAM=Invalid value: ''{0}'', for initialization parameter: ''{1}''. Acceptable values are 'true' or 'false'. Defaulting to 'false'.
com.sun.faces.ERROR_SETTING_BEAN_PROPERTY=Can''t set managed bean property: ''{0}''.
com.sun.faces.ERROR_GETTING_VALUE_BINDING=Can''t get ValueBinding for value: ''{0}''.
com.sun.faces.ERROR_GETTING_VALUEREF_VALUE=Can''t get value from value reference expression: ''{0}''.
Index: src/javax/faces/Messages_fr.properties
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/javax/faces/Messages_fr.properties,v
retrieving revision 1.14
diff -u -r1.14 Messages_fr.properties
--- src/javax/faces/Messages_fr.properties 11 Jun 2004 15:00:28 -0000 1.14
+++ src/javax/faces/Messages_fr.properties 26 Jul 2004 18:53:17 -0000
@@ -83,6 +83,7 @@
com.sun.faces.CANT_INSTANTIATE_CLASS=Can''t instantiate class: ''{0}''.
com.sun.faces.ILLEGAL_CHARACTERS_ERROR=Characters not allowed.
com.sun.faces.NOT_NESTED_IN_FACES_TAG_ERROR=Not nested in a FacesTag Error for tag with handler class: ''{0}''.
+com.sun.faces.NO_DTD_FOUND_ERROR=Unable to locate DTD with PUBLIC ID ''{0}'' at path ''{1}''.
com.sun.faces.NULL_BODY_CONTENT_ERROR=BodyContent is null for tag with handler class: ''{0}''.
com.sun.faces.SAVING_STATE_ERROR=Error while saving state in ''{0}'': ''{1}''.
com.sun.faces.RENDERER_NOT_FOUND=Renderer not found for Renderer type: ''{0}''.
@@ -90,7 +91,7 @@
com.sun.faces.NULL_CONFIGURATION=No Configuration loaded for the application.
com.sun.faces.ERROR_OPENING_FILE=Can''t open configuration file: ''{0}''.
com.sun.faces.ERROR_REGISTERING_DTD=Can''t register DTD: ''{0}''.
-com.sun.faces.INVALID_INIT_PARAM=Invalid initialization parameter: ''{0}''.
+com.sun.faces.INVALID_INIT_PARAM=Invalid value: ''{0}'', for initialization parameter: ''{1}''. Acceptable values are 'true' or 'false'. Defaulting to 'false'.
com.sun.faces.ERROR_SETTING_BEAN_PROPERTY=Can''t set managed bean property: ''{0}''.
com.sun.faces.ERROR_GETTING_VALUE_BINDING=Can''t get ValueBinding for value: ''{0}''.
com.sun.faces.ERROR_GETTING_VALUEREF_VALUE=Can''t get value from value reference expression: ''{0}''.
Index: test/com/sun/faces/config/ConfigFileTestCase.java
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/test/com/sun/faces/config/ConfigFileTestCase.java,v
retrieving revision 1.62
diff -u -r1.62 ConfigFileTestCase.java
--- test/com/sun/faces/config/ConfigFileTestCase.java 20 Jul 2004 21:54:50 -0000 1.62
+++ test/com/sun/faces/config/ConfigFileTestCase.java 26 Jul 2004 18:53:17 -0000
@@ -56,8 +56,7 @@
(FacesConfigBean) context.getAttribute(FACES_CONFIG_BEAN_KEY);
// Step 1, configure a Digester instance we can use
- boolean validateXml = validateTheXml(context);
- digester = digester(validateXml);
+ digester = digester(isFeatureEnabled(context, VALIDATE_XML));
url = (new File(System.getProperty("testRootDir"))).toURL();
url = new URL(url, str);
Index: test/com/sun/faces/util/TestUtil_messages.java
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/test/com/sun/faces/util/TestUtil_messages.java,v
retrieving revision 1.34
diff -u -r1.34 TestUtil_messages.java
--- test/com/sun/faces/util/TestUtil_messages.java 3 May 2004 19:30:41 -0000 1.34
+++ test/com/sun/faces/util/TestUtil_messages.java 26 Jul 2004 18:53:18 -0000
@@ -111,6 +111,7 @@
{Util.ASSERTION_FAILED_ID, "0"},
{Util.OBJECT_CREATION_ERROR_ID, "0"},
{Util.CYCLIC_REFERENCE_ERROR_ID, "1"},
+ {Util.NO_DTD_FOUND_ERROR_ID, "2"}
};
// Attribute Instance Variables
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net