[seam-commits] Seam SVN: r13736 - in modules/drools/trunk: api and 9 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Sun Sep 12 12:15:26 EDT 2010


Author: tsurdilovic
Date: 2010-09-12 12:15:25 -0400 (Sun, 12 Sep 2010)
New Revision: 13736

Added:
   modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Channel.java
   modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/SessionReport.java
   modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/SessionReportProducer.java
   modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/channel/
   modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/channel/ChannelBean.java
   modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/channel/ChannelTest.java
   modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/channel/Person.java
   modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/channel/
   modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/channel/ChannelTest-beans.xml
   modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/channel/channeltest.drl
Modified:
   modules/drools/trunk/api/pom.xml
   modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Query.java
   modules/drools/trunk/impl/pom.xml
   modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeSessionProducer.java
   modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/StatefulKnowledgeSessionWrapper.java
   modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/bootstrap/DroolsExtension.java
   modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/customoperator/CustomOperatorTest.java
   modules/drools/trunk/pom.xml
Log:
SEAMDROOLS-7 - Add support for Channel registration and integration 

Modified: modules/drools/trunk/api/pom.xml
===================================================================
--- modules/drools/trunk/api/pom.xml	2010-09-11 05:48:19 UTC (rev 13735)
+++ modules/drools/trunk/api/pom.xml	2010-09-12 16:15:25 UTC (rev 13736)
@@ -36,30 +36,37 @@
 		<dependency>
 			<groupId>org.drools</groupId>
 			<artifactId>drools-core</artifactId>
+			<version>${drools.version}</version>
 		</dependency>
 		<dependency>
 			<groupId>org.drools</groupId>
 			<artifactId>drools-compiler</artifactId>
+			<version>${drools.version}</version>
 		</dependency>
 		<dependency>
 			<groupId>org.drools</groupId>
 			<artifactId>drools-api</artifactId>
+			<version>${drools.version}</version>
 		</dependency>
 		<dependency>
 			<groupId>org.drools</groupId>
 			<artifactId>drools-templates</artifactId>
+			<version>${drools.version}</version>
 		</dependency>
 		<dependency>
 			<groupId>org.drools</groupId>
 			<artifactId>drools-decisiontables</artifactId>
+			<version>${drools.version}</version>
 		</dependency>
 		<dependency>
 			<groupId>org.drools</groupId>
 			<artifactId>drools-workitems</artifactId>
+			<version>${drools.version}</version>
 		</dependency>
 		<dependency>
 			<groupId>org.drools</groupId>
-			<artifactId>drools-transformer-xstream</artifactId>
+			<artifactId>drools-pipeline</artifactId>
+			<version>${drools.version}</version>
 		</dependency>
 		<dependency>
 			<groupId>org.jboss.weld</groupId>

Added: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Channel.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Channel.java	                        (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Channel.java	2010-09-12 16:15:25 UTC (rev 13736)
@@ -0,0 +1,50 @@
+/*
+ * 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.qualifiers;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+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.inject.Qualifier;
+
+/**
+ * 
+ * @author Tihomir Surdilovic
+ */
+ at Qualifier
+ at Target( { TYPE, METHOD, FIELD, PARAMETER })
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface Channel
+{
+   @Nonbinding String value() default "";
+}


Property changes on: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Channel.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Query.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Query.java	2010-09-11 05:48:19 UTC (rev 13735)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Query.java	2010-09-12 16:15:25 UTC (rev 13736)
@@ -18,7 +18,7 @@
  * 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.qualifiers;
 
 import static java.lang.annotation.ElementType.FIELD;
@@ -40,10 +40,12 @@
  * @author Tihomir Surdilovic
  */
 @Qualifier
- at Target( { TYPE, METHOD, FIELD, PARAMETER })
+ at Target({ TYPE, METHOD, FIELD, PARAMETER })
 @Documented
 @Retention(RUNTIME)
 @Inherited
-public @interface Query {
-	@Nonbinding String value() default "";
+public @interface Query
+{
+   @Nonbinding
+   String value() default "";
 }

Added: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/SessionReport.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/SessionReport.java	                        (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/SessionReport.java	2010-09-12 16:15:25 UTC (rev 13736)
@@ -0,0 +1,51 @@
+/*
+ * 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.qualifiers;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+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.inject.Qualifier;
+
+/**
+ * 
+ * @author Tihomir Surdilovic
+ */
+ at Qualifier
+ at Target({ TYPE, METHOD, FIELD, PARAMETER })
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface SessionReport
+{
+   @Nonbinding
+   String value() default "";
+}


Property changes on: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/SessionReport.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: modules/drools/trunk/impl/pom.xml
===================================================================
--- modules/drools/trunk/impl/pom.xml	2010-09-11 05:48:19 UTC (rev 13735)
+++ modules/drools/trunk/impl/pom.xml	2010-09-12 16:15:25 UTC (rev 13736)
@@ -40,26 +40,32 @@
 		<dependency>
 			<groupId>org.drools</groupId>
 			<artifactId>drools-core</artifactId>
+			<version>${drools.version}</version>
 		</dependency>
 		<dependency>
 			<groupId>org.drools</groupId>
 			<artifactId>drools-compiler</artifactId>
+			<version>${drools.version}</version>
 		</dependency>
 		<dependency>
 			<groupId>org.drools</groupId>
 			<artifactId>drools-api</artifactId>
+			<version>${drools.version}</version>
 		</dependency>
 		<dependency>
 			<groupId>org.drools</groupId>
 			<artifactId>drools-templates</artifactId>
+			<version>${drools.version}</version>
 		</dependency>
 		<dependency>
 			<groupId>org.drools</groupId>
 			<artifactId>drools-decisiontables</artifactId>
+			<version>${drools.version}</version>
 		</dependency>
 		<dependency>
 			<groupId>org.drools</groupId>
 			<artifactId>drools-workitems</artifactId>
+			<version>${drools.version}</version>
 		</dependency>
 		<dependency>
 			<groupId>org.jboss.weld</groupId>

Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeSessionProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeSessionProducer.java	2010-09-11 05:48:19 UTC (rev 13735)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeSessionProducer.java	2010-09-12 16:15:25 UTC (rev 13736)
@@ -28,7 +28,6 @@
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.context.SessionScoped;
 import javax.enterprise.inject.Disposes;
-import javax.enterprise.inject.New;
 import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.inject.Inject;
@@ -67,7 +66,7 @@
    
    @Inject 
    SeamDelegate delegate;
-
+   
    @Produces
    @RequestScoped
    public StatefulKnowledgeSession produceStatefulSession(KnowledgeBase kbase,DroolsConfig config) throws Exception
@@ -79,6 +78,7 @@
       addEventListeners(ksession);
       addWorkItemHandlers(ksession);
       addFactProviders(ksession);
+      addChannels(ksession);
       
       return ksession;
    }
@@ -95,6 +95,7 @@
       addEventListeners(ksession);
       addWorkItemHandlers(ksession);
       addFactProviders(ksession);
+      addChannels(ksession);
 
       return ksession;
    }
@@ -179,6 +180,15 @@
       }
    }
    
+   private void addChannels(StatefulKnowledgeSession ksession) {
+      Iterator<String> iter = droolsExtension.getChannels().keySet().iterator();
+      while(iter.hasNext())
+      {
+         String channelName = iter.next();
+         ksession.registerChannel(channelName, droolsExtension.getChannels().get(channelName));
+      }
+   }
+   
    private void addFactProviders(StatefulKnowledgeSession ksession) {
       Iterator<FactProvider> iter = droolsExtension.getFactProviderSet().iterator();
       while(iter.hasNext())

Added: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/SessionReportProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/SessionReportProducer.java	                        (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/SessionReportProducer.java	2010-09-12 16:15:25 UTC (rev 13736)
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+import javax.enterprise.context.SessionScoped;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 
+ * @author Tihomir Surdilovic
+ */
+ at SessionScoped
+public class SessionReportProducer
+{
+   private static final Logger log = LoggerFactory.getLogger(SessionReportProducer.class);
+   
+}


Property changes on: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/SessionReportProducer.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/StatefulKnowledgeSessionWrapper.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/StatefulKnowledgeSessionWrapper.java	2010-09-11 05:48:19 UTC (rev 13735)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/StatefulKnowledgeSessionWrapper.java	2010-09-12 16:15:25 UTC (rev 13736)
@@ -39,6 +39,8 @@
 import org.drools.marshalling.MarshallerFactory;
 import org.drools.marshalling.ObjectMarshallingStrategy;
 import org.drools.marshalling.ObjectMarshallingStrategyAcceptor;
+import org.drools.runtime.Calendars;
+import org.drools.runtime.Channel;
 import org.drools.runtime.Environment;
 import org.drools.runtime.ExecutionResults;
 import org.drools.runtime.ExitPoint;
@@ -50,7 +52,9 @@
 import org.drools.runtime.rule.Agenda;
 import org.drools.runtime.rule.AgendaFilter;
 import org.drools.runtime.rule.FactHandle;
+import org.drools.runtime.rule.LiveQuery;
 import org.drools.runtime.rule.QueryResults;
+import org.drools.runtime.rule.ViewChangedEventListener;
 import org.drools.runtime.rule.WorkingMemoryEntryPoint;
 import org.drools.time.SessionClock;
 
@@ -281,7 +285,7 @@
    @SuppressWarnings("unchecked")
    public ExecutionResults execute(Command command)
    {
-      return ksession.execute(command);
+      return (ExecutionResults) ksession.execute(command);
    }
 
    public void addEventListener(AgendaEventListener listener)
@@ -333,7 +337,50 @@
    {
       return ksession.getWorkingMemoryEntryPoint(name);
    }
+   
+   
 
+   public Calendars getCalendars()
+   {
+      return ksession.getCalendars();
+   }
+
+   public Map<String, Channel> getChannels()
+   {
+      return ksession.getChannels();
+   }
+
+   public void registerChannel(String arg0, Channel arg1)
+   {
+      ksession.registerChannel(arg0, arg1);
+      
+   }
+
+   public void unregisterChannel(String arg0)
+   {
+      ksession.unregisterChannel(arg0);
+   }
+
+   public void signalEvent(String arg0, Object arg1, long arg2)
+   {
+      ksession.signalEvent(arg0, arg1, arg2);
+   }
+
+   public LiveQuery openLiveQuery(String arg0, Object[] arg1, ViewChangedEventListener arg2)
+   {
+      return ksession.openLiveQuery(arg0, arg1, arg2);
+   }
+
+   public String getEntryPointId()
+   {
+      return ksession.getEntryPointId();
+   }
+
+   public long getFactCount()
+   {
+      return ksession.getFactCount();
+   }
+
    public Collection<? extends WorkingMemoryEntryPoint> getWorkingMemoryEntryPoints()
    {
       return ksession.getWorkingMemoryEntryPoints();

Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/bootstrap/DroolsExtension.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/bootstrap/DroolsExtension.java	2010-09-11 05:48:19 UTC (rev 13735)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/bootstrap/DroolsExtension.java	2010-09-12 16:15:25 UTC (rev 13736)
@@ -36,6 +36,7 @@
 import javax.enterprise.inject.spi.Extension;
 import javax.enterprise.util.AnnotationLiteral;
 
+import org.drools.runtime.Channel;
 import org.drools.base.evaluators.EvaluatorDefinition;
 import org.drools.event.knowledgebase.KnowledgeBaseEventListener;
 import org.drools.runtime.process.WorkItemHandler;
@@ -58,6 +59,7 @@
    private Map<String, TemplateDataProvider> templateDataProviders = new HashMap<String, TemplateDataProvider>();
    private Set<FactProvider> factProviderSet = new HashSet<FactProvider>();
    private Map<String, EvaluatorDefinition> evaluatorDefinitions = new HashMap<String, EvaluatorDefinition>();
+   private Map<String, Channel> channels = new HashMap<String, Channel>();
    
    @SuppressWarnings("serial")
    void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager bm) {
@@ -130,7 +132,28 @@
        }
       log.info("End creating [" + ( allEvaluatorDefinitions== null ? 0 : allEvaluatorDefinitions.size())+ "] evaluator definitions");      
       
+      // Channels
+      log.info("Start creating channel definitions");
+      Set<Bean<?>> allChannels = bm.getBeans(org.drools.runtime.Channel.class, new AnnotationLiteral<Any>(){});
+      if(allChannels != null) {
+          Iterator<Bean<?>> iter = allChannels.iterator();
+          while (iter.hasNext())
+          {
+             Bean<?> channel = iter.next();
+             org.jboss.seam.drools.qualifiers.Channel evaluatorAnnotation = channel.getBeanClass().getAnnotation(org.jboss.seam.drools.qualifiers.Channel.class);
+             String channelName = evaluatorAnnotation.value();
+             if(channelName.length() > 0) {
+                CreationalContext<?> context = bm.createCreationalContext(channel);
+                org.drools.runtime.Channel channelInstance = (org.drools.runtime.Channel) bm.getReference(channel, org.drools.runtime.Channel.class, context);
+                channels.put(channelName, channelInstance);
+             } else {
+                throw new IllegalStateException("Channel name cannot be empty in class: " + channel.getBeanClass().getName());
+             }
+          }
+       }
+      log.info("End creating [" + ( allChannels== null ? 0 : allChannels.size())+ "] channel definitions");      
       
+      
       //Template Data Providers
       log.info("Start creating template providers");
       Set<Bean<?>> allTemplateProviders = bm.getBeans(TemplateDataProvider.class, new AnnotationLiteral<Any>(){});
@@ -194,5 +217,15 @@
 
    public Map<String, EvaluatorDefinition> getEvaluatorDefinitions() {
 	   return evaluatorDefinitions;
+   }
+
+   public static Logger getLog()
+   {
+      return log;
+   }
+
+   public Map<String, Channel> getChannels()
+   {
+      return channels;
    }  
 }

Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/channel/ChannelBean.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/channel/ChannelBean.java	                        (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/channel/ChannelBean.java	2010-09-12 16:15:25 UTC (rev 13736)
@@ -0,0 +1,37 @@
+package org.jboss.seam.drools.test.channel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.seam.drools.qualifiers.Channel;
+
+ at Channel("testChannel")
+public class ChannelBean implements org.drools.runtime.Channel
+{
+   private int numOfSentObjects = 0;
+   private List<Person> eligiblesList = new ArrayList<Person>();
+   private List<Person> notEligiblesList = new ArrayList<Person>();
+   
+   public void send(Object personObject)
+   {
+      Person p = (Person) personObject;
+      if(p.isEligible()) {
+         eligiblesList.add(p);
+      } else {
+         notEligiblesList.add(p);
+      }
+      numOfSentObjects++;
+   }  
+   
+   public int getNumOfSentObjects() {
+      return numOfSentObjects;
+   }
+   
+   public List<Person> getEligiblesList() {
+      return eligiblesList;
+   }
+   
+   public List<Person> getNotEligiblesList() {
+      return notEligiblesList;
+   }
+}


Property changes on: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/channel/ChannelBean.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/channel/ChannelTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/channel/ChannelTest.java	                        (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/channel/ChannelTest.java	2010-09-12 16:15:25 UTC (rev 13736)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.test.channel;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import javax.enterprise.inject.Default;
+import javax.inject.Inject;
+
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.drools.KnowledgeBaseProducer;
+import org.jboss.seam.drools.qualifiers.config.DefaultConfig;
+import org.jboss.seam.drools.test.DroolsModuleFilter;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.weld.extensions.resourceLoader.ResourceProvider;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class ChannelTest
+{
+   @Deployment
+   public static JavaArchive createTestArchive()
+   {
+      String pkgPath = ChannelTest.class.getPackage().getName().replaceAll("\\.", "/");
+      JavaArchive archive = ShrinkWrap.create("test.jar", JavaArchive.class)
+      .addPackages(true, new DroolsModuleFilter("channel"), KnowledgeBaseProducer.class.getPackage())
+      .addPackages(true, ResourceProvider.class.getPackage())
+      .addClass(ChannelBean.class)
+      .addClass(Person.class)
+      .addResource(pkgPath + "/channeltest.drl", ArchivePaths.create("channeltest.drl"))
+      // .addResource(pkgPath + "/kbuilderconfig.properties",
+      // ArchivePaths.create("kbuilderconfig.properties"))
+      // .addResource(pkgPath + "/kbaseconfig.properties",
+      // ArchivePaths.create("kbaseconfig.properties"))
+      .addManifestResource(pkgPath + "/ChannelTest-beans.xml", ArchivePaths.create("beans.xml"));
+      // System.out.println(archive.toString(Formatters.VERBOSE));
+      return archive;
+   }
+   
+   @Inject
+   @Default
+   @DefaultConfig
+   StatefulKnowledgeSession ksession;
+   
+   @Inject ChannelBean channelBean;
+   
+   @Test
+   public void testChannel()
+   {
+      assertNotNull(ksession);
+      assertNotNull(channelBean);
+      
+      Person p1 = new Person();
+      p1.setAge(12);
+      
+      Person p2 = new Person();
+      p2.setAge(20);
+      
+      Person p3 = new Person();
+      p3.setAge(4);
+      
+      Person p4 = new Person();
+      p4.setAge(19);
+      
+      Person p5 = new Person();
+      p5.setAge(33);
+      
+      Person p6 = new Person();
+      p6.setAge(55);
+      
+      Person p7 = new Person();
+      p7.setAge(15);
+      
+      Person p8 = new Person();
+      p8.setAge(69);
+      
+      ksession.insert(p1);
+      ksession.insert(p2);
+      ksession.insert(p3);
+      ksession.insert(p4);
+      ksession.insert(p5);
+      ksession.insert(p6);
+      ksession.insert(p7);
+      ksession.insert(p8);
+      
+      ksession.fireAllRules();
+      
+      assertTrue(channelBean.getEligiblesList().size() == 5);
+      assertTrue(channelBean.getNotEligiblesList().size() == 3);
+      
+   }
+}


Property changes on: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/channel/ChannelTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/channel/Person.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/channel/Person.java	                        (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/channel/Person.java	2010-09-12 16:15:25 UTC (rev 13736)
@@ -0,0 +1,27 @@
+package org.jboss.seam.drools.test.channel;
+
+public class Person
+{
+   private int age;
+   private boolean eligible = false;
+   
+   public int getAge() {
+      return age;
+   }
+   
+   public void setAge(int age) {
+      this.age = age;
+   }
+
+   public boolean isEligible()
+   {
+      return eligible;
+   }
+
+   public void setEligible(boolean eligible)
+   {
+      this.eligible = eligible;
+   }
+   
+   
+}


Property changes on: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/channel/Person.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/customoperator/CustomOperatorTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/customoperator/CustomOperatorTest.java	2010-09-11 05:48:19 UTC (rev 13735)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/customoperator/CustomOperatorTest.java	2010-09-12 16:15:25 UTC (rev 13736)
@@ -47,12 +47,18 @@
    public static JavaArchive createTestArchive()
    {
       String pkgPath = CustomOperatorTest.class.getPackage().getName().replaceAll("\\.", "/");
-      JavaArchive archive = ShrinkWrap.create("test.jar", JavaArchive.class).addPackages(true, new DroolsModuleFilter("customoperator"), KnowledgeBaseProducer.class.getPackage()).addPackages(true, ResourceProvider.class.getPackage()).addClass(MessageBean.class).addClass(StrEvaluator.class).addClass(StrEvaluatorDefinition.class).addResource(pkgPath + "/customoperatortest.drl", ArchivePaths.create("customoperatortest.drl"))
+      JavaArchive archive = ShrinkWrap.create("test.jar", JavaArchive.class)
+      .addPackages(true, new DroolsModuleFilter("customoperator"), KnowledgeBaseProducer.class.getPackage())
+      .addPackages(true, ResourceProvider.class.getPackage())
+      .addClass(MessageBean.class)
+      .addClass(StrEvaluator.class)
+      .addClass(StrEvaluatorDefinition.class)
+      .addResource(pkgPath + "/customoperatortest.drl", ArchivePaths.create("customoperatortest.drl"))
       // .addResource(pkgPath + "/kbuilderconfig.properties",
       // ArchivePaths.create("kbuilderconfig.properties"))
       // .addResource(pkgPath + "/kbaseconfig.properties",
       // ArchivePaths.create("kbaseconfig.properties"))
-            .addManifestResource(pkgPath + "/CustomOperatorTest-beans.xml", ArchivePaths.create("beans.xml"));
+      .addManifestResource(pkgPath + "/CustomOperatorTest-beans.xml", ArchivePaths.create("beans.xml"));
       // System.out.println(archive.toString(Formatters.VERBOSE));
       return archive;
    }

Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/channel/ChannelTest-beans.xml
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/channel/ChannelTest-beans.xml	                        (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/channel/ChannelTest-beans.xml	2010-09-12 16:15:25 UTC (rev 13736)
@@ -0,0 +1,35 @@
+<!--
+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.
+--> 
+<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:s="urn:java:ee" 
+	xmlns:d="urn:java:org.jboss.seam.drools:org.jboss.seam.drools.config"
+	xmlns:test="urn:java:org.jboss.seam.drools.test.ksession">
+
+	<d:DefaultRuleResources>
+  		<s:modifies/>
+  		<s:Exact>org.jboss.seam.drools.config.DefaultRuleResources</s:Exact>
+   		<d:resources>
+   			<s:value>classpath;channeltest.drl;DRL</s:value>
+   		</d:resources>
+	</d:DefaultRuleResources>
+	
+</beans>       


Property changes on: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/channel/ChannelTest-beans.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/channel/channeltest.drl
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/channel/channeltest.drl	                        (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/channel/channeltest.drl	2010-09-12 16:15:25 UTC (rev 13736)
@@ -0,0 +1,19 @@
+package org.jboss.seam.drools.test.channel
+
+import org.jboss.seam.drools.test.channel.Person; 
+
+rule eligiblePerson
+	when
+		$p : Person( age <= 18 )
+	then
+		$p.setEligible(true);
+		channels["testChannel"].send( $p );
+end
+
+rule notElibiglePerson
+	when
+		$p : Person( age > 18 )
+	then
+		$p.setEligible(false);
+	    channels["testChannel"].send( $p );
+end
\ No newline at end of file

Modified: modules/drools/trunk/pom.xml
===================================================================
--- modules/drools/trunk/pom.xml	2010-09-11 05:48:19 UTC (rev 13735)
+++ modules/drools/trunk/pom.xml	2010-09-12 16:15:25 UTC (rev 13736)
@@ -7,7 +7,7 @@
 		<artifactId>seam-parent</artifactId>
 		<version>3</version>
 	</parent>
-
+	
 	<artifactId>seam-drools-parent</artifactId>
 	<groupId>org.jboss.seam.drools</groupId>
 	<version>3.0.0-SNAPSHOT</version>
@@ -47,6 +47,7 @@
 	</developers>
 
 	<properties>
+		<drools.version>5.1.1</drools.version>
 		<seam.version>3.0.0.b01</seam.version>
 		<weld-extensions.version>1.0.0-SNAPSHOT</weld-extensions.version>
 	</properties>



More information about the seam-commits mailing list