[seam-commits] Seam SVN: r12529 - in modules/drools/trunk: api/src/main/java/org/jboss/seam/drools/annotations and 19 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Tue Apr 20 12:21:36 EDT 2010
Author: tsurdilovic
Date: 2010-04-20 12:21:25 -0400 (Tue, 20 Apr 2010)
New Revision: 12529
Added:
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/FactProvider.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/annotations/EntryPoint.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/annotations/Query.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPPseudoClockConfig.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPRealitimeClockConfig.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/DefaultConfig.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/MVELDialectConfig.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExecutionResultsProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/CEPPseudoClockRuleResources.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/CEPRealtimeClockRuleResources.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DefaultRuleResources.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfig.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/MVELDialectRuleResources.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/RuleResources.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/CEPTest.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/CEPTestFilter.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/FireAlarm.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/FireDetected.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/SprinklerActivated.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/KAgentTest.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/KAgentTestFilter.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/Person.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryFactProvider.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryTest.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryTestFilter.java
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/cep/
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/cep/CEPTest-beans.xml
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/cep/ceptest.drl
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/KAgentTest-beans.xml
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagentconfig.properties
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagentestchangeset.xml
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagenttestone.drl
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagenttesttwo.drl
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/query/
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/query/QueryTest-beans.xml
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/query/querytest.drl
Removed:
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/EntryPoint.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Query.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExcecutionResultsProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfiguration.java
Modified:
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/TemplateDataProvider.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/EntryPointProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeAgentProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeLoggerProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeSessionProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/QueryResultsProducer.java
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/utils/ConfigUtils.java
modules/drools/trunk/impl/src/main/resources/META-INF/beans.xml
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/KBaseTest.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/kbase/KBaseTest-beans.xml
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/ksession/KSessionTest-beans.xml
Log:
added more tests and producers for executionresults (stateless session).
Added: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/FactProvider.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/FactProvider.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/FactProvider.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Interface for fact data providers.
+ *
+ * @author Tihomir Surdilovic
+ */
+public interface FactProvider {
+ public List<Object> getFacts();
+
+ public void setFacts(List<Object> facts);
+
+ public Map<String, Object> getGlobals();
+
+ public void setGlobals(Map<String, Object> globals);
+
+ public List<String> getQueries();
+
+ public void setQueries(List<String> queries);
+}
Modified: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/TemplateDataProvider.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/TemplateDataProvider.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/TemplateDataProvider.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -21,13 +21,6 @@
*/
package org.jboss.seam.drools;
-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 java.util.Collection;
import java.util.Map;
Copied: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/annotations/EntryPoint.java (from rev 12499, modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/EntryPoint.java)
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/annotations/EntryPoint.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/annotations/EntryPoint.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,45 @@
+/*
+ * 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.annotations;
+
+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;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+ at Target( { TYPE, METHOD, FIELD, PARAMETER })
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface EntryPoint {
+ String value() default "";
+}
Copied: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/annotations/Query.java (from rev 12499, 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/annotations/Query.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/annotations/Query.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,45 @@
+/*
+ * 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.annotations;
+
+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;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+ at Target( { TYPE, METHOD, FIELD, PARAMETER })
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface Query {
+ String value() default "";
+}
Deleted: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/EntryPoint.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/EntryPoint.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/EntryPoint.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -1,49 +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.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 EntryPoint {
- @Nonbinding String value() default "";
-}
Deleted: 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-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Query.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -1,49 +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.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 Query {
- @Nonbinding String value() default "";
-}
Added: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPPseudoClockConfig.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPPseudoClockConfig.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPPseudoClockConfig.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,48 @@
+/*
+ * 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.qualifiers.config;
+
+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.inject.Qualifier;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+ at Qualifier
+ at Target( { TYPE, METHOD, FIELD, PARAMETER })
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface CEPPseudoClockConfig {
+
+}
Added: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPRealitimeClockConfig.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPRealitimeClockConfig.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPRealitimeClockConfig.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,48 @@
+/*
+ * 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.qualifiers.config;
+
+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.inject.Qualifier;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+ at Qualifier
+ at Target( { TYPE, METHOD, FIELD, PARAMETER })
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface CEPRealitimeClockConfig {
+
+}
Added: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/DefaultConfig.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/DefaultConfig.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/DefaultConfig.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,48 @@
+/*
+ * 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.qualifiers.config;
+
+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.inject.Qualifier;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+ at Qualifier
+ at Target( { TYPE, METHOD, FIELD, PARAMETER })
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface DefaultConfig {
+
+}
Added: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/MVELDialectConfig.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/MVELDialectConfig.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/MVELDialectConfig.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,48 @@
+/*
+ * 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.qualifiers.config;
+
+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.inject.Qualifier;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+ at Qualifier
+ at Target( { TYPE, METHOD, FIELD, PARAMETER })
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface MVELDialectConfig {
+
+}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/EntryPointProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/EntryPointProducer.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/EntryPointProducer.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -21,12 +21,16 @@
*/
package org.jboss.seam.drools;
+import java.io.Serializable;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.rule.WorkingMemoryEntryPoint;
-import org.jboss.seam.drools.qualifiers.EntryPoint;
+import org.jboss.seam.drools.annotations.EntryPoint;
import org.jboss.seam.drools.qualifiers.Scanned;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,19 +39,20 @@
*
* @author Tihomir Surdilovic
*/
-public class EntryPointProducer
+ at SessionScoped
+public class EntryPointProducer implements Serializable
{
private static final Logger log = LoggerFactory.getLogger(EntryPointProducer.class);
@Produces
- @EntryPoint
public WorkingMemoryEntryPoint produceEntryPoint(StatefulKnowledgeSession ksession, InjectionPoint ip) throws Exception
{
String entryPointName = ip.getAnnotated().getAnnotation(EntryPoint.class).value();
if (entryPointName != null && entryPointName.length() > 0)
{
log.debug("EntryPoint Name requested: " + entryPointName);
- return ksession.getWorkingMemoryEntryPoint(entryPointName);
+ WorkingMemoryEntryPoint entryPoint = ksession.getWorkingMemoryEntryPoint( entryPointName );
+ return entryPoint;
}
else
{
@@ -56,7 +61,6 @@
}
@Produces
- @EntryPoint
@Scanned
public WorkingMemoryEntryPoint produceScannedEntryPoint(@Scanned StatefulKnowledgeSession ksession, InjectionPoint ip) throws Exception
{
@@ -64,7 +68,7 @@
if (entryPointName != null && entryPointName.length() > 0)
{
log.debug("EntryPoint Name requested: " + entryPointName);
- return ksession.getWorkingMemoryEntryPoint(ip.getAnnotated().getAnnotation(EntryPoint.class).value());
+ return ksession.getWorkingMemoryEntryPoint(entryPointName);
}
else
{
Deleted: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExcecutionResultsProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExcecutionResultsProducer.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExcecutionResultsProducer.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -1,27 +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;
-
-public class ExcecutionResultsProducer
-{
-
-}
Added: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExecutionResultsProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExecutionResultsProducer.java (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExecutionResultsProducer.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,108 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map.Entry;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+
+import org.drools.command.CommandFactory;
+import org.drools.runtime.ExecutionResults;
+import org.drools.runtime.StatelessKnowledgeSession;
+import org.jboss.seam.drools.bootstrap.DroolsExtension;
+import org.jboss.seam.drools.qualifiers.Scanned;
+import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+ at SessionScoped
+public class ExecutionResultsProducer implements Serializable
+{
+ private static final Logger log = LoggerFactory.getLogger(ExecutionResultsProducer.class);
+
+ @Inject
+ BeanManager manager;
+
+ @Inject
+ ResourceProvider resourceProvider;
+
+ @Inject
+ DroolsExtension droolsExtension;
+
+ @SuppressWarnings("unchecked")
+ @Produces
+ @RequestScoped
+ public ExecutionResults produceExecutionResults(StatelessKnowledgeSession ksession) {
+ return ksession.execute(CommandFactory.newBatchExecution(getCommandList()));
+ }
+
+ @SuppressWarnings("unchecked")
+ @Produces
+ @Scanned
+ @RequestScoped
+ public ExecutionResults produceScannedExecutionResults(@Scanned StatelessKnowledgeSession ksession) {
+ return ksession.execute(CommandFactory.newBatchExecution(getCommandList()));
+ }
+
+ @SuppressWarnings("unchecked")
+ private List getCommandList() {
+ List commandList = new ArrayList();
+ Iterator<FactProvider> iter = droolsExtension.getFactProviderSet().iterator();
+ while(iter.hasNext())
+ {
+ FactProvider factProvider = iter.next();
+ if(factProvider.getGlobals() != null) {
+ Iterator<Entry<String, Object>> globalIterator = factProvider.getGlobals().entrySet().iterator();
+ while(globalIterator.hasNext()) {
+ Entry<String, Object> nextEntry = globalIterator.next();
+ commandList.add(CommandFactory.newSetGlobal(nextEntry.getKey(), nextEntry.getValue()));
+ }
+ }
+
+ if(factProvider.getFacts() != null) {
+ for(Object nextFact : factProvider.getFacts()) {
+ commandList.add(CommandFactory.newInsert(nextFact));
+ }
+ }
+ if(factProvider.getQueries() != null) {
+ for(Object nextQuery : factProvider.getQueries()) {
+ commandList.add(CommandFactory.newQuery((String) nextQuery, (String) nextQuery));
+ }
+ }
+ }
+ return commandList;
+ }
+
+
+}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeAgentProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeAgentProducer.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeAgentProducer.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -18,138 +18,127 @@
* 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 java.util.Properties;
+import java.io.Serializable;
+import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseFactory;
import org.drools.agent.KnowledgeAgent;
-import org.drools.agent.KnowledgeAgentConfiguration;
import org.drools.agent.KnowledgeAgentFactory;
import org.drools.builder.ResourceType;
-import org.drools.io.ResourceChangeScannerConfiguration;
import org.drools.io.ResourceFactory;
-import org.jboss.seam.drools.config.DroolsConfiguration;
-import org.jboss.seam.drools.events.RuleResourceAddedEvent;
+import org.jboss.seam.drools.config.DroolsConfig;
+import org.jboss.seam.drools.config.RuleResources;
import org.jboss.seam.drools.qualifiers.Scanned;
-import org.jboss.seam.drools.utils.ConfigUtils;
import org.jboss.weld.extensions.resources.ResourceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
+ * KnowledgeAgent producer.
*
* @author Tihomir Surdilovic
*/
-public class KnowledgeAgentProducer
+ at ApplicationScoped
+public class KnowledgeAgentProducer implements Serializable
{
private static final Logger log = LoggerFactory.getLogger(KnowledgeAgentProducer.class);
@Inject
BeanManager manager;
+
@Inject
ResourceProvider resourceProvider;
@Produces
@Scanned
- public KnowledgeBase produceScannedKnowledgeBase(DroolsConfiguration kagentConfig) throws Exception
+ @ApplicationScoped
+ public KnowledgeBase produceScannedKnowledgeBase(DroolsConfig config) throws Exception
{
- ResourceFactory.getResourceChangeScannerService().configure(getResourceChangeScannerConfig(kagentConfig.getResourceChangeScannerConfigPath()));
- KnowledgeAgentConfiguration aconf = getKnowledgeAgentConfiguration(kagentConfig.getKnowledgeAgentConfigPath());
+ if (config.getAgentName() == null || config.getAgentName().length() < 1)
+ {
+ throw new IllegalStateException("KnowledgeAgent configuration does not specify the name of the KnowlegeAgent.");
+ }
- KnowledgeAgent kagent;
- kagent = KnowledgeAgentFactory.newKnowledgeAgent(kagentConfig.getKnowledgeAgentName(), aconf);
- applyChangeSet(kagent, kagentConfig.getChangeSetResource());
+ if(config.getRuleResources().getResources() == null || config.getRuleResources().getResources().length == 0)
+ {
+ throw new IllegalStateException("No change set rule resource specified.");
+ }
- if(kagentConfig.isStartChangeNotifierService()) {
+ if(config.getRuleResources().getResources().length > 0) {
+ throw new IllegalStateException("More than one change set rule resource specified for KnowledgeAgent. Make sure only a single change set resource is specified.");
+ }
+
+ ResourceFactory.getResourceChangeScannerService().configure(config.getResourceChangeScannerConfiguration());
+
+ KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(config.getKnowledgeBaseConfiguration());
+ KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent(config.getAgentName(), kbase, config.getKnowledgeAgentConfiguration());
+
+ applyChangeSet(kagent, config.getRuleResources().getResources()[0]);
+
+ if (config.isStartChangeNotifierService())
+ {
ResourceFactory.getResourceChangeNotifierService().start();
}
- if(kagentConfig.isStartChangeScannerService()) {
+ if (config.isStartChangeScannerService())
+ {
ResourceFactory.getResourceChangeScannerService().start();
}
-
+
return kagent.getKnowledgeBase();
-
+
}
-
- public void disposeScannedKnowledgeBase(@Disposes @Scanned KnowledgeBase kbase) {
+
+ public void disposeScannedKnowledgeBase(@Disposes @Scanned KnowledgeBase kbase)
+ {
+ // do we really want to stop ?
ResourceFactory.getResourceChangeNotifierService().stop();
ResourceFactory.getResourceChangeScannerService().stop();
}
-
- private void applyChangeSet(KnowledgeAgent kagent, String changeSetResource) {
- if (ConfigUtils.isValidResource(changeSetResource))
+
+ private void applyChangeSet(KnowledgeAgent kagent, String entry)
+ {
+ String[] entryParts = RuleResources.DIVIDER.split(entry.trim());
+
+ if (entryParts.length >= 3)
{
- ResourceType resourceType = ResourceType.getResourceType(ConfigUtils.getResourceType(changeSetResource));
- if(resourceType.equals(ResourceType.CHANGE_SET)) {
- if (ConfigUtils.getResourcePath(changeSetResource).equals(ConfigUtils.RESOURCE_TYPE_URL))
+ ResourceType resourceType = ResourceType.getResourceType(entryParts[RuleResources.RESOURCE_TYPE]);
+ if (resourceType.equals(ResourceType.CHANGE_SET))
+ {
+ if (entryParts[RuleResources.LOCATION_TYPE].equals(RuleResources.LOCATION_TYPE_URL))
{
- kagent.applyChangeSet(ResourceFactory.newUrlResource(ConfigUtils.getRuleResource(changeSetResource)));
- manager.fireEvent(new RuleResourceAddedEvent(ConfigUtils.getRuleResource(changeSetResource)));
+ kagent.applyChangeSet(ResourceFactory.newUrlResource(entryParts[RuleResources.RESOURCE_PATH]));
}
- else if (ConfigUtils.getResourcePath(changeSetResource).equals(ConfigUtils.RESOURCE_TYPE_FILE))
+ else if (entryParts[RuleResources.LOCATION_TYPE].equals(RuleResources.LOCATION_TYPE_FILE))
{
- kagent.applyChangeSet(ResourceFactory.newFileResource(ConfigUtils.getRuleResource(changeSetResource)));
- manager.fireEvent(new RuleResourceAddedEvent(ConfigUtils.getRuleResource(changeSetResource)));
+ kagent.applyChangeSet(ResourceFactory.newFileResource(entryParts[RuleResources.RESOURCE_PATH]));
}
- else if (ConfigUtils.getResourcePath(changeSetResource).equals(ConfigUtils.RESOURCE_TYPE_CLASSPATH))
+ else if (entryParts[RuleResources.LOCATION_TYPE].equals(RuleResources.LOCATION_TYPE_CLASSPATH))
{
- kagent.applyChangeSet(ResourceFactory.newClassPathResource(ConfigUtils.getRuleResource(changeSetResource)));
- manager.fireEvent(new RuleResourceAddedEvent(ConfigUtils.getRuleResource(changeSetResource)));
+ kagent.applyChangeSet(ResourceFactory.newClassPathResource(entryParts[RuleResources.RESOURCE_PATH]));
}
else
{
- log.error("Invalid resource: " + ConfigUtils.getResourcePath(changeSetResource));
+ log.error("Invalid resource: " + entry);
}
- } else {
+ }
+ else
+ {
log.error("Resource must be of type CHANGE_SET");
}
- } else {
- log.error("Invalid resource definition: " + changeSetResource);
}
-
-
- }
-
- private ResourceChangeScannerConfiguration getResourceChangeScannerConfig(String resourceChangeScannerConfigPath) throws Exception
- {
- ResourceChangeScannerConfiguration sconf = ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
-
- if (resourceChangeScannerConfigPath != null && resourceChangeScannerConfigPath.endsWith(".properties"))
- {
- Properties resourceChangeScannerConfProp = ConfigUtils.loadProperties(resourceProvider, resourceChangeScannerConfigPath);
- sconf = ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration(resourceChangeScannerConfProp);
- log.debug("ResourceChangeScannerConfiguration loaded: " + resourceChangeScannerConfigPath);
- }
else
{
- log.warn("Invalid config type: " + resourceChangeScannerConfigPath);
+ log.error("Invalid resource definition: " + entry);
}
-
- return sconf;
}
- private KnowledgeAgentConfiguration getKnowledgeAgentConfiguration(String knowledgeAgentConfigPath) throws Exception
- {
- KnowledgeAgentConfiguration aconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
-
- if (knowledgeAgentConfigPath != null && knowledgeAgentConfigPath.endsWith(".properties"))
- {
- Properties knowledgeAgentConfProp = ConfigUtils.loadProperties(resourceProvider, knowledgeAgentConfigPath);
- aconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration(knowledgeAgentConfProp);
- log.debug("KnowledgeAgentConfiguration loaded: " + knowledgeAgentConfigPath);
- }
- else
- {
- log.warn("Invalid config type: " + knowledgeAgentConfigPath);
- }
-
- return aconf;
- }
}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -23,19 +23,18 @@
import java.io.InputStream;
import java.io.Reader;
+import java.io.Serializable;
import java.io.StringReader;
import java.util.Iterator;
-import java.util.Properties;
+import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
import org.drools.KnowledgeBase;
-import org.drools.KnowledgeBaseConfiguration;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
-import org.drools.builder.KnowledgeBuilderConfiguration;
import org.drools.builder.KnowledgeBuilderError;
import org.drools.builder.KnowledgeBuilderErrors;
import org.drools.builder.KnowledgeBuilderFactory;
@@ -44,10 +43,10 @@
import org.drools.io.ResourceFactory;
import org.drools.template.ObjectDataCompiler;
import org.jboss.seam.drools.bootstrap.DroolsExtension;
-import org.jboss.seam.drools.config.DroolsConfiguration;
+import org.jboss.seam.drools.config.DroolsConfig;
+import org.jboss.seam.drools.config.RuleResources;
import org.jboss.seam.drools.events.KnowledgeBuilderErrorsEvent;
import org.jboss.seam.drools.events.RuleResourceAddedEvent;
-import org.jboss.seam.drools.utils.ConfigUtils;
import org.jboss.weld.extensions.resources.ResourceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,7 +55,8 @@
*
* @author Tihomir Surdilovic
*/
-public class KnowledgeBaseProducer
+ at ApplicationScoped
+public class KnowledgeBaseProducer implements Serializable
{
private static final Logger log = LoggerFactory.getLogger(KnowledgeBaseProducer.class);
@@ -70,14 +70,18 @@
DroolsExtension droolsExtension;
@Produces
- public KnowledgeBase produceKnowledgeBase(DroolsConfiguration kbaseConfig) throws Exception
+ @ApplicationScoped
+ public KnowledgeBase produceKnowledgeBase(DroolsConfig config) throws Exception
{
- KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(getKnowledgeBuilderConfiguration(kbaseConfig.getKnowledgeBuilderConfigPath()));
+ KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(config.getKnowledgeBuilderConfiguration());
- for (String nextResource : kbaseConfig.getRuleResources())
- {
- addResource(kbuilder, nextResource);
+ if(config.getRuleResources().getResources() == null || config.getRuleResources().getResources().length == 0) {
+ throw new IllegalStateException("No rule resources are specified.");
}
+
+ for(String resourceEntry : config.getRuleResources().getResources()) {
+ addResource(kbuilder, resourceEntry);
+ }
KnowledgeBuilderErrors kbuildererrors = kbuilder.getErrors();
if (kbuildererrors.size() > 0)
@@ -89,7 +93,7 @@
manager.fireEvent(new KnowledgeBuilderErrorsEvent(kbuildererrors));
}
- KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(getKnowledgeBaseConfiguration(kbaseConfig.getKnowledgeBaseConfigPath()));
+ KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(config.getKnowledgeBaseConfiguration());
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
addEventListeners(kbase);
@@ -108,50 +112,23 @@
}
}
- private KnowledgeBuilderConfiguration getKnowledgeBuilderConfiguration(String knowledgeBuilderConfigPath) throws Exception
+ private void addResource(KnowledgeBuilder kbuilder, String entry) throws Exception
{
- KnowledgeBuilderConfiguration droolsKbuilderConfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
- if (knowledgeBuilderConfigPath != null && knowledgeBuilderConfigPath.endsWith(".properties"))
+ String[] entryParts = RuleResources.DIVIDER.split(entry.trim());
+
+ if (entryParts.length >= 3)
{
+ ResourceType resourceType = ResourceType.getResourceType(entryParts[RuleResources.RESOURCE_TYPE]);
- Properties kbuilderProp = ConfigUtils.loadProperties(resourceProvider, knowledgeBuilderConfigPath);
- droolsKbuilderConfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(kbuilderProp, null);
- log.debug("KnowledgeBuilderConfiguration loaded: " + knowledgeBuilderConfigPath);
- }
- else
- {
- log.warn("Invalid config type: " + knowledgeBuilderConfigPath);
- }
- return droolsKbuilderConfig;
- }
-
- public KnowledgeBaseConfiguration getKnowledgeBaseConfiguration(String knowledgeBaseConfigPath) throws Exception
- {
- KnowledgeBaseConfiguration droolsKbaseConfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
- if (knowledgeBaseConfigPath != null && knowledgeBaseConfigPath.endsWith(".properties"))
- {
- Properties kbaseProp = ConfigUtils.loadProperties(resourceProvider, knowledgeBaseConfigPath);
- droolsKbaseConfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(kbaseProp, null);
- log.debug("KnowledgeBaseConfiguration loaded: " + knowledgeBaseConfigPath);
- }
- return droolsKbaseConfig;
- }
-
- private void addResource(KnowledgeBuilder kbuilder, String resource) throws Exception
- {
- if (ConfigUtils.isValidResource(resource))
- {
- ResourceType resourceType = ResourceType.getResourceType(ConfigUtils.getResourceType(resource));
-
- if (ConfigUtils.isRuleTemplate(resource))
+ if (entryParts.length == 4)
{
- TemplateDataProvider templateDataProvider = droolsExtension.getTemplateDataProviders().get(ConfigUtils.getTemplateData(resource));
+ TemplateDataProvider templateDataProvider = droolsExtension.getTemplateDataProviders().get(entryParts[RuleResources.TEMPLATE_DATAPROVIDER_NAME]);
if (templateDataProvider != null)
{
- InputStream templateStream = resourceProvider.loadResourceStream(ConfigUtils.getRuleResource(resource));
+ InputStream templateStream = resourceProvider.loadResourceStream(entryParts[RuleResources.RESOURCE_PATH]);
if (templateStream == null)
{
- throw new IllegalStateException("Could not load rule template: " + ConfigUtils.getRuleResource(resource));
+ throw new IllegalStateException("Could not load rule template: " + entryParts[RuleResources.RESOURCE_PATH]);
}
ObjectDataCompiler converter = new ObjectDataCompiler();
String drl = converter.compile(templateDataProvider.getTemplateData(), templateStream);
@@ -162,35 +139,35 @@
}
else
{
- throw new IllegalStateException("Requested template data provider: " + ConfigUtils.getTemplateData(resource) + " for resource " + resource + " has not been created. Check to make sure you have defined one.");
+ throw new IllegalStateException("Requested template data provider: " + entryParts[RuleResources.TEMPLATE_DATAPROVIDER_NAME] + " for resource " + entryParts[RuleResources.RESOURCE_PATH] + " has not been created. Check to make sure you have defined one.");
}
}
else
{
- if (ConfigUtils.getResourcePath(resource).equals(ConfigUtils.RESOURCE_TYPE_URL))
+ if (entryParts[RuleResources.LOCATION_TYPE].equals(RuleResources.LOCATION_TYPE_URL))
{
- kbuilder.add(ResourceFactory.newUrlResource(ConfigUtils.getRuleResource(resource)), resourceType);
- manager.fireEvent(new RuleResourceAddedEvent(ConfigUtils.getRuleResource(resource)));
+ kbuilder.add(ResourceFactory.newUrlResource(entryParts[RuleResources.RESOURCE_PATH]), resourceType);
+ manager.fireEvent(new RuleResourceAddedEvent(entryParts[RuleResources.RESOURCE_PATH]));
}
- else if (ConfigUtils.getResourcePath(resource).equals(ConfigUtils.RESOURCE_TYPE_FILE))
+ else if (entryParts[RuleResources.LOCATION_TYPE].equals(RuleResources.LOCATION_TYPE_FILE))
{
- kbuilder.add(ResourceFactory.newFileResource(ConfigUtils.getRuleResource(resource)), resourceType);
- manager.fireEvent(new RuleResourceAddedEvent(ConfigUtils.getRuleResource(resource)));
+ kbuilder.add(ResourceFactory.newFileResource(entryParts[RuleResources.RESOURCE_PATH]), resourceType);
+ manager.fireEvent(new RuleResourceAddedEvent(entryParts[RuleResources.RESOURCE_PATH]));
}
- else if (ConfigUtils.getResourcePath(resource).equals(ConfigUtils.RESOURCE_TYPE_CLASSPATH))
+ else if (entryParts[RuleResources.LOCATION_TYPE].equals(RuleResources.LOCATION_TYPE_CLASSPATH))
{
- kbuilder.add(ResourceFactory.newClassPathResource(ConfigUtils.getRuleResource(resource)), resourceType);
- manager.fireEvent(new RuleResourceAddedEvent(ConfigUtils.getRuleResource(resource)));
+ kbuilder.add(ResourceFactory.newClassPathResource(entryParts[RuleResources.RESOURCE_PATH]), resourceType);
+ manager.fireEvent(new RuleResourceAddedEvent(entryParts[RuleResources.RESOURCE_PATH]));
}
else
{
- log.error("Invalid resource: " + ConfigUtils.getResourcePath(resource));
+ log.error("Invalid resource: " + entryParts[RuleResources.RESOURCE_PATH]);
}
}
}
else
{
- log.error("Invalid resource definition: " + resource);
+ log.error("Invalid resource entry definition: " + entry);
}
}
}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeLoggerProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeLoggerProducer.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeLoggerProducer.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -18,9 +18,13 @@
* 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 java.io.Serializable;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
@@ -29,65 +33,85 @@
import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.StatelessKnowledgeSession;
-import org.jboss.seam.drools.config.DroolsConfiguration;
+import org.jboss.seam.drools.config.DroolsConfig;
import org.jboss.seam.drools.qualifiers.Scanned;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
+ * Producer for stateful and stateless KnowledgerRuntimeLogger.
*
* @author Tihomir Surdilovic
*/
-public class KnowledgeLoggerProducer
+ at SessionScoped
+public class KnowledgeLoggerProducer implements Serializable
{
private static final Logger log = LoggerFactory.getLogger(KnowledgeLoggerProducer.class);
@Produces
- public KnowledgeRuntimeLogger produceStatefulKnowledgeLogger(StatefulKnowledgeSession ksession, DroolsConfiguration loggerConfig)
+ @RequestScoped
+ public KnowledgeRuntimeLogger produceStatefulKnowledgeLogger(StatefulKnowledgeSession ksession, DroolsConfig config)
{
- return getLogger(ksession, loggerConfig);
+ return getLogger(ksession, config);
}
-
+
@Produces
@Scanned
- public KnowledgeRuntimeLogger produceScannedStatefulKnowledgeLogger(@Scanned StatefulKnowledgeSession ksession, DroolsConfiguration loggerConfig)
+ @RequestScoped
+ public KnowledgeRuntimeLogger produceScannedStatefulKnowledgeLogger(@Scanned StatefulKnowledgeSession ksession, DroolsConfig config)
{
- return getLogger(ksession, loggerConfig);
+ return getLogger(ksession, config);
}
@Produces
- public KnowledgeRuntimeLogger produceStatelessKnowledgeLogger(StatelessKnowledgeSession ksession, DroolsConfiguration loggerConfig)
+ @RequestScoped
+ public KnowledgeRuntimeLogger produceStatelessKnowledgeLogger(StatelessKnowledgeSession ksession, DroolsConfig config)
{
- return getLogger(ksession, loggerConfig);
+ return getLogger(ksession, config);
}
-
+
@Produces
@Scanned
- public KnowledgeRuntimeLogger produceStatelessKnowledgeLoggerForKAgent(@Scanned StatelessKnowledgeSession ksession, DroolsConfiguration loggerConfig)
+ @RequestScoped
+ public KnowledgeRuntimeLogger produceScannedStatelessKnowledgeLogger(@Scanned StatelessKnowledgeSession ksession, DroolsConfig config)
{
- return getLogger(ksession, loggerConfig);
+ return getLogger(ksession, config);
}
- private KnowledgeRuntimeLogger getLogger(KnowledgeRuntimeEventManager ksession, DroolsConfiguration loggerConfig)
+ private KnowledgeRuntimeLogger getLogger(KnowledgeRuntimeEventManager ksession, DroolsConfig config)
{
KnowledgeRuntimeLogger krLogger = null;
- if (loggerConfig.getLoggerType().equalsIgnoreCase("file"))
+ if (config.getLoggerType() != null && config.getLoggerType().equalsIgnoreCase("file"))
{
- String logName = loggerConfig.getLoggerPath() + System.currentTimeMillis();
- krLogger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, logName);
+ if (config.getLoggerPath() == null || config.getLoggerName() == null)
+ {
+ log.error("Invalid file logger information - path: " + config.getLoggerPath() + ", name: " + config.getLoggerName());
+ }
+ else
+ {
+ String logName = config.getLoggerPath() + config.getLoggerName() + System.currentTimeMillis();
+ krLogger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, logName);
+ }
}
- else if (loggerConfig.getLoggerType().equalsIgnoreCase("console"))
+ else if (config.getLoggerType() != null && config.getLoggerType().equalsIgnoreCase("console"))
{
krLogger = KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);
}
- else if (loggerConfig.getLoggerType().equalsIgnoreCase("threaded"))
+ else if (config.getLoggerType() != null && config.getLoggerType().equalsIgnoreCase("threaded"))
{
- String logName = loggerConfig.getLoggerPath() + System.currentTimeMillis();
- krLogger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, logName, loggerConfig.getLoggerInterval());
+ if (config.getLoggerPath() == null || config.getLoggerName() == null || config.getLoggerInterval() == -1)
+ {
+ log.error("Invalid threaded logger information - path: " + config.getLoggerPath() + ", name: " + config.getLoggerName() + ", interval: " + config.getLoggerInterval());
+ }
+ else
+ {
+ String logName = config.getLoggerPath() + config.getLoggerName() + System.currentTimeMillis();
+ krLogger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, logName, config.getLoggerInterval());
+ }
}
else
{
- log.error("Invalid logger specified: type: " + loggerConfig.getLoggerType() + " path: " + loggerConfig.getLoggerPath() + " interval: " + loggerConfig.getLoggerInterval());
+ log.error("Invalid logger specified: type: " + config.getLoggerType() + " path: " + config.getLoggerPath() + " interval: " + config.getLoggerInterval());
}
return krLogger;
}
@@ -96,8 +120,9 @@
{
logger.close();
}
-
- public void disposeScannedKnowledgeRuntimeLogger(@Disposes @Scanned KnowledgeRuntimeLogger logger) {
+
+ public void disposeScannedKnowledgeRuntimeLogger(@Disposes @Scanned KnowledgeRuntimeLogger logger)
+ {
logger.close();
}
}
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-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeSessionProducer.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -21,27 +21,27 @@
*/
package org.jboss.seam.drools;
+import java.io.Serializable;
import java.util.Iterator;
-import java.util.Properties;
+import java.util.Map.Entry;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
import org.drools.KnowledgeBase;
-import org.drools.KnowledgeBaseFactory;
import org.drools.event.KnowledgeRuntimeEventManager;
import org.drools.event.process.ProcessEventListener;
import org.drools.event.rule.AgendaEventListener;
import org.drools.event.rule.WorkingMemoryEventListener;
-import org.drools.runtime.KnowledgeSessionConfiguration;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.StatelessKnowledgeSession;
import org.jboss.seam.drools.bootstrap.DroolsExtension;
-import org.jboss.seam.drools.config.DroolsConfiguration;
+import org.jboss.seam.drools.config.DroolsConfig;
import org.jboss.seam.drools.qualifiers.Scanned;
-import org.jboss.seam.drools.utils.ConfigUtils;
import org.jboss.weld.extensions.resources.ResourceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -50,7 +50,8 @@
*
* @author Tihomir Surdilovic
*/
-public class KnowledgeSessionProducer
+ at SessionScoped
+public class KnowledgeSessionProducer implements Serializable
{
private static final Logger log = LoggerFactory.getLogger(KnowledgeSessionProducer.class);
@@ -64,42 +65,48 @@
DroolsExtension droolsExtension;
@Produces
- public StatefulKnowledgeSession produceStatefulSession(KnowledgeBase kbase,DroolsConfiguration ksessionConfig) throws Exception
+ @RequestScoped
+ public StatefulKnowledgeSession produceStatefulSession(KnowledgeBase kbase,DroolsConfig config) throws Exception
{
- StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(getConfig(ksessionConfig.getKnowledgeSessionConfigPath()), null);
+ StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(config.getKnowledgeSessionConfiguration(), null);
addEventListeners(ksession);
addWorkItemHandlers(ksession);
+ addFactProviders(ksession);
return ksession;
}
@Produces
@Scanned
- public StatefulKnowledgeSession produceScannedStatefulSession(@Scanned KnowledgeBase kbase, DroolsConfiguration ksessionConfig) throws Exception
+ @RequestScoped
+ public StatefulKnowledgeSession produceScannedStatefulSession(@Scanned KnowledgeBase kbase, DroolsConfig config) throws Exception
{
- StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(getConfig(ksessionConfig.getKnowledgeSessionConfigPath()), null);
+ StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(config.getKnowledgeSessionConfiguration(), null);
addEventListeners(ksession);
addWorkItemHandlers(ksession);
+ addFactProviders(ksession);
return ksession;
}
@Produces
@Scanned
- public StatelessKnowledgeSession produceScannedStatelessSession(@Scanned KnowledgeBase kbase, DroolsConfiguration ksessionConfig) throws Exception
+ @RequestScoped
+ public StatelessKnowledgeSession produceScannedStatelessSession(@Scanned KnowledgeBase kbase, DroolsConfig config) throws Exception
{
- StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(getConfig(ksessionConfig.getKnowledgeSessionConfigPath()));
+ StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(config.getKnowledgeSessionConfiguration());
addEventListeners(ksession);
-
+
return ksession;
}
@Produces
- public StatelessKnowledgeSession produceStatelessSession(KnowledgeBase kbase, DroolsConfiguration ksessionConfig) throws Exception
+ @RequestScoped
+ public StatelessKnowledgeSession produceStatelessSession(KnowledgeBase kbase, DroolsConfig config) throws Exception
{
- StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(getConfig(ksessionConfig.getKnowledgeSessionConfigPath()));
+ StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(config.getKnowledgeSessionConfiguration());
addEventListeners(ksession);
-
+
return ksession;
}
@@ -108,23 +115,10 @@
session.dispose();
}
+ public void disposeScannedStatefulSession(@Disposes @Scanned StatefulKnowledgeSession session) {
+ session.dispose();
+ }
- private KnowledgeSessionConfiguration getConfig(String knowledgeSessionConfigPath) throws Exception
- {
- KnowledgeSessionConfiguration droolsKsessionConfig = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
- if (knowledgeSessionConfigPath != null && knowledgeSessionConfigPath.endsWith(".properties"))
- {
- Properties ksessionProp = ConfigUtils.loadProperties(resourceProvider, knowledgeSessionConfigPath);
- droolsKsessionConfig = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(ksessionProp);
- log.debug("KnowledgeSessionConfiguration loaded: " + knowledgeSessionConfigPath);
- }
- else
- {
- log.warn("Invalid config type: " + knowledgeSessionConfigPath);
- }
- return droolsKsessionConfig;
- }
-
private void addEventListeners(KnowledgeRuntimeEventManager ksession)
{
Iterator<Object> iter = droolsExtension.getKsessionEventListenerSet().iterator();
@@ -160,4 +154,25 @@
ksession.getWorkItemManager().registerWorkItemHandler(name, droolsExtension.getWorkItemHandlers().get(name));
}
}
+
+ private void addFactProviders(StatefulKnowledgeSession ksession) {
+ Iterator<FactProvider> iter = droolsExtension.getFactProviderSet().iterator();
+ while(iter.hasNext())
+ {
+ FactProvider factProvider = iter.next();
+ if(factProvider.getGlobals() != null) {
+ Iterator<Entry<String, Object>> globalIterator = factProvider.getGlobals().entrySet().iterator();
+ while(globalIterator.hasNext()) {
+ Entry<String, Object> nextEntry = globalIterator.next();
+ ksession.setGlobal(nextEntry.getKey(), nextEntry.getValue());
+ }
+ }
+
+ if(factProvider.getFacts() != null) {
+ for(Object nextFact : factProvider.getFacts()) {
+ ksession.insert(nextFact);
+ }
+ }
+ }
+ }
}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/QueryResultsProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/QueryResultsProducer.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/QueryResultsProducer.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -21,12 +21,15 @@
*/
package org.jboss.seam.drools;
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.rule.QueryResults;
-import org.jboss.seam.drools.qualifiers.Query;
+import org.jboss.seam.drools.annotations.Query;
import org.jboss.seam.drools.qualifiers.Scanned;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,12 +38,12 @@
*
* @author Tihomir Surdilovic
*/
-public class QueryResultsProducer
+ at SessionScoped
+public class QueryResultsProducer implements Serializable
{
private static final Logger log = LoggerFactory.getLogger(QueryResultsProducer.class);
@Produces
- @Query
public QueryResults produceQueryResults(StatefulKnowledgeSession ksession, InjectionPoint ip)
{
String queryName = ip.getAnnotated().getAnnotation(Query.class).value();
@@ -56,7 +59,6 @@
}
@Produces
- @Query
@Scanned
public QueryResults produceScannedQueryResults(@Scanned StatefulKnowledgeSession ksession, InjectionPoint ip) {
String queryName = ip.getAnnotated().getAnnotation(Query.class).value();
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-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/bootstrap/DroolsExtension.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -38,6 +38,7 @@
import org.drools.event.knowledgebase.KnowledgeBaseEventListener;
import org.drools.runtime.process.WorkItemHandler;
+import org.jboss.seam.drools.FactProvider;
import org.jboss.seam.drools.TemplateDataProvider;
import org.jboss.seam.drools.qualifiers.KBaseEventListener;
import org.jboss.seam.drools.qualifiers.KSessionEventListener;
@@ -53,6 +54,7 @@
private Set<Object> ksessionEventListenerSet = new HashSet<Object>();
private Map<String, WorkItemHandler> workItemHandlers = new HashMap<String, WorkItemHandler>();
private Map<String, TemplateDataProvider> templateDataProviders = new HashMap<String, TemplateDataProvider>();
+ private Set<FactProvider> factProviderSet = new HashSet<FactProvider>();
@SuppressWarnings("serial")
void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager bm) {
@@ -125,12 +127,30 @@
}
log.info("End creating [" + (allTemplateProviders == null ? 0 : allTemplateProviders.size())+ "] template data providers");
+ //Fact Providers
+ log.info("Start creating fact providers");
+ Set<Bean<?>> allFactProviders = bm.getBeans(FactProvider.class, new AnnotationLiteral<Any>() {});
+ if(allFactProviders != null) {
+ Iterator<Bean<?>> factProviderIterator = allFactProviders.iterator();
+ while (factProviderIterator.hasNext()) {
+ Bean<?> factProvider = factProviderIterator.next();
+ CreationalContext<?> context = bm.createCreationalContext(factProvider);
+ factProviderSet.add((FactProvider) bm.getReference(factProvider, FactProvider.class, context));
+ }
+ }
+ log.info("End creating [" + (allFactProviders == null ? 0 : allFactProviders.size())+ "] fact providers");
+
}
public Set<KnowledgeBaseEventListener> getKbaseEventListenerSet()
{
return kbaseEventListenerSet;
}
+
+ public Set<FactProvider> getFactProviderSet()
+ {
+ return factProviderSet;
+ }
public Map<String, WorkItemHandler> getWorkItemHandlers()
{
Added: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/CEPPseudoClockRuleResources.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/CEPPseudoClockRuleResources.java (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/CEPPseudoClockRuleResources.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,34 @@
+/*
+ * 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.config;
+
+import org.jboss.seam.drools.qualifiers.config.CEPPseudoClockConfig;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+ at CEPPseudoClockConfig
+public class CEPPseudoClockRuleResources extends RuleResources
+{
+
+}
Added: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/CEPRealtimeClockRuleResources.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/CEPRealtimeClockRuleResources.java (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/CEPRealtimeClockRuleResources.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,34 @@
+/*
+ * 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.config;
+
+import org.jboss.seam.drools.qualifiers.config.CEPRealitimeClockConfig;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+ at CEPRealitimeClockConfig
+public class CEPRealtimeClockRuleResources extends RuleResources
+{
+
+}
Added: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DefaultRuleResources.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DefaultRuleResources.java (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DefaultRuleResources.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,34 @@
+/*
+ * 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.config;
+
+import org.jboss.seam.drools.qualifiers.config.DefaultConfig;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+ at DefaultConfig
+public class DefaultRuleResources extends RuleResources
+{
+
+}
Copied: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfig.java (from rev 12499, modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfiguration.java)
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfig.java (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfig.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,311 @@
+/*
+ * 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.config;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Map.Entry;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+
+import org.drools.KnowledgeBaseConfiguration;
+import org.drools.KnowledgeBaseFactory;
+import org.drools.agent.KnowledgeAgentConfiguration;
+import org.drools.agent.KnowledgeAgentFactory;
+import org.drools.builder.KnowledgeBuilderConfiguration;
+import org.drools.builder.KnowledgeBuilderFactory;
+import org.drools.io.ResourceChangeScannerConfiguration;
+import org.drools.io.ResourceFactory;
+import org.drools.runtime.KnowledgeSessionConfiguration;
+import org.jboss.seam.drools.utils.ConfigUtils;
+import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Drools configuration file.
+ *
+ * @author Tihomir Surdilovic
+ */
+public class DroolsConfig implements Serializable
+{
+ private static final Logger log = LoggerFactory.getLogger(DroolsConfig.class);
+
+ @Inject
+ ResourceProvider resourceProvider;
+
+ private String knowledgeBuilderConfigProperties;
+ private String knowledgeBaseConfigProperties;
+ private String knowledgeSessionProperties;
+ private String knowledgeAgentProperties;
+
+ private boolean startChangeNotifierService;
+ private boolean startChangeScannerService;
+ private int scannerInterval = -1;
+ private String agentName;
+
+ private String loggerName;
+ private String loggerType;
+ private String loggerPath;
+ private int loggerInterval;
+
+ private RuleResources ruleResources;
+
+ private Map<String, String> kbuilderPropertiesMap = new HashMap<String, String>();
+ private Map<String, String> kbasePropertiesMap = new HashMap<String, String>();
+ private Map<String, String> ksessionPropertiesMap = new HashMap<String, String>();
+ private Map<String, String> kagentPropertiestMap = new HashMap<String, String>();
+
+ public DroolsConfig()
+ {
+ }
+
+ public DroolsConfig(RuleResources ruleResources)
+ {
+ this.ruleResources = ruleResources;
+ }
+
+ @PostConstruct
+ public void setup()
+ {
+ readProperties(kbuilderPropertiesMap, knowledgeBuilderConfigProperties);
+ readProperties(kbasePropertiesMap, knowledgeBaseConfigProperties);
+ readProperties(ksessionPropertiesMap, knowledgeSessionProperties);
+ readProperties(kagentPropertiestMap, knowledgeAgentProperties);
+
+ }
+
+ public ResourceChangeScannerConfiguration getResourceChangeScannerConfiguration()
+ {
+ ResourceChangeScannerConfiguration sconf = ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
+ if (scannerInterval >= 0)
+ {
+ sconf.setProperty("drools.resource.scanner.interval", String.valueOf(scannerInterval));
+ }
+ return sconf;
+ }
+
+ public KnowledgeAgentConfiguration getKnowledgeAgentConfiguration()
+ {
+ KnowledgeAgentConfiguration config = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
+ Iterator<Entry<String, String>> it = kagentPropertiestMap.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry<String, String> nextExtry = it.next();
+ config.setProperty(nextExtry.getKey(), nextExtry.getValue());
+ }
+ return config;
+ }
+
+ public KnowledgeSessionConfiguration getKnowledgeSessionConfiguration()
+ {
+ KnowledgeSessionConfiguration config = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
+ Iterator<Entry<String, String>> it = ksessionPropertiesMap.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry<String, String> nextExtry = it.next();
+ config.setProperty(nextExtry.getKey(), nextExtry.getValue());
+ }
+ return config;
+ }
+
+ public KnowledgeBaseConfiguration getKnowledgeBaseConfiguration()
+ {
+ KnowledgeBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
+ Iterator<Entry<String, String>> it = kbasePropertiesMap.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry<String, String> nextExtry = it.next();
+ config.setProperty(nextExtry.getKey(), nextExtry.getValue());
+ }
+ return config;
+ }
+
+ public KnowledgeBuilderConfiguration getKnowledgeBuilderConfiguration()
+ {
+ KnowledgeBuilderConfiguration config = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
+ Iterator<Entry<String, String>> it = kbuilderPropertiesMap.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry<String, String> nextExtry = it.next();
+ config.setProperty(nextExtry.getKey(), nextExtry.getValue());
+ }
+ return config;
+ }
+
+ private void readProperties(Map<String, String> propertiesMap, String propertiesPath)
+ {
+ if (propertiesPath != null)
+ {
+ try
+ {
+ Properties kbuilderProp = ConfigUtils.loadProperties(resourceProvider, propertiesPath);
+ for (Object key : kbuilderProp.keySet())
+ {
+ propertiesMap.put((String) key, (String) kbuilderProp.get(key));
+ }
+ }
+ catch (IOException e)
+ {
+ log.error("Unable to read configuration properties file: " + propertiesPath);
+ }
+ } else {
+ log.debug("NULL properties path specified, bypassing reading properties");
+ }
+ }
+
+ public String getKnowledgeBuilderConfigProperties()
+ {
+ return knowledgeBuilderConfigProperties;
+ }
+
+ public void setKnowledgeBuilderConfigProperties(String knowledgeBuilderConfigProperties)
+ {
+ this.knowledgeBuilderConfigProperties = knowledgeBuilderConfigProperties;
+ }
+
+ public String getKnowledgeBaseConfigProperties()
+ {
+ return knowledgeBaseConfigProperties;
+ }
+
+ public void setKnowledgeBaseConfigProperties(String knowledgeBaseConfigProperties)
+ {
+ this.knowledgeBaseConfigProperties = knowledgeBaseConfigProperties;
+ }
+
+ public String getKnowledgeSessionProperties()
+ {
+ return knowledgeSessionProperties;
+ }
+
+ public void setKnowledgeSessionProperties(String knowledgeSessionProperties)
+ {
+ this.knowledgeSessionProperties = knowledgeSessionProperties;
+ }
+
+ public String getKnowledgeAgentProperties()
+ {
+ return knowledgeAgentProperties;
+ }
+
+ public void setKnowledgeAgentProperties(String knowledgeAgentProperties)
+ {
+ this.knowledgeAgentProperties = knowledgeAgentProperties;
+ }
+
+ public boolean isStartChangeNotifierService()
+ {
+ return startChangeNotifierService;
+ }
+
+ public void setStartChangeNotifierService(boolean startChangeNotifierService)
+ {
+ this.startChangeNotifierService = startChangeNotifierService;
+ }
+
+ public boolean isStartChangeScannerService()
+ {
+ return startChangeScannerService;
+ }
+
+ public void setStartChangeScannerService(boolean startChangeScannerService)
+ {
+ this.startChangeScannerService = startChangeScannerService;
+ }
+
+ public int getScannerInterval()
+ {
+ return scannerInterval;
+ }
+
+ public void setScannerInterval(int scannerInterval)
+ {
+ this.scannerInterval = scannerInterval;
+ }
+
+ public String getAgentName()
+ {
+ return agentName;
+ }
+
+ public void setAgentName(String agentName)
+ {
+ this.agentName = agentName;
+ }
+
+ public String getLoggerName()
+ {
+ return loggerName;
+ }
+
+ public void setLoggerName(String loggerName)
+ {
+ this.loggerName = loggerName;
+ }
+
+ public String getLoggerType()
+ {
+ return loggerType;
+ }
+
+ public void setLoggerType(String loggerType)
+ {
+ this.loggerType = loggerType;
+ }
+
+ public String getLoggerPath()
+ {
+ return loggerPath;
+ }
+
+ public void setLoggerPath(String loggerPath)
+ {
+ this.loggerPath = loggerPath;
+ }
+
+ public int getLoggerInterval()
+ {
+ return loggerInterval;
+ }
+
+ public void setLoggerInterval(int loggerInterval)
+ {
+ this.loggerInterval = loggerInterval;
+ }
+
+ public RuleResources getRuleResources()
+ {
+ return ruleResources;
+ }
+
+ public void setRuleResources(RuleResources ruleResources)
+ {
+ this.ruleResources = ruleResources;
+ }
+
+}
Deleted: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfiguration.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfiguration.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfiguration.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -1,162 +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.config;
-
-import org.jboss.seam.drools.qualifiers.config.DroolsConfig;
-
- at DroolsConfig
-public class DroolsConfiguration
-{
- //KnowledgeBase configuration
- private String knowledgeBuilderConfigPath;
- private String knowledgeBaseConfigPath;
- private String[] ruleResources;
- //KnowledgeSession configuration
- private String knowledgeSessionConfigPath;
- //KnowledgeAgent configuration
- private String resourceChangeScannerConfigPath;
- private String knowledgeAgentConfigPath;
- private String changeSetResource;
- private String knowledgeAgentName;
- private boolean startChangeNotifierService;
- private boolean startChangeScannerService;
- //KnowledgeLogger configuration
- private String loggerName;
- private String loggerType;
- private String loggerPath;
- private int loggerInterval;
-
- public String getKnowledgeBuilderConfigPath()
- {
- return knowledgeBuilderConfigPath;
- }
- public void setKnowledgeBuilderConfigPath(String knowledgeBuilderConfigPath)
- {
- this.knowledgeBuilderConfigPath = knowledgeBuilderConfigPath;
- }
- public String getKnowledgeBaseConfigPath()
- {
- return knowledgeBaseConfigPath;
- }
- public void setKnowledgeBaseConfigPath(String knowledgeBaseConfigPath)
- {
- this.knowledgeBaseConfigPath = knowledgeBaseConfigPath;
- }
- public String[] getRuleResources()
- {
- return ruleResources;
- }
- public void setRuleResources(String[] ruleResources)
- {
- this.ruleResources = ruleResources;
- }
- public String getKnowledgeSessionConfigPath()
- {
- return knowledgeSessionConfigPath;
- }
- public void setKnowledgeSessionConfigPath(String knowledgeSessionConfigPath)
- {
- this.knowledgeSessionConfigPath = knowledgeSessionConfigPath;
- }
- public String getResourceChangeScannerConfigPath()
- {
- return resourceChangeScannerConfigPath;
- }
- public void setResourceChangeScannerConfigPath(String resourceChangeScannerConfigPath)
- {
- this.resourceChangeScannerConfigPath = resourceChangeScannerConfigPath;
- }
- public String getKnowledgeAgentConfigPath()
- {
- return knowledgeAgentConfigPath;
- }
- public void setKnowledgeAgentConfigPath(String knowledgeAgentConfigPath)
- {
- this.knowledgeAgentConfigPath = knowledgeAgentConfigPath;
- }
- public String getChangeSetResource()
- {
- return changeSetResource;
- }
- public void setChangeSetResource(String changeSetResource)
- {
- this.changeSetResource = changeSetResource;
- }
- public String getKnowledgeAgentName()
- {
- return knowledgeAgentName;
- }
- public void setKnowledgeAgentName(String knowledgeAgentName)
- {
- this.knowledgeAgentName = knowledgeAgentName;
- }
- public boolean isStartChangeNotifierService()
- {
- return startChangeNotifierService;
- }
- public void setStartChangeNotifierService(boolean startChangeNotifierService)
- {
- this.startChangeNotifierService = startChangeNotifierService;
- }
- public boolean isStartChangeScannerService()
- {
- return startChangeScannerService;
- }
- public void setStartChangeScannerService(boolean startChangeScannerService)
- {
- this.startChangeScannerService = startChangeScannerService;
- }
- public String getLoggerName()
- {
- return loggerName;
- }
- public void setLoggerName(String loggerName)
- {
- this.loggerName = loggerName;
- }
- public String getLoggerType()
- {
- return loggerType;
- }
- public void setLoggerType(String loggerType)
- {
- this.loggerType = loggerType;
- }
- public String getLoggerPath()
- {
- return loggerPath;
- }
- public void setLoggerPath(String loggerPath)
- {
- this.loggerPath = loggerPath;
- }
- public int getLoggerInterval()
- {
- return loggerInterval;
- }
- public void setLoggerInterval(int loggerInterval)
- {
- this.loggerInterval = loggerInterval;
- }
-
-
-}
Added: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/MVELDialectRuleResources.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/MVELDialectRuleResources.java (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/MVELDialectRuleResources.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,34 @@
+/*
+ * 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.config;
+
+import org.jboss.seam.drools.qualifiers.config.MVELDialectConfig;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+ at MVELDialectConfig
+public class MVELDialectRuleResources extends RuleResources
+{
+
+}
Added: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/RuleResources.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/RuleResources.java (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/RuleResources.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,57 @@
+/*
+ * 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.config;
+
+import java.util.regex.Pattern;
+
+import org.drools.io.Resource;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+public class RuleResources
+{
+ public static final Pattern DIVIDER = Pattern.compile(";");
+ public static final int LOCATION_TYPE = 0;
+ public static final int RESOURCE_PATH = 1;
+ public static final int RESOURCE_TYPE = 2;
+ public static final int TEMPLATE_DATAPROVIDER_NAME = 3;
+
+ public static final String LOCATION_TYPE_URL = "url";
+ public static final String LOCATION_TYPE_FILE = "file";
+ public static final String LOCATION_TYPE_CLASSPATH = "classpath";
+
+
+ private String[] resources;
+
+ public String[] getResources()
+ {
+ return resources;
+ }
+
+ public void setResources(String[] resources)
+ {
+ this.resources = resources;
+ }
+
+}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/utils/ConfigUtils.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/utils/ConfigUtils.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/utils/ConfigUtils.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -21,6 +21,7 @@
*/
package org.jboss.seam.drools.utils;
+import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.regex.Pattern;
@@ -33,67 +34,8 @@
*/
public class ConfigUtils
{
- private static final Pattern DIVIDER = Pattern.compile(";");
-
- private static final int RESOURCE_PATH = 0;
- private static final int RESOURCE = 1;
- private static final int RESOURCE_TYPE = 2;
- private static final int RESOURCE_TEMPLATE_DATA = 3;
-
- public static final String RESOURCE_TYPE_URL = "url";
- public static final String RESOURCE_TYPE_FILE = "file";
- public static final String RESOURCE_TYPE_CLASSPATH = "classpath";
-
- public static boolean isValidResource(String resource)
+ public static Properties loadProperties(ResourceProvider resourceProvider, String path) throws IOException
{
- return DIVIDER.split(resource.trim()).length >= 3;
- }
-
- public static boolean isRuleTemplate(String resource)
- {
- return DIVIDER.split(resource.trim()).length == 4;
- }
-
- public static String getResourceType(String resource)
- {
- return DIVIDER.split(resource.trim())[RESOURCE_TYPE];
- }
-
- public static String getRuleResource(String resource)
- {
- return DIVIDER.split(resource.trim())[RESOURCE];
- }
-
- public static String getTemplateData(String resource)
- {
- return DIVIDER.split(resource.trim())[RESOURCE_TEMPLATE_DATA];
- }
-
- public static String getResourcePath(String resource)
- {
- return DIVIDER.split(resource.trim())[RESOURCE_PATH];
- }
-
- private static final int WORKITEMHANDLER_NAME = 0;
- private static final int WORKITEMHANDLER_TYPE = 1;
-
- public static String getWorkItemHandlerName(String workItemHandlerStr)
- {
- return DIVIDER.split(workItemHandlerStr.trim())[WORKITEMHANDLER_NAME];
- }
-
- public static String getWorkItemHandlerType(String workItemHandlerStr)
- {
- return DIVIDER.split(workItemHandlerStr.trim())[WORKITEMHANDLER_TYPE];
- }
-
- public static boolean isValidWorkItemHandler(String workItemHandlerStr)
- {
- return DIVIDER.split(workItemHandlerStr.trim()).length == 2;
- }
-
- public static Properties loadProperties(ResourceProvider resourceProvider, String path) throws Exception
- {
Properties prop = new Properties();
InputStream in = resourceProvider.loadResourceStream(path);
if (in == null)
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-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/resources/META-INF/beans.xml 2010-04-20 16:21:25 UTC (rev 12529)
@@ -1,43 +1,39 @@
-<!--
-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.
--->
+ <!--
+ 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:seam:core"
- xmlns:d="urn:java:org.jboss.seam.drools:org.jboss.seam.drools.config"
+ xmlns:s="urn:java:seam:core"
+ xmlns:d="urn:java:org.jboss.seam.drools:org.jboss.seam.drools.config:org.jboss.seam.drools.qualifiers.config"
xmlns:drools="urn:java:org.drools:org.drools.runtime">
- <s:genericBean class="org.jboss.seam.drools.config.DroolsConfiguration">
+ <s:genericBean class="org.jboss.seam.drools.config.DroolsConfig">
<d:KnowledgeBaseProducer>
<s:specializes />
<d:produceKnowledgeBase>
<s:ApplyQualifiers />
<s:parameters>
- <d:DroolsConfiguration>
+ <d:DroolsConfig>
<s:Inject />
<s:ApplyQualifiers />
- </d:DroolsConfiguration>
+ </d:DroolsConfig>
</s:parameters>
</d:produceKnowledgeBase>
</d:KnowledgeBaseProducer>
-
+
<d:KnowledgeSessionProducer>
<s:specializes />
<d:produceStatefulSession>
@@ -47,10 +43,10 @@
<s:Inject />
<s:ApplyQualifiers />
</drools:KnowledgeBase>
- <d:DroolsConfiguration>
+ <d:DroolsConfig>
<s:Inject />
<s:ApplyQualifiers />
- </d:DroolsConfiguration>
+ </d:DroolsConfig>
</s:parameters>
</d:produceStatefulSession>
<d:disposeStatefulSession>
@@ -68,13 +64,13 @@
<s:Inject />
<s:ApplyQualifiers />
</drools:KnowledgeBase>
- <d:DroolsConfiguration>
+ <d:DroolsConfig>
<s:Inject />
<s:ApplyQualifiers />
- </d:DroolsConfiguration>
+ </d:DroolsConfig>
</s:parameters>
</d:produceScannedStatefulSession>
- <!--<d:disposeScannedStatefulSession>
+ <d:disposeScannedStatefulSession>
<s:parameters>
<drools:StatefulKnowledgeSession>
<s:Inject />
@@ -82,17 +78,17 @@
</drools:StatefulKnowledgeSession>
</s:parameters>
</d:disposeScannedStatefulSession>
- --><d:produceStatelessSession>
+ <d:produceStatelessSession>
<s:ApplyQualifiers />
<s:parameters>
<drools:KnowledgeBase>
<s:Inject />
<s:ApplyQualifiers />
</drools:KnowledgeBase>
- <d:DroolsConfiguration>
+ <d:DroolsConfig>
<s:Inject />
<s:ApplyQualifiers />
- </d:DroolsConfiguration>
+ </d:DroolsConfig>
</s:parameters>
</d:produceStatelessSession>
<d:produceScannedStatelessSession>
@@ -102,10 +98,10 @@
<s:Inject />
<s:ApplyQualifiers />
</drools:KnowledgeBase>
- <d:DroolsConfiguration>
+ <d:DroolsConfig>
<s:Inject />
<s:ApplyQualifiers />
- </d:DroolsConfiguration>
+ </d:DroolsConfig>
</s:parameters>
</d:produceScannedStatelessSession>
</d:KnowledgeSessionProducer>
@@ -115,10 +111,10 @@
<d:produceScannedKnowledgeBase>
<s:ApplyQualifiers />
<s:parameters>
- <d:DroolsConfiguration>
+ <d:DroolsConfig>
<s:Inject />
<s:ApplyQualifiers />
- </d:DroolsConfiguration>
+ </d:DroolsConfig>
</s:parameters>
</d:produceScannedKnowledgeBase>
<d:disposeScannedKnowledgeBase>
@@ -130,7 +126,7 @@
</s:parameters>
</d:disposeScannedKnowledgeBase>
</d:KnowledgeAgentProducer>
-
+
<d:EntryPointProducer>
<s:specializes />
<d:produceEntryPoint>
@@ -162,10 +158,10 @@
<s:Inject />
<s:ApplyQualifiers />
</drools:StatefulKnowledgeSession>
- <d:DroolsConfiguration>
+ <d:DroolsConfig>
<s:Inject />
<s:ApplyQualifiers />
- </d:DroolsConfiguration>
+ </d:DroolsConfig>
</s:parameters>
</d:produceStatefulKnowledgeLogger>
<d:produceScannedStatefulKnowledgeLogger>
@@ -175,14 +171,62 @@
<s:Inject />
<s:ApplyQualifiers />
</drools:StatefulKnowledgeSession>
- <d:DroolsConfiguration>
+ <d:DroolsConfig>
<s:Inject />
<s:ApplyQualifiers />
- </d:DroolsConfiguration>
+ </d:DroolsConfig>
</s:parameters>
- </d:produceScannedStatefulKnowledgeLogger>
+ </d:produceScannedStatefulKnowledgeLogger>
+ <d:produceStatelessKnowledgeLogger>
+ <s:ApplyQualifiers />
+ <s:parameters>
+ <drools:StatefulKnowledgeSession>
+ <s:Inject />
+ <s:ApplyQualifiers />
+ </drools:StatefulKnowledgeSession>
+ <d:DroolsConfig>
+ <s:Inject />
+ <s:ApplyQualifiers />
+ </d:DroolsConfig>
+ </s:parameters>
+ </d:produceStatelessKnowledgeLogger>
+ <d:produceScannedStatelessKnowledgeLogger>
+ <s:ApplyQualifiers />
+ <s:parameters>
+ <drools:StatefulKnowledgeSession>
+ <s:Inject />
+ <s:ApplyQualifiers />
+ </drools:StatefulKnowledgeSession>
+ <d:DroolsConfig>
+ <s:Inject />
+ <s:ApplyQualifiers />
+ </d:DroolsConfig>
+ </s:parameters>
+ </d:produceScannedStatelessKnowledgeLogger>
</d:KnowledgeLoggerProducer>
-
+
+ <d:ExecutionResultsProducer>
+ <s:specializes />
+ <d:produceExecutionResults>
+ <s:ApplyQualifiers />
+ <s:parameters>
+ <drools:StatelessKnowledgeSession>
+ <s:Inject />
+ <s:ApplyQualifiers />
+ </drools:StatelessKnowledgeSession>
+ </s:parameters>
+ </d:produceExecutionResults>
+ <d:produceScannedExecutionResults>
+ <s:ApplyQualifiers />
+ <s:parameters>
+ <drools:StatelessKnowledgeSession>
+ <s:Inject />
+ <s:ApplyQualifiers />
+ </drools:StatelessKnowledgeSession>
+ </s:parameters>
+ </d:produceScannedExecutionResults>
+ </d:ExecutionResultsProducer>
+
<d:QueryResultsProducer>
<s:specializes />
<d:produceQueryResults>
@@ -204,7 +248,87 @@
</s:parameters>
</d:produceScannedQueryResults>
</d:QueryResultsProducer>
-
</s:genericBean>
+ <d:DroolsConfig>
+ <s:specializes />
+ <d:DefaultConfig />
+ <s:parameters>
+ <d:RuleResources>
+ <d:DefaultConfig />
+ <s:type>
+ <d:DefaultRuleResources />
+ </s:type>
+ </d:RuleResources>
+ </s:parameters>
+ </d:DroolsConfig>
+
+ <d:DroolsConfig>
+ <s:specializes />
+ <d:MVELDialectConfig />
+ <d:kbuilderPropertiesMap>
+ <s:entry>
+ <s:key>drools.dialect.default</s:key>
+ <s:value>mvel</s:value>
+ </s:entry>
+ </d:kbuilderPropertiesMap>
+ <s:parameters>
+ <d:RuleResources>
+ <d:MVELDialectConfig />
+ <s:type>
+ <d:MVELDialectRuleResources />
+ </s:type>
+ </d:RuleResources>
+ </s:parameters>
+ </d:DroolsConfig>
+
+ <d:DroolsConfig>
+ <s:specializes />
+ <d:CEPRealitimeClockConfig />
+ <d:kbasePropertiesMap>
+ <s:entry>
+ <s:key>drools.eventProcessingMode</s:key>
+ <s:value>stream</s:value>
+ </s:entry>
+ </d:kbasePropertiesMap>
+ <d:ksessionPropertiesMap>
+ <s:entry>
+ <s:key>drools.clockType</s:key>
+ <s:value>realtime</s:value>
+ </s:entry>
+ </d:ksessionPropertiesMap>
+ <s:parameters>
+ <d:RuleResources>
+ <d:CEPRealitimeClockConfig />
+ <s:type>
+ <d:CEPRealtimeClockRuleResources />
+ </s:type>
+ </d:RuleResources>
+ </s:parameters>
+ </d:DroolsConfig>
+
+ <d:DroolsConfig>
+ <s:specializes />
+ <d:CEPPseudoClockConfig />
+ <d:kbasePropertiesMap>
+ <s:entry>
+ <s:key>drools.eventProcessingMode</s:key>
+ <s:value>stream</s:value>
+ </s:entry>
+ </d:kbasePropertiesMap>
+ <d:ksessionPropertiesMap>
+ <s:entry>
+ <s:key>drools.clockType</s:key>
+ <s:value>pseudo</s:value>
+ </s:entry>
+ </d:ksessionPropertiesMap>
+ <s:parameters>
+ <d:RuleResources>
+ <d:CEPPseudoClockConfig />
+ <s:type>
+ <d:CEPPseudoClockRuleResources />
+ </s:type>
+ </d:RuleResources>
+ </s:parameters>
+ </d:DroolsConfig>
</beans>
\ No newline at end of file
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/CEPTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/CEPTest.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/CEPTest.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,102 @@
+/*
+ * 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.cep;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotSame;
+
+import java.util.concurrent.TimeUnit;
+
+import javax.enterprise.inject.Default;
+import javax.inject.Inject;
+
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.rule.WorkingMemoryEntryPoint;
+import org.drools.time.SessionPseudoClock;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.drools.KnowledgeBaseProducer;
+import org.jboss.seam.drools.annotations.EntryPoint;
+import org.jboss.seam.drools.qualifiers.config.CEPPseudoClockConfig;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class CEPTest
+{
+ @Deployment
+ public static JavaArchive createTestArchive()
+ {
+ String pkgPath = CEPTest.class.getPackage().getName().replaceAll("\\.", "/");
+ JavaArchive archive = Archives.create("test.jar", JavaArchive.class)
+ .addPackages(true, new CEPTestFilter(), KnowledgeBaseProducer.class.getPackage())
+ .addPackages(true, ResourceProvider.class.getPackage())
+ .addClass(FireAlarm.class)
+ .addClass(FireDetected.class)
+ .addClass(SprinklerActivated.class)
+ .addResource(pkgPath + "/ceptest.drl", ArchivePaths.create("ceptest.drl"))
+ //.addResource(pkgPath + "/kbuilderconfig.properties", ArchivePaths.create("kbuilderconfig.properties"))
+ //.addResource(pkgPath + "/kbaseconfig.properties", ArchivePaths.create("kbaseconfig.properties"))
+ .addManifestResource(pkgPath + "/CEPTest-beans.xml", ArchivePaths.create("beans.xml"));
+ //System.out.println(archive.toString(Formatters.VERBOSE));
+ return archive;
+ }
+
+ @Inject @Default @CEPPseudoClockConfig StatefulKnowledgeSession cepSession;
+ @Inject @Default @CEPPseudoClockConfig @EntryPoint("FireDetectionStream") WorkingMemoryEntryPoint fireDetectionStream;
+ @Inject @Default @CEPPseudoClockConfig @EntryPoint("SprinklerDetectionStream") WorkingMemoryEntryPoint sprinklerDetectionStream;
+
+
+ @Test
+ public void testCEP() {
+ assertNotNull(cepSession);
+ assertTrue(cepSession.getId() >= 0);
+ assertNotNull(fireDetectionStream);
+ assertNotNull(sprinklerDetectionStream);
+ assertNotSame(fireDetectionStream, sprinklerDetectionStream);
+
+ FireAlarm fireAlarm = new FireAlarm();
+ assertTrue(!fireAlarm.isActivated());
+ cepSession.setGlobal("fireAlarm", fireAlarm);
+ SessionPseudoClock clock = cepSession.getSessionClock();
+ fireDetectionStream.insert(new FireDetected());
+ clock.advanceTime(9, TimeUnit.SECONDS);
+
+ cepSession.fireAllRules();
+
+ FireAlarm afireAlarm = (FireAlarm) cepSession.getGlobal("fireAlarm");
+ assertTrue(!afireAlarm.isActivated());
+
+ clock.advanceTime(2, TimeUnit.SECONDS);
+
+ cepSession.fireAllRules();
+
+ FireAlarm bfireAlarm = (FireAlarm) cepSession.getGlobal("fireAlarm");
+ assertTrue(bfireAlarm.isActivated());
+
+ }
+}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/CEPTestFilter.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/CEPTestFilter.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/CEPTestFilter.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,41 @@
+/*
+ * 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.cep;
+
+import org.jboss.shrinkwrap.api.Filter;
+
+public class CEPTestFilter implements Filter<Class<?>>
+{
+
+ public boolean include(Class<?> clazz)
+ {
+ // exclude classes in all other test packages except your own
+ if(clazz.getPackage().getName().startsWith("org.jboss.seam.drools.test")
+ && !clazz.getPackage().getName().equals(CEPTestFilter.class.getPackage().getName())) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+}
+
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/FireAlarm.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/FireAlarm.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/FireAlarm.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,39 @@
+/*
+ * 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.cep;
+
+public class FireAlarm
+{
+ private boolean activated;
+
+ public boolean isActivated()
+ {
+ return activated;
+ }
+
+ public void setActivated(boolean activated)
+ {
+ this.activated = activated;
+ }
+
+
+}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/FireDetected.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/FireDetected.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/FireDetected.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,27 @@
+/*
+ * 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.cep;
+
+public class FireDetected
+{
+
+}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/SprinklerActivated.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/SprinklerActivated.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/SprinklerActivated.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,27 @@
+/*
+ * 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.cep;
+
+public class SprinklerActivated
+{
+
+}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/KAgentTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/KAgentTest.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/KAgentTest.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,32 @@
+/*
+ * 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.kagent;
+
+import org.junit.Test;
+
+public class KAgentTest
+{
+ @Test
+ public void testKAgent() {
+
+ }
+}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/KAgentTestFilter.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/KAgentTestFilter.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/KAgentTestFilter.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,27 @@
+/*
+ * 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.kagent;
+
+public class KAgentTestFilter
+{
+
+}
Modified: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/KBaseTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/KBaseTest.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/KBaseTest.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -24,12 +24,14 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import javax.enterprise.inject.Default;
import javax.inject.Inject;
import org.drools.KnowledgeBase;
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.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.Archives;
import org.jboss.shrinkwrap.api.formatter.Formatters;
@@ -54,11 +56,11 @@
.addResource(pkgPath + "/kbuilderconfig.properties", ArchivePaths.create("kbuilderconfig.properties"))
.addResource(pkgPath + "/kbaseconfig.properties", ArchivePaths.create("kbaseconfig.properties"))
.addManifestResource(pkgPath + "/KBaseTest-beans.xml", ArchivePaths.create("beans.xml"));
- System.out.println(archive.toString(Formatters.VERBOSE));
+ //System.out.println(archive.toString(Formatters.VERBOSE));
return archive;
}
- @Inject @KBaseTestRules KnowledgeBase kbase;
+ @Inject @Default @DefaultConfig KnowledgeBase kbase;
@Test
public void testKBase()
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-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/ksession/KSessionTest.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -23,16 +23,20 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+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.qualifiers.config.MVELDialectConfig;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.Archives;
-import org.jboss.shrinkwrap.api.formatter.Formatters;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.weld.extensions.resources.ResourceProvider;
import org.junit.Test;
@@ -53,16 +57,24 @@
.addResource(pkgPath + "/kbuilderconfig.properties", ArchivePaths.create("kbuilderconfig.properties"))
.addResource(pkgPath + "/kbaseconfig.properties", ArchivePaths.create("kbaseconfig.properties"))
.addManifestResource(pkgPath + "/KSessionTest-beans.xml", ArchivePaths.create("beans.xml"));
- System.out.println(archive.toString(Formatters.VERBOSE));
+ //System.out.println(archive.toString(Formatters.VERBOSE));
return archive;
}
- @Inject @KSessionTestRules StatefulKnowledgeSession ksession;
+ @Inject @Default @DefaultConfig StatefulKnowledgeSession ksession;
+ @Inject @Default @MVELDialectConfig StatefulKnowledgeSession mvelksession;
+ @Inject @Default @MVELDialectConfig StatefulKnowledgeSession mvelksession2;
@Test
public void testKSession()
{
assertNotNull(ksession);
assertTrue(ksession.getId() >= 0);
+
+ assertNotNull(mvelksession);
+ assertTrue(mvelksession.getId() >= 0);
+
+ assertNotSame(ksession, mvelksession);
+ assertSame(mvelksession, mvelksession2);
}
}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/Person.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/Person.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/Person.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,43 @@
+/*
+ * 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.query;
+
+public class Person
+{
+ private int age;
+
+ public Person(int age) {
+ this.age = age;
+ }
+
+ public int getAge()
+ {
+ return age;
+ }
+
+ public void setAge(int age)
+ {
+ this.age = age;
+ }
+
+
+}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryFactProvider.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryFactProvider.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryFactProvider.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,85 @@
+package org.jboss.seam.drools.test.query;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.seam.drools.FactProvider;
+
+/*
+ * 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.
+ */
+
+public class QueryFactProvider implements FactProvider
+{
+
+ public List<Object> getFacts()
+ {
+ List<Object> personList = new ArrayList<Object>();
+ personList.add(new Person(10));
+ personList.add(new Person(17));
+ personList.add(new Person(16));
+ personList.add(new Person(13));
+ personList.add(new Person(33));
+ personList.add(new Person(22));
+ personList.add(new Person(54));
+ personList.add(new Person(7));
+ personList.add(new Person(32));
+ personList.add(new Person(12));
+ personList.add(new Person(67));
+ personList.add(new Person(55));
+ personList.add(new Person(77));
+ personList.add(new Person(13));
+
+ return personList;
+ }
+
+ public Map<String, Object> getGlobals()
+ {
+ return null;
+ }
+
+ public void setFacts(List<Object> facts)
+ {
+
+ }
+
+ public void setGlobals(Map<String, Object> globals)
+ {
+
+ }
+
+ public List<String> getQueries()
+ {
+ List<String> queries = new ArrayList<String>();
+ queries.add("number of adults");
+ queries.add("number of minors");
+ return queries;
+ }
+
+ public void setQueries(List<String> queries)
+ {
+
+ }
+
+
+
+}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryTest.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryTest.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,86 @@
+/*
+ * 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.query;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+
+import javax.enterprise.inject.Default;
+import javax.inject.Inject;
+
+import org.drools.runtime.ExecutionResults;
+import org.drools.runtime.rule.QueryResults;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.drools.KnowledgeBaseProducer;
+import org.jboss.seam.drools.annotations.Query;
+import org.jboss.seam.drools.qualifiers.config.DefaultConfig;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class QueryTest
+{
+ @Deployment
+ public static JavaArchive createTestArchive()
+ {
+ String pkgPath = QueryTest.class.getPackage().getName().replaceAll("\\.", "/");
+ JavaArchive archive = Archives.create("test.jar", JavaArchive.class)
+ .addPackages(true, new QueryTestFilter(), KnowledgeBaseProducer.class.getPackage())
+ .addPackages(true, ResourceProvider.class.getPackage())
+ .addClass(Person.class)
+ .addClass(QueryFactProvider.class)
+ .addResource(pkgPath + "/querytest.drl", ArchivePaths.create("querytest.drl"))
+ //.addResource(pkgPath + "/kbuilderconfig.properties", ArchivePaths.create("kbuilderconfig.properties"))
+ //.addResource(pkgPath + "/kbaseconfig.properties", ArchivePaths.create("kbaseconfig.properties"))
+ .addManifestResource(pkgPath + "/QueryTest-beans.xml", ArchivePaths.create("beans.xml"));
+ //System.out.println(archive.toString(Formatters.VERBOSE));
+ return archive;
+ }
+
+ @Inject @Default @DefaultConfig @Query("number of adults") QueryResults adultsQuery;
+ @Inject @Default @DefaultConfig @Query("number of minors") QueryResults minorsQuery;
+
+ @Inject @Default @DefaultConfig ExecutionResults executionResults;
+
+ @Test
+ public void testQuery() {
+ assertNotNull(adultsQuery);
+ assertNotNull(minorsQuery);
+ assertNotSame(adultsQuery, minorsQuery);
+
+ assertTrue(adultsQuery.size() == 7);
+ assertTrue(minorsQuery.size() == 7);
+
+ assertNotNull(executionResults);
+ assertTrue(((QueryResults) executionResults.getValue("number of adults")).size() == 7);
+ assertTrue(((QueryResults) executionResults.getValue("number of minors")).size() == 7);
+
+
+ }
+}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryTestFilter.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryTestFilter.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryTestFilter.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,41 @@
+/*
+ * 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.query;
+
+import org.jboss.shrinkwrap.api.Filter;
+
+public class QueryTestFilter implements Filter<Class<?>>
+{
+
+ public boolean include(Class<?> clazz)
+ {
+ // exclude classes in all other test packages except your own
+ if(clazz.getPackage().getName().startsWith("org.jboss.seam.drools.test")
+ && !clazz.getPackage().getName().equals(QueryTestFilter.class.getPackage().getName())) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+}
+
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/cep/CEPTest-beans.xml
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/cep/CEPTest-beans.xml (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/cep/CEPTest-beans.xml 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,34 @@
+<!--
+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:seam:core"
+ xmlns:d="urn:java:org.jboss.seam.drools:org.jboss.seam.drools.config"
+ xmlns:test="urn:java:org.jboss.seam.drools.test.ksession">
+
+ <d:CEPPseudoClockRuleResources>
+ <s:specializes/>
+ <d:resources>
+ <s:value>classpath;ceptest.drl;DRL</s:value>
+ </d:resources>
+ </d:CEPPseudoClockRuleResources>
+
+</beans>
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/cep/ceptest.drl
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/cep/ceptest.drl (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/cep/ceptest.drl 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,25 @@
+package org.jboss.seam.drools.test.cep
+
+import org.jboss.seam.drools.test.cep.FireAlarm;
+import org.jboss.seam.drools.test.cep.FireDetected;
+import org.jboss.seam.drools.test.cep.SprinklerActivated;
+
+global FireAlarm fireAlarm;
+
+declare SprinklerActivated
+ @role( event )
+ @expires( 1h )
+end
+
+declare FireDetected
+ @role( event )
+ @expires( 1h )
+end
+
+rule "Sound the alarm"
+when
+ $f : FireDetected( ) from entry-point "FireDetectionStream"
+ not( SprinklerActivated( this after[0s,10s] $f ) from entry-point "SprinklerDetectionStream" )
+then
+ fireAlarm.setActivated(true);
+end
\ No newline at end of file
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/KAgentTest-beans.xml
===================================================================
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagentconfig.properties
===================================================================
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagentestchangeset.xml
===================================================================
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagenttestone.drl
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagenttestone.drl (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagenttestone.drl 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,29 @@
+#created on: Apr 19, 2010
+package org.jboss.seam.drools.test.kagent
+
+#list any import classes here.
+
+
+
+#declare any global variables here
+
+
+
+
+rule "Your First Rule"
+
+ when
+ #conditions
+ then
+ #actions
+
+end
+
+rule "Your Second Rule"
+ #include attributes such as "salience" here...
+ when
+ #conditions
+ then
+ #actions
+
+end
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagenttesttwo.drl
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagenttesttwo.drl (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagenttesttwo.drl 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,29 @@
+#created on: Apr 19, 2010
+package org.jboss.seam.drools.test.kagent
+
+#list any import classes here.
+
+
+
+#declare any global variables here
+
+
+
+
+rule "Your First Rule"
+
+ when
+ #conditions
+ then
+ #actions
+
+end
+
+rule "Your Second Rule"
+ #include attributes such as "salience" here...
+ when
+ #conditions
+ then
+ #actions
+
+end
Modified: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/KBaseTest-beans.xml
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/KBaseTest-beans.xml 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/KBaseTest-beans.xml 2010-04-20 16:21:25 UTC (rev 12529)
@@ -24,14 +24,10 @@
xmlns:d="urn:java:org.jboss.seam.drools:org.jboss.seam.drools.config"
xmlns:test="urn:java:org.jboss.seam.drools.test.kbase">
-
- <d:DroolsConfiguration>
- <test:KBaseTestRules />
- <d:knowledgeBuilderConfigPath>kbuilderconfig.properties</d:knowledgeBuilderConfigPath>
- <d:knowledgeBaseConfigPath>kbaseconfig.properties</d:knowledgeBaseConfigPath>
- <d:ruleResources>
- <s:value>classpath;kbasetest.drl;DRL;forkbasetest</s:value>
- </d:ruleResources>
- </d:DroolsConfiguration>
-
+ <d:DefaultRuleResources>
+ <s:specializes/>
+ <d:resources>
+ <s:value>classpath;kbasetest.drl;DRL;forkbasetest</s:value>
+ </d:resources>
+ </d:DefaultRuleResources>
</beans>
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-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/ksession/KSessionTest-beans.xml 2010-04-20 16:21:25 UTC (rev 12529)
@@ -24,14 +24,18 @@
xmlns:d="urn:java:org.jboss.seam.drools:org.jboss.seam.drools.config"
xmlns:test="urn:java:org.jboss.seam.drools.test.ksession">
- <d:DroolsConfiguration>
- <test:KSessionTestRules />
- <d:knowledgeBuilderConfigPath>kbuilderconfig.properties
- </d:knowledgeBuilderConfigPath>
- <d:knowledgeBaseConfigPath>kbaseconfig.properties
- </d:knowledgeBaseConfigPath>
- <d:ruleResources>
+ <d:DefaultRuleResources>
+ <s:specializes/>
+ <d:resources>
+ <s:value>classpath;ksessiontest.drl;DRL</s:value>
+ </d:resources>
+ </d:DefaultRuleResources>
+
+ <d:MVELDialectRuleResources>
+ <s:specializes/>
+ <d:resources>
<s:value>classpath;ksessiontest.drl;DRL</s:value>
- </d:ruleResources>
- </d:DroolsConfiguration>
+ </d:resources>
+ </d:MVELDialectRuleResources>
+
</beans>
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/query/QueryTest-beans.xml
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/query/QueryTest-beans.xml (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/query/QueryTest-beans.xml 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,34 @@
+<!--
+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:seam:core"
+ 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:specializes/>
+ <d:resources>
+ <s:value>classpath;querytest.drl;DRL</s:value>
+ </d:resources>
+ </d:DefaultRuleResources>
+
+</beans>
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/query/querytest.drl
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/query/querytest.drl (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/query/querytest.drl 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,11 @@
+package org.jboss.seam.drools.test.query
+
+import org.jboss.seam.drools.test.query.Person;
+
+query "number of adults"
+ person : Person( age >= 18 )
+end
+
+query "number of minors"
+ person : Person( age < 18 )
+end
\ No newline at end of file
More information about the seam-commits
mailing list