[seam-commits] Seam SVN: r8875 - in trunk/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:23 EDT 2008


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

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

Copied: trunk/src/main/org/jboss/seam/CyclicDependencyException.java (from rev 8872, trunk/src/main/org/jboss/seam/core/CyclicDependencyException.java)
===================================================================
--- trunk/src/main/org/jboss/seam/CyclicDependencyException.java	                        (rev 0)
+++ trunk/src/main/org/jboss/seam/CyclicDependencyException.java	2008-09-02 04:56:23 UTC (rev 8875)
@@ -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: trunk/src/main/org/jboss/seam/CyclicDependencyException.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: trunk/src/main/org/jboss/seam/core/BijectionInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/core/BijectionInterceptor.java	2008-09-02 04:53:18 UTC (rev 8874)
+++ trunk/src/main/org/jboss/seam/core/BijectionInterceptor.java	2008-09-02 04:56:23 UTC (rev 8875)
@@ -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: trunk/src/main/org/jboss/seam/core/CyclicDependencyException.java
===================================================================
--- trunk/src/main/org/jboss/seam/core/CyclicDependencyException.java	2008-09-02 04:53:18 UTC (rev 8874)
+++ trunk/src/main/org/jboss/seam/core/CyclicDependencyException.java	2008-09-02 04:56:23 UTC (rev 8875)
@@ -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: trunk/src/test/unit/org/jboss/seam/test/unit/InterceptorTest.java
===================================================================
--- trunk/src/test/unit/org/jboss/seam/test/unit/InterceptorTest.java	2008-09-02 04:53:18 UTC (rev 8874)
+++ trunk/src/test/unit/org/jboss/seam/test/unit/InterceptorTest.java	2008-09-02 04:56:23 UTC (rev 8875)
@@ -8,6 +8,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;
@@ -20,7 +21,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