Author: craigmcc
Date: Wed Aug 2 11:17:11 2006
New Revision: 428077
URL: http://svn.apache.org/viewvc?rev=428077&view=rev
Log:
Adjust the mechanism by which ExceptionHandler and ViewControllerMapper
service objects are accessed. The core Shale library will define
default implementations as application scoped managed beans, under keys
found in ort.apache.shale.view.faces.FacesConstants ... but the
application can specialize the behavior by replacing the implementation
at those attribute keys.
SHALE-246
Added:
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/ExceptionHandler.java
- copied, changed from r427919,
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ExceptionHandler.java
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/impl/DefaultExceptionHandler.java
Removed:
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ExceptionHandler.java
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ExceptionHandlerFactory.java
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ExceptionHandlerImpl.java
Modified:
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/component/Subview.java
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/FacesConstants.java
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/LifecycleListener.java
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ViewActionListener.java
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ViewPhaseListener.java
shale/framework/trunk/shale-core/src/main/resources/META-INF/faces-config.xml
shale/framework/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/view/faces/LifecycleListener2.java
shale/framework/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/view/faces/ViewControllerCallbacks2.java
shale/framework/trunk/shale-tiger/src/test/java/org/apache/shale/tiger/faces/LifecycleListenerTestCase.java
shale/framework/trunk/shale-tiger/src/test/java/org/apache/shale/tiger/faces/VariableResolverImplTestCase.java
Modified:
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/component/Subview.java
URL:
http://svn.apache.org/viewvc/shale/framework/trunk/shale-core/src/main/java/org/apache/shale/component/Subview.java?rev=428077&r1=428076&r2=428077&view=diff
==============================================================================
---
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/component/Subview.java
(original)
+++
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/component/Subview.java
Wed Aug 2 11:17:11 2006
@@ -23,13 +23,14 @@
import javax.faces.component.UINamingContainer;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shale.util.Messages;
+import org.apache.shale.view.ExceptionHandler;
import org.apache.shale.view.ViewController;
import org.apache.shale.view.faces.CallbacksFactory;
-import org.apache.shale.view.faces.ExceptionHandlerFactory;
import org.apache.shale.view.faces.FacesConstants;
import org.apache.shale.view.faces.ViewControllerCallbacks;
@@ -76,7 +77,7 @@
try {
getViewControllerCallbacks(context).prerender(vc);
} catch (Exception e) {
- handleException(e);
+ handleException(context, e);
}
}
super.processDecodes(context);
@@ -98,7 +99,7 @@
try {
getViewControllerCallbacks(context).preprocess(vc);
} catch (Exception e) {
- handleException(e);
+ handleException(context, e);
}
}
super.processDecodes(context);
@@ -205,12 +206,14 @@
* <p>Handle the specified exception according to the strategy
* defined by our current [EMAIL PROTECTED] ExceptionHandler}.</p>
*
+ * @param context FacesContext for the current request
* @param exception Exception to be handled
*/
- private void handleException(Exception exception) {
+ private void handleException(FacesContext context, Exception exception) {
- ExceptionHandlerFactory.getInstance().getExceptionHandler().
- handleException(exception);
+ ValueBinding vb = context.getApplication().createValueBinding
+ ("#{" + FacesConstants.EXCEPTION_HANDLER + "}");
+ ((ExceptionHandler) vb.getValue(context)).handleException(exception);
}
Copied:
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/ExceptionHandler.java
(from r427919,
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ExceptionHandler.java)
URL:
http://svn.apache.org/viewvc/shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/ExceptionHandler.java?p2=shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/ExceptionHandler.java&p1=shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ExceptionHandler.java&r1=427919&r2=428077&rev=428077&view=diff
==============================================================================
---
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ExceptionHandler.java
(original)
+++
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/ExceptionHandler.java
Wed Aug 2 11:17:11 2006
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.apache.shale.view.faces;
+package org.apache.shale.view;
/**
* <p>Interface describing a "strategy pattern" implementation for
Modified:
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/FacesConstants.java
URL:
http://svn.apache.org/viewvc/shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/FacesConstants.java?rev=428077&r1=428076&r2=428077&view=diff
==============================================================================
---
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/FacesConstants.java
(original)
+++
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/FacesConstants.java
Wed Aug 2 11:17:11 2006
@@ -16,6 +16,8 @@
package org.apache.shale.view.faces;
+import org.apache.shale.view.ExceptionHandler;
+import org.apache.shale.view.ViewController;
import org.apache.shale.view.ViewControllerMapper;
@@ -42,22 +44,31 @@
/**
+ * <p>Application scope attribute under which the
+ * [EMAIL PROTECTED] ExceptionHandler} for handling exceptions is
stored.</p>
+ */
+ public static final String EXCEPTION_HANDLER =
+ "org$apache$shale$view$EXCEPTION_HANDLER";
+
+
+
+ /**
* <p>Request scope attribute under which a <code>java.util.List</code>
* of exceptions accumulated during the current request processing
lifecycle
* are accumulated. If there is no such <code>List</code> present, then
* no exceptions have been accumulated for the current request.</p>
*/
- static final String EXCEPTIONS_LIST =
- "org.apache.shale.view.EXCEPTIONS_LIST";
+ public static final String EXCEPTIONS_LIST =
+ "org$apache$shale$view$EXCEPTIONS_LIST";
/**
* <p>Application scope attribute under which the
- * <code>ViewControllerCallbacks</code> instance for this application
+ * [EMAIL PROTECTED] ViewControllerCallbacks} instance for this application
* is stored.</p>
*/
public static final String VIEW_CALLBACKS =
- "org.apache.shale.view.VIEW_CALLBACKS";
+ "org$apache$shale$view$VIEW_CALLBACKS";
/**
@@ -66,7 +77,7 @@
* for the current request are stored.</p>
*/
public static final String VIEWS_INITIALIZED =
- "org.apache.shale.view.VIEWS_INITIALIZED";
+ "org$apache$shale$view$VIEWS_INITIALIZED";
/**
@@ -76,7 +87,7 @@
* is stored.</p>
*/
public static final String VIEW_MAPPER =
- "org.apache.shale.view.VIEW_MAPPER";
+ "org$apache$shale$view$VIEW_MAPPER";
/**
@@ -84,7 +95,7 @@
* flag is stored if this request is a postback.</p>
*/
public static final String VIEW_POSTBACK =
- "org.apache.shale.view.VIEW_POSTBACK";
+ "org$apache$shale$view$VIEW_POSTBACK";
/**
@@ -93,7 +104,7 @@
* (if any) is stored.</p>
*/
static final String VIEW_NAME_RENDERED =
- "org.apache.shale.view.VIEW_NAME_RENDERED";
+ "org$apache$shale$view$VIEW_NAME_RENDERED";
}
Modified:
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/LifecycleListener.java
URL:
http://svn.apache.org/viewvc/shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/LifecycleListener.java?rev=428077&r1=428076&r2=428077&view=diff
==============================================================================
---
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/LifecycleListener.java
(original)
+++
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/LifecycleListener.java
Wed Aug 2 11:17:11 2006
@@ -20,6 +20,8 @@
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletContextAttributeListener;
import javax.servlet.ServletContextEvent;
@@ -38,6 +40,7 @@
import org.apache.shale.view.AbstractApplicationBean;
import org.apache.shale.view.AbstractRequestBean;
import org.apache.shale.view.AbstractSessionBean;
+import org.apache.shale.view.ExceptionHandler;
import org.apache.shale.view.ViewController;
@@ -595,7 +598,7 @@
((AbstractApplicationBean) bean).destroy();
}
} catch (Exception e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
}
}
@@ -613,7 +616,7 @@
((AbstractApplicationBean) bean).init();
}
} catch (Exception e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
}
}
@@ -633,7 +636,7 @@
((ViewController) bean).destroy();
}
} catch (Exception e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
}
}
@@ -653,7 +656,7 @@
((ViewController) bean).init();
}
} catch (Exception e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
}
}
@@ -671,7 +674,7 @@
((AbstractSessionBean) bean).activate();
}
} catch (Exception e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
}
}
@@ -689,7 +692,7 @@
((AbstractSessionBean) bean).destroy();
}
} catch (Exception e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
}
}
@@ -707,7 +710,7 @@
((AbstractSessionBean) bean).init();
}
} catch (Exception e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
}
}
@@ -725,7 +728,7 @@
((AbstractSessionBean) bean).passivate();
}
} catch (Exception e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
}
}
@@ -735,12 +738,18 @@
* <p>Handle the specified exception according to the strategy
* defined by our current [EMAIL PROTECTED] ExceptionHandler}.</p>
*
+ * @param context FacesContext for the current request
* @param exception Exception to be handled
*/
- protected void handleException(Exception exception) {
+ protected void handleException(FacesContext context, Exception exception) {
- ExceptionHandlerFactory.getInstance().getExceptionHandler().
- handleException(exception);
+ if (context == null) {
+ exception.printStackTrace(System.out);
+ return;
+ }
+ ValueBinding vb = context.getApplication().createValueBinding
+ ("#{" + FacesConstants.EXCEPTION_HANDLER + "}");
+ ((ExceptionHandler) vb.getValue(context)).handleException(exception);
}
Modified:
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ViewActionListener.java
URL:
http://svn.apache.org/viewvc/shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ViewActionListener.java?rev=428077&r1=428076&r2=428077&view=diff
==============================================================================
---
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ViewActionListener.java
(original)
+++
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ViewActionListener.java
Wed Aug 2 11:17:11 2006
@@ -16,8 +16,11 @@
package org.apache.shale.view.faces;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;
+import org.apache.shale.view.ExceptionHandler;
/**
* <p>Replacement for the default <code>ActionListener</code> implementation
@@ -69,7 +72,7 @@
try {
original.processAction(event);
} catch (Exception e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
}
}
@@ -82,12 +85,18 @@
* <p>Handle the specified exception according to the strategy
* defined by our current [EMAIL PROTECTED] ExceptionHandler}.</p>
*
+ * @param context FacesContext for the current request
* @param exception Exception to be handled
*/
- private void handleException(Exception exception) {
+ private void handleException(FacesContext context, Exception exception) {
- ExceptionHandlerFactory.getInstance().getExceptionHandler().
- handleException(exception);
+ if (context == null) {
+ exception.printStackTrace(System.out);
+ return;
+ }
+ ValueBinding vb = context.getApplication().createValueBinding
+ ("#{" + FacesConstants.EXCEPTION_HANDLER + "}");
+ ((ExceptionHandler) vb.getValue(context)).handleException(exception);
}
Modified:
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ViewPhaseListener.java
URL:
http://svn.apache.org/viewvc/shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ViewPhaseListener.java?rev=428077&r1=428076&r2=428077&view=diff
==============================================================================
---
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ViewPhaseListener.java
(original)
+++
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ViewPhaseListener.java
Wed Aug 2 11:17:11 2006
@@ -20,6 +20,7 @@
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
@@ -28,6 +29,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shale.view.Constants;
+import org.apache.shale.view.ExceptionHandler;
import org.apache.shale.view.ViewController;
/**
@@ -164,7 +166,7 @@
try {
viewControllerCallbacks(event.getFacesContext()).preprocess(vc);
} catch (Exception e) {
- handleException(e);
+ handleException(event.getFacesContext(), e);
}
}
@@ -192,7 +194,7 @@
try {
viewControllerCallbacks(event.getFacesContext()).prerender(vc);
} catch (Exception e) {
- handleException(e);
+ handleException(event.getFacesContext(), e);
}
map.remove(FacesConstants.VIEW_NAME_RENDERED);
@@ -233,12 +235,18 @@
* <p>Handle the specified exception according to the strategy
* defined by our current [EMAIL PROTECTED] ExceptionHandler}.</p>
*
+ * @param context FacesContext for the current request
* @param exception Exception to be handled
*/
- private void handleException(Exception exception) {
+ private void handleException(FacesContext context, Exception exception) {
- ExceptionHandlerFactory.getInstance().getExceptionHandler().
- handleException(exception);
+ if (context == null) {
+ exception.printStackTrace(System.out);
+ return;
+ }
+ ValueBinding vb = context.getApplication().createValueBinding
+ ("#{" + FacesConstants.EXCEPTION_HANDLER + "}");
+ ((ExceptionHandler) vb.getValue(context)).handleException(exception);
}
Added:
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/impl/DefaultExceptionHandler.java
URL:
http://svn.apache.org/viewvc/shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/impl/DefaultExceptionHandler.java?rev=428077&view=auto
==============================================================================
---
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/impl/DefaultExceptionHandler.java
(added)
+++
shale/framework/trunk/shale-core/src/main/java/org/apache/shale/view/impl/DefaultExceptionHandler.java
Wed Aug 2 11:17:11 2006
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shale.view.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.faces.context.FacesContext;
+import org.apache.shale.view.ExceptionHandler;
+import org.apache.shale.view.faces.FacesConstants;
+
+/**
+ * <p>Default implementation of the [EMAIL PROTECTED] ExceptionHandler}
interface.</p>
+ *
+ * $Id: ExceptionHandlerImpl.java 422609 2006-07-17 03:17:18Z craigmcc $
+ */
+public class DefaultExceptionHandler implements ExceptionHandler {
+
+
+ /**
+ * <p>Log the specified exception, and record it in a request scoped
+ * <code>List</code> that can be used to report them all at a future
+ * point in time to report all of the accumulated exceptions.</p>
+ *
+ * @param exception Exception to be handled
+ */
+ public void handleException(Exception exception) {
+
+ // Log the exception unconditionally
+ FacesContext context = FacesContext.getCurrentInstance();
+ if (context != null) {
+ context.getExternalContext().log(exception.getMessage(),
exception);
+ } else {
+ System.out.println(exception.getMessage());
+ exception.printStackTrace(System.out);
+ }
+
+ // Are we within the context of a JavaServer Faces request?
+ // If so, accumulate this exception to the list that can be
+ // reported at the completion of the request.
+ if (context == null) {
+ return;
+ }
+ List list = (List) context.getExternalContext().getRequestMap().
+ get(FacesConstants.EXCEPTIONS_LIST);
+ if (list == null) {
+ list = new ArrayList();
+ context.getExternalContext().getRequestMap().
+ put(FacesConstants.EXCEPTIONS_LIST, list);
+ }
+ list.add(exception);
+
+ }
+
+
+}
Modified:
shale/framework/trunk/shale-core/src/main/resources/META-INF/faces-config.xml
URL:
http://svn.apache.org/viewvc/shale/framework/trunk/shale-core/src/main/resources/META-INF/faces-config.xml?rev=428077&r1=428076&r2=428077&view=diff
==============================================================================
---
shale/framework/trunk/shale-core/src/main/resources/META-INF/faces-config.xml
(original)
+++
shale/framework/trunk/shale-core/src/main/resources/META-INF/faces-config.xml
Wed Aug 2 11:17:11 2006
@@ -107,11 +107,21 @@
<managed-bean>
<description>
+ Default implementation of org.apache.shale.view.ExceptionHandler
+ used to process application-triggered exceptions.
+ </description>
+
<managed-bean-name>org$apache.$shale$view$EXCEPTION_HANDLER</managed-bean-name>
+
<managed-bean-class>org.apache.shale.view.impl.DefaultExceptionHandler</managed-bean-class>
+ <managed-bean-scope>application</managed-bean-scope>
+ </managed-bean>
+
+ <managed-bean>
+ <description>
Default implementation of org.apache.shale.view.ViewControllerMapper
used to map from view identifiers to the managed bean name of the
corresponding view controller bean.
</description>
- <managed-bean-name>org.apache.shale.view.VIEW_MAPPER</managed-bean-name>
+ <managed-bean-name>org$apache$shale$view$VIEW_MAPPER</managed-bean-name>
<managed-bean-class>org.apache.shale.view.impl.DefaultViewControllerMapper</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
</managed-bean>
Modified:
shale/framework/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/view/faces/LifecycleListener2.java
URL:
http://svn.apache.org/viewvc/shale/framework/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/view/faces/LifecycleListener2.java?rev=428077&r1=428076&r2=428077&view=diff
==============================================================================
---
shale/framework/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/view/faces/LifecycleListener2.java
(original)
+++
shale/framework/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/view/faces/LifecycleListener2.java
Wed Aug 2 11:17:11 2006
@@ -21,6 +21,7 @@
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
+import javax.faces.context.FacesContext;
import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletRequestAttributeEvent;
import javax.servlet.http.HttpSessionBindingEvent;
@@ -320,9 +321,9 @@
method.invoke(bean, PARAMETERS);
}
} catch (InvocationTargetException e) {
- handleException((Exception) e.getCause());
+ handleException(FacesContext.getCurrentInstance(), (Exception)
e.getCause());
} catch (Exception e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
}
}
@@ -346,9 +347,9 @@
method.invoke(bean, PARAMETERS);
}
} catch (InvocationTargetException e) {
- handleException((Exception) e.getCause());
+ handleException(FacesContext.getCurrentInstance(), (Exception)
e.getCause());
} catch (Exception e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
}
}
@@ -373,9 +374,9 @@
method.invoke(bean, PARAMETERS);
}
} catch (InvocationTargetException e) {
- handleException((Exception) e.getCause());
+ handleException(FacesContext.getCurrentInstance(), (Exception)
e.getCause());
} catch (Exception e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
}
}
@@ -400,9 +401,9 @@
method.invoke(bean, PARAMETERS);
}
} catch (InvocationTargetException e) {
- handleException((Exception) e.getCause());
+ handleException(FacesContext.getCurrentInstance(), (Exception)
e.getCause());
} catch (Exception e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
}
}
@@ -426,9 +427,9 @@
method.invoke(bean, PARAMETERS);
}
} catch (InvocationTargetException e) {
- handleException((Exception) e.getCause());
+ handleException(FacesContext.getCurrentInstance(), (Exception)
e.getCause());
} catch (Exception e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
}
}
@@ -452,9 +453,9 @@
method.invoke(bean, PARAMETERS);
}
} catch (InvocationTargetException e) {
- handleException((Exception) e.getCause());
+ handleException(FacesContext.getCurrentInstance(), (Exception)
e.getCause());
} catch (Exception e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
}
}
@@ -478,9 +479,9 @@
method.invoke(bean, PARAMETERS);
}
} catch (InvocationTargetException e) {
- handleException((Exception) e.getCause());
+ handleException(FacesContext.getCurrentInstance(), (Exception)
e.getCause());
} catch (Exception e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
}
}
@@ -504,9 +505,9 @@
method.invoke(bean, PARAMETERS);
}
} catch (InvocationTargetException e) {
- handleException((Exception) e.getCause());
+ handleException(FacesContext.getCurrentInstance(), (Exception)
e.getCause());
} catch (Exception e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
}
}
Modified:
shale/framework/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/view/faces/ViewControllerCallbacks2.java
URL:
http://svn.apache.org/viewvc/shale/framework/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/view/faces/ViewControllerCallbacks2.java?rev=428077&r1=428076&r2=428077&view=diff
==============================================================================
---
shale/framework/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/view/faces/ViewControllerCallbacks2.java
(original)
+++
shale/framework/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/view/faces/ViewControllerCallbacks2.java
Wed Aug 2 11:17:11 2006
@@ -20,13 +20,16 @@
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
import org.apache.shale.tiger.view.Destroy;
import org.apache.shale.tiger.view.Init;
import org.apache.shale.tiger.view.Preprocess;
import org.apache.shale.tiger.view.Prerender;
import org.apache.shale.tiger.view.View;
+import org.apache.shale.view.ExceptionHandler;
import org.apache.shale.view.ViewController;
-import org.apache.shale.view.faces.ExceptionHandlerFactory;
+import org.apache.shale.view.faces.FacesConstants;
import org.apache.shale.view.faces.ViewControllerCallbacks;
/**
@@ -67,7 +70,7 @@
try {
((ViewController) instance).preprocess();
} catch (Exception e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
}
return;
}
@@ -77,9 +80,9 @@
try {
method.invoke(instance, new Object[0]);
} catch (IllegalAccessException e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
} catch (InvocationTargetException e) {
- handleException((Exception) e.getCause());
+ handleException(FacesContext.getCurrentInstance(), (Exception)
e.getCause());
}
}
@@ -98,7 +101,7 @@
try {
((ViewController) instance).prerender();
} catch (Exception e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
}
return;
}
@@ -108,9 +111,9 @@
try {
method.invoke(instance, new Object[0]);
} catch (IllegalAccessException e) {
- handleException(e);
+ handleException(FacesContext.getCurrentInstance(), e);
} catch (InvocationTargetException e) {
- handleException((Exception) e.getCause());
+ handleException(FacesContext.getCurrentInstance(), (Exception)
e.getCause());
}
}
@@ -124,12 +127,18 @@
* <p>Handle the specified exception according to the strategy
* defined by our current [EMAIL PROTECTED] ExceptionHandler}.</p>
*
+ * @param context FacesContext for the current request
* @param exception Exception to be handled
*/
- private void handleException(Exception exception) {
+ private void handleException(FacesContext context, Exception exception) {
- ExceptionHandlerFactory.getInstance().getExceptionHandler().
- handleException(exception);
+ if (context == null) {
+ exception.printStackTrace(System.out);
+ return;
+ }
+ ValueBinding vb = context.getApplication().createValueBinding
+ ("#{" + FacesConstants.EXCEPTION_HANDLER + "}");
+ ((ExceptionHandler) vb.getValue(context)).handleException(exception);
}
Modified:
shale/framework/trunk/shale-tiger/src/test/java/org/apache/shale/tiger/faces/LifecycleListenerTestCase.java
URL:
http://svn.apache.org/viewvc/shale/framework/trunk/shale-tiger/src/test/java/org/apache/shale/tiger/faces/LifecycleListenerTestCase.java?rev=428077&r1=428076&r2=428077&view=diff
==============================================================================
---
shale/framework/trunk/shale-tiger/src/test/java/org/apache/shale/tiger/faces/LifecycleListenerTestCase.java
(original)
+++
shale/framework/trunk/shale-tiger/src/test/java/org/apache/shale/tiger/faces/LifecycleListenerTestCase.java
Wed Aug 2 11:17:11 2006
@@ -128,7 +128,7 @@
assertNotNull(config);
Map<String,ManagedBeanConfig> mbMap = fcConfig.getManagedBeans();
assertNotNull(mbMap);
- assertEquals(5, mbMap.size());
+ assertEquals(7, mbMap.size());
ManagedPropertyConfig mpConfig = null;
Modified:
shale/framework/trunk/shale-tiger/src/test/java/org/apache/shale/tiger/faces/VariableResolverImplTestCase.java
URL:
http://svn.apache.org/viewvc/shale/framework/trunk/shale-tiger/src/test/java/org/apache/shale/tiger/faces/VariableResolverImplTestCase.java?rev=428077&r1=428076&r2=428077&view=diff
==============================================================================
---
shale/framework/trunk/shale-tiger/src/test/java/org/apache/shale/tiger/faces/VariableResolverImplTestCase.java
(original)
+++
shale/framework/trunk/shale-tiger/src/test/java/org/apache/shale/tiger/faces/VariableResolverImplTestCase.java
Wed Aug 2 11:17:11 2006
@@ -221,7 +221,7 @@
externalContext.getApplicationMap().
get(LifecycleListener.FACES_CONFIG_CONFIG);
assertNotNull(config);
- assertEquals(5, config.getManagedBeans().size());
+ assertEquals(7, config.getManagedBeans().size());
}