Author: tsurdilovic
Date: 2010-04-06 22:52:49 -0400 (Tue, 06 Apr 2010)
New Revision: 12405
Added:
modules/drools/trunk/core/
modules/drools/trunk/impl/
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExcecutionResultsProducer.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/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/annotations/
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/InsertFact.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/
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/qualifiers/
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KAgentProduced.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KSession.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/utils/
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/utils/ConfigUtils.java
modules/drools/trunk/impl/src/main/resources/META-INF/javax.enterprise.inject.spi.Extension
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/insertion/
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/ForKBaseTest.java
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/insertion/
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/insertion/InsertInterceptorTest-beans.xml
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/
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/kbaseconfig.properties
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/kbasetest.drl
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/kbuilderconfig.properties
Removed:
modules/drools/trunk/core/
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotation/InsertFact.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotation/flow/
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/events/KnowledgeSessionCreatedEvent.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifier/
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/util/
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/insertion/
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/kbase/
modules/drools/trunk/impl/src/test/resources/META-INF/beans.xml
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/insertion/
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/kbase/
Modified:
modules/drools/trunk/impl/pom.xml
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/Abort.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/SignalEvent.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/StartProcess.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/interceptor/InsertInterceptor.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/old/KnowledgeSessionManager.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KBase.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KBaseConfig.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/insertion/InsertInterceptorTest.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/insertion/InsertionBean.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/KBaseTest.java
Log:
Module Anatomy
Copied: modules/drools/trunk/impl (from rev 12376, modules/drools/trunk/core)
Modified: modules/drools/trunk/impl/pom.xml
===================================================================
--- modules/drools/trunk/core/pom.xml 2010-04-03 03:32:15 UTC (rev 12376)
+++ modules/drools/trunk/impl/pom.xml 2010-04-07 02:52:49 UTC (rev 12405)
@@ -9,10 +9,10 @@
</parent>
<groupId>org.jboss.seam.drools</groupId>
- <artifactId>seam-drools-core</artifactId>
+ <artifactId>seam-drools-impl</artifactId>
<version>3.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
- <name>Seam Drools Core</name>
+ <name>Seam Drools Module Core Implementation</name>
<repositories>
<repository>
@@ -78,7 +78,7 @@
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-extensions</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
<!-- Test Dependencies -->
<dependency>
@@ -89,7 +89,6 @@
<dependency>
<groupId>org.jboss.seam.xml</groupId>
<artifactId>seam-xml-bean-config</artifactId>
- <version>3.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -102,6 +101,13 @@
<artifactId>arquillian-weld-embedded</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <artifactId>seam-drools-api</artifactId>
+ <groupId>org.jboss.seam.drools</groupId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
Added:
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
(rev 0)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExcecutionResultsProducer.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -0,0 +1,6 @@
+package org.jboss.seam.drools;
+
+public class ExcecutionResultsProducer
+{
+
+}
Added:
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
(rev 0)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeAgentProducer.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -0,0 +1,18 @@
+package org.jboss.seam.drools;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+public class KnowledgeAgentProducer
+{
+ private static final Logger log =
LoggerFactory.getLogger(KnowledgeBaseProducer.class);
+
+ @Inject BeanManager manager;
+}
Modified:
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java 2010-04-03
03:32:15 UTC (rev 12376)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -3,6 +3,8 @@
import java.io.InputStream;
import java.util.Properties;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
@@ -21,6 +23,7 @@
import org.jboss.seam.drools.config.KnowledgeBaseConfig;
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;
@@ -36,8 +39,7 @@
@Inject BeanManager manager;
@Inject ResourceProvider resourceProvider;
- @Produces
- public KnowledgeBase produceKBase(KnowledgeBaseConfig kbaseConfig) throws Exception
+ @Produces public KnowledgeBase produceKBase(KnowledgeBaseConfig kbaseConfig) throws
Exception
{
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder(getKnowledgeBuilderConfiguration(kbaseConfig));
@@ -68,6 +70,11 @@
}
return kbase;
}
+
+ public void disposeKBase(@Disposes @Any KnowledgeBase kbase) {
+ log.info("Disposing Knowledge Base");
+ kbase = null;
+ }
private KnowledgeBuilderConfiguration
getKnowledgeBuilderConfiguration(KnowledgeBaseConfig kbaseConfig) throws Exception
{
@@ -84,6 +91,8 @@
in.close();
droolsKbuilderConfig =
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(kbuilderProp, null);
log.debug("KnowledgeBuilderConfiguration loaded: " +
kbaseConfig.getKnowledgeBuilderConfig());
+ } else {
+ log.warn("Invalid config type: " +
kbaseConfig.getKnowledgeBuilderConfig());
}
return droolsKbuilderConfig;
}
@@ -110,26 +119,26 @@
private void addResource(KnowledgeBuilder kbuilder, String resource) throws Exception
{
//TODO add support for drools templates definition!
- ResourceType resourceType =
ResourceType.getResourceType(KnowledgeBaseConfig.getResourceType(resource));
- if(KnowledgeBaseConfig.isValidResource(resource)) {
- if
(KnowledgeBaseConfig.getResourcePath(resource).equals(KnowledgeBaseConfig.RESOURCE_TYPE_URL))
+ ResourceType resourceType =
ResourceType.getResourceType(ConfigUtils.getResourceType(resource));
+ if(ConfigUtils.isValidResource(resource)) {
+ if
(ConfigUtils.getResourcePath(resource).equals(ConfigUtils.RESOURCE_TYPE_URL))
{
-
kbuilder.add(ResourceFactory.newUrlResource(KnowledgeBaseConfig.getRuleResource(resource)),
resourceType);
- manager.fireEvent(new
RuleResourceAddedEvent(KnowledgeBaseConfig.getRuleResource(resource)));
+
kbuilder.add(ResourceFactory.newUrlResource(ConfigUtils.getRuleResource(resource)),
resourceType);
+ manager.fireEvent(new
RuleResourceAddedEvent(ConfigUtils.getRuleResource(resource)));
}
- else if
(KnowledgeBaseConfig.getResourcePath(resource).equals(KnowledgeBaseConfig.RESOURCE_TYPE_FILE))
+ else if
(ConfigUtils.getResourcePath(resource).equals(ConfigUtils.RESOURCE_TYPE_FILE))
{
-
kbuilder.add(ResourceFactory.newFileResource(KnowledgeBaseConfig.getRuleResource(resource)),
resourceType);
- manager.fireEvent(new
RuleResourceAddedEvent(KnowledgeBaseConfig.getRuleResource(resource)));
+
kbuilder.add(ResourceFactory.newFileResource(ConfigUtils.getRuleResource(resource)),
resourceType);
+ manager.fireEvent(new
RuleResourceAddedEvent(ConfigUtils.getRuleResource(resource)));
}
- else if
(KnowledgeBaseConfig.getResourcePath(resource).equals(KnowledgeBaseConfig.RESOURCE_TYPE_CLASSPATH))
+ else if
(ConfigUtils.getResourcePath(resource).equals(ConfigUtils.RESOURCE_TYPE_CLASSPATH))
{
-
kbuilder.add(ResourceFactory.newClassPathResource(KnowledgeBaseConfig.getRuleResource(resource)),
resourceType);
- manager.fireEvent(new
RuleResourceAddedEvent(KnowledgeBaseConfig.getRuleResource(resource)));
+
kbuilder.add(ResourceFactory.newClassPathResource(ConfigUtils.getRuleResource(resource)),
resourceType);
+ manager.fireEvent(new
RuleResourceAddedEvent(ConfigUtils.getRuleResource(resource)));
}
else
{
- log.error("Invalid resource path: " +
KnowledgeBaseConfig.getResourcePath(resource));
+ log.error("Invalid resource path: " + ConfigUtils
.getResourcePath(resource));
}
} else {
log.error("Invalid resource definition: " + resource);
Added:
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
(rev 0)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeLoggerProducer.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -0,0 +1,56 @@
+package org.jboss.seam.drools;
+
+import java.util.Map;
+
+import java.lang.annotation.Annotation;
+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.InjectionPoint;
+
+import org.drools.event.KnowledgeRuntimeEventManager;
+import org.drools.logger.KnowledgeRuntimeLogger;
+import org.drools.logger.KnowledgeRuntimeLoggerFactory;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+public class KnowledgeLoggerProducer
+{
+ private static final String fileLoggerType = "file";
+ private static final String consoleLoggerType = "console";
+ private static final String threadedLoggerType = "threaded";
+ private static final String loggerType = "type";
+ private static final String loggerPath = "path";
+ private static final String loggerInterval = "interval";
+
+ private static final Logger log =
LoggerFactory.getLogger(KnowledgeLoggerProducer.class);
+
+
+ @Produces public KnowledgeRuntimeLogger produceKnowledgeLogger(InjectionPoint ip,
Instance<KnowledgeRuntimeEventManager> ksessionInstance, Instance<Map<String,
String>> loggerInfoInstance) {
+ KnowledgeRuntimeLogger krLogger = null;
+ KnowledgeRuntimeEventManager ksession =
ksessionInstance.select(ip.getQualifiers().toArray(new Annotation[0])).get();
+ Map<String, String> loggerInfo =
loggerInfoInstance.select(ip.getQualifiers().toArray(new Annotation[0])).get();
+ if(loggerInfo.get(loggerType).equalsIgnoreCase(fileLoggerType)) {
+ String logName = loggerInfo.get(loggerPath) + System.currentTimeMillis();
+ krLogger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, logName);
+ } else if(loggerInfo.get(loggerType).equalsIgnoreCase(consoleLoggerType)) {
+ krLogger = KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);
+ } else if(loggerInfo.get(loggerType).equalsIgnoreCase(threadedLoggerType)) {
+ String logName = loggerInfo.get(loggerPath) + System.currentTimeMillis();
+ krLogger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession,
logName, Integer.parseInt(loggerInfo.get(loggerInterval)));
+ } else {
+ log.error("Invalid logger specified: type: " +
loggerInfo.get(loggerType) + " path: " + loggerInfo.get(loggerPath) + "
loggerInfo.get(loggerInterval): " + loggerInfo.get(loggerInterval));
+ }
+ return krLogger;
+ }
+
+ public void disposeKnowledgeLogger(@Disposes KnowledgeRuntimeLogger logger) {
+ logger.close();
+ }
+}
Added:
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
(rev 0)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeSessionProducer.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -0,0 +1,118 @@
+package org.jboss.seam.drools;
+
+import java.io.InputStream;
+import java.util.Properties;
+
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.Bean;
+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.drools.runtime.process.WorkItemHandler;
+import org.jboss.seam.drools.config.KnowledgeSessionConfig;
+import org.jboss.seam.drools.utils.ConfigUtils;
+import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+public class KnowledgeSessionProducer
+{
+ private static final Logger log =
LoggerFactory.getLogger(KnowledgeSessionProducer.class);
+
+ @Inject BeanManager manager;
+ @Inject ResourceProvider resourceProvider;
+
+ @Produces public StatefulKnowledgeSession produceStatefulSession(@Any KnowledgeBase
kbase, KnowledgeSessionConfig ksessionConfig) throws Exception {
+ StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession(getConfig(ksessionConfig), null);
+ addEventListeners(ksession, ksessionConfig);
+ addWorkItemHandlers(ksession, ksessionConfig);
+
+ return ksession;
+ }
+
+ @Produces public StatelessKnowledgeSession produceStatelessSession(@Any KnowledgeBase
kbase, KnowledgeSessionConfig ksessionConfig) throws Exception {
+ StatelessKnowledgeSession ksession =
kbase.newStatelessKnowledgeSession(getConfig(ksessionConfig));
+ addEventListeners(ksession, ksessionConfig);
+
+ return ksession;
+ }
+
+ void disposeStatefulSession(@Disposes StatefulKnowledgeSession session) {
+ session.dispose();
+ }
+
+ void disposeStatelessSession(@Disposes StatelessKnowledgeSession session) {
+ session = null;
+ }
+
+ private KnowledgeSessionConfiguration getConfig(KnowledgeSessionConfig ksessionConfig)
throws Exception{
+ KnowledgeSessionConfiguration droolsKsessionConfig =
KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
+ if (ksessionConfig.getKnowledgeSessionConfig() != null &&
ksessionConfig.getKnowledgeSessionConfig().endsWith(".properties"))
+ {
+ Properties ksessionProp = new Properties();
+ //InputStream in =
this.getClass().getClassLoader().getResourceAsStream(ksessionManagerConfig.getKnowledgeSessionConfig());
+ InputStream in =
resourceProvider.loadResourceStream(ksessionConfig.getKnowledgeSessionConfig());
+ if (in == null)
+ {
+ throw new IllegalStateException("Could not locate
knowledgeSessionrConfig: " + ksessionConfig.getKnowledgeSessionConfig());
+ }
+ ksessionProp.load(in);
+ in.close();
+ droolsKsessionConfig =
KnowledgeBaseFactory.newKnowledgeSessionConfiguration(ksessionProp);
+ log.debug("KnowledgeSessionConfiguration loaded: " +
ksessionConfig.getKnowledgeSessionConfig());
+ } else {
+
+ }
+ return droolsKsessionConfig;
+ }
+
+ private void addEventListeners(KnowledgeRuntimeEventManager ksession,
KnowledgeSessionConfig ksessionConfig) throws Exception {
+ if(ksessionConfig.getEventListeners() != null) {
+ for(String eventListener : ksessionConfig.getEventListeners()) {
+ @SuppressWarnings("unchecked")
+ Class eventListenerClass = Class.forName(eventListener);
+ Object eventListenerObject = eventListenerClass.newInstance();
+ if(eventListenerObject instanceof WorkingMemoryEventListener) {
+ ksession.addEventListener((WorkingMemoryEventListener)
eventListenerObject);
+ } else if(eventListenerObject instanceof AgendaEventListener) {
+ ksession.addEventListener((AgendaEventListener) eventListenerObject);
+ } else if(eventListenerObject instanceof ProcessEventListener) {
+ ksession.addEventListener((ProcessEventListener) eventListenerObject);
+ } else {
+ log.debug("Invalid Event Listener: " + eventListener);
+ }
+ }
+ }
+ }
+
+ private void addWorkItemHandlers(StatefulKnowledgeSession ksession,
KnowledgeSessionConfig ksessionConfig) {
+ if(ksessionConfig.getWorkItemHandlers() != null) {
+ for(String workItemHandlerStr : ksessionConfig.getWorkItemHandlers()) {
+ 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);
+ }
+ }
+ }
+ }
+}
Added:
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
(rev 0)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/QueryResultsProducer.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -0,0 +1,20 @@
+package org.jboss.seam.drools;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+
+import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+public class QueryResultsProducer
+{
+ private static final Logger log =
LoggerFactory.getLogger(KnowledgeBaseProducer.class);
+
+ @Inject BeanManager manager;
+ @Inject ResourceProvider resourceProvider;
+}
Deleted:
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotation/InsertFact.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/InsertFact.java 2010-04-03
03:32:15 UTC (rev 12376)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotation/InsertFact.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -1,32 +0,0 @@
-package org.jboss.seam.drools.annotation;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.enterprise.util.Nonbinding;
-import javax.interceptor.InterceptorBinding;
-
-/**
- * Insert fact into WM or EntryPoint. Also determine firing rules decisions.
- *
- * @author Tihomir Surdilovic
- */
-@InterceptorBinding
-@Target({TYPE, METHOD})
-@Documented
-@Retention(RUNTIME)
-@Inherited
-public @interface InsertFact
-{
- @Nonbinding int ksessionId() default -1;
- @Nonbinding boolean fireAllRules() default false;
- @Nonbinding int fireCount() default -1;
- @Nonbinding boolean fireUntilHalt() default false;
- @Nonbinding String entryPointName() default "";
-}
Copied:
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/InsertFact.java
(from rev 12376,
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/InsertFact.java)
===================================================================
---
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/InsertFact.java
(rev 0)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/InsertFact.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -0,0 +1,32 @@
+package org.jboss.seam.drools.annotations;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.util.Nonbinding;
+import javax.interceptor.InterceptorBinding;
+
+/**
+ * Insert fact into WM or EntryPoint. Also determine firing rules decisions.
+ *
+ * @author Tihomir Surdilovic
+ */
+@InterceptorBinding
+@Target({TYPE, METHOD})
+@Documented
+@Retention(RUNTIME)
+@Inherited
+public @interface InsertFact
+{
+ @Nonbinding int ksessionId() default -1;
+ @Nonbinding boolean fireAllRules() default false;
+ @Nonbinding int fireCount() default -1;
+ @Nonbinding boolean fireUntilHalt() default false;
+ @Nonbinding String entryPointName() default "";
+}
Copied: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow
(from rev 12376,
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/flow)
Modified:
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/Abort.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/flow/Abort.java 2010-04-03
03:32:15 UTC (rev 12376)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/Abort.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -1,4 +1,4 @@
-package org.jboss.seam.drools.annotation.flow;
+package org.jboss.seam.drools.annotations.flow;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
Modified:
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/SignalEvent.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/flow/SignalEvent.java 2010-04-03
03:32:15 UTC (rev 12376)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/SignalEvent.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -1,4 +1,4 @@
-package org.jboss.seam.drools.annotation.flow;
+package org.jboss.seam.drools.annotations.flow;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
Modified:
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/StartProcess.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/annotation/flow/StartProcess.java 2010-04-03
03:32:15 UTC (rev 12376)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/StartProcess.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -1,4 +1,4 @@
-package org.jboss.seam.drools.annotation.flow;
+package org.jboss.seam.drools.annotations.flow;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.ElementType.METHOD;
Modified:
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeBaseConfig.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/config/KnowledgeBaseConfig.java 2010-04-03
03:32:15 UTC (rev 12376)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeBaseConfig.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -1,67 +1,15 @@
package org.jboss.seam.drools.config;
-import java.util.regex.Pattern;
-
/**
*
* @author Tihomir Surdilovic
*/
public class KnowledgeBaseConfig
-{
- 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) {
- 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 String knowledgeBuilderConfig;
private String knowledgeBaseConfig;
private String[] ruleResources;
private String[] eventListeners;
-
- public String toString() {
- StringBuffer buff = new StringBuffer();
- buff.append("knowledgeBuilderConfig: " + getKnowledgeBuilderConfig() +
"\n")
- .append("knowledgeBaseConfig: " + getKnowledgeBaseConfig() +
"\n")
- .append("Rule Resources:\n");
- for(String rr : getRuleResources()) {
- buff.append("\t" + rr);
- }
- buff.append("\nEvent Listeners: \n");
- for(String el : getEventListeners()) {
- buff.append("\t" + el);
- }
-
- return buff.toString();
- }
public String getKnowledgeBuilderConfig()
{
@@ -102,4 +50,28 @@
{
this.eventListeners = eventListeners;
}
+
+ public String toString()
+ {
+ StringBuffer buff = new StringBuffer();
+ buff.append("knowledgeBuilderConfig: " + knowledgeBuilderConfig +
"\n").append("knowledgeBaseConfig: " + knowledgeBaseConfig +
"\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();
+ }
}
Added:
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
(rev 0)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeSessionConfig.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -0,0 +1,65 @@
+package org.jboss.seam.drools.config;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+public class KnowledgeSessionConfig
+{
+ private String[] eventListeners;
+ private String[] workItemHandlers;
+ private String knowledgeSessionConfig;
+
+ 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 getKnowledgeSessionConfig()
+ {
+ return knowledgeSessionConfig;
+ }
+
+ public void setKnowledgeSessionConfig(String knowledgeSessionConfig)
+ {
+ this.knowledgeSessionConfig = knowledgeSessionConfig;
+ }
+
+ public String toString()
+ {
+ StringBuffer buff = new StringBuffer();
+ buff.append("knowledgeSessionConfig: " + knowledgeSessionConfig +
"\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();
+ }
+}
Deleted:
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/events/KnowledgeSessionCreatedEvent.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/events/KnowledgeSessionCreatedEvent.java 2010-04-03
03:32:15 UTC (rev 12376)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/events/KnowledgeSessionCreatedEvent.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -1,26 +0,0 @@
-package org.jboss.seam.drools.events;
-
-/**
- * This event is fires when Stateful or Stateless KnowledgeSession is created.
- *
- * @author Tihomir Surdilovic
- */
-public class KnowledgeSessionCreatedEvent
-{
- private int sessionId;
-
- public KnowledgeSessionCreatedEvent(int sessionId) {
- this.sessionId = sessionId;
- }
-
- public int getSessionId()
- {
- return sessionId;
- }
-
- public void setSessionId(int sessionId)
- {
- this.sessionId = sessionId;
- }
-
-}
Modified:
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertInterceptor.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/interceptor/InsertInterceptor.java 2010-04-03
03:32:15 UTC (rev 12376)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertInterceptor.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -4,7 +4,7 @@
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;
-import org.jboss.seam.drools.annotation.InsertFact;
+import org.jboss.seam.drools.annotations.InsertFact;
@InsertFact @Interceptor
public class InsertInterceptor
Modified:
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/old/KnowledgeSessionManager.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/old/KnowledgeSessionManager.java 2010-04-03
03:32:15 UTC (rev 12376)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/old/KnowledgeSessionManager.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -28,7 +28,7 @@
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.StatelessKnowledgeSession;
import org.drools.runtime.process.WorkItemHandler;
-import org.jboss.seam.drools.events.KnowledgeSessionCreatedEvent;
+//import org.jboss.seam.drools.events.KnowledgeSessionCreatedEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Copied: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers (from rev
12376, modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/qualifier)
Added:
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KAgentProduced.java
===================================================================
---
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KAgentProduced.java
(rev 0)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KAgentProduced.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -0,0 +1,28 @@
+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 produced by the KnowledgeAgent.
+ * @author Tihomir Surdilovic
+ */
+@Qualifier
+@Target({TYPE, METHOD, FIELD, PARAMETER})
+@Documented
+@Retention(RUNTIME)
+@Inherited
+public @interface KAgentProduced
+{
+
+}
Modified:
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KBase.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/qualifier/KBase.java 2010-04-03
03:32:15 UTC (rev 12376)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KBase.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -1,4 +1,4 @@
-package org.jboss.seam.drools.qualifier;
+package org.jboss.seam.drools.qualifiers;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.FIELD;
@@ -13,6 +13,10 @@
import javax.inject.Qualifier;
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
@Qualifier
@Target({TYPE, METHOD, FIELD, PARAMETER})
@Documented
Modified:
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KBaseConfig.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/qualifier/KBaseConfig.java 2010-04-03
03:32:15 UTC (rev 12376)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KBaseConfig.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -1,4 +1,4 @@
-package org.jboss.seam.drools.qualifier;
+package org.jboss.seam.drools.qualifiers;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
@@ -13,6 +13,10 @@
import javax.inject.Qualifier;
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
@Qualifier
@Target({TYPE, METHOD, FIELD, PARAMETER})
@Documented
Added:
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KSession.java
===================================================================
---
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KSession.java
(rev 0)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KSession.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -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.inject.Qualifier;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+@Qualifier
+@Target({TYPE, METHOD, FIELD, PARAMETER})
+@Documented
+@Retention(RUNTIME)
+@Inherited
+public @interface KSession
+{
+ String value() default "";
+}
Copied: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/utils (from rev
12376, modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/util)
Added:
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
(rev 0)
+++
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/utils/ConfigUtils.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -0,0 +1,73 @@
+package org.jboss.seam.drools.utils;
+
+import java.util.regex.Pattern;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+public class ConfigUtils
+{
+ private static final Pattern DIVIDER = Pattern.compile(":");
+ // KBase config
+ 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)
+ {
+ 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];
+ }
+
+ // KSession config
+ 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;
+ }
+
+ // KAgent config
+
+}
Added:
modules/drools/trunk/impl/src/main/resources/META-INF/javax.enterprise.inject.spi.Extension
===================================================================
Copied: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/insertion (from
rev 12376, modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/insertion)
Modified:
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/insertion/InsertInterceptorTest.java
===================================================================
---
modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/insertion/InsertInterceptorTest.java 2010-04-03
03:32:15 UTC (rev 12376)
+++
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/insertion/InsertInterceptorTest.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -1,4 +1,4 @@
-package org.jboss.seam.drools.insertion;
+package org.jboss.seam.drools.test.insertion;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
@@ -10,6 +10,7 @@
import org.jboss.seam.drools.interceptor.InsertInterceptor;
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.junit.Test;
import org.junit.runner.RunWith;
@@ -20,7 +21,12 @@
@Deployment
public static JavaArchive createTestArchive()
{
- return Archives.create("test.jar",
JavaArchive.class).addClasses(InsertInterceptor.class,
InsertionBean.class).addManifestResource(InsertInterceptorTest.class.getPackage().getName().replaceAll("\\.",
"/") + "/InsertInterceptorTest-beans.xml",
ArchivePaths.create("beans.xml"));
+ String pkgPath =
InsertInterceptorTest.class.getPackage().getName().replaceAll("\\.",
"/");
+ JavaArchive archive = Archives.create("test.jar", JavaArchive.class)
+ .addClasses(InsertInterceptor.class, InsertionBean.class)
+ .addManifestResource(pkgPath + "/InsertInterceptorTest-beans.xml",
ArchivePaths.create("beans.xml"));
+ System.out.println(archive.toString(Formatters.VERBOSE));
+ return archive;
}
@Inject InsertionBean insertionBean;
Modified:
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/insertion/InsertionBean.java
===================================================================
---
modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/insertion/InsertionBean.java 2010-04-03
03:32:15 UTC (rev 12376)
+++
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/insertion/InsertionBean.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -1,6 +1,6 @@
-package org.jboss.seam.drools.insertion;
+package org.jboss.seam.drools.test.insertion;
-import org.jboss.seam.drools.annotation.InsertFact;
+import org.jboss.seam.drools.annotations.InsertFact;
public class InsertionBean
{
Copied: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase (from rev
12376, modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/kbase)
Added:
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/ForKBaseTest.java
===================================================================
---
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/ForKBaseTest.java
(rev 0)
+++
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/ForKBaseTest.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -0,0 +1,25 @@
+package org.jboss.seam.drools.test.kbase;
+
+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.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({TYPE, METHOD, FIELD, PARAMETER})
+@Documented
+@Retention(RUNTIME)
+@Inherited
+public @interface ForKBaseTest
+{
+
+}
Modified:
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/KBaseTest.java
===================================================================
---
modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/kbase/KBaseTest.java 2010-04-03
03:32:15 UTC (rev 12376)
+++
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/KBaseTest.java 2010-04-07
02:52:49 UTC (rev 12405)
@@ -1,4 +1,4 @@
-package org.jboss.seam.drools.kbase;
+package org.jboss.seam.drools.test.kbase;
import javax.enterprise.inject.Any;
import javax.enterprise.inject.Instance;
@@ -13,8 +13,8 @@
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.drools.KnowledgeBaseProducer;
import org.jboss.seam.drools.config.KnowledgeBaseConfig;
-import org.jboss.seam.drools.qualifier.KBase;
-import org.jboss.seam.drools.qualifier.KBaseConfig;
+import org.jboss.seam.drools.qualifiers.KBase;
+import org.jboss.seam.drools.qualifiers.KBaseConfig;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.Archives;
import org.jboss.shrinkwrap.api.formatter.Formatters;
@@ -33,6 +33,7 @@
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"))
@@ -41,34 +42,35 @@
return archive;
}
- @Inject @Any Instance<KnowledgeBaseConfig> kbaseConfigResolver;
- @Inject @KBaseConfig("kbaseconfig1") KnowledgeBaseConfig config;
+ //@Inject @Any Instance<KnowledgeBaseConfig> kbaseConfigResolver;
+ @Inject @ForKBaseTest KnowledgeBaseConfig config;
+ @Inject @ForKBaseTest KnowledgeBase kbase;
- @Inject @KBase("kbase1") KnowledgeBase kbase;
-
@Test
public void testKBaseConfig() {
- Assert.assertFalse(kbaseConfigResolver.select(new
KBaseConfigBinding("kbaseconfig1")).isUnsatisfied());
- KnowledgeBaseConfig kbaseConfig = kbaseConfigResolver.select(new
KBaseConfigBinding("kbaseconfig1")).get();
- assertNotNull(kbaseConfig);
- System.out.println("\n\n\n**** " + kbaseConfig.toString() +
"********\n\n\n");
+ System.out.println("*********** GOT HERE!");
+ //Assert.assertFalse(kbaseConfigResolver.select(new
KBaseConfigBinding("kbaseconfig1")).isUnsatisfied());
+ //KnowledgeBaseConfig kbaseConfig = kbaseConfigResolver.select(new
KBaseConfigBinding("kbaseconfig1")).get();
+ assertNotNull(config);
+ System.out.println("\n\n\n**** " + config.toString() +
"********\n\n\n");
}
@Test
public void testKBase() {
assertNotNull(kbase);
+ System.out.println("KBASE: " + kbase.toString());
}
- static class KBaseConfigBinding extends AnnotationLiteral<KBaseConfig>
implements KBaseConfig
- {
- private String value = null;
- public KBaseConfigBinding(String value)
- {
- this.value = value;
- }
-
- public String value() {
- return value;
- }
- }
+// static class KBaseConfigBinding extends AnnotationLiteral<ForKBaseTest>
implements KBaseConfig
+// {
+// private String value = null;
+// public KBaseConfigBinding(String value)
+// {
+// this.value = value;
+// }
+//
+// public String value() {
+// return value;
+// }
+// }
}
Deleted: modules/drools/trunk/impl/src/test/resources/META-INF/beans.xml
===================================================================
--- modules/drools/trunk/core/src/test/resources/META-INF/beans.xml 2010-04-03 03:32:15
UTC (rev 12376)
+++ modules/drools/trunk/impl/src/test/resources/META-INF/beans.xml 2010-04-07 02:52:49
UTC (rev 12405)
@@ -1,38 +0,0 @@
-<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:drools="urn:java:org.jboss.seam.drools:org.jboss.seam.drools.config"
- xmlns:drools-qualifier="urn:java:org.jboss.seam.drools.qualifier"
- xmlns:drools-test="urn:java:org.jboss.seam.drools.kbase">
-
- <drools:KnowledgeBaseConfig>
- <s:overrides/>
- <drools-qualifier:KBaseConfig value="kbaseconfig1" />
- <drools:knowledgeBuilderConfig>
- <s:value>/kbuilderconfig.properties</s:value>
- </drools:knowledgeBuilderConfig>
- <drools:knowledgeBaseConfig>
- <s:value>/kbaseconfig.properties</s:value>
- </drools:knowledgeBaseConfig>
- <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:KnowledgeBaseProducer>
- <s:specializes />
- <drools:produceKBase>
- <drools-qualifier:KBase value="kbase1" />
- <s:parameters>
- <drools:KnowledgeBaseConfig>
- <s:Inject />
- <drools-qualifier:KBaseConfig value="kbaseconfig1" />
- </drools:KnowledgeBaseConfig>
- </s:parameters>
- </drools:produceKBase>
- </drools:KnowledgeBaseProducer>
-
-</beans>
\ No newline at end of file
Copied:
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/insertion/InsertInterceptorTest-beans.xml
(from rev 12376,
modules/drools/trunk/core/src/test/resources/org/jboss/seam/drools/insertion/InsertInterceptorTest-beans.xml)
===================================================================
---
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/insertion/InsertInterceptorTest-beans.xml
(rev 0)
+++
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/insertion/InsertInterceptorTest-beans.xml 2010-04-07
02:52:49 UTC (rev 12405)
@@ -0,0 +1,10 @@
+<beans
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+
http://java.sun.com/xml/ns/javaee
+
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+
+ <interceptors>
+ <class>org.jboss.seam.drools.interceptor.InsertInterceptor</class>
+ </interceptors>
+
+</beans>
\ No newline at end of file
Copied:
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/KBaseTest-beans.xml
(from rev 12376,
modules/drools/trunk/core/src/test/resources/org/jboss/seam/drools/kbase/KBaseTest-beans.xml)
===================================================================
---
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/KBaseTest-beans.xml
(rev 0)
+++
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/KBaseTest-beans.xml 2010-04-07
02:52:49 UTC (rev 12405)
@@ -0,0 +1,33 @@
+<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:drools="urn:java:org.jboss.seam.drools:org.jboss.seam.drools.config"
+ xmlns:test="urn:java:org.jboss.seam.drools.test.kbase">
+
+ <drools:KnowledgeBaseConfig>
+ <s:overrides/>
+ <test:ForKBaseTest/>
+
<drools:knowledgeBuilderConfig>kbuilderconfig.properties</drools:knowledgeBuilderConfig>
+
<drools:knowledgeBaseConfig>kbaseconfig.properties</drools:knowledgeBaseConfig>
+ <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:KnowledgeBaseProducer>
+ <s:specializes/>
+ <drools:produceKBase>
+ <test:ForKBaseTest/>
+ <s:parameters>
+ <drools:KnowledgeBaseConfig>
+ <s:Inject/>
+ <test:ForKBaseTest/>
+ </drools:KnowledgeBaseConfig>
+ </s:parameters>
+ </drools:produceKBase>
+ </drools:KnowledgeBaseProducer>
+
+</beans>
Copied:
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/kbaseconfig.properties
(from rev 12376,
modules/drools/trunk/core/src/test/resources/org/jboss/seam/drools/kbase/kbaseconfig.properties)
===================================================================
Copied:
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/kbasetest.drl
(from rev 12376,
modules/drools/trunk/core/src/test/resources/org/jboss/seam/drools/kbase/kbasetest.drl)
===================================================================
---
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/kbasetest.drl
(rev 0)
+++
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/kbasetest.drl 2010-04-07
02:52:49 UTC (rev 12405)
@@ -0,0 +1,6 @@
+package org.jboss.seam.drools.kbase
+
+rule "dummy"
+ then
+ System.out.println("in dummy action");
+end
Copied:
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/kbuilderconfig.properties
(from rev 12376,
modules/drools/trunk/core/src/test/resources/org/jboss/seam/drools/kbase/kbuilderconfig.properties)
===================================================================