Author: craigmcc
Date: Mon Dec 12 18:04:37 2005
New Revision: 356449
URL: http://svn.apache.org/viewcvs?rev=356449&view=rev
Log:
Conditionally insert the Shale Tiger Extensions variable resolver below
the Shale standard variable resolver. This will occur *only* if the
corresponding library (shale-tiger.jar) is included in the web application.
Modified:
struts/shale/trunk/core-library/src/java/org/apache/shale/faces/ShaleVariableResolver.java
struts/shale/trunk/tiger/src/java/org/apache/shale/tiger/faces/VariableResolverImpl.java
Modified:
struts/shale/trunk/core-library/src/java/org/apache/shale/faces/ShaleVariableResolver.java
URL:
http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/faces/ShaleVariableResolver.java?rev=356449&r1=356448&r2=356449&view=diff
==============================================================================
---
struts/shale/trunk/core-library/src/java/org/apache/shale/faces/ShaleVariableResolver.java
(original)
+++
struts/shale/trunk/core-library/src/java/org/apache/shale/faces/ShaleVariableResolver.java
Mon Dec 12 18:04:37 2005
@@ -16,6 +16,7 @@
package org.apache.shale.faces;
+import java.lang.reflect.Constructor;
import javax.faces.context.FacesContext;
import javax.faces.el.EvaluationException;
import javax.faces.el.VariableResolver;
@@ -35,6 +36,12 @@
* <p>All other evaluations are delegated to the previous implementation
* that was passed to our constructor.</p>
*
+ * <p>Since 1.0.1, if the optional <code>shale-tiger.jar</code> file
+ * (containing the Shale Tiger Extensions) is available to this web
+ * application, the extra variable resolver implementation found there
+ * will be interposed between this instance and the previous
+ * implementation instance passed to our constructor.</p>
+ *
* $Id$
*/
public class ShaleVariableResolver extends VariableResolver {
@@ -46,12 +53,31 @@
/**
* <p>Construct a new [EMAIL PROTECTED] ShaleVariableResolver}
instance.</p>
*
- *
* @param original Original resolver to delegate to.
*/
public ShaleVariableResolver(VariableResolver original) {
- this.original = original;
+ // Determine if our optional resolver is present
+ VariableResolver delegate = null;
+ try {
+ // Attempt to load the Shale Tiger Extensions class
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ Class clazz = cl.loadClass(TIGER_DELEGATE);
+ // Instantiate a new instance, passing the original resolver
+ Constructor constructor =
clazz.getConstructor(VARIABLE_RESOLVER_ARGS);
+ delegate =
+ (VariableResolver) constructor.newInstance(new Object[] {
original });
+ } catch (Exception e) {
+ delegate = null;
+ }
+
+ if (delegate != null) {
+ // Interpose our delegate into the chain
+ this.original = delegate;
+ } else {
+ // Use the provided instance directly
+ this.original = original;
+ }
}
@@ -74,6 +100,20 @@
private static final String JNDI_VARIABLE_NAME = "jndi";
+ /**
+ * <p>Fully qualified class name of the variable resolver implementation
+ * in the Shale Tiger Extensions library.</p>
+ */
+ private static final String TIGER_DELEGATE =
+ "org.apache.shale.tiger.faces.ViewResolverImpl";
+
+
+ /**
+ * <p>Constructor signature for a VariableResolver that takes a
+ * VariableResolver as a parameter.</p>
+ */
+ private static final Class VARIABLE_RESOLVER_ARGS[] =
+ { VariableResolver.class };
// ------------------------------------------------ VariableResolver
Methods
Modified:
struts/shale/trunk/tiger/src/java/org/apache/shale/tiger/faces/VariableResolverImpl.java
URL:
http://svn.apache.org/viewcvs/struts/shale/trunk/tiger/src/java/org/apache/shale/tiger/faces/VariableResolverImpl.java?rev=356449&r1=356448&r2=356449&view=diff
==============================================================================
---
struts/shale/trunk/tiger/src/java/org/apache/shale/tiger/faces/VariableResolverImpl.java
(original)
+++
struts/shale/trunk/tiger/src/java/org/apache/shale/tiger/faces/VariableResolverImpl.java
Mon Dec 12 18:04:37 2005
@@ -68,6 +68,14 @@
* <li>Processing a <code>list-entries</code> or <code>map-entries</code>
* elemente nested in a <code>managed-property</code> element.</li>
* </ul>
+ *
+ * <p><strong>IMPLEMENTATION NOTE</strong> - There is no
<code>faces-config.xml</code>
+ * resource that registers this variable resolver, since we could end up with
+ * ordering issues with the standard Shale variable resolver. Therefore, the
+ * standard implementation will dynamically insert an instance of this
+ * resolver (below the standard instance, but above the implementation
+ * provided instance) in the standard decorator chain that is implemented
+ * as the JavaServer Faces runtime parses configuration resources.</p>
*/
public class VariableResolverImpl extends VariableResolver {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]