[seam-commits] Seam SVN: r12430 - in modules/drools/trunk: impl/src/main/java/org/jboss/seam/drools and 6 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Mon Apr 12 03:21:38 EDT 2010
Author: tsurdilovic
Date: 2010-04-12 03:21:35 -0400 (Mon, 12 Apr 2010)
New Revision: 12430
Added:
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/FactProvider.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/KAgentConfigured.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/KBaseConfigured.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/KBaseEventListener.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/KSessionEventListener.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/TemplateData.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/WIHandler.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/config/DroolsConfiguration.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/MyKnowledgeBaseEventListener.java
Removed:
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/kbase/
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeAgentConfig.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeBaseConfig.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeLoggerConfig.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeSessionConfig.java
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/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/bootstrap/DroolsExtension.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/config/DroolsConfig.java
modules/drools/trunk/impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/KBaseTest.java
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/KBaseTest-beans.xml
Log:
moved all configs into single Drools configuration bean.
Added: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/FactProvider.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/FactProvider.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/FactProvider.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -0,0 +1,29 @@
+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 FactProvider {
+ @Nonbinding String name();
+ @Nonbinding String entryPointName();
+}
Copied: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/KAgentConfigured.java (from rev 12428, modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/kbase/KAgentConfigured.java)
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/KAgentConfigured.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/KAgentConfigured.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -0,0 +1,29 @@
+package org.jboss.seam.drools.qualifiers;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+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;
+
+/**
+ * Qualifier for Drools KnowledgeBase configured for KnowledgeAgent.
+ *
+ * @author Tihomir Surdilovic
+ */
+ at Qualifier
+ at Target( { TYPE, METHOD, FIELD, PARAMETER })
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface KAgentConfigured
+{
+
+}
Copied: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/KBaseConfigured.java (from rev 12428, modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/kbase/KBaseConfigured.java)
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/KBaseConfigured.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/KBaseConfigured.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -0,0 +1,29 @@
+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.inject.Qualifier;
+
+/**
+ * Qualifier for Drools KnowledgeBase default configuration.
+ *
+ * @author Tihomir Surdilovic
+ */
+ at Qualifier
+ at Target( { TYPE, METHOD, FIELD, PARAMETER })
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface KBaseConfigured
+{
+
+}
Added: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/KBaseEventListener.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/KBaseEventListener.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/KBaseEventListener.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -0,0 +1,27 @@
+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.inject.Qualifier;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+ at Qualifier
+ at Target( { TYPE, METHOD, FIELD, PARAMETER })
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface KBaseEventListener {
+
+}
Added: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/KSessionEventListener.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/KSessionEventListener.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/KSessionEventListener.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -0,0 +1,27 @@
+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.inject.Qualifier;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+ at Qualifier
+ at Target( { TYPE, METHOD, FIELD, PARAMETER })
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface KSessionEventListener {
+
+}
Added: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/TemplateData.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/TemplateData.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/TemplateData.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -0,0 +1,28 @@
+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 TemplateData {
+ @Nonbinding String name();
+}
Added: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/WIHandler.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/WIHandler.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/WIHandler.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -0,0 +1,28 @@
+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 WIHandler {
+ @Nonbinding String name();
+}
Added: 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 (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/EntryPointProducer.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -0,0 +1,25 @@
+package org.jboss.seam.drools;
+
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.Produces;
+
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.rule.WorkingMemoryEntryPoint;
+import org.jboss.seam.drools.qualifiers.KAgentConfigured;
+import org.jboss.seam.drools.qualifiers.KBaseConfigured;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+public class EntryPointProducer
+{
+ @Produces @KBaseConfigured WorkingMemoryEntryPoint produceEntryPoint(@KBaseConfigured StatefulKnowledgeSession ksession, Instance<String> entryPointNameInstance) {
+ return ksession.getWorkingMemoryEntryPoint(entryPointNameInstance.get());
+ }
+
+ @Produces @KAgentConfigured WorkingMemoryEntryPoint produceKAgentEntryPoint(@KAgentConfigured StatefulKnowledgeSession ksession, Instance<String> entryPointNameInstance) {
+ return ksession.getWorkingMemoryEntryPoint(entryPointNameInstance.get());
+ }
+
+}
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-12 07:07:53 UTC (rev 12429)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeAgentProducer.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -2,7 +2,9 @@
import java.util.Properties;
+import javax.enterprise.inject.Any;
import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Instance;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
@@ -14,9 +16,10 @@
import org.drools.builder.ResourceType;
import org.drools.io.ResourceChangeScannerConfiguration;
import org.drools.io.ResourceFactory;
-import org.jboss.seam.drools.config.KnowledgeAgentConfig;
+import org.jboss.seam.drools.config.DroolsConfiguration;
import org.jboss.seam.drools.events.RuleResourceAddedEvent;
-import org.jboss.seam.drools.qualifiers.kbase.KAgentConfigured;
+import org.jboss.seam.drools.qualifiers.KAgentConfigured;
+import org.jboss.seam.drools.qualifiers.config.DroolsConfig;
import org.jboss.seam.drools.utils.ConfigUtils;
import org.jboss.weld.extensions.resources.ResourceProvider;
import org.slf4j.Logger;
@@ -37,13 +40,14 @@
@Produces
@KAgentConfigured
- KnowledgeBase produceAgentKBase(KnowledgeAgentConfig kagentConfig) throws Exception
+ KnowledgeBase produceAgentKBase(Instance<DroolsConfiguration> kagentConfigInstance) throws Exception
{
+ DroolsConfiguration kagentConfig = kagentConfigInstance.get();
ResourceFactory.getResourceChangeScannerService().configure(getResourceChangeScannerConfig(kagentConfig.getResourceChangeScannerConfigPath()));
KnowledgeAgentConfiguration aconf = getKnowledgeAgentConfiguration(kagentConfig.getKnowledgeAgentConfigPath());
KnowledgeAgent kagent;
- kagent = KnowledgeAgentFactory.newKnowledgeAgent(kagentConfig.getName(), aconf);
+ kagent = KnowledgeAgentFactory.newKnowledgeAgent(kagentConfig.getKnowledgeAgentName(), aconf);
applyChangeSet(kagent, kagentConfig.getChangeSetResource());
if(kagentConfig.isStartChangeNotifierService()) {
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-12 07:07:53 UTC (rev 12429)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -1,9 +1,15 @@
package org.jboss.seam.drools;
+import java.util.Iterator;
import java.util.Properties;
+import java.util.Set;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.Instance;
import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Inject;
import org.drools.KnowledgeBase;
@@ -17,10 +23,11 @@
import org.drools.builder.ResourceType;
import org.drools.event.knowledgebase.KnowledgeBaseEventListener;
import org.drools.io.ResourceFactory;
-import org.jboss.seam.drools.config.KnowledgeBaseConfig;
+import org.jboss.seam.drools.config.DroolsConfiguration;
import org.jboss.seam.drools.events.KnowledgeBuilderErrorsEvent;
import org.jboss.seam.drools.events.RuleResourceAddedEvent;
-import org.jboss.seam.drools.qualifiers.kbase.KBaseConfigured;
+import org.jboss.seam.drools.qualifiers.KBaseConfigured;
+import org.jboss.seam.drools.qualifiers.KBaseEventListener;
import org.jboss.seam.drools.utils.ConfigUtils;
import org.jboss.weld.extensions.resources.ResourceProvider;
import org.slf4j.Logger;
@@ -39,8 +46,9 @@
@Inject
ResourceProvider resourceProvider;
- @Produces @KBaseConfigured
- public KnowledgeBase produceKBase(KnowledgeBaseConfig kbaseConfig) throws Exception
+ @Produces
+ @KBaseConfigured
+ public KnowledgeBase produceKBase(DroolsConfiguration kbaseConfig) throws Exception
{
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(getKnowledgeBuilderConfiguration(kbaseConfig.getKnowledgeBuilderConfigPath()));
@@ -62,13 +70,16 @@
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(getKnowledgeBaseConfiguration(kbaseConfig.getKnowledgeBaseConfigPath()));
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
- if (kbaseConfig.getEventListeners() != null)
- {
- for (String eventListener : kbaseConfig.getEventListeners())
+ Set<Bean<?>> allKBaseEventListeners = manager.getBeans(KnowledgeBaseEventListener.class, new AnnotationLiteral<KBaseEventListener>() {});
+ if (allKBaseEventListeners != null)
+ {
+ Iterator<Bean<?>> iter = allKBaseEventListeners.iterator();
+ while (iter.hasNext())
{
- addEventListener(kbase, eventListener);
+ addEventListener(kbase, iter.next());
}
}
+
return kbase;
}
@@ -77,7 +88,7 @@
KnowledgeBuilderConfiguration droolsKbuilderConfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
if (knowledgeBuilderConfigPath != null && knowledgeBuilderConfigPath.endsWith(".properties"))
{
-
+
Properties kbuilderProp = ConfigUtils.loadProperties(resourceProvider, knowledgeBuilderConfigPath);
droolsKbuilderConfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(kbuilderProp, null);
log.debug("KnowledgeBuilderConfiguration loaded: " + knowledgeBuilderConfigPath);
@@ -133,26 +144,11 @@
}
}
- private void addEventListener(org.drools.KnowledgeBase kbase, String eventListener)
+ private void addEventListener(org.drools.KnowledgeBase kbase, Bean<?> listener)
{
- try
- {
- @SuppressWarnings("unchecked")
- Class eventListenerClass = Class.forName(eventListener);
- Object eventListenerObject = eventListenerClass.newInstance();
-
- if (eventListenerObject instanceof KnowledgeBaseEventListener)
- {
- kbase.addEventListener((KnowledgeBaseEventListener) eventListenerObject);
- }
- else
- {
- log.debug("Event Listener " + eventListener + " is not of type KnowledgeBaseEventListener");
- }
- }
- catch (Exception e)
- {
- log.error("Error adding event listener " + e.getMessage());
- }
- }
+ CreationalContext<?> context = manager.createCreationalContext(listener);
+ KnowledgeBaseEventListener listenerInstance = (KnowledgeBaseEventListener) manager.getReference(listener, KnowledgeBaseEventListener.class, context);
+ kbase.addEventListener(listenerInstance);
+ log.debug("Added KnowledgeBaseEventListener: " + listener);
+ }
}
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-12 07:07:53 UTC (rev 12429)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeLoggerProducer.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -1,6 +1,7 @@
package org.jboss.seam.drools;
import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Instance;
import javax.enterprise.inject.Produces;
import org.drools.event.KnowledgeRuntimeEventManager;
@@ -8,9 +9,9 @@
import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.StatelessKnowledgeSession;
-import org.jboss.seam.drools.config.KnowledgeLoggerConfig;
-import org.jboss.seam.drools.qualifiers.kbase.KAgentConfigured;
-import org.jboss.seam.drools.qualifiers.kbase.KBaseConfigured;
+import org.jboss.seam.drools.config.DroolsConfiguration;
+import org.jboss.seam.drools.qualifiers.KAgentConfigured;
+import org.jboss.seam.drools.qualifiers.KBaseConfigured;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -23,55 +24,63 @@
private static final Logger log = LoggerFactory.getLogger(KnowledgeLoggerProducer.class);
@Produces
- public KnowledgeRuntimeLogger produceStatefulKnowledgeLogger(@KBaseConfigured StatefulKnowledgeSession ksession, KnowledgeLoggerConfig loggerConfig)
+ @KBaseConfigured
+ public KnowledgeRuntimeLogger produceStatefulKnowledgeLogger(@KBaseConfigured StatefulKnowledgeSession ksession, Instance<DroolsConfiguration> loggerConfigInstance)
{
- return getLogger(ksession, loggerConfig);
+ return getLogger(ksession, loggerConfigInstance.get());
}
@Produces
- public KnowledgeRuntimeLogger produceStatefulKnowledgeLoggerForKAgent(@KAgentConfigured StatefulKnowledgeSession ksession, KnowledgeLoggerConfig loggerConfig)
+ @KAgentConfigured
+ public KnowledgeRuntimeLogger produceStatefulKnowledgeLoggerForKAgent(@KAgentConfigured StatefulKnowledgeSession ksession, Instance<DroolsConfiguration> loggerConfigInstance)
{
- return getLogger(ksession, loggerConfig);
+ return getLogger(ksession, loggerConfigInstance.get());
}
@Produces
- public KnowledgeRuntimeLogger produceStatelessKnowledgeLogger(@KBaseConfigured StatelessKnowledgeSession ksession, KnowledgeLoggerConfig loggerConfig)
+ @KBaseConfigured
+ public KnowledgeRuntimeLogger produceStatelessKnowledgeLogger(@KBaseConfigured StatelessKnowledgeSession ksession, Instance<DroolsConfiguration> loggerConfigInstance)
{
- return getLogger(ksession, loggerConfig);
+ return getLogger(ksession, loggerConfigInstance.get());
}
@Produces
- public KnowledgeRuntimeLogger produceStatelessKnowledgeLoggerForKAgent(@KAgentConfigured StatelessKnowledgeSession ksession, KnowledgeLoggerConfig loggerConfig)
+ @KAgentConfigured
+ public KnowledgeRuntimeLogger produceStatelessKnowledgeLoggerForKAgent(@KAgentConfigured StatelessKnowledgeSession ksession, Instance<DroolsConfiguration> loggerConfigInstance)
{
- return getLogger(ksession, loggerConfig);
+ return getLogger(ksession, loggerConfigInstance.get());
}
- private KnowledgeRuntimeLogger getLogger(KnowledgeRuntimeEventManager ksession, KnowledgeLoggerConfig loggerConfig)
+ private KnowledgeRuntimeLogger getLogger(KnowledgeRuntimeEventManager ksession, DroolsConfiguration loggerConfig)
{
KnowledgeRuntimeLogger krLogger = null;
- if (loggerConfig.isFileType())
+ if (loggerConfig.getLoggerType().equalsIgnoreCase("file"))
{
- String logName = loggerConfig.getPath() + System.currentTimeMillis();
+ String logName = loggerConfig.getLoggerPath() + System.currentTimeMillis();
krLogger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, logName);
}
- else if (loggerConfig.isConsoleType())
+ else if (loggerConfig.getLoggerType().equalsIgnoreCase("console"))
{
krLogger = KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);
}
- else if (loggerConfig.isThreadedType())
+ else if (loggerConfig.getLoggerType().equalsIgnoreCase("threaded"))
{
- String logName = loggerConfig.getPath() + System.currentTimeMillis();
- krLogger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, logName, loggerConfig.getInterval());
+ String logName = loggerConfig.getLoggerPath() + System.currentTimeMillis();
+ krLogger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, logName, loggerConfig.getLoggerInterval());
}
else
{
- log.error("Invalid logger specified: type: " + loggerConfig.getType() + " path: " + loggerConfig.getPath() + " interval: " + loggerConfig.getInterval());
+ log.error("Invalid logger specified: type: " + loggerConfig.getLoggerType() + " path: " + loggerConfig.getLoggerPath() + " interval: " + loggerConfig.getLoggerInterval());
}
return krLogger;
}
- public void disposeKnowledgeLogger(@Disposes KnowledgeRuntimeLogger logger)
+ public void disposeKBaseConfiguredKnowledgeLogger(@Disposes @KBaseConfigured KnowledgeRuntimeLogger logger)
{
logger.close();
}
+
+ public void disposeKAgentConfiguredKnowledgeLogger(@Disposes @KAgentConfigured 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-12 07:07:53 UTC (rev 12429)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeSessionProducer.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -1,12 +1,17 @@
package org.jboss.seam.drools;
+import java.util.Iterator;
import java.util.Properties;
+import java.util.Set;
+import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.Any;
import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Instance;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Inject;
import org.drools.KnowledgeBase;
@@ -19,9 +24,11 @@
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.StatelessKnowledgeSession;
import org.drools.runtime.process.WorkItemHandler;
-import org.jboss.seam.drools.config.KnowledgeSessionConfig;
-import org.jboss.seam.drools.qualifiers.kbase.KAgentConfigured;
-import org.jboss.seam.drools.qualifiers.kbase.KBaseConfigured;
+import org.jboss.seam.drools.config.DroolsConfiguration;
+import org.jboss.seam.drools.qualifiers.KAgentConfigured;
+import org.jboss.seam.drools.qualifiers.KBaseConfigured;
+import org.jboss.seam.drools.qualifiers.KSessionEventListener;
+import org.jboss.seam.drools.qualifiers.WIHandler;
import org.jboss.seam.drools.utils.ConfigUtils;
import org.jboss.weld.extensions.resources.ResourceProvider;
import org.slf4j.Logger;
@@ -42,35 +49,42 @@
@Produces
@KBaseConfigured
- public StatefulKnowledgeSession produceStatefulSession(@KBaseConfigured KnowledgeBase kbase, KnowledgeSessionConfig ksessionConfig) throws Exception
+ public StatefulKnowledgeSession produceStatefulSession(@KBaseConfigured KnowledgeBase kbase, Instance<DroolsConfiguration> ksessionConfigInstance) throws Exception
{
- StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(getConfig(ksessionConfig.getKnowledgeSessionConfigPath()), null);
- addEventListeners(ksession, ksessionConfig);
- addWorkItemHandlers(ksession, ksessionConfig);
+ StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(getConfig(ksessionConfigInstance.get().getKnowledgeSessionConfigPath()), null);
+ addEventListeners(ksession);
+ addWorkItemHandlers(ksession);
return ksession;
}
@Produces
@KAgentConfigured
- StatefulKnowledgeSession produceStatefulSessionFromKAgent(@KAgentConfigured KnowledgeBase kbase, KnowledgeSessionConfig ksessionConfig) throws Exception
+ StatefulKnowledgeSession produceStatefulSessionFromKAgent(@KAgentConfigured KnowledgeBase kbase, Instance<DroolsConfiguration> ksessionConfigInstance) throws Exception
{
- return null;
+ StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(getConfig(ksessionConfigInstance.get().getKnowledgeSessionConfigPath()), null);
+ addEventListeners(ksession);
+ addWorkItemHandlers(ksession);
+
+ return ksession;
}
@Produces
@KAgentConfigured
- StatelessKnowledgeSession produceStatelessSessionFromKAgent(@KAgentConfigured KnowledgeBase kbase, KnowledgeSessionConfig ksesiosnConfig)
+ StatelessKnowledgeSession produceStatelessSessionFromKAgent(@KAgentConfigured KnowledgeBase kbase, Instance<DroolsConfiguration> ksessionConfigInstance) throws Exception
{
- return null;
+ StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(getConfig(ksessionConfigInstance.get().getKnowledgeSessionConfigPath()));
+ addEventListeners(ksession);
+
+ return ksession;
}
@Produces
@KBaseConfigured
- public StatelessKnowledgeSession produceStatelessSession(@KBaseConfigured KnowledgeBase kbase, KnowledgeSessionConfig ksessionConfig) throws Exception
+ public StatelessKnowledgeSession produceStatelessSession(@KBaseConfigured KnowledgeBase kbase, Instance<DroolsConfiguration> ksessionConfigInstance) throws Exception
{
- StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(getConfig(ksessionConfig.getKnowledgeSessionConfigPath()));
- addEventListeners(ksession, ksessionConfig);
+ StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(getConfig(ksessionConfigInstance.get().getKnowledgeSessionConfigPath()));
+ addEventListeners(ksession);
return ksession;
}
@@ -96,53 +110,55 @@
return droolsKsessionConfig;
}
- private void addEventListeners(KnowledgeRuntimeEventManager ksession, KnowledgeSessionConfig ksessionConfig) throws Exception
+ private void addEventListeners(KnowledgeRuntimeEventManager ksession)
{
- if (ksessionConfig.getEventListeners() != null)
+ Set<Bean<?>> allKSessionEventListeners = manager.getBeans(Object.class, new AnnotationLiteral<KSessionEventListener>()
{
- for (String eventListener : ksessionConfig.getEventListeners())
- {
- @SuppressWarnings("unchecked")
- Class eventListenerClass = Class.forName(eventListener);
- Object eventListenerObject = eventListenerClass.newInstance();
- if (eventListenerObject instanceof WorkingMemoryEventListener)
+ });
+ if(allKSessionEventListeners != null) {
+ Iterator<Bean<?>> iter = allKSessionEventListeners.iterator();
+ while(iter.hasNext()) {
+ Bean<?> eventListener = iter.next();
+ CreationalContext<?> context = manager.createCreationalContext(eventListener);
+ Object eventListenerInstance = manager.getReference(eventListener, Object.class, context);
+
+ if (eventListenerInstance instanceof WorkingMemoryEventListener)
{
- ksession.addEventListener((WorkingMemoryEventListener) eventListenerObject);
+ ksession.addEventListener((WorkingMemoryEventListener) eventListenerInstance);
}
- else if (eventListenerObject instanceof AgendaEventListener)
+ else if (eventListenerInstance instanceof AgendaEventListener)
{
- ksession.addEventListener((AgendaEventListener) eventListenerObject);
+ ksession.addEventListener((AgendaEventListener) eventListenerInstance);
}
- else if (eventListenerObject instanceof ProcessEventListener)
+ else if (eventListenerInstance instanceof ProcessEventListener)
{
- ksession.addEventListener((ProcessEventListener) eventListenerObject);
+ ksession.addEventListener((ProcessEventListener) eventListenerInstance);
}
else
{
- log.debug("Invalid Event Listener: " + eventListener);
+ log.debug("Invalid Event Listener: " + eventListenerInstance);
}
}
}
}
- private void addWorkItemHandlers(StatefulKnowledgeSession ksession, KnowledgeSessionConfig ksessionConfig)
+ private void addWorkItemHandlers(StatefulKnowledgeSession ksession)
{
- if (ksessionConfig.getWorkItemHandlers() != null)
+ Set<Bean<?>> allWorkItemHandlers = manager.getBeans(WorkItemHandler.class, new AnnotationLiteral<WIHandler>()
{
- for (String workItemHandlerStr : ksessionConfig.getWorkItemHandlers())
+ });
+ if (allWorkItemHandlers != null)
+ {
+ Iterator<Bean<?>> iter = allWorkItemHandlers.iterator();
+ while (iter.hasNext())
{
- if (ConfigUtils.isValidWorkItemHandler(workItemHandlerStr))
- {
- @SuppressWarnings("unchecked")
- Bean<WorkItemHandler> workItemHandlerBean = (Bean<WorkItemHandler>) manager.getBeans(ConfigUtils.getWorkItemHandlerType(workItemHandlerStr)).iterator().next();
- WorkItemHandler handler = (WorkItemHandler) manager.getReference(workItemHandlerBean, WorkItemHandler.class, manager.createCreationalContext(workItemHandlerBean));
- log.debug("Registering new WorkItemHandler: " + ConfigUtils.getWorkItemHandlerName(workItemHandlerStr));
- ksession.getWorkItemManager().registerWorkItemHandler(ConfigUtils.getWorkItemHandlerName(workItemHandlerStr), handler);
- }
- else
- {
- log.warn("Invalid workitem handler configuration for: " + workItemHandlerStr);
- }
+ Bean<?> handler = iter.next();
+ WIHandler handlerQualifier = (WIHandler) handler.getQualifiers().toArray()[0];
+ CreationalContext<?> context = manager.createCreationalContext(handler);
+ WorkItemHandler handlerInstance = (WorkItemHandler) manager.getReference(handler, WorkItemHandler.class, context);
+
+ log.info("Registering new WorkItemHandler: " + handlerQualifier.name());
+ ksession.getWorkItemManager().registerWorkItemHandler(handlerQualifier.name(), handlerInstance);
}
}
}
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-12 07:07:53 UTC (rev 12429)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/bootstrap/DroolsExtension.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -1,8 +1,18 @@
package org.jboss.seam.drools.bootstrap;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
import javax.enterprise.inject.spi.Extension;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class DroolsExtension implements Extension
{
+ private static final Logger log = LoggerFactory.getLogger(DroolsExtension.class);
+ void afterBeanDiscovery(@Observes AfterBeanDiscovery abd) {
+
+ }
+
}
Added: 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 (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfiguration.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -0,0 +1,141 @@
+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;
+ }
+
+
+}
Deleted: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeAgentConfig.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeAgentConfig.java 2010-04-12 07:07:53 UTC (rev 12429)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeAgentConfig.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -1,77 +0,0 @@
-package org.jboss.seam.drools.config;
-
-/**
- * Configuration data for Drools KnowledeAgent.
- *
- * @author Tihomir Surdilovic
- */
-public class KnowledgeAgentConfig
-{
- private String resourceChangeScannerConfigPath;
- private String knowledgeAgentConfigPath;
- private String changeSetResource;
- private String name;
- private boolean startChangeNotifierService;
- private boolean startChangeScannerService;
-
- 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 getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- 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;
- }
-
-}
Deleted: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeBaseConfig.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeBaseConfig.java 2010-04-12 07:07:53 UTC (rev 12429)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeBaseConfig.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -1,77 +0,0 @@
-package org.jboss.seam.drools.config;
-
-/**
- *
- * @author Tihomir Surdilovic
- */
-public class KnowledgeBaseConfig
-{
- private String knowledgeBuilderConfigPath;
- private String knowledgeBaseConfigPath;
- private String[] ruleResources;
- private String[] eventListeners;
-
- 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[] getEventListeners()
- {
- return eventListeners;
- }
-
- public void setEventListeners(String[] eventListeners)
- {
- this.eventListeners = eventListeners;
- }
-
- public String toString()
- {
- StringBuffer buff = new StringBuffer();
- buff.append("knowledgeBuilderConfigPath: " + knowledgeBuilderConfigPath + "\n").append("knowledgeBaseConfigPath: " + knowledgeBaseConfigPath + "\n");
- if (ruleResources != null)
- {
- buff.append("Rule Resources:\n");
- for (String rr : ruleResources)
- {
- buff.append("\t" + rr);
- }
- }
- if (eventListeners != null)
- {
- buff.append("\nEvent Listeners: \n");
- for (String el : eventListeners)
- {
- buff.append("\t" + el);
- }
- }
-
- return buff.toString();
- }
-}
Deleted: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeLoggerConfig.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeLoggerConfig.java 2010-04-12 07:07:53 UTC (rev 12429)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeLoggerConfig.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -1,65 +0,0 @@
-package org.jboss.seam.drools.config;
-
-public class KnowledgeLoggerConfig
-{
- private String name;
- private String type;
- private String path;
- private int interval;
-
- public boolean isFileType()
- {
- return type != null && type.equalsIgnoreCase("file");
- }
-
- public boolean isConsoleType()
- {
- return type != null && type.equalsIgnoreCase("console");
- }
-
- public boolean isThreadedType()
- {
- return type != null && type.equalsIgnoreCase("threaded");
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- public String getType()
- {
- return type;
- }
-
- public void setType(String type)
- {
- this.type = type;
- }
-
- public String getPath()
- {
- return path;
- }
-
- public void setPath(String path)
- {
- this.path = path;
- }
-
- public int getInterval()
- {
- return interval;
- }
-
- public void setInterval(int interval)
- {
- this.interval = interval;
- }
-
-}
Deleted: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeSessionConfig.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeSessionConfig.java 2010-04-12 07:07:53 UTC (rev 12429)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeSessionConfig.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -1,65 +0,0 @@
-package org.jboss.seam.drools.config;
-
-/**
- *
- * @author Tihomir Surdilovic
- */
-public class KnowledgeSessionConfig
-{
- private String[] eventListeners;
- private String[] workItemHandlers;
- private String knowledgeSessionConfigPath;
-
- public String[] getEventListeners()
- {
- return eventListeners;
- }
-
- public void setEventListeners(String[] eventListeners)
- {
- this.eventListeners = eventListeners;
- }
-
- public String[] getWorkItemHandlers()
- {
- return workItemHandlers;
- }
-
- public void setWorkItemHandlers(String[] workItemHandlers)
- {
- this.workItemHandlers = workItemHandlers;
- }
-
- public String getKnowledgeSessionConfigPath()
- {
- return knowledgeSessionConfigPath;
- }
-
- public void setKnowledgeSessionConfigPath(String knowledgeSessionConfigPath)
- {
- this.knowledgeSessionConfigPath = knowledgeSessionConfigPath;
- }
-
- public String toString()
- {
- StringBuffer buff = new StringBuffer();
- buff.append("knowledgeSessionConfigPath: " + knowledgeSessionConfigPath + "\n");
- if (eventListeners != null)
- {
- buff.append("Event Listeners:\n");
- for (String el : eventListeners)
- {
- buff.append("\t" + el);
- }
- }
- if (workItemHandlers != null)
- {
- buff.append("\nWorkitem handlers: \n");
- for (String el : workItemHandlers)
- {
- buff.append("\t" + el);
- }
- }
- return buff.toString();
- }
-}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/config/DroolsConfig.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/config/DroolsConfig.java 2010-04-12 07:07:53 UTC (rev 12429)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/config/DroolsConfig.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -1,5 +1,8 @@
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;
@@ -10,8 +13,12 @@
import javax.inject.Qualifier;
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
@Qualifier
- at Target( { TYPE })
+ at Target( { TYPE, METHOD, FIELD, PARAMETER })
@Documented
@Retention(RUNTIME)
@Inherited
Modified: modules/drools/trunk/impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
===================================================================
--- modules/drools/trunk/impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension 2010-04-12 07:07:53 UTC (rev 12429)
+++ modules/drools/trunk/impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension 2010-04-12 07:21:35 UTC (rev 12430)
@@ -0,0 +1 @@
+org.jboss.seam.drools.bootstrap.DroolsExtension
\ No newline at end of file
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-12 07:07:53 UTC (rev 12429)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/KBaseTest.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -8,8 +8,9 @@
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.drools.KnowledgeBaseProducer;
-import org.jboss.seam.drools.config.KnowledgeBaseConfig;
-import org.jboss.seam.drools.qualifiers.kbase.KBaseConfigured;
+import org.jboss.seam.drools.config.DroolsConfiguration;
+import org.jboss.seam.drools.qualifiers.KBaseConfigured;
+import org.jboss.seam.drools.qualifiers.config.DroolsConfig;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.Archives;
import org.jboss.shrinkwrap.api.formatter.Formatters;
@@ -25,15 +26,23 @@
public static JavaArchive createTestArchive()
{
String pkgPath = KBaseTest.class.getPackage().getName().replaceAll("\\.", "/");
- JavaArchive archive = Archives.create("test.jar", JavaArchive.class).addPackages(true, KnowledgeBaseProducer.class.getPackage()).addPackages(true, ResourceProvider.class.getPackage()).addClass(ForKBaseTest.class).addResource(pkgPath + "/kbasetest.drl", ArchivePaths.create("kbasetest.drl")).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"));
+ JavaArchive archive = Archives.create("test.jar", JavaArchive.class)
+ .addPackages(true, KnowledgeBaseProducer.class.getPackage())
+ .addPackages(true, ResourceProvider.class.getPackage())
+ .addClass(ForKBaseTest.class)
+ .addClass(MyKnowledgeBaseEventListener.class)
+ .addResource(pkgPath + "/kbasetest.drl", ArchivePaths.create("kbasetest.drl"))
+ .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));
return archive;
}
- // @Inject @Any Instance<KnowledgeBaseConfig> kbaseConfigResolver;
@Inject
@ForKBaseTest
- KnowledgeBaseConfig config;
+ DroolsConfiguration config;
+
@Inject
@ForKBaseTest
@KBaseConfigured
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/MyKnowledgeBaseEventListener.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/MyKnowledgeBaseEventListener.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/MyKnowledgeBaseEventListener.java 2010-04-12 07:21:35 UTC (rev 12430)
@@ -0,0 +1,13 @@
+package org.jboss.seam.drools.test.kbase;
+
+import org.drools.event.knowledgebase.DefaultKnowledgeBaseEventListener;
+import org.drools.event.knowledgebase.KnowledgeBaseEventListener;
+import org.jboss.seam.drools.qualifiers.KBaseEventListener;
+
+ at KBaseEventListener
+public class MyKnowledgeBaseEventListener extends DefaultKnowledgeBaseEventListener implements KnowledgeBaseEventListener
+{
+ public MyKnowledgeBaseEventListener() {
+ super();
+ }
+}
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-12 07:07:53 UTC (rev 12429)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/KBaseTest-beans.xml 2010-04-12 07:21:35 UTC (rev 12430)
@@ -4,7 +4,7 @@
xmlns:drools="urn:java:org.jboss.seam.drools:org.jboss.seam.drools.config"
xmlns:test="urn:java:org.jboss.seam.drools.test.kbase">
- <drools:KnowledgeBaseConfig>
+ <drools:DroolsConfiguration>
<s:overrides/>
<test:ForKBaseTest/>
<drools:knowledgeBuilderConfigPath>kbuilderconfig.properties</drools:knowledgeBuilderConfigPath>
@@ -12,22 +12,33 @@
<drools:ruleResources>
<s:value>classpath;kbasetest.drl;DRL</s:value>
</drools:ruleResources>
- <drools:eventListeners>
- <s:value>org.drools.event.knowledgebase.DefaultKnowledgeBaseEventListener</s:value>
- </drools:eventListeners>
- </drools:KnowledgeBaseConfig>
+ </drools:DroolsConfiguration>
<drools:KnowledgeBaseProducer>
<s:specializes/>
<drools:produceKBase>
<test:ForKBaseTest/>
<s:parameters>
- <drools:KnowledgeBaseConfig>
+ <drools:DroolsConfiguration>
<s:Inject/>
<test:ForKBaseTest/>
- </drools:KnowledgeBaseConfig>
+ </drools:DroolsConfiguration>
</s:parameters>
</drools:produceKBase>
</drools:KnowledgeBaseProducer>
-
+
+ <!--
+ WITH LATEST WELD-EXTENSION AND Instance<XYZ> zyx param in producer!
+ <drools:KnowledgeBaseProducer>
+ <s:specializes/>
+ <drools:produceKBase>
+ <test:ForKBaseTest/>
+ <s:parameters>
+ <s:Instance>
+ <s:Inject/>
+ <test:ForKBaseTest/>
+ </s:Instance>
+ </s:parameters>
+ </drools:produceKBase>
+ </drools:KnowledgeBaseProducer> -->
</beans>
More information about the seam-commits
mailing list