+ * TODO: This should probably go into weld-extensions so other portable
+ * extensions can leverage it.
+ * =
+ * @author Lincoln Baxter, III=
+ * =
+ */
+public class Annotations
+{
+ /**
+ * Discover if a Method m has been annotated with type. T=
his
+ * also discovers annotations defined through a @{@link Stereotype}.
+ * =
+ * @return True if annotation is present either on the method itself, o=
r on
+ * the declaring class of the method. Returns false if the anno=
tation
+ * is not present.
+ */
+ public static boolean hasAnnotation(final Method m, final Class exten=
ds Annotation> type)
+ {
+ boolean result =3D false;
+ if (m.isAnnotationPresent(type))
+ {
+ result =3D true;
+ }
+ else
+ {
+ for (Annotation a : m.getAnnotations())
+ {
+ if (a.annotationType().isAnnotationPresent(type))
+ {
+ result =3D true;
+ }
+ }
+ }
+
+ if (result =3D=3D false)
+ {
+ result =3D hasAnnotation(m.getDeclaringClass(), type);
+ }
+ return result;
+ }
+
+ /**
+ * Discover if a Class c has been annotated with type. Th=
is
+ * also discovers annotations defined through a @{@link Stereotype}.
+ * =
+ * @return True if annotation is present either on class, false if the
+ * annotation is not present.
+ */
+ public static boolean hasAnnotation(final Class> c, final Class ext=
ends Annotation> type)
+ {
+ boolean result =3D false;
+ if (c.isAnnotationPresent(type))
+ {
+ result =3D true;
+ }
+ else
+ {
+ for (Annotation a : c.getAnnotations())
+ {
+ if (a.annotationType().isAnnotationPresent(type))
+ {
+ result =3D true;
+ }
+ }
+ }
+ return result;
+ }
+}
Modified: modules/faces/trunk/src/main/resources/META-INF/services/javax.en=
terprise.inject.spi.Extension
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- modules/faces/trunk/src/main/resources/META-INF/services/javax.enterpri=
se.inject.spi.Extension 2010-03-29 16:26:07 UTC (rev 12311)
+++ modules/faces/trunk/src/main/resources/META-INF/services/javax.enterpri=
se.inject.spi.Extension 2010-03-29 20:36:45 UTC (rev 12312)
@@ -1,3 +1,2 @@
org.jboss.seam.faces.context.ViewScopedExtension
-org.jboss.seam.faces.context.FlashScopedExtension
-org.jboss.seam.faces.context.conversation.ConversationAnnotationExtension
\ No newline at end of file
+org.jboss.seam.faces.context.FlashScopedExtension
\ No newline at end of file
Deleted: modules/faces/trunk/src/test/java/org/jboss/seam/faces/context/con=
versation/BeginConversationBean.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- modules/faces/trunk/src/test/java/org/jboss/seam/faces/context/conversa=
tion/BeginConversationBean.java 2010-03-29 16:26:07 UTC (rev 12311)
+++ modules/faces/trunk/src/test/java/org/jboss/seam/faces/context/conversa=
tion/BeginConversationBean.java 2010-03-29 20:36:45 UTC (rev 12312)
@@ -1,34 +0,0 @@
-/**
- * =
- */
-package org.jboss.seam.faces.context.conversation;
-
-import javax.enterprise.context.Conversation;
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Inject;
-
-/**
- * @author Lincoln Baxter, II=
I
- * =
- */
-(a)RequestScoped
-public class BeginConversationBean
-{
- @Inject Conversation conversation;
-
- private boolean conversationLongRunningDuringInvocation =3D false;
-
- @Begin
- public void beginConversation()
- {
- if (!conversation.isTransient())
- {
- conversationLongRunningDuringInvocation =3D true;
- }
- }
-
- public boolean isConversationLongRunningInsideMethodCall() {
- return conversationLongRunningDuringInvocation;
- }
-
-}
Deleted: modules/faces/trunk/src/test/java/org/jboss/seam/faces/context/con=
versation/BeginConversationInterceptorTest.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- modules/faces/trunk/src/test/java/org/jboss/seam/faces/context/conversa=
tion/BeginConversationInterceptorTest.java 2010-03-29 16:26:07 UTC (rev 123=
11)
+++ modules/faces/trunk/src/test/java/org/jboss/seam/faces/context/conversa=
tion/BeginConversationInterceptorTest.java 2010-03-29 20:36:45 UTC (rev 123=
12)
@@ -1,54 +0,0 @@
-/**
- * =
- */
-package org.jboss.seam.faces.context.conversation;
-
-import javax.enterprise.context.Conversation;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-
-import javax.inject.Inject;
-
-import org.jboss.arquillian.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.seam.faces.MockConversation;
-import org.jboss.seam.faces.MockLogger;
-import org.jboss.shrinkwrap.api.ArchivePaths;
-import org.jboss.shrinkwrap.api.Archives;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.internal.runners.statements.Fail;
-import org.junit.runner.RunWith;
-
-/**
- * @author Lincoln Baxter, II=
I
- * =
- */
-(a)RunWith(Arquillian.class)
-public class BeginConversationInterceptorTest
-{
- @Deployment
- public static JavaArchive createTestArchive()
- {
- return Archives.create("test.jar", JavaArchive.class).addClasses(Beg=
inConversationInterceptor.class, BeginConversationBean.class, MockLogger.cl=
ass, MockConversation.class).addManifestResource(BeginConversationIntercept=
orTest.class.getPackage().getName().replaceAll("\\.", "/") + "/BeginConvers=
ationInterceptorTest-beans.xml", ArchivePaths.create("beans.xml"));
- }
-
- @Inject Conversation conversation;
-
- @Inject private BeginConversationBean interceptedBean;
-
- @Test
- //@Category(Fail.class)
- public void testConversationStarted()
- {
- // assert fixtures
- assertTrue(conversation.isTransient());
- assertFalse(interceptedBean.isConversationLongRunningInsideMethodCal=
l());
-
- interceptedBean.beginConversation();
-
- assertFalse(conversation.isTransient());
- assertTrue(interceptedBean.isConversationLongRunningInsideMethodCall=
());
- }
-}
Copied: modules/faces/trunk/src/test/java/org/jboss/seam/faces/context/conv=
ersation/ConversationBoundaryInterceptorTest.java (from rev 12311, modules/=
faces/trunk/src/test/java/org/jboss/seam/faces/context/conversation/BeginCo=
nversationInterceptorTest.java)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- modules/faces/trunk/src/test/java/org/jboss/seam/faces/context/conversa=
tion/ConversationBoundaryInterceptorTest.java (rev =
0)
+++ modules/faces/trunk/src/test/java/org/jboss/seam/faces/context/conversa=
tion/ConversationBoundaryInterceptorTest.java 2010-03-29 20:36:45 UTC (rev =
12312)
@@ -0,0 +1,64 @@
+/**
+ * =
+ */
+package org.jboss.seam.faces.context.conversation;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import javax.enterprise.context.Conversation;
+import javax.inject.Inject;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.faces.MockConversation;
+import org.jboss.seam.faces.MockLogger;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Lincoln Baxter, II=
I
+ * =
+ */
+(a)RunWith(Arquillian.class)
+public class ConversationBoundaryInterceptorTest
+{
+ @Deployment
+ public static JavaArchive createTestArchive()
+ {
+ return Archives.create("test.jar", JavaArchive.class).addClasses(Con=
versationBoundaryInterceptor.class, ConversationalBean.class, MockLogger.cl=
ass, MockConversation.class).addManifestResource(ConversationBoundaryInterc=
eptorTest.class.getPackage().getName().replaceAll("\\.", "/") + "/Conversat=
ionBoundaryInterceptorTest-beans.xml", ArchivePaths.create("beans.xml"));
+ }
+
+ @Inject
+ Conversation conversation;
+
+ @Inject
+ private ConversationalBean interceptedBean;
+
+ @Test
+ public void testConversationStarted()
+ {
+ assertTrue(conversation.isTransient());
+ assertFalse(interceptedBean.isConversationLongRunningInsideMethodCal=
l());
+
+ interceptedBean.beginConversation();
+
+ assertFalse(conversation.isTransient());
+ assertTrue(interceptedBean.isConversationLongRunningInsideMethodCall=
());
+ }
+
+ @Test
+ public void testConversationBeginsAndEnds()
+ {
+ assertTrue(conversation.isTransient());
+ assertFalse(interceptedBean.isConversationLongRunningDuringInvocatio=
n2());
+
+ interceptedBean.beginAndEndConversation();
+
+ assertTrue(conversation.isTransient());
+ assertTrue(interceptedBean.isConversationLongRunningDuringInvocation=
2());
+ }
+}
Copied: modules/faces/trunk/src/test/java/org/jboss/seam/faces/context/conv=
ersation/ConversationalBean.java (from rev 12311, modules/faces/trunk/src/t=
est/java/org/jboss/seam/faces/context/conversation/BeginConversationBean.ja=
va)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- modules/faces/trunk/src/test/java/org/jboss/seam/faces/context/conversa=
tion/ConversationalBean.java (rev 0)
+++ modules/faces/trunk/src/test/java/org/jboss/seam/faces/context/conversa=
tion/ConversationalBean.java 2010-03-29 20:36:45 UTC (rev 12312)
@@ -0,0 +1,55 @@
+/**
+ * =
+ */
+package org.jboss.seam.faces.context.conversation;
+
+import javax.enterprise.context.Conversation;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+
+/**
+ * @author Lincoln Baxter, II=
I
+ * =
+ */
+(a)RequestScoped
+public class ConversationalBean
+{
+ @Inject
+ Conversation conversation;
+
+ private boolean conversationLongRunningDuringInvocation =3D false;
+
+ private boolean conversationLongRunningDuringInvocation2;
+
+ @Begin
+ public void beginConversation()
+ {
+ if (!conversation.isTransient())
+ {
+ conversationLongRunningDuringInvocation =3D true;
+ }
+ }
+
+ @Begin
+ @End
+ public void beginAndEndConversation()
+ {
+ conversationLongRunningDuringInvocation2 =3D true;
+ }
+
+ public boolean isConversationLongRunningDuringInvocation2()
+ {
+ return conversationLongRunningDuringInvocation2;
+ }
+
+ public void setConversationLongRunningDuringInvocation2(final boolean c=
onversationLongRunningDuringInvocation2)
+ {
+ this.conversationLongRunningDuringInvocation2 =3D conversationLongRu=
nningDuringInvocation2;
+ }
+
+ public boolean isConversationLongRunningInsideMethodCall()
+ {
+ return conversationLongRunningDuringInvocation;
+ }
+
+}
Added: modules/faces/trunk/src/test/java/org/jboss/seam/faces/util/Annotati=
onTestObject.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- modules/faces/trunk/src/test/java/org/jboss/seam/faces/util/AnnotationT=
estObject.java (rev 0)
+++ modules/faces/trunk/src/test/java/org/jboss/seam/faces/util/AnnotationT=
estObject.java 2010-03-29 20:36:45 UTC (rev 12312)
@@ -0,0 +1,19 @@
+package org.jboss.seam.faces.util;
+
+import org.jboss.seam.faces.context.conversation.Begin;
+import org.jboss.seam.faces.context.conversation.End;
+
+(a)Begin
+public class AnnotationTestObject
+{
+
+ public void begin()
+ {
+ }
+
+ @End
+ public void end()
+ {
+ }
+
+}
Added: modules/faces/trunk/src/test/java/org/jboss/seam/faces/util/Annotati=
onsTest.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- modules/faces/trunk/src/test/java/org/jboss/seam/faces/util/Annotations=
Test.java (rev 0)
+++ modules/faces/trunk/src/test/java/org/jboss/seam/faces/util/Annotations=
Test.java 2010-03-29 20:36:45 UTC (rev 12312)
@@ -0,0 +1,46 @@
+package org.jboss.seam.faces.util;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Method;
+
+import org.jboss.seam.faces.context.conversation.Begin;
+import org.jboss.seam.faces.context.conversation.End;
+import org.junit.Test;
+
+/**
+ * =
+ * @author Lincoln Baxter, III=
+ * =
+ */
+public class AnnotationsTest
+{
+ @Test
+ public void testHasAnnotationOnClassDirectly() throws Exception
+ {
+ Method begin =3D AnnotationTestObject.class.getMethod("begin", new C=
lass[] {});
+
+ assertTrue(Annotations.hasAnnotation(begin, Begin.class));
+ assertFalse(Annotations.hasAnnotation(begin, End.class));
+ }
+
+ @Test
+ public void testHasAnnotationOnMethodDirectly() throws Exception
+ {
+ Method end =3D AnnotationTestObject.class.getMethod("end", new Class=
[] {});
+
+ assertTrue(Annotations.hasAnnotation(end, End.class));
+ }
+
+ @Test
+ public void testHasAnnotationOnMethodIndirectlyFromClass() throws Excep=
tion
+ {
+ Method begin =3D AnnotationTestObject.class.getMethod("begin", new C=
lass[] {});
+ Method end =3D AnnotationTestObject.class.getMethod("end", new Class=
[] {});
+
+ assertTrue(Annotations.hasAnnotation(begin, Begin.class));
+ assertTrue(Annotations.hasAnnotation(end, Begin.class));
+ }
+
+}
Deleted: modules/faces/trunk/src/test/resources/org/jboss/seam/faces/contex=
t/conversation/BeginConversationInterceptorTest-beans.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- modules/faces/trunk/src/test/resources/org/jboss/seam/faces/context/con=
versation/BeginConversationInterceptorTest-beans.xml 2010-03-29 16:26:07 UT=
C (rev 12311)
+++ modules/faces/trunk/src/test/resources/org/jboss/seam/faces/context/con=
versation/BeginConversationInterceptorTest-beans.xml 2010-03-29 20:36:45 UT=
C (rev 12312)
@@ -1,12 +0,0 @@
-