Author: craigmcc
Date: Mon Apr 10 23:09:52 2006
New Revision: 393148

URL: http://svn.apache.org/viewcvs?rev=393148&view=rev
Log:
Migrate the initialization logic for configuring which ViewControllerMapper
instance will be used from ShaleApplicationFiter to ViewViewHandler, since
the org.apache.shale.view package is the only place this is actually used.

Modified:
    
struts/shale/trunk/core-library/src/java/org/apache/shale/faces/ShaleApplicationFilter.java
    
struts/shale/trunk/core-library/src/java/org/apache/shale/resources/Bundle.properties
    
struts/shale/trunk/core-library/src/java/org/apache/shale/view/Constants.java
    
struts/shale/trunk/core-library/src/java/org/apache/shale/view/faces/ViewViewHandler.java

Modified: 
struts/shale/trunk/core-library/src/java/org/apache/shale/faces/ShaleApplicationFilter.java
URL: 
http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/faces/ShaleApplicationFilter.java?rev=393148&r1=393147&r2=393148&view=diff
==============================================================================
--- 
struts/shale/trunk/core-library/src/java/org/apache/shale/faces/ShaleApplicationFilter.java
 (original)
+++ 
struts/shale/trunk/core-library/src/java/org/apache/shale/faces/ShaleApplicationFilter.java
 Mon Apr 10 23:09:52 2006
@@ -158,16 +158,6 @@
       "org/apache/shale/faces/shale-config.xml";
 
 
-    /**
-     * <p>The name of the context initialization parameter that defines the
-     * fully qualified class name of the [EMAIL PROTECTED] 
ViewControllerMapper} to be
-     * used is stored.  If not present, the default value is
-     * <code>org.apache.shale.view.DefaultViewControllerMapper</code>.</p>
-     */
-    public static final String VIEW_CONTROLLER_MAPPER =
-      "org.apache.shale.view.VIEW_CONTROLLER_MAPPER";
-
-
     // ------------------------------------------------------ Instance 
Variables
 
 
@@ -316,8 +306,6 @@
         }
 
         context = config.getServletContext();
-        context.setAttribute(Constants.VIEW_MAPPER,
-                             getViewControllerMapper());
 
         // Initialize the Shale Tiger Extensions (if present)
         initTiger(config);
@@ -391,46 +379,6 @@
         parser.parse(url);
 
         return catalog;
-
-    }
-
-
-    /**
-     * <p>Create and return the [EMAIL PROTECTED] ViewControllerMapper} 
instance
-     * we will use for this application
-     *
-     * @exception ServletException if no instance can be created
-     */
-    private ViewControllerMapper getViewControllerMapper() throws 
ServletException {
-
-        String className = context.getInitParameter(VIEW_CONTROLLER_MAPPER);
-        if (className == null) {
-            className = 
"org.apache.shale.view.impl.DefaultViewControllerMapper";
-        }
-        ClassLoader cl = Thread.currentThread().getContextClassLoader();
-        if (cl == null) {
-            cl = this.getClass().getClassLoader();
-        }
-        try {
-            Class clazz = cl.loadClass(className);
-            return (ViewControllerMapper) clazz.newInstance();
-        } catch (ClassCastException e) {
-            throw new ServletException
-              (messages.getMessage("filter.vcmCast",
-                                   new Object[] { className }), e);
-        } catch (ClassNotFoundException e) {
-            throw new ServletException
-              (messages.getMessage("filter.vcmClass",
-                                   new Object[] { className }), e);
-        } catch (IllegalAccessException e) {
-            throw new ServletException
-              (messages.getMessage("filter.vcmAccess",
-                                   new Object[] { className }), e);
-        } catch (InstantiationException e) {
-            throw new ServletException
-              (messages.getMessage("filter.vcmInstantiate",
-                                   new Object[] { className }), e);
-        }
 
     }
 

Modified: 
struts/shale/trunk/core-library/src/java/org/apache/shale/resources/Bundle.properties
URL: 
http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/resources/Bundle.properties?rev=393148&r1=393147&r2=393148&view=diff
==============================================================================
--- 
struts/shale/trunk/core-library/src/java/org/apache/shale/resources/Bundle.properties
 (original)
+++ 
struts/shale/trunk/core-library/src/java/org/apache/shale/resources/Bundle.properties
 Mon Apr 10 23:09:52 2006
@@ -23,16 +23,16 @@
 filter.initException=Exception occurred during init command
 filter.initializing=Initializing Shale Application Filter
 filter.parsingResource=Parsing default resource {0}
-filter.vcmAccess=ViewControllerMapper class {0} does not have a public no-args 
constructor
-filter.vcmCast=Class {0} does not implement ViewControllerMapper
-filter.vcmClass=Cannot find ViewControllerMapper class {0}
-filter.vcmInstantiate=ViewControllerMapper class {0} instance cannot be 
instantiated
 
-# org.apache.shale.application.ShaleViewHandler
+# org.apache.shale.view.faces.ViewViewHandler
 view.evalException=Evaluation exception creating a managed bean named {1} for 
viewId {0}
 view.notViewController=Bean for viewId {0} under name {1} is not a 
ViewController
 view.noViewController=No ViewController for viewId {0} found under name {1}
 view.noViewControllerMapper=No ViewControllerMapper has been configured for 
this application
+view.vcmAccess=ViewControllerMapper class {0} does not have a public no-args 
constructor
+view.vcmCast=Class {0} does not implement ViewControllerMapper
+view.vcmClass=Cannot find ViewControllerMapper class {0}
+view.vcmInstantiate=ViewControllerMapper class {0} instance cannot be 
instantiated
 
 # org.apache.shale.application.ShaleWebContext
 context.requestWrapper=Must be an HttpServletRequestWrapper

Modified: 
struts/shale/trunk/core-library/src/java/org/apache/shale/view/Constants.java
URL: 
http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/view/Constants.java?rev=393148&r1=393147&r2=393148&view=diff
==============================================================================
--- 
struts/shale/trunk/core-library/src/java/org/apache/shale/view/Constants.java 
(original)
+++ 
struts/shale/trunk/core-library/src/java/org/apache/shale/view/Constants.java 
Mon Apr 10 23:09:52 2006
@@ -45,6 +45,16 @@
 
 
     /**
+     * <p>The name of the context initialization parameter that defines the
+     * fully qualified class name of the [EMAIL PROTECTED] 
ViewControllerMapper} to be
+     * used is stored.  If not present, the default value is
+     * <code>org.apache.shale.view.DefaultViewControllerMapper</code>.</p>
+     */
+    public static final String VIEW_CONTROLLER_MAPPER =
+      "org.apache.shale.view.VIEW_CONTROLLER_MAPPER";
+
+
+    /**
      * <p>Application scope attribute under which the
      * [EMAIL PROTECTED] ViewControllerMapper} for translating view identifiers
      * to class names of the corresponding [EMAIL PROTECTED] ViewController}

Modified: 
struts/shale/trunk/core-library/src/java/org/apache/shale/view/faces/ViewViewHandler.java
URL: 
http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/view/faces/ViewViewHandler.java?rev=393148&r1=393147&r2=393148&view=diff
==============================================================================
--- 
struts/shale/trunk/core-library/src/java/org/apache/shale/view/faces/ViewViewHandler.java
 (original)
+++ 
struts/shale/trunk/core-library/src/java/org/apache/shale/view/faces/ViewViewHandler.java
 Mon Apr 10 23:09:52 2006
@@ -31,6 +31,7 @@
 import javax.faces.el.VariableResolver;
 import javax.faces.render.RenderKit;
 import javax.faces.render.RenderKitFactory;
+import javax.servlet.ServletException;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -188,7 +189,54 @@
               context.getExternalContext().getApplicationMap().
               get(Constants.VIEW_MAPPER);
         }
+        if (mapper == null) {
+            mapper = getViewControllerMapperInstance(context);
+            context.getExternalContext().getApplicationMap().
+              put(Constants.VIEW_MAPPER, mapper);
+        }
         return mapper;
+    }
+
+
+    /**
+     * <p>Create and return the [EMAIL PROTECTED] ViewControllerMapper} 
instance
+     * we will use for this application.</p>
+     *
+     * @param context <code>FacesContext</code> for the current request
+     */
+    private ViewControllerMapper getViewControllerMapperInstance
+            (FacesContext context) {
+
+        String className =
+          
context.getExternalContext().getInitParameter(Constants.VIEW_CONTROLLER_MAPPER);
+        if (className == null) {
+            className = 
"org.apache.shale.view.impl.DefaultViewControllerMapper";
+        }
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+        if (cl == null) {
+            cl = this.getClass().getClassLoader();
+        }
+        try {
+            Class clazz = cl.loadClass(className);
+            return (ViewControllerMapper) clazz.newInstance();
+        } catch (ClassCastException e) {
+            throw new FacesException
+              (messages.getMessage("view.vcmCast",
+                                   new Object[] { className }), e);
+        } catch (ClassNotFoundException e) {
+            throw new FacesException
+              (messages.getMessage("view.vcmClass",
+                                   new Object[] { className }), e);
+        } catch (IllegalAccessException e) {
+            throw new FacesException
+              (messages.getMessage("view.vcmAccess",
+                                   new Object[] { className }), e);
+        } catch (InstantiationException e) {
+            throw new FacesException
+              (messages.getMessage("view.vcmInstantiate",
+                                   new Object[] { className }), e);
+        }
+
     }
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to