You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by cr...@apache.org on 2006/05/09 13:56:43 UTC

svn commit: r405398 - /struts/shale/trunk/core-library/src/java/org/apache/shale/view/faces/LifecycleListener.java

Author: craigmcc
Date: Tue May  9 04:56:42 2006
New Revision: 405398

URL: http://svn.apache.org/viewcvs?rev=405398&view=rev
Log:
Refactor to make subclassing (in Tiger Extensions) a bit easier.

Modified:
    struts/shale/trunk/core-library/src/java/org/apache/shale/view/faces/LifecycleListener.java

Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/view/faces/LifecycleListener.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/view/faces/LifecycleListener.java?rev=405398&r1=405397&r2=405398&view=diff
==============================================================================
--- struts/shale/trunk/core-library/src/java/org/apache/shale/view/faces/LifecycleListener.java (original)
+++ struts/shale/trunk/core-library/src/java/org/apache/shale/view/faces/LifecycleListener.java Tue May  9 04:56:42 2006
@@ -52,6 +52,8 @@
  * or a tag library descriptor included in the web application.</p>
  *
  * $Id$
+ *
+ * @since 1.0.3
  */
 public class LifecycleListener
     implements ServletContextAttributeListener,
@@ -167,7 +169,7 @@
 
         // If the new value is an AbstractApplicationBean, notify it
         Object value = event.getValue();
-        if ((value != null) && (value instanceof AbstractApplicationBean)) {
+        if (value != null) {
             fireApplicationInit(value);
         }
 
@@ -194,13 +196,13 @@
 
         // If the old value is an AbstractApplicationBean, notify it
         Object value = event.getValue();
-        if ((value != null) && (value instanceof AbstractApplicationBean)) {
+        if (value != null) {
             fireApplicationDestroy(value);
         }
 
         // If the new value is an AbstractApplicationBean, notify it
         value = event.getServletContext().getAttribute(event.getName());
-        if ((value != null) && (value instanceof AbstractApplicationBean)) {
+        if (value != null) {
             fireApplicationInit(value);
         }
 
@@ -225,7 +227,7 @@
 
         // If the old value is an AbstractApplicationBean, notify it
         Object value = event.getValue();
-        if ((value != null) && (value instanceof AbstractApplicationBean)) {
+        if (value != null) {
             fireApplicationDestroy(value);
         }
 
@@ -305,7 +307,7 @@
         while (names.hasMoreElements()) {
             String name = (String) names.nextElement();
             Object value = event.getSession().getAttribute(name);
-            if ((value != null) && (value instanceof AbstractSessionBean)) {
+            if (value != null) {
                 fireSessionPassivate(value);
             }
         }
@@ -333,7 +335,7 @@
         while (names.hasMoreElements()) {
             String name = (String) names.nextElement();
             Object value = event.getSession().getAttribute(name);
-            if ((value != null) && (value instanceof AbstractSessionBean)) {
+            if (value != null) {
                 fireSessionActivate(value);
             }
         }
@@ -362,7 +364,7 @@
 
         // If the new value is an AbstractSessionBean, notify it
         Object value = event.getValue();
-        if ((value != null) && (value instanceof AbstractSessionBean)) {
+        if (value != null) {
             fireSessionInit(value);
         }
 
@@ -389,13 +391,13 @@
 
         // If the old value is an AbstractSessionBean, notify it
         Object value = event.getValue();
-        if ((value != null) && (value instanceof AbstractSessionBean)) {
+        if (value != null) {
             fireSessionDestroy(value);
         }
 
         // If the new value is an AbstractSessionBean, notify it
         value = event.getSession().getAttribute(event.getName());
-        if ((value != null) && (value instanceof AbstractSessionBean)) {
+        if (value != null) {
             fireSessionInit(value);
         }
 
@@ -420,7 +422,7 @@
 
         // If the old value is an AbstractSessionBean, notify it
         Object value = event.getValue();
-        if ((value != null) && (value instanceof AbstractSessionBean)) {
+        if (value != null) {
             fireSessionDestroy(value);
         }
 
@@ -492,9 +494,7 @@
 
         Object value = event.getValue();
         if (value != null) {
-            if (value instanceof AbstractRequestBean) {
-                fireRequestInit(value);
-            }
+            fireRequestInit(value);
         }
 
     }
@@ -519,16 +519,12 @@
 
         Object value = event.getValue();
         if (value != null) {
-            if (value instanceof AbstractRequestBean) {
-                fireRequestDestroy(value);
-            }
+            fireRequestDestroy(value);
         }
 
         value = event.getServletRequest().getAttribute(event.getName());
         if (value != null) {
-            if (value instanceof AbstractRequestBean) {
-                fireRequestInit(value);
-            }
+            fireRequestInit(value);
         }
 
     }
@@ -552,9 +548,7 @@
 
         Object value = event.getValue();
         if (value != null) {
-            if (value instanceof AbstractRequestBean) {
-                fireRequestDestroy(value);
-            }
+            fireRequestDestroy(value);
         }
 
     }
@@ -602,7 +596,9 @@
     protected void fireApplicationDestroy(Object bean) {
 
         try {
-            ((AbstractApplicationBean) bean).destroy();
+            if (bean instanceof AbstractApplicationBean) {
+                ((AbstractApplicationBean) bean).destroy();
+            }
         } catch (Exception e) {
             cacheException(e);
         }
@@ -618,7 +614,9 @@
     protected void fireApplicationInit(Object bean) {
 
         try {
-            ((AbstractApplicationBean) bean).init();
+            if (bean instanceof AbstractApplicationBean) {
+                ((AbstractApplicationBean) bean).init();
+            }
         } catch (Exception e) {
             cacheException(e);
         }
@@ -634,7 +632,9 @@
     protected void fireRequestDestroy(Object bean) {
 
         try {
-            ((AbstractRequestBean) bean).destroy();
+            if (bean instanceof AbstractRequestBean) {
+                ((AbstractRequestBean) bean).destroy();
+            }
         } catch (Exception e) {
             cacheException(e);
         }
@@ -650,7 +650,9 @@
     protected void fireRequestInit(Object bean) {
 
         try {
-            ((AbstractRequestBean) bean).init();
+            if (bean instanceof AbstractRequestBean) {
+                ((AbstractRequestBean) bean).init();
+            }
         } catch (Exception e) {
             cacheException(e);
         }
@@ -666,7 +668,9 @@
     protected void fireSessionActivate(Object bean) {
 
         try {
-            ((AbstractSessionBean) bean).activate();
+            if (bean instanceof AbstractSessionBean) {
+                ((AbstractSessionBean) bean).activate();
+            }
         } catch (Exception e) {
             cacheException(e);
         }
@@ -682,7 +686,9 @@
     protected void fireSessionDestroy(Object bean) {
 
         try {
-            ((AbstractSessionBean) bean).destroy();
+            if (bean instanceof AbstractSessionBean) {
+                ((AbstractSessionBean) bean).destroy();
+            }
         } catch (Exception e) {
             cacheException(e);
         }
@@ -698,7 +704,9 @@
     protected void fireSessionInit(Object bean) {
 
         try {
-            ((AbstractSessionBean) bean).init();
+            if (bean instanceof AbstractSessionBean) {
+                ((AbstractSessionBean) bean).init();
+            }
         } catch (Exception e) {
             cacheException(e);
         }
@@ -714,7 +722,9 @@
     protected void fireSessionPassivate(Object bean) {
 
         try {
-            ((AbstractSessionBean) bean).passivate();
+            if (bean instanceof AbstractSessionBean) {
+                ((AbstractSessionBean) bean).passivate();
+            }
         } catch (Exception e) {
             cacheException(e);
         }