[seam-commits] Seam SVN: r12547 - in modules/drools/trunk/impl/src: main/java/org/jboss/seam/drools/interceptor and 5 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Wed Apr 21 12:42:00 EDT 2010


Author: tsurdilovic
Date: 2010-04-21 12:41:56 -0400 (Wed, 21 Apr 2010)
New Revision: 12547

Added:
   modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertFactInterceptor.java
Removed:
   modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertInterceptor.java
   modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/insertion/
Modified:
   modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/InsertFact.java
   modules/drools/trunk/impl/src/main/resources/META-INF/beans.xml
   modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/FlowTest.java
   modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/ksession/KSessionTest.java
   modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/ksession/KSessionTest-beans.xml
Log:
insertfact interceptor.

Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/InsertFact.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/InsertFact.java	2010-04-21 16:34:34 UTC (rev 12546)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/InsertFact.java	2010-04-21 16:41:56 UTC (rev 12547)
@@ -26,7 +26,6 @@
 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;
 
@@ -34,7 +33,7 @@
 import javax.interceptor.InterceptorBinding;
 
 /**
- * Insert fact into WM or EntryPoint. Also determine firing rules decisions.
+ * Interceptor binding for inserting facts into the KnowledgeSession.
  * 
  * @author Tihomir Surdilovic
  */
@@ -42,21 +41,8 @@
 @Target( { TYPE, METHOD })
 @Documented
 @Retention(RUNTIME)
- at 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 "";
+   @Nonbinding boolean fire() default false;   
+   @Nonbinding String entrypoint() default "";
 }

Copied: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertFactInterceptor.java (from rev 12499, modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertInterceptor.java)
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertFactInterceptor.java	                        (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertFactInterceptor.java	2010-04-21 16:41:56 UTC (rev 12547)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.seam.drools.interceptor;
+
+import java.lang.annotation.Annotation;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+import org.jboss.seam.drools.annotations.InsertFact;
+
+ at InsertFact
+ at Interceptor
+public class InsertFactInterceptor
+{
+   @Inject
+   BeanManager manager;
+   
+   @AroundInvoke
+   public Object insertFact(InvocationContext ctx) throws Exception
+   {
+      System.out.println("*******\n\nIN INTERCEPTOR! \n\n ********");
+      Annotation[] methodAnnotations = ctx.getMethod().getAnnotations();
+      for(Annotation nextAnnotation : methodAnnotations) {
+         if(manager.isQualifier(nextAnnotation.getClass())) {
+            System.out.println("**************** \n\n\nNEXT QUALIFIER: " + nextAnnotation);
+         }
+         if(manager.isInterceptorBinding(nextAnnotation.getClass())) {
+            System.out.println("**************** \n\n\n\n NEXT INTERCEPTOR BINDING: " + nextAnnotation);   
+         }
+      }
+      
+      return ctx.proceed();
+   }
+}

Deleted: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertInterceptor.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertInterceptor.java	2010-04-21 16:34:34 UTC (rev 12546)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertInterceptor.java	2010-04-21 16:41:56 UTC (rev 12547)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */ 
-package org.jboss.seam.drools.interceptor;
-
-import javax.interceptor.AroundInvoke;
-import javax.interceptor.Interceptor;
-import javax.interceptor.InvocationContext;
-
-import org.jboss.seam.drools.annotations.InsertFact;
-
- at InsertFact
- at 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();
-   }
-}

Modified: modules/drools/trunk/impl/src/main/resources/META-INF/beans.xml
===================================================================
--- modules/drools/trunk/impl/src/main/resources/META-INF/beans.xml	2010-04-21 16:34:34 UTC (rev 12546)
+++ modules/drools/trunk/impl/src/main/resources/META-INF/beans.xml	2010-04-21 16:41:56 UTC (rev 12547)
@@ -331,4 +331,9 @@
 			</d:RuleResources>
 		</s:parameters>
 	</d:DroolsConfig>
+	
+	
+	<interceptors>
+      <class>org.jboss.seam.drools.interceptor.InsertFactInterceptor</class>
+   </interceptors>
 </beans>
\ No newline at end of file

Modified: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/FlowTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/FlowTest.java	2010-04-21 16:34:34 UTC (rev 12546)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/FlowTest.java	2010-04-21 16:41:56 UTC (rev 12547)
@@ -76,7 +76,7 @@
       ksession.fireAllRules();
       
       assertTrue( ((ArrayList<String>) ksession.getGlobal("errors")).size() == 1 );
-      assertTrue(((ArrayList<String>) ksession.getGlobal("errors")).get(0).equals("You must enter a Telephone Number"));
+      assertTrue( ((ArrayList<String>) ksession.getGlobal("errors")).get(0).equals("You must enter a Telephone Number") );
      
    
    }

Modified: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/ksession/KSessionTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/ksession/KSessionTest.java	2010-04-21 16:34:34 UTC (rev 12546)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/ksession/KSessionTest.java	2010-04-21 16:41:56 UTC (rev 12547)
@@ -33,6 +33,7 @@
 import org.jboss.arquillian.api.Deployment;
 import org.jboss.arquillian.junit.Arquillian;
 import org.jboss.seam.drools.KnowledgeBaseProducer;
+import org.jboss.seam.drools.annotations.InsertFact;
 import org.jboss.seam.drools.qualifiers.config.DefaultConfig;
 import org.jboss.seam.drools.qualifiers.config.MVELDialectConfig;
 import org.jboss.shrinkwrap.api.ArchivePaths;
@@ -76,5 +77,11 @@
       
       assertNotSame(ksession, mvelksession);
       assertSame(mvelksession, mvelksession2);
+      doSomething();
    }
+ 
+   @InsertFact @Default @DefaultConfig
+   public void doSomething() {
+      
+   }
 }

Modified: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/ksession/KSessionTest-beans.xml
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/ksession/KSessionTest-beans.xml	2010-04-21 16:34:34 UTC (rev 12546)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/ksession/KSessionTest-beans.xml	2010-04-21 16:41:56 UTC (rev 12547)
@@ -37,5 +37,4 @@
 			<s:value>classpath;ksessiontest.drl;DRL</s:value>
 		</d:resources>
 	</d:MVELDialectRuleResources> 
-	
 </beans>       



More information about the seam-commits mailing list