Author: tsurdilovic
Date: 2010-03-30 02:16:10 -0400 (Tue, 30 Mar 2010)
New Revision: 12317
Added:
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/InsertFact.java
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/flow/
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/flow/Abort.java
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/flow/SignalEvent.java
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/flow/StartProcess.java
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/interceptor/
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/interceptor/InsertInterceptor.java
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/interceptor/flow/
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/util/
modules/drools/trunk/core/src/test/java/org/
modules/drools/trunk/core/src/test/java/org/jboss/
modules/drools/trunk/core/src/test/java/org/jboss/seam/
modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/
modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/insertion/
modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/insertion/InsertInterceptorTest.java
modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/insertion/InsertionBean.java
modules/drools/trunk/core/src/test/resources/
modules/drools/trunk/core/src/test/resources/org/
modules/drools/trunk/core/src/test/resources/org/jboss/
modules/drools/trunk/core/src/test/resources/org/jboss/seam/
modules/drools/trunk/core/src/test/resources/org/jboss/seam/drools/
modules/drools/trunk/core/src/test/resources/org/jboss/seam/drools/insertion/
modules/drools/trunk/core/src/test/resources/org/jboss/seam/drools/insertion/InsertInterceptorTest-beans.xml
Modified:
modules/drools/trunk/docs/drools-reference.pdf
modules/drools/trunk/pom.xml
Log:
added test
Added:
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/InsertFact.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/InsertFact.java
(rev 0)
+++
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/InsertFact.java 2010-03-30
06:16:10 UTC (rev 12317)
@@ -0,0 +1,32 @@
+package org.jboss.seam.drools.annotation;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.util.Nonbinding;
+import javax.interceptor.InterceptorBinding;
+
+/**
+ * Insert fact into WM or EntryPoint. Also determine firing rules decisions.
+ *
+ * @author Tihomir Surdilovic
+ */
+@InterceptorBinding
+@Target({TYPE, METHOD})
+@Documented
+@Retention(RUNTIME)
+@Inherited
+public @interface InsertFact
+{
+ @Nonbinding int ksessionId() default -1;
+ @Nonbinding boolean fireAllRules() default false;
+ @Nonbinding int fireCount() default -1;
+ @Nonbinding boolean fireUntilHalt() default false;
+ @Nonbinding String entryPointName() default "";
+}
Added:
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/flow/Abort.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/flow/Abort.java
(rev 0)
+++
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/flow/Abort.java 2010-03-30
06:16:10 UTC (rev 12317)
@@ -0,0 +1,28 @@
+package org.jboss.seam.drools.annotation.flow;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.util.Nonbinding;
+import javax.interceptor.InterceptorBinding;
+
+/**
+ * Abort the process instace.
+ *
+ * @author Tihomir Surdilovic
+ */
+@InterceptorBinding
+@Target({TYPE, METHOD})
+@Documented
+@Retention(RUNTIME)
+@Inherited
+public @interface Abort
+{
+ @Nonbinding long processid();
+}
Added:
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/flow/SignalEvent.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/flow/SignalEvent.java
(rev 0)
+++
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/flow/SignalEvent.java 2010-03-30
06:16:10 UTC (rev 12317)
@@ -0,0 +1,31 @@
+package org.jboss.seam.drools.annotation.flow;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.util.Nonbinding;
+import javax.interceptor.InterceptorBinding;
+
+/**
+ * Event to be signalled to the process instance or process engine directly.
+ *
+ * @author Tihomir Surdilovic
+ */
+@InterceptorBinding
+@Target({TYPE, METHOD})
+@Documented
+@Retention(RUNTIME)
+@Inherited
+public @interface SignalEvent
+{
+ @Nonbinding String type() default "";
+ @Nonbinding String event() default "";
+ @Nonbinding String processId() default "";
+ @Nonbinding String sessionId() default "";
+}
Added:
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/flow/StartProcess.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/flow/StartProcess.java
(rev 0)
+++
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/flow/StartProcess.java 2010-03-30
06:16:10 UTC (rev 12317)
@@ -0,0 +1,27 @@
+package org.jboss.seam.drools.annotation.flow;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.util.Nonbinding;
+import javax.interceptor.InterceptorBinding;
+
+/**
+ * Starts a Rule Flow process.
+ *
+ * @author Tihomir Surdilovic
+ */
+@InterceptorBinding
+@Target({TYPE, METHOD})
+@Documented
+@Retention(RUNTIME)
+public @interface StartProcess
+{
+ @Nonbinding String processId() default "";
+ @Nonbinding String sessionId() default "";
+}
Added:
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/interceptor/InsertInterceptor.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/interceptor/InsertInterceptor.java
(rev 0)
+++
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/interceptor/InsertInterceptor.java 2010-03-30
06:16:10 UTC (rev 12317)
@@ -0,0 +1,19 @@
+package org.jboss.seam.drools.interceptor;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+import org.jboss.seam.drools.annotation.InsertFact;
+
+@InsertFact @Interceptor
+public class InsertInterceptor
+{
+ @AroundInvoke
+ public Object manageTransaction(InvocationContext ctx) throws Exception {
+ InsertFact insertFactAnnotation = ctx.getMethod().getAnnotation(InsertFact.class);
+ System.out.println("ksession id: " +insertFactAnnotation.ksessionId());
+
+ return ctx.proceed();
+ }
+}
Added:
modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/insertion/InsertInterceptorTest.java
===================================================================
---
modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/insertion/InsertInterceptorTest.java
(rev 0)
+++
modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/insertion/InsertInterceptorTest.java 2010-03-30
06:16:10 UTC (rev 12317)
@@ -0,0 +1,33 @@
+package org.jboss.seam.drools.insertion;
+
+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.drools.interceptor.InsertInterceptor;
+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;
+
+(a)RunWith(Arquillian.class)
+public class InsertInterceptorTest
+{
+ @Deployment
+ public static JavaArchive createTestArchive()
+ {
+ return Archives.create("test.jar",
JavaArchive.class).addClasses(InsertInterceptor.class,
InsertionBean.class).addManifestResource(InsertInterceptorTest.class.getPackage().getName().replaceAll("\\.",
"/") + "/InsertInterceptorTest-beans.xml",
ArchivePaths.create("beans.xml"));
+ }
+
+ @Inject InsertionBean insertionBean;
+
+ @Test
+ public void testInsertFactHappens() {
+ String result = insertionBean.insertResultAsFact();
+ assertTrue(result.equals("abc")); //TODO finish this test
+ }
+}
Added:
modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/insertion/InsertionBean.java
===================================================================
---
modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/insertion/InsertionBean.java
(rev 0)
+++
modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/insertion/InsertionBean.java 2010-03-30
06:16:10 UTC (rev 12317)
@@ -0,0 +1,11 @@
+package org.jboss.seam.drools.insertion;
+
+import org.jboss.seam.drools.annotation.InsertFact;
+
+public class InsertionBean
+{
+ @InsertFact(ksessionId=123)
+ public String insertResultAsFact() {
+ return "abc";
+ }
+}
Added:
modules/drools/trunk/core/src/test/resources/org/jboss/seam/drools/insertion/InsertInterceptorTest-beans.xml
===================================================================
---
modules/drools/trunk/core/src/test/resources/org/jboss/seam/drools/insertion/InsertInterceptorTest-beans.xml
(rev 0)
+++
modules/drools/trunk/core/src/test/resources/org/jboss/seam/drools/insertion/InsertInterceptorTest-beans.xml 2010-03-30
06:16:10 UTC (rev 12317)
@@ -0,0 +1,10 @@
+<beans
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+
http://java.sun.com/xml/ns/javaee
+
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+
+ <interceptors>
+ <class>org.jboss.seam.drools.interceptor.InsertInterceptor</class>
+ </interceptors>
+
+</beans>
\ No newline at end of file
Modified: modules/drools/trunk/docs/drools-reference.pdf
===================================================================
(Binary files differ)
Modified: modules/drools/trunk/pom.xml
===================================================================
--- modules/drools/trunk/pom.xml 2010-03-30 04:29:25 UTC (rev 12316)
+++ modules/drools/trunk/pom.xml 2010-03-30 06:16:10 UTC (rev 12317)
@@ -29,7 +29,7 @@
<organizationUrl>http://jboss.org</organizationUrl>
<timezone>EST</timezone>
<roles>
- <role>Project Lead</role>
+ <role>Module Lead</role>
</roles>
</developer>
</developers>