Author: nbelaevski
Date: 2007-04-09 09:56:00 -0400 (Mon, 09 Apr 2007)
New Revision: 59
Added:
trunk/test/src/main/java/org/ajax4jsf/tests/xml/
trunk/test/src/main/java/org/ajax4jsf/tests/xml/FacesEntityResolver.java
Modified:
trunk/test/src/main/java/org/ajax4jsf/tests/org/apache/shale/test/config/ConfigParser.java
Log:
ConfigParser has got EntityResolver for SUN RI & MyFaces
Modified:
trunk/test/src/main/java/org/ajax4jsf/tests/org/apache/shale/test/config/ConfigParser.java
===================================================================
---
trunk/test/src/main/java/org/ajax4jsf/tests/org/apache/shale/test/config/ConfigParser.java 2007-04-08
22:19:35 UTC (rev 58)
+++
trunk/test/src/main/java/org/ajax4jsf/tests/org/apache/shale/test/config/ConfigParser.java 2007-04-09
13:56:00 UTC (rev 59)
@@ -46,6 +46,8 @@
import javax.faces.render.RenderKit;
import javax.faces.render.RenderKitFactory;
import javax.faces.render.Renderer;
+
+import org.ajax4jsf.tests.xml.FacesEntityResolver;
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.Rule;
import org.apache.shale.test.mock.MockRenderKit;
@@ -230,6 +232,9 @@
digester.addCallMethod
("faces-config/validator/validator-class",
"setValidatorClass", 0);
}
+
+ digester.setEntityResolver(new FacesEntityResolver());
+
return this.digester;
}
Added: trunk/test/src/main/java/org/ajax4jsf/tests/xml/FacesEntityResolver.java
===================================================================
--- trunk/test/src/main/java/org/ajax4jsf/tests/xml/FacesEntityResolver.java
(rev 0)
+++ trunk/test/src/main/java/org/ajax4jsf/tests/xml/FacesEntityResolver.java 2007-04-09
13:56:00 UTC (rev 59)
@@ -0,0 +1,73 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.tests.xml;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 09.04.2007
+ *
+ */
+public class FacesEntityResolver implements EntityResolver {
+
+ private static final String[] PREFIXES = new String[] {
+ "/com/sun/faces/", "/org/apache/myfaces/resource/"
+ };
+
+ /* (non-Javadoc)
+ * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
+ */
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException, IOException {
+
+ if (systemId == null) {
+ return null;
+ }
+
+ String fileName;
+
+ int idx = systemId.lastIndexOf('/');
+ if (idx == -1) {
+ fileName = systemId;
+ } else {
+ fileName = systemId.substring(idx + 1);
+ }
+
+ for (int i = 0; i < PREFIXES.length; i++) {
+ String prefix = PREFIXES[i];
+
+ URL url = getClass().getResource(prefix + fileName);
+ if (url != null) {
+ return new InputSource(url.openStream());
+ }
+ }
+
+ return null;
+ }
+
+}