[seam-commits] Seam SVN: r8876 - in branches/Seam_2_0/src: main/org/jboss/seam/core and 1 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Tue Sep 2 00:56:59 EDT 2008


Author: matt.drees
Date: 2008-09-02 00:56:59 -0400 (Tue, 02 Sep 2008)
New Revision: 8876

Added:
   branches/Seam_2_0/src/main/org/jboss/seam/CyclicDependencyException.java
Removed:
   branches/Seam_2_0/src/main/org/jboss/seam/core/CyclicDependencyException.java
Modified:
   branches/Seam_2_0/src/main/org/jboss/seam/core/BijectionInterceptor.java
   branches/Seam_2_0/src/test/unit/org/jboss/seam/test/unit/InterceptorTest.java
Log:
Move CyclicDependencyException next to other exceptions

Copied: branches/Seam_2_0/src/main/org/jboss/seam/CyclicDependencyException.java (from rev 8863, branches/Seam_2_0/src/main/org/jboss/seam/core/CyclicDependencyException.java)
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/CyclicDependencyException.java	                        (rev 0)
+++ branches/Seam_2_0/src/main/org/jboss/seam/CyclicDependencyException.java	2008-09-02 04:56:59 UTC (rev 8876)
@@ -0,0 +1,98 @@
+package org.jboss.seam;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.seam.core.BijectionInterceptor;
+
+/**
+ * An exception that is thrown when {@link BijectionInterceptor} detects that a
+ * component's dependencies cannot be injected due to a cyclic dependency. As
+ * the exception is passed up the stack, the call sequence is recorded so that a
+ * useful exception message can be constructed.
+ * 
+ * @author Matt Drees
+ * 
+ */
+public class CyclicDependencyException extends IllegalStateException
+{
+
+   /**
+    * stores the invocations in reverse call order
+    */
+   private final List<String> invocations = new ArrayList<String>();
+   private String tailComponentName;
+   private boolean cycleComplete;
+
+   /**
+    * Records this invocation's component name and method to be displayed in
+    * {@link #getMessage()}, unless this invocation is not part of the detected
+    * cycle. This method will be successively called as the exception is
+    * propagated up the stack.
+    * 
+    * @param componentName
+    * @param method
+    */
+   public void addInvocation(String componentName, Method method)
+   {
+      if (cycleComplete)
+      {
+         return;
+      }
+
+      if (invocations.isEmpty())
+      {
+         tailComponentName = componentName;
+      }
+      else
+      {
+         if (tailComponentName.equals(componentName))
+         {
+            cycleComplete = true;
+         }
+      }
+      invocations.add(createInvocationLabel(componentName, method));
+   }
+
+   /**
+    * returns e.g. "foo.doSomething()"
+    */
+   private String createInvocationLabel(String componentName, Method method)
+   {
+      String invocationLabel = componentName + "." + method.getName() + "(";
+      int i = 1;
+      for (Class<?> parameterType : method.getParameterTypes())
+      {
+         invocationLabel += parameterType.getSimpleName();
+         if (i < method.getParameterTypes().length)
+         {
+            invocationLabel += ", ";
+         }
+         i++;
+      }
+      invocationLabel += ")";
+      return invocationLabel;
+   }
+
+   @Override
+   public String getMessage()
+   {
+      if (!cycleComplete)
+      {
+         return "Cyclic dependency found";
+      }
+      else
+      {
+         String message = "Injection into " + tailComponentName + " resulted in a dependency cycle, requiring the invocation of " + invocations.get(0) + ".  The complete cycle: ";
+         for (int i = invocations.size() - 1; i >= 0; i--)
+         {
+            message += invocations.get(i);
+            if (i != 0)
+               message += " -> ";
+         }
+         return message;
+      }
+   }
+
+}


Property changes on: branches/Seam_2_0/src/main/org/jboss/seam/CyclicDependencyException.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: branches/Seam_2_0/src/main/org/jboss/seam/core/BijectionInterceptor.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/core/BijectionInterceptor.java	2008-09-02 04:56:23 UTC (rev 8875)
+++ branches/Seam_2_0/src/main/org/jboss/seam/core/BijectionInterceptor.java	2008-09-02 04:56:59 UTC (rev 8876)
@@ -4,6 +4,7 @@
 import java.util.concurrent.locks.ReentrantLock;
 
 import org.jboss.seam.Component;
+import org.jboss.seam.CyclicDependencyException;
 import org.jboss.seam.annotations.intercept.AroundInvoke;
 import org.jboss.seam.annotations.intercept.Interceptor;
 import org.jboss.seam.intercept.AbstractInterceptor;

Deleted: branches/Seam_2_0/src/main/org/jboss/seam/core/CyclicDependencyException.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/core/CyclicDependencyException.java	2008-09-02 04:56:23 UTC (rev 8875)
+++ branches/Seam_2_0/src/main/org/jboss/seam/core/CyclicDependencyException.java	2008-09-02 04:56:59 UTC (rev 8876)
@@ -1,96 +0,0 @@
-package org.jboss.seam.core;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * An exception that is thrown when {@link BijectionInterceptor} detects that a
- * component's dependencies cannot be injected due to a cyclic dependency. As
- * the exception is passed up the stack, the call sequence is recorded so that a
- * useful exception message can be constructed.
- * 
- * @author Matt Drees
- * 
- */
-public class CyclicDependencyException extends IllegalStateException
-{
-
-   /**
-    * stores the invocations in reverse call order
-    */
-   private final List<String> invocations = new ArrayList<String>();
-   private String tailComponentName;
-   private boolean cycleComplete;
-
-   /**
-    * Records this invocation's component name and method to be displayed in
-    * {@link #getMessage()}, unless this invocation is not part of the detected
-    * cycle. This method will be successively called as the exception is
-    * propagated up the stack.
-    * 
-    * @param componentName
-    * @param method
-    */
-   public void addInvocation(String componentName, Method method)
-   {
-      if (cycleComplete)
-      {
-         return;
-      }
-
-      if (invocations.isEmpty())
-      {
-         tailComponentName = componentName;
-      }
-      else
-      {
-         if (tailComponentName.equals(componentName))
-         {
-            cycleComplete = true;
-         }
-      }
-      invocations.add(createInvocationLabel(componentName, method));
-   }
-
-   /**
-    * returns e.g. "foo.doSomething()"
-    */
-   private String createInvocationLabel(String componentName, Method method)
-   {
-      String invocationLabel = componentName + "." + method.getName() + "(";
-      int i = 1;
-      for (Class<?> parameterType : method.getParameterTypes())
-      {
-         invocationLabel += parameterType.getSimpleName();
-         if (i < method.getParameterTypes().length)
-         {
-            invocationLabel += ", ";
-         }
-         i++;
-      }
-      invocationLabel += ")";
-      return invocationLabel;
-   }
-
-   @Override
-   public String getMessage()
-   {
-      if (!cycleComplete)
-      {
-         return "Cyclic dependency found";
-      }
-      else
-      {
-         String message = "Injection into " + tailComponentName + " resulted in a dependency cycle, requiring the invocation of " + invocations.get(0) + ".  The complete cycle: ";
-         for (int i = invocations.size() - 1; i >= 0; i--)
-         {
-            message += invocations.get(i);
-            if (i != 0)
-               message += " -> ";
-         }
-         return message;
-      }
-   }
-
-}

Modified: branches/Seam_2_0/src/test/unit/org/jboss/seam/test/unit/InterceptorTest.java
===================================================================
--- branches/Seam_2_0/src/test/unit/org/jboss/seam/test/unit/InterceptorTest.java	2008-09-02 04:56:23 UTC (rev 8875)
+++ branches/Seam_2_0/src/test/unit/org/jboss/seam/test/unit/InterceptorTest.java	2008-09-02 04:56:59 UTC (rev 8876)
@@ -7,6 +7,7 @@
 import javax.faces.event.PhaseId;
 
 import org.jboss.seam.Component;
+import org.jboss.seam.CyclicDependencyException;
 import org.jboss.seam.NoConversationException;
 import org.jboss.seam.RequiredException;
 import org.jboss.seam.Seam;
@@ -19,7 +20,6 @@
 import org.jboss.seam.core.ConversationEntries;
 import org.jboss.seam.core.ConversationInterceptor;
 import org.jboss.seam.core.ConversationalInterceptor;
-import org.jboss.seam.core.CyclicDependencyException;
 import org.jboss.seam.core.Events;
 import org.jboss.seam.core.Init;
 import org.jboss.seam.core.Interpolator;




More information about the seam-commits mailing list