[seam-commits] Seam SVN: r12427 - in modules/drools/trunk: api/src/main/java/org/jboss/seam/drools and 18 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Sun Apr 11 03:32:04 EDT 2010
Author: tsurdilovic
Date: 2010-04-11 03:32:02 -0400 (Sun, 11 Apr 2010)
New Revision: 12427
Added:
modules/drools/trunk/.settings/
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/annotations/
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/events/
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/events/KnowledgeBuilderErrorsEvent.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/events/RuleResourceAddedEvent.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/bootstrap/
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/config/KnowledgeAgentConfig.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/qualifiers/config/
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/kbase/
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/kbase/KAgentConfigured.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/kbase/KBaseConfigured.java
modules/drools/trunk/impl/src/main/resources/META-INF/services/
modules/drools/trunk/impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
Removed:
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotation/
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/events/
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/KBase.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KBaseConfig.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KSession.java
modules/drools/trunk/impl/src/main/resources/META-INF/javax.enterprise.inject.spi.Extension
Modified:
modules/drools/trunk/impl/pom.xml
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeAgentProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeLoggerProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeSessionProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/QueryResultsProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/InsertFact.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/config/KnowledgeSessionConfig.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/FactProvider.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/old/KnowledgeBaseManager.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/old/KnowledgeBaseManagerConfig.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/old/KnowledgeSessionManagerConfig.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/utils/ConfigUtils.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/ForKBaseTest.java
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:
added support for knowledge agent and minor configuration changes.
Added: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/events/KnowledgeBuilderErrorsEvent.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/events/KnowledgeBuilderErrorsEvent.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/events/KnowledgeBuilderErrorsEvent.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -0,0 +1,29 @@
+package org.jboss.seam.drools.events;
+
+import org.drools.builder.KnowledgeBuilderErrors;
+
+/**
+ * This event is fires in case of KnowledgeBuilder errors.
+ *
+ * @author Tihomir Surdilovic
+ */
+public class KnowledgeBuilderErrorsEvent
+{
+ private KnowledgeBuilderErrors errors;
+
+ public KnowledgeBuilderErrorsEvent(KnowledgeBuilderErrors errors)
+ {
+ this.errors = errors;
+ }
+
+ public KnowledgeBuilderErrors getErrors()
+ {
+ return errors;
+ }
+
+ public void setErrors(KnowledgeBuilderErrors errors)
+ {
+ this.errors = errors;
+ }
+
+}
Added: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/events/RuleResourceAddedEvent.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/events/RuleResourceAddedEvent.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/events/RuleResourceAddedEvent.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -0,0 +1,26 @@
+package org.jboss.seam.drools.events;
+
+/**
+ * This event is fires when a rule resource is added.
+ *
+ * @author Tihomir Surdilovic
+ */
+public class RuleResourceAddedEvent
+{
+ String resource;
+
+ public RuleResourceAddedEvent(String resource)
+ {
+ this.resource = resource;
+ }
+
+ public String getResource()
+ {
+ return resource;
+ }
+
+ public void setResource(String resource)
+ {
+ this.resource = resource;
+ }
+}
Modified: modules/drools/trunk/impl/pom.xml
===================================================================
--- modules/drools/trunk/impl/pom.xml 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/pom.xml 2010-04-11 07:32:02 UTC (rev 12427)
@@ -89,7 +89,8 @@
<dependency>
<groupId>org.jboss.seam.xml</groupId>
<artifactId>seam-xml-bean-config</artifactId>
- <scope>test</scope>
+ <!-- TODO change back to test scope after we figure out what to do w/ @XmlConfigured -->
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian</groupId>
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-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeAgentProducer.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -1,8 +1,24 @@
package org.jboss.seam.drools;
+import java.util.Properties;
+
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
+import org.drools.KnowledgeBase;
+import org.drools.agent.KnowledgeAgent;
+import org.drools.agent.KnowledgeAgentConfiguration;
+import org.drools.agent.KnowledgeAgentFactory;
+import org.drools.builder.ResourceType;
+import org.drools.io.ResourceChangeScannerConfiguration;
+import org.drools.io.ResourceFactory;
+import org.jboss.seam.drools.config.KnowledgeAgentConfig;
+import org.jboss.seam.drools.events.RuleResourceAddedEvent;
+import org.jboss.seam.drools.qualifiers.kbase.KAgentConfigured;
+import org.jboss.seam.drools.utils.ConfigUtils;
+import org.jboss.weld.extensions.resources.ResourceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -12,7 +28,107 @@
*/
public class KnowledgeAgentProducer
{
- private static final Logger log = LoggerFactory.getLogger(KnowledgeBaseProducer.class);
+ private static final Logger log = LoggerFactory.getLogger(KnowledgeAgentProducer.class);
+
+ @Inject
+ BeanManager manager;
+ @Inject
+ ResourceProvider resourceProvider;
+
+ @Produces
+ @KAgentConfigured
+ KnowledgeBase produceAgentKBase(KnowledgeAgentConfig kagentConfig) throws Exception
+ {
+ ResourceFactory.getResourceChangeScannerService().configure(getResourceChangeScannerConfig(kagentConfig.getResourceChangeScannerConfigPath()));
+ KnowledgeAgentConfiguration aconf = getKnowledgeAgentConfiguration(kagentConfig.getKnowledgeAgentConfigPath());
+
+ KnowledgeAgent kagent;
+ kagent = KnowledgeAgentFactory.newKnowledgeAgent(kagentConfig.getName(), aconf);
+ applyChangeSet(kagent, kagentConfig.getChangeSetResource());
+
+ if(kagentConfig.isStartChangeNotifierService()) {
+ ResourceFactory.getResourceChangeNotifierService().start();
+ }
+ if(kagentConfig.isStartChangeScannerService()) {
+ ResourceFactory.getResourceChangeScannerService().start();
+ }
+
+ return kagent.getKnowledgeBase();
+
+ }
- @Inject BeanManager manager;
+ public void disposeAgentKBase(@Disposes @KAgentConfigured KnowledgeBase kbase) {
+ ResourceFactory.getResourceChangeNotifierService().stop();
+ ResourceFactory.getResourceChangeScannerService().stop();
+ }
+
+ private void applyChangeSet(KnowledgeAgent kagent, String changeSetResource) {
+ if (ConfigUtils.isValidResource(changeSetResource))
+ {
+ ResourceType resourceType = ResourceType.getResourceType(ConfigUtils.getResourceType(changeSetResource));
+ if(resourceType.equals(ResourceType.CHANGE_SET)) {
+ if (ConfigUtils.getResourcePath(changeSetResource).equals(ConfigUtils.RESOURCE_TYPE_URL))
+ {
+ kagent.applyChangeSet(ResourceFactory.newUrlResource(ConfigUtils.getRuleResource(changeSetResource)));
+ manager.fireEvent(new RuleResourceAddedEvent(ConfigUtils.getRuleResource(changeSetResource)));
+ }
+ else if (ConfigUtils.getResourcePath(changeSetResource).equals(ConfigUtils.RESOURCE_TYPE_FILE))
+ {
+ kagent.applyChangeSet(ResourceFactory.newFileResource(ConfigUtils.getRuleResource(changeSetResource)));
+ manager.fireEvent(new RuleResourceAddedEvent(ConfigUtils.getRuleResource(changeSetResource)));
+ }
+ else if (ConfigUtils.getResourcePath(changeSetResource).equals(ConfigUtils.RESOURCE_TYPE_CLASSPATH))
+ {
+ kagent.applyChangeSet(ResourceFactory.newClassPathResource(ConfigUtils.getRuleResource(changeSetResource)));
+ manager.fireEvent(new RuleResourceAddedEvent(ConfigUtils.getRuleResource(changeSetResource)));
+ }
+ else
+ {
+ log.error("Invalid resource: " + ConfigUtils.getResourcePath(changeSetResource));
+ }
+ } else {
+ log.error("Resource must be of type CHANGE_SET");
+ }
+ } else {
+ log.error("Invalid resource definition: " + changeSetResource);
+ }
+
+
+ }
+
+ private ResourceChangeScannerConfiguration getResourceChangeScannerConfig(String resourceChangeScannerConfigPath) throws Exception
+ {
+ ResourceChangeScannerConfiguration sconf = ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
+
+ if (resourceChangeScannerConfigPath != null && resourceChangeScannerConfigPath.endsWith(".properties"))
+ {
+ Properties resourceChangeScannerConfProp = ConfigUtils.loadProperties(resourceProvider, resourceChangeScannerConfigPath);
+ sconf = ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration(resourceChangeScannerConfProp);
+ log.debug("ResourceChangeScannerConfiguration loaded: " + resourceChangeScannerConfigPath);
+ }
+ else
+ {
+ log.warn("Invalid config type: " + resourceChangeScannerConfigPath);
+ }
+
+ return sconf;
+ }
+
+ private KnowledgeAgentConfiguration getKnowledgeAgentConfiguration(String knowledgeAgentConfigPath) throws Exception
+ {
+ KnowledgeAgentConfiguration aconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
+
+ if (knowledgeAgentConfigPath != null && knowledgeAgentConfigPath.endsWith(".properties"))
+ {
+ Properties knowledgeAgentConfProp = ConfigUtils.loadProperties(resourceProvider, knowledgeAgentConfigPath);
+ aconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration(knowledgeAgentConfProp);
+ log.debug("KnowledgeAgentConfiguration loaded: " + knowledgeAgentConfigPath);
+ }
+ else
+ {
+ log.warn("Invalid config type: " + knowledgeAgentConfigPath);
+ }
+
+ return aconf;
+ }
}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -1,10 +1,7 @@
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.BeanManager;
import javax.inject.Inject;
@@ -23,6 +20,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.qualifiers.kbase.KBaseConfigured;
import org.jboss.seam.drools.utils.ConfigUtils;
import org.jboss.weld.extensions.resources.ResourceProvider;
import org.slf4j.Logger;
@@ -35,19 +33,22 @@
public class KnowledgeBaseProducer
{
private static final Logger log = LoggerFactory.getLogger(KnowledgeBaseProducer.class);
-
- @Inject BeanManager manager;
- @Inject ResourceProvider resourceProvider;
-
- @Produces public KnowledgeBase produceKBase(KnowledgeBaseConfig kbaseConfig) throws Exception
+
+ @Inject
+ BeanManager manager;
+ @Inject
+ ResourceProvider resourceProvider;
+
+ @Produces @KBaseConfigured
+ public KnowledgeBase produceKBase(KnowledgeBaseConfig kbaseConfig) throws Exception
{
- KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(getKnowledgeBuilderConfiguration(kbaseConfig));
-
+ KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(getKnowledgeBuilderConfiguration(kbaseConfig.getKnowledgeBuilderConfigPath()));
+
for (String nextResource : kbaseConfig.getRuleResources())
{
addResource(kbuilder, nextResource);
}
-
+
KnowledgeBuilderErrors kbuildererrors = kbuilder.getErrors();
if (kbuildererrors.size() > 0)
{
@@ -57,8 +58,8 @@
}
manager.fireEvent(new KnowledgeBuilderErrorsEvent(kbuildererrors));
}
-
- KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(getKnowledgeBaseConfiguration(kbaseConfig));
+
+ KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(getKnowledgeBaseConfiguration(kbaseConfig.getKnowledgeBaseConfigPath()));
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
if (kbaseConfig.getEventListeners() != null)
@@ -70,57 +71,42 @@
}
return kbase;
}
-
- public void disposeKBase(@Disposes @Any KnowledgeBase kbase) {
- log.info("Disposing Knowledge Base");
- kbase = null;
- }
- private KnowledgeBuilderConfiguration getKnowledgeBuilderConfiguration(KnowledgeBaseConfig kbaseConfig) throws Exception
+ private KnowledgeBuilderConfiguration getKnowledgeBuilderConfiguration(String knowledgeBuilderConfigPath) throws Exception
{
- KnowledgeBuilderConfiguration droolsKbuilderConfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
- if (kbaseConfig.getKnowledgeBuilderConfig() != null && kbaseConfig.getKnowledgeBuilderConfig().endsWith(".properties"))
+ KnowledgeBuilderConfiguration droolsKbuilderConfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
+ if (knowledgeBuilderConfigPath != null && knowledgeBuilderConfigPath.endsWith(".properties"))
{
- Properties kbuilderProp = new Properties();
- InputStream in = resourceProvider.loadResourceStream(kbaseConfig.getKnowledgeBuilderConfig());
- if (in == null)
- {
- throw new IllegalStateException("Could not locate knowledgeBuilderConfig: " + kbaseConfig.getKnowledgeBuilderConfig());
- }
- kbuilderProp.load(in);
- in.close();
+
+ Properties kbuilderProp = ConfigUtils.loadProperties(resourceProvider, knowledgeBuilderConfigPath);
droolsKbuilderConfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(kbuilderProp, null);
- log.debug("KnowledgeBuilderConfiguration loaded: " + kbaseConfig.getKnowledgeBuilderConfig());
- } else {
- log.warn("Invalid config type: " + kbaseConfig.getKnowledgeBuilderConfig());
+ log.debug("KnowledgeBuilderConfiguration loaded: " + knowledgeBuilderConfigPath);
}
+ else
+ {
+ log.warn("Invalid config type: " + knowledgeBuilderConfigPath);
+ }
return droolsKbuilderConfig;
}
-
- public KnowledgeBaseConfiguration getKnowledgeBaseConfiguration(KnowledgeBaseConfig kbaseConfig) throws Exception
+
+ public KnowledgeBaseConfiguration getKnowledgeBaseConfiguration(String knowledgeBaseConfigPath) throws Exception
{
KnowledgeBaseConfiguration droolsKbaseConfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
- if (kbaseConfig.getKnowledgeBaseConfig() != null && kbaseConfig.getKnowledgeBaseConfig().endsWith(".properties"))
+ if (knowledgeBaseConfigPath != null && knowledgeBaseConfigPath.endsWith(".properties"))
{
- Properties kbaseProp = new Properties();
- InputStream in = resourceProvider.loadResourceStream(kbaseConfig.getKnowledgeBaseConfig());
- if (in == null)
- {
- throw new IllegalStateException("Could not locate knowledgeBaseConfig: " + kbaseConfig.getKnowledgeBaseConfig());
- }
- kbaseProp.load(in);
- in.close();
+ Properties kbaseProp = ConfigUtils.loadProperties(resourceProvider, knowledgeBaseConfigPath);
droolsKbaseConfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(kbaseProp, null);
- log.debug("KnowledgeBaseConfiguration loaded: " + kbaseConfig.getKnowledgeBaseConfig());
+ log.debug("KnowledgeBaseConfiguration loaded: " + knowledgeBaseConfigPath);
}
return droolsKbaseConfig;
}
-
+
private void addResource(KnowledgeBuilder kbuilder, String resource) throws Exception
{
- //TODO add support for drools templates definition!
- ResourceType resourceType = ResourceType.getResourceType(ConfigUtils.getResourceType(resource));
- if(ConfigUtils.isValidResource(resource)) {
+ // TODO add support for drools templates definition!
+ if (ConfigUtils.isValidResource(resource))
+ {
+ ResourceType resourceType = ResourceType.getResourceType(ConfigUtils.getResourceType(resource));
if (ConfigUtils.getResourcePath(resource).equals(ConfigUtils.RESOURCE_TYPE_URL))
{
kbuilder.add(ResourceFactory.newUrlResource(ConfigUtils.getRuleResource(resource)), resourceType);
@@ -138,25 +124,34 @@
}
else
{
- log.error("Invalid resource path: " + ConfigUtils .getResourcePath(resource));
+ log.error("Invalid resource: " + ConfigUtils.getResourcePath(resource));
}
- } else {
+ }
+ else
+ {
log.error("Invalid resource definition: " + resource);
}
}
-
- private void addEventListener(org.drools.KnowledgeBase kbase, String eventListener) {
- try {
+
+ private void addEventListener(org.drools.KnowledgeBase kbase, String eventListener)
+ {
+ try
+ {
@SuppressWarnings("unchecked")
Class eventListenerClass = Class.forName(eventListener);
Object eventListenerObject = eventListenerClass.newInstance();
-
- if(eventListenerObject instanceof KnowledgeBaseEventListener) {
+
+ if (eventListenerObject instanceof KnowledgeBaseEventListener)
+ {
kbase.addEventListener((KnowledgeBaseEventListener) eventListenerObject);
- } else {
+ }
+ else
+ {
log.debug("Event Listener " + eventListener + " is not of type KnowledgeBaseEventListener");
}
- } catch(Exception e) {
+ }
+ catch (Exception e)
+ {
log.error("Error adding event listener " + e.getMessage());
}
}
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-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeLoggerProducer.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -1,18 +1,17 @@
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.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.xml.annotations.XmlConfigured;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -22,35 +21,58 @@
*/
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 produceStatefulKnowledgeLogger(@KBaseConfigured StatefulKnowledgeSession ksession, KnowledgeLoggerConfig loggerConfig)
+ {
+ return getLogger(ksession, loggerConfig);
+ }
+ @Produces
+ public KnowledgeRuntimeLogger produceStatefulKnowledgeLoggerForKAgent(@KAgentConfigured StatefulKnowledgeSession ksession, KnowledgeLoggerConfig loggerConfig)
+ {
+ return getLogger(ksession, loggerConfig);
+ }
+
+ @Produces
+ public KnowledgeRuntimeLogger produceStatelessKnowledgeLogger(@KBaseConfigured StatelessKnowledgeSession ksession, KnowledgeLoggerConfig loggerConfig)
+ {
+ return getLogger(ksession, loggerConfig);
+ }
- @Produces public KnowledgeRuntimeLogger produceKnowledgeLogger(InjectionPoint ip, Instance<KnowledgeRuntimeEventManager> ksessionInstance, Instance<Map<String, String>> loggerInfoInstance) {
+ @Produces
+ public KnowledgeRuntimeLogger produceStatelessKnowledgeLoggerForKAgent(@KAgentConfigured StatelessKnowledgeSession ksession, KnowledgeLoggerConfig loggerConfig)
+ {
+ return getLogger(ksession, loggerConfig);
+ }
+
+ private KnowledgeRuntimeLogger getLogger(KnowledgeRuntimeEventManager ksession, KnowledgeLoggerConfig loggerConfig)
+ {
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();
+ if (loggerConfig.isFileType())
+ {
+ String logName = loggerConfig.getPath() + System.currentTimeMillis();
krLogger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, logName);
- } else if(loggerInfo.get(loggerType).equalsIgnoreCase(consoleLoggerType)) {
+ }
+ else if (loggerConfig.isConsoleType())
+ {
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));
}
+ else if (loggerConfig.isThreadedType())
+ {
+ String logName = loggerConfig.getPath() + System.currentTimeMillis();
+ krLogger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, logName, loggerConfig.getInterval());
+ }
+ else
+ {
+ log.error("Invalid logger specified: type: " + loggerConfig.getType() + " path: " + loggerConfig.getPath() + " interval: " + loggerConfig.getInterval());
+ }
return krLogger;
}
-
- public void disposeKnowledgeLogger(@Disposes KnowledgeRuntimeLogger logger) {
+
+ public void disposeKnowledgeLogger(@Disposes 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-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeSessionProducer.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -1,6 +1,5 @@
package org.jboss.seam.drools;
-import java.io.InputStream;
import java.util.Properties;
import javax.enterprise.inject.Any;
@@ -21,6 +20,8 @@
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.utils.ConfigUtils;
import org.jboss.weld.extensions.resources.ResourceProvider;
import org.slf4j.Logger;
@@ -33,83 +34,113 @@
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);
+
+ @Inject
+ BeanManager manager;
+ @Inject
+ ResourceProvider resourceProvider;
+
+ @Produces
+ @KBaseConfigured
+ public StatefulKnowledgeSession produceStatefulSession(@KBaseConfigured KnowledgeBase kbase, KnowledgeSessionConfig ksessionConfig) throws Exception
+ {
+ StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(getConfig(ksessionConfig.getKnowledgeSessionConfigPath()), 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));
+
+ @Produces
+ @KAgentConfigured
+ StatefulKnowledgeSession produceStatefulSessionFromKAgent(@KAgentConfigured KnowledgeBase kbase, KnowledgeSessionConfig ksessionConfig) throws Exception
+ {
+ return null;
+ }
+
+ @Produces
+ @KAgentConfigured
+ StatelessKnowledgeSession produceStatelessSessionFromKAgent(@KAgentConfigured KnowledgeBase kbase, KnowledgeSessionConfig ksesiosnConfig)
+ {
+ return null;
+ }
+
+ @Produces
+ @KBaseConfigured
+ public StatelessKnowledgeSession produceStatelessSession(@KBaseConfigured KnowledgeBase kbase, KnowledgeSessionConfig ksessionConfig) throws Exception
+ {
+ StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(getConfig(ksessionConfig.getKnowledgeSessionConfigPath()));
addEventListeners(ksession, ksessionConfig);
-
+
return ksession;
}
-
- void disposeStatefulSession(@Disposes StatefulKnowledgeSession session) {
+
+ void disposeStatefulSession(@Disposes @Any StatefulKnowledgeSession session)
+ {
session.dispose();
}
-
- void disposeStatelessSession(@Disposes StatelessKnowledgeSession session) {
- session = null;
- }
-
- private KnowledgeSessionConfiguration getConfig(KnowledgeSessionConfig ksessionConfig) throws Exception{
+
+ private KnowledgeSessionConfiguration getConfig(String knowledgeSessionConfigPath) throws Exception
+ {
KnowledgeSessionConfiguration droolsKsessionConfig = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
- if (ksessionConfig.getKnowledgeSessionConfig() != null && ksessionConfig.getKnowledgeSessionConfig().endsWith(".properties"))
+ if (knowledgeSessionConfigPath != null && knowledgeSessionConfigPath.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();
+ Properties ksessionProp = ConfigUtils.loadProperties(resourceProvider, knowledgeSessionConfigPath);
droolsKsessionConfig = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(ksessionProp);
- log.debug("KnowledgeSessionConfiguration loaded: " + ksessionConfig.getKnowledgeSessionConfig());
- } else {
-
+ log.debug("KnowledgeSessionConfiguration loaded: " + knowledgeSessionConfigPath);
}
+ else
+ {
+ log.warn("Invalid config type: " + knowledgeSessionConfigPath);
+ }
return droolsKsessionConfig;
}
-
- private void addEventListeners(KnowledgeRuntimeEventManager ksession, KnowledgeSessionConfig ksessionConfig) throws Exception {
- if(ksessionConfig.getEventListeners() != null) {
- for(String eventListener : ksessionConfig.getEventListeners()) {
+
+ 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) {
+ Object eventListenerObject = eventListenerClass.newInstance();
+ if (eventListenerObject instanceof WorkingMemoryEventListener)
+ {
ksession.addEventListener((WorkingMemoryEventListener) eventListenerObject);
- } else if(eventListenerObject instanceof AgendaEventListener) {
+ }
+ else if (eventListenerObject instanceof AgendaEventListener)
+ {
ksession.addEventListener((AgendaEventListener) eventListenerObject);
- } else if(eventListenerObject instanceof ProcessEventListener) {
+ }
+ else if (eventListenerObject instanceof ProcessEventListener)
+ {
ksession.addEventListener((ProcessEventListener) eventListenerObject);
- } else {
+ }
+ 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)) {
+
+ 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 {
+ }
+ else
+ {
log.warn("Invalid workitem handler configuration for: " + workItemHandlerStr);
}
}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/QueryResultsProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/QueryResultsProducer.java 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/QueryResultsProducer.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -14,7 +14,9 @@
public class QueryResultsProducer
{
private static final Logger log = LoggerFactory.getLogger(KnowledgeBaseProducer.class);
-
- @Inject BeanManager manager;
- @Inject ResourceProvider resourceProvider;
+
+ @Inject
+ BeanManager manager;
+ @Inject
+ ResourceProvider resourceProvider;
}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/InsertFact.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/InsertFact.java 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/InsertFact.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -14,19 +14,28 @@
/**
* Insert fact into WM or EntryPoint. Also determine firing rules decisions.
- *
+ *
* @author Tihomir Surdilovic
*/
@InterceptorBinding
- at Target({TYPE, METHOD})
+ at 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 "";
+ @Nonbinding
+ int ksessionId() default -1;
+
+ @Nonbinding
+ boolean fireAllRules() default false;
+
+ @Nonbinding
+ int fireCount() default -1;
+
+ @Nonbinding
+ boolean fireUntilHalt() default false;
+
+ @Nonbinding
+ String entryPointName() default "";
}
Modified: 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/Abort.java 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/Abort.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -14,15 +14,16 @@
/**
* Abort the process instace.
- *
+ *
* @author Tihomir Surdilovic
*/
@InterceptorBinding
- at Target({TYPE, METHOD})
+ at Target( { TYPE, METHOD })
@Documented
@Retention(RUNTIME)
@Inherited
public @interface Abort
{
- @Nonbinding long processid();
+ @Nonbinding
+ long processid();
}
Modified: 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/SignalEvent.java 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/SignalEvent.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -14,18 +14,25 @@
/**
* Event to be signalled to the process instance or process engine directly.
- *
+ *
* @author Tihomir Surdilovic
*/
@InterceptorBinding
- at Target({TYPE, METHOD})
+ at Target( { TYPE, METHOD })
@Documented
@Retention(RUNTIME)
@Inherited
public @interface SignalEvent
{
- @Nonbinding String type() default "";
- @Nonbinding String event() default "";
- @Nonbinding String processId() default "";
- @Nonbinding String sessionId() default "";
+ @Nonbinding
+ String type() default "";
+
+ @Nonbinding
+ String event() default "";
+
+ @Nonbinding
+ String processId() default "";
+
+ @Nonbinding
+ String sessionId() default "";
}
Modified: 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/annotations/flow/StartProcess.java 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/StartProcess.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -13,15 +13,18 @@
/**
* Starts a Rule Flow process.
- *
+ *
* @author Tihomir Surdilovic
*/
@InterceptorBinding
- at Target({TYPE, METHOD})
+ at Target( { TYPE, METHOD })
@Documented
@Retention(RUNTIME)
public @interface StartProcess
{
- @Nonbinding String processId() default "";
- @Nonbinding String sessionId() default "";
+ @Nonbinding
+ String processId() default "";
+
+ @Nonbinding
+ String sessionId() default "";
}
Added: 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 (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/bootstrap/DroolsExtension.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -0,0 +1,8 @@
+package org.jboss.seam.drools.bootstrap;
+
+import javax.enterprise.inject.spi.Extension;
+
+public class DroolsExtension implements Extension
+{
+
+}
Added: 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 (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeAgentConfig.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -0,0 +1,77 @@
+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;
+ }
+
+}
Modified: 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-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeBaseConfig.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -6,29 +6,29 @@
*/
public class KnowledgeBaseConfig
{
- private String knowledgeBuilderConfig;
- private String knowledgeBaseConfig;
+ private String knowledgeBuilderConfigPath;
+ private String knowledgeBaseConfigPath;
private String[] ruleResources;
private String[] eventListeners;
- public String getKnowledgeBuilderConfig()
+ public String getKnowledgeBuilderConfigPath()
{
- return knowledgeBuilderConfig;
+ return knowledgeBuilderConfigPath;
}
- public void setKnowledgeBuilderConfig(String knowledgeBuilderConfig)
+ public void setKnowledgeBuilderConfigPath(String knowledgeBuilderConfigPath)
{
- this.knowledgeBuilderConfig = knowledgeBuilderConfig;
+ this.knowledgeBuilderConfigPath = knowledgeBuilderConfigPath;
}
- public String getKnowledgeBaseConfig()
+ public String getKnowledgeBaseConfigPath()
{
- return knowledgeBaseConfig;
+ return knowledgeBaseConfigPath;
}
- public void setKnowledgeBaseConfig(String knowledgeBaseConfig)
+ public void setKnowledgeBaseConfigPath(String knowledgeBaseConfigPath)
{
- this.knowledgeBaseConfig = knowledgeBaseConfig;
+ this.knowledgeBaseConfigPath = knowledgeBaseConfigPath;
}
public String[] getRuleResources()
@@ -54,7 +54,7 @@
public String toString()
{
StringBuffer buff = new StringBuffer();
- buff.append("knowledgeBuilderConfig: " + knowledgeBuilderConfig + "\n").append("knowledgeBaseConfig: " + knowledgeBaseConfig + "\n");
+ buff.append("knowledgeBuilderConfigPath: " + knowledgeBuilderConfigPath + "\n").append("knowledgeBaseConfigPath: " + knowledgeBaseConfigPath + "\n");
if (ruleResources != null)
{
buff.append("Rule Resources:\n");
Added: 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 (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeLoggerConfig.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -0,0 +1,65 @@
+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;
+ }
+
+}
Modified: 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-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/KnowledgeSessionConfig.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -8,8 +8,8 @@
{
private String[] eventListeners;
private String[] workItemHandlers;
- private String knowledgeSessionConfig;
-
+ private String knowledgeSessionConfigPath;
+
public String[] getEventListeners()
{
return eventListeners;
@@ -30,20 +30,20 @@
this.workItemHandlers = workItemHandlers;
}
- public String getKnowledgeSessionConfig()
+ public String getKnowledgeSessionConfigPath()
{
- return knowledgeSessionConfig;
+ return knowledgeSessionConfigPath;
}
- public void setKnowledgeSessionConfig(String knowledgeSessionConfig)
+ public void setKnowledgeSessionConfigPath(String knowledgeSessionConfigPath)
{
- this.knowledgeSessionConfig = knowledgeSessionConfig;
+ this.knowledgeSessionConfigPath = knowledgeSessionConfigPath;
}
public String toString()
{
StringBuffer buff = new StringBuffer();
- buff.append("knowledgeSessionConfig: " + knowledgeSessionConfig + "\n");
+ buff.append("knowledgeSessionConfigPath: " + knowledgeSessionConfigPath + "\n");
if (eventListeners != null)
{
buff.append("Event Listeners:\n");
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertInterceptor.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertInterceptor.java 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertInterceptor.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -6,14 +6,16 @@
import org.jboss.seam.drools.annotations.InsertFact;
- at InsertFact @Interceptor
+ at InsertFact
+ at Interceptor
public class InsertInterceptor
{
- @AroundInvoke
- public Object manageTransaction(InvocationContext ctx) throws Exception {
+ @AroundInvoke
+ public Object manageTransaction(InvocationContext ctx) throws Exception
+ {
InsertFact insertFactAnnotation = ctx.getMethod().getAnnotation(InsertFact.class);
- System.out.println("ksession id: " +insertFactAnnotation.ksessionId());
-
+ System.out.println("ksession id: " + insertFactAnnotation.ksessionId());
+
return ctx.proceed();
}
}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/old/FactProvider.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/old/FactProvider.java 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/old/FactProvider.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -12,9 +12,11 @@
public interface FactProvider
{
public List<Object> getFacts();
+
public void setFacts(List<Object> facts);
-
+
public Map<String, Object> getGlobals();
+
public void setGlobals(Map<String, Object> globals);
-
+
}
\ No newline at end of file
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/old/KnowledgeBaseManager.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/old/KnowledgeBaseManager.java 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/old/KnowledgeBaseManager.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -37,171 +37,229 @@
*/
public class KnowledgeBaseManager
{
- /** private static final Logger log = LoggerFactory.getLogger(KnowledgeBaseManager.class);
-
- private KnowledgeBaseManagerConfig kbaseManagerConfig;
-
- @Inject
- BeanManager manager;
-
- @Inject
- public KnowledgeBaseManager(KnowledgeBaseManagerConfig kbaseManagerConfig) {
- this.kbaseManagerConfig = kbaseManagerConfig;
- }
-
- //@Produces
- //@ApplicationScoped
- public KnowledgeBase createKBase() throws Exception
- {
- KnowledgeBase kbase;
- KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(getKnowledgeBuilderConfiguration());
-
- for (String nextResource : kbaseManagerConfig.getRuleResources())
- {
- addResource(kbuilder, nextResource);
- }
-
- KnowledgeBuilderErrors kbuildererrors = kbuilder.getErrors();
- if (kbuildererrors.size() > 0)
- {
- for (KnowledgeBuilderError kbuildererror : kbuildererrors)
- {
- log.error(kbuildererror.getMessage());
- }
- manager.fireEvent(new KnowledgeBuilderErrorsEvent(kbuildererrors));
- }
-
- kbase = KnowledgeBaseFactory.newKnowledgeBase(getKnowledgeBaseConfiguration());
- kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
-
- if (kbaseManagerConfig.getEventListeners() != null)
- {
- for (String eventListener : kbaseManagerConfig.getEventListeners())
- {
- addEventListener(kbase, eventListener);
- }
- }
- return kbase;
- }
-
- //public void disposeKBase(@Disposes KnowledgeBase kbase)
- //{
- // kbase = null;
- // }
-
- private void addEventListener(org.drools.KnowledgeBase kbase, String eventListener) {
- 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());
- }
- }
-
- protected void addResource(KnowledgeBuilder kbuilder, String resource) throws Exception
- {
- if(KnowledgeBaseManagerConfig.isValidResource(resource)) {
- ResourceType resourceType = ResourceType.getResourceType(KnowledgeBaseManagerConfig.getResourceType(resource));
- if(KnowledgeBaseManagerConfig.isRuleTemplate(resource)) {
- @SuppressWarnings("unchecked")
- Bean<TemplateDataProvider> templateDataProviderBean = (Bean<TemplateDataProvider>) manager.getBeans(KnowledgeBaseManagerConfig.getTemplateData(resource)).iterator().next();
-
- TemplateDataProvider templateDataProvider = (TemplateDataProvider) manager.getReference(templateDataProviderBean, Configuration.class, manager.createCreationalContext(templateDataProviderBean));
-
- InputStream templateStream = this.getClass().getClassLoader().getResourceAsStream(KnowledgeBaseManagerConfig.getRuleResource(resource));
- if (templateStream == null)
- {
- throw new IllegalStateException("Could not locate rule resource: " + KnowledgeBaseManagerConfig.getRuleResource(resource));
- }
-
- ObjectDataCompiler converter = new ObjectDataCompiler();
- String drl = converter.compile(templateDataProvider.getTemplateData(), templateStream);
- templateStream.close();
- log.debug("Generated following DRL from template: " + drl);
- Reader rdr = new StringReader(drl);
-
- kbuilder.add(ResourceFactory.newReaderResource(rdr), resourceType);
- } else {
- if (KnowledgeBaseManagerConfig.getResourcePath(resource).equals(KnowledgeBaseManagerConfig.RESOURCE_TYPE_URL))
- {
- kbuilder.add(ResourceFactory.newUrlResource(KnowledgeBaseManagerConfig.getRuleResource(resource)), resourceType);
- manager.fireEvent(new RuleResourceAddedEvent(KnowledgeBaseManagerConfig.getRuleResource(resource)));
- }
- else if (KnowledgeBaseManagerConfig.getResourcePath(resource).equals(KnowledgeBaseManagerConfig.RESOURCE_TYPE_FILE))
- {
- kbuilder.add(ResourceFactory.newFileResource(KnowledgeBaseManagerConfig.getRuleResource(resource)), resourceType);
- manager.fireEvent(new RuleResourceAddedEvent(KnowledgeBaseManagerConfig.getRuleResource(resource)));
- }
- else if (KnowledgeBaseManagerConfig.getResourcePath(resource).equals(KnowledgeBaseManagerConfig.RESOURCE_TYPE_CLASSPATH))
- {
- kbuilder.add(ResourceFactory.newClassPathResource(KnowledgeBaseManagerConfig.getRuleResource(resource)), resourceType);
- manager.fireEvent(new RuleResourceAddedEvent(KnowledgeBaseManagerConfig.getRuleResource(resource)));
- }
- else
- {
- log.error("Invalid resource path: " + KnowledgeBaseManagerConfig.getResourcePath(resource));
- }
- }
- } else {
- log.error("Invalid resource definition: " + resource);
- }
- }
-
- public KnowledgeBuilderConfiguration getKnowledgeBuilderConfiguration() throws Exception
- {
- KnowledgeBuilderConfiguration kbuilderconfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
- if(kbaseManagerConfig.getKnowledgeBuilderConfigProp() != null) {
- kbuilderconfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(kbaseManagerConfig.getKnowledgeBuilderConfigProp(), null);
- log.debug("KnowledgeBuilderConfiguration loaded: " + kbaseManagerConfig.getKnowledgeBuilderConfigProp());
- } else {
- // Only allow resource for .properties files
- if (kbaseManagerConfig.getKnowledgeBuilderConfig() != null && kbaseManagerConfig.getKnowledgeBuilderConfig().endsWith(".properties"))
- {
- Properties kbuilderProp = new Properties();
- InputStream in = this.getClass().getClassLoader().getResourceAsStream(kbaseManagerConfig.getKnowledgeBuilderConfig());
- if (in == null)
- {
- throw new IllegalStateException("Could not locate knowledgeBuilderConfig: " + kbaseManagerConfig.getKnowledgeBuilderConfig());
- }
- kbuilderProp.load(in);
- in.close();
- kbuilderconfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(kbuilderProp, null);
- log.debug("KnowledgeBuilderConfiguration loaded: " + kbaseManagerConfig.getKnowledgeBuilderConfig());
- }
- }
- return kbuilderconfig;
- }
-
- public KnowledgeBaseConfiguration getKnowledgeBaseConfiguration() throws Exception
- {
- KnowledgeBaseConfiguration kbaseconfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
-
- if(kbaseManagerConfig.getKnowledgeBaseConfigProp() != null) {
- kbaseconfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(kbaseManagerConfig.getKnowledgeBaseConfigProp(), null);
- log.debug("KnowledgeBaseConfiguration loaded: " + kbaseManagerConfig.getKnowledgeBaseConfigProp());
- } else {
- // Only allow resource for .properties files
- if (kbaseManagerConfig.getKnowledgeBaseConfig() != null && kbaseManagerConfig.getKnowledgeBaseConfig().endsWith(".properties"))
- {
- Properties kbaseProp = new Properties();
- InputStream in = this.getClass().getClassLoader().getResourceAsStream(kbaseManagerConfig.getKnowledgeBaseConfig());
- if (in == null)
- {
- throw new IllegalStateException("Could not locate knowledgeBaseConfig: " + kbaseManagerConfig.getKnowledgeBaseConfig());
- }
- kbaseProp.load(in);
- in.close();
- kbaseconfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(kbaseProp, null);
- log.debug("KnowledgeBaseConfiguration loaded: " + kbaseManagerConfig.getKnowledgeBaseConfig());
- }
- }
- return kbaseconfig;
- }
-**/}
\ No newline at end of file
+ /**
+ * private static final Logger log =
+ * LoggerFactory.getLogger(KnowledgeBaseManager.class);
+ *
+ * private KnowledgeBaseManagerConfig kbaseManagerConfig;
+ *
+ * @Inject BeanManager manager;
+ * @Inject public KnowledgeBaseManager(KnowledgeBaseManagerConfig
+ * kbaseManagerConfig) { this.kbaseManagerConfig =
+ * kbaseManagerConfig; }
+ *
+ * //@Produces //@ApplicationScoped public KnowledgeBase
+ * createKBase() throws Exception { KnowledgeBase kbase;
+ * KnowledgeBuilder kbuilder =
+ * KnowledgeBuilderFactory.newKnowledgeBuilder
+ * (getKnowledgeBuilderConfiguration());
+ *
+ * for (String nextResource : kbaseManagerConfig.getRuleResources())
+ * { addResource(kbuilder, nextResource); }
+ *
+ * KnowledgeBuilderErrors kbuildererrors = kbuilder.getErrors(); if
+ * (kbuildererrors.size() > 0) { for (KnowledgeBuilderError
+ * kbuildererror : kbuildererrors) {
+ * log.error(kbuildererror.getMessage()); } manager.fireEvent(new
+ * KnowledgeBuilderErrorsEvent(kbuildererrors)); }
+ *
+ * kbase =
+ * KnowledgeBaseFactory.newKnowledgeBase(getKnowledgeBaseConfiguration
+ * ()); kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
+ *
+ * if (kbaseManagerConfig.getEventListeners() != null) { for (String
+ * eventListener : kbaseManagerConfig.getEventListeners()) {
+ * addEventListener(kbase, eventListener); } } return kbase; }
+ *
+ * //public void disposeKBase(@Disposes KnowledgeBase kbase) //{ //
+ * kbase = null; // }
+ *
+ * private void addEventListener(org.drools.KnowledgeBase kbase,
+ * String eventListener) { 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()); } }
+ *
+ * protected void addResource(KnowledgeBuilder
+ * kbuilder, String resource) throws Exception
+ * {
+ * if(KnowledgeBaseManagerConfig.isValidResource
+ * (resource)) { ResourceType resourceType =
+ * ResourceType.getResourceType(
+ * KnowledgeBaseManagerConfig
+ * .getResourceType(resource));
+ * if(KnowledgeBaseManagerConfig
+ * .isRuleTemplate(resource)) {
+ * @SuppressWarnings("unchecked") Bean<TemplateDataProvider>
+ * templateDataProviderBean =
+ * (Bean<TemplateDataProvider>)
+ * manager.getBeans
+ * (KnowledgeBaseManagerConfig.
+ * getTemplateData(
+ * resource)).iterator().next();
+ *
+ * TemplateDataProvider templateDataProvider =
+ * (TemplateDataProvider)
+ * manager.getReference(
+ * templateDataProviderBean,
+ * Configuration.class,
+ * manager.createCreationalContext
+ * (templateDataProviderBean));
+ *
+ * InputStream templateStream =
+ * this.getClass()
+ * .getClassLoader().getResourceAsStream
+ * (KnowledgeBaseManagerConfig
+ * .getRuleResource(resource)); if
+ * (templateStream == null) { throw new
+ * IllegalStateException
+ * ("Could not locate rule resource: " +
+ * KnowledgeBaseManagerConfig
+ * .getRuleResource(resource)); }
+ *
+ * ObjectDataCompiler converter = new
+ * ObjectDataCompiler(); String drl =
+ * converter.compile(templateDataProvider.
+ * getTemplateData(), templateStream);
+ * templateStream.close();
+ * log.debug("Generated following DRL from template: "
+ * + drl); Reader rdr = new StringReader(drl);
+ *
+ *
+ * kbuilder.add(ResourceFactory.newReaderResource
+ * (rdr), resourceType); } else { if
+ * (KnowledgeBaseManagerConfig
+ * .getResourcePath(resource).equals(
+ * KnowledgeBaseManagerConfig
+ * .RESOURCE_TYPE_URL)) {
+ * kbuilder.add(ResourceFactory
+ * .newUrlResource(
+ * KnowledgeBaseManagerConfig.getRuleResource
+ * (resource)), resourceType);
+ * manager.fireEvent(new
+ * RuleResourceAddedEvent
+ * (KnowledgeBaseManagerConfig
+ * .getRuleResource(resource))); } else if
+ * (KnowledgeBaseManagerConfig
+ * .getResourcePath(resource).equals(
+ * KnowledgeBaseManagerConfig
+ * .RESOURCE_TYPE_FILE)) {
+ * kbuilder.add(ResourceFactory
+ * .newFileResource
+ * (KnowledgeBaseManagerConfig.
+ * getRuleResource(resource)), resourceType);
+ * manager.fireEvent(new
+ * RuleResourceAddedEvent
+ * (KnowledgeBaseManagerConfig
+ * .getRuleResource(resource))); } else if
+ * (KnowledgeBaseManagerConfig
+ * .getResourcePath(resource).equals(
+ * KnowledgeBaseManagerConfig
+ * .RESOURCE_TYPE_CLASSPATH)) {
+ * kbuilder.add(ResourceFactory
+ * .newClassPathResource
+ * (KnowledgeBaseManagerConfig
+ * .getRuleResource(resource)), resourceType);
+ * manager.fireEvent(new
+ * RuleResourceAddedEvent
+ * (KnowledgeBaseManagerConfig
+ * .getRuleResource(resource))); } else {
+ * log.error("Invalid resource path: " +
+ * KnowledgeBaseManagerConfig
+ * .getResourcePath(resource)); } } } else {
+ * log.error("Invalid resource definition: " +
+ * resource); } }
+ *
+ * public KnowledgeBuilderConfiguration
+ * getKnowledgeBuilderConfiguration() throws
+ * Exception { KnowledgeBuilderConfiguration
+ * kbuilderconfig = KnowledgeBuilderFactory.
+ * newKnowledgeBuilderConfiguration();
+ * if(kbaseManagerConfig
+ * .getKnowledgeBuilderConfigProp() != null) {
+ * kbuilderconfig = KnowledgeBuilderFactory.
+ * newKnowledgeBuilderConfiguration
+ * (kbaseManagerConfig
+ * .getKnowledgeBuilderConfigProp(), null);
+ * log.debug(
+ * "KnowledgeBuilderConfiguration loaded: " +
+ * kbaseManagerConfig
+ * .getKnowledgeBuilderConfigProp()); } else {
+ * // Only allow resource for .properties
+ * files if
+ * (kbaseManagerConfig.getKnowledgeBuilderConfig
+ * () != null && kbaseManagerConfig.
+ * getKnowledgeBuilderConfig
+ * ().endsWith(".properties")) { Properties
+ * kbuilderProp = new Properties();
+ * InputStream in =
+ * this.getClass().getClassLoader
+ * ().getResourceAsStream(kbaseManagerConfig.
+ * getKnowledgeBuilderConfig()); if (in ==
+ * null) { throw new
+ * IllegalStateException("Could not locate knowledgeBuilderConfig: "
+ * + kbaseManagerConfig.
+ * getKnowledgeBuilderConfig()); }
+ * kbuilderProp.load(in); in.close();
+ * kbuilderconfig = KnowledgeBuilderFactory.
+ * newKnowledgeBuilderConfiguration
+ * (kbuilderProp, null);
+ * log.debug("KnowledgeBuilderConfiguration loaded: "
+ * + kbaseManagerConfig.
+ * getKnowledgeBuilderConfig()); } } return
+ * kbuilderconfig; }
+ *
+ * public KnowledgeBaseConfiguration
+ * getKnowledgeBaseConfiguration() throws
+ * Exception { KnowledgeBaseConfiguration
+ * kbaseconfig = KnowledgeBaseFactory.
+ * newKnowledgeBaseConfiguration();
+ *
+ *
+ * if(kbaseManagerConfig.getKnowledgeBaseConfigProp
+ * () != null) { kbaseconfig =
+ * KnowledgeBaseFactory
+ * .newKnowledgeBaseConfiguration
+ * (kbaseManagerConfig
+ * .getKnowledgeBaseConfigProp(), null);
+ * log.debug
+ * ("KnowledgeBaseConfiguration loaded: " +
+ * kbaseManagerConfig
+ * .getKnowledgeBaseConfigProp()); } else { //
+ * Only allow resource for .properties files
+ * if (kbaseManagerConfig.
+ * getKnowledgeBaseConfig() != null &&
+ * kbaseManagerConfig
+ * .getKnowledgeBaseConfig().
+ * endsWith(".properties")) { Properties
+ * kbaseProp = new Properties(); InputStream
+ * in = this.getClass().getClassLoader().
+ * getResourceAsStream
+ * (kbaseManagerConfig.getKnowledgeBaseConfig
+ * ()); if (in == null) { throw new
+ * IllegalStateException
+ * ("Could not locate knowledgeBaseConfig: " +
+ * kbaseManagerConfig
+ * .getKnowledgeBaseConfig()); }
+ * kbaseProp.load(in); in.close(); kbaseconfig
+ * = KnowledgeBaseFactory.
+ * newKnowledgeBaseConfiguration(kbaseProp,
+ * null);
+ * log.debug("KnowledgeBaseConfiguration loaded: "
+ * + kbaseManagerConfig.getKnowledgeBaseConfig
+ * ()); } } return kbaseconfig; }
+ **/
+}
\ No newline at end of file
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/old/KnowledgeBaseManagerConfig.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/old/KnowledgeBaseManagerConfig.java 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/old/KnowledgeBaseManagerConfig.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -10,107 +10,71 @@
*/
public class KnowledgeBaseManagerConfig
{
- /** 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";
-
- private String knowledgeBuilderConfig;
- private String knowledgeBaseConfig;
- private Properties knowledgeBuilderConfigProp;
- private Properties knowledgeBaseConfigProp;
- private String[] ruleResources;
- private String[] eventListeners;
-
- 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];
- }
-
- public String getKnowledgeBuilderConfig()
- {
- return knowledgeBuilderConfig;
- }
-
- public void setKnowledgeBuilderConfig(String knowledgeBuilderConfig)
- {
- this.knowledgeBuilderConfig = knowledgeBuilderConfig;
- }
-
- public String getKnowledgeBaseConfig()
- {
- return knowledgeBaseConfig;
- }
-
- public void setKnowledgeBaseConfig(String knowledgeBaseConfig)
- {
- this.knowledgeBaseConfig = knowledgeBaseConfig;
- }
-
- 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 Properties getKnowledgeBuilderConfigProp()
- {
- return knowledgeBuilderConfigProp;
- }
-
- public void setKnowledgeBuilderConfigProp(Properties knowledgeBuilderConfigProp)
- {
- this.knowledgeBuilderConfigProp = knowledgeBuilderConfigProp;
- }
-
- public Properties getKnowledgeBaseConfigProp()
- {
- return knowledgeBaseConfigProp;
- }
-
- public void setKnowledgeBaseConfigProp(Properties knowledgeBaseConfigProp)
- {
- this.knowledgeBaseConfigProp = knowledgeBaseConfigProp;
- }
-
-
-
-**/ }
+ /**
+ * 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";
+ *
+ * private String knowledgeBuilderConfig; private String knowledgeBaseConfig;
+ * private Properties knowledgeBuilderConfigProp; private Properties
+ * knowledgeBaseConfigProp; private String[] ruleResources; private String[]
+ * eventListeners;
+ *
+ * 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]; }
+ *
+ * public String getKnowledgeBuilderConfig() { return knowledgeBuilderConfig;
+ * }
+ *
+ * public void setKnowledgeBuilderConfig(String knowledgeBuilderConfig) {
+ * this.knowledgeBuilderConfig = knowledgeBuilderConfig; }
+ *
+ * public String getKnowledgeBaseConfig() { return knowledgeBaseConfig; }
+ *
+ * public void setKnowledgeBaseConfig(String knowledgeBaseConfig) {
+ * this.knowledgeBaseConfig = knowledgeBaseConfig; }
+ *
+ * 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 Properties getKnowledgeBuilderConfigProp() { return
+ * knowledgeBuilderConfigProp; }
+ *
+ * public void setKnowledgeBuilderConfigProp(Properties
+ * knowledgeBuilderConfigProp) { this.knowledgeBuilderConfigProp =
+ * knowledgeBuilderConfigProp; }
+ *
+ * public Properties getKnowledgeBaseConfigProp() { return
+ * knowledgeBaseConfigProp; }
+ *
+ * public void setKnowledgeBaseConfigProp(Properties knowledgeBaseConfigProp)
+ * { this.knowledgeBaseConfigProp = knowledgeBaseConfigProp; }
+ **/
+}
Modified: 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/old/KnowledgeSessionManager.java 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/old/KnowledgeSessionManager.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -27,8 +27,7 @@
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.events.KnowledgeSessionCreatedEvent;
+import org.drools.runtime.process.WorkItemHandler; //import org.jboss.seam.drools.events.KnowledgeSessionCreatedEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,148 +38,168 @@
*/
public class KnowledgeSessionManager
{
- /** private static final Logger log = LoggerFactory.getLogger(KnowledgeSessionManager.class);
-
- private KnowledgeSessionManagerConfig ksessionManagerConfig;
- private Map<Integer, KnowledgeRuntimeLogger> statefulKnowledgeLoggers = new Hashtable<Integer, KnowledgeRuntimeLogger>();
-
- @Inject
- BeanManager manager;
-
- @Inject
- public KnowledgeSessionManager(KnowledgeSessionManagerConfig ksessionManagerConfig)
- {
- this.ksessionManagerConfig = ksessionManagerConfig;
- }
-
- //@Produces
- //@Any
- public StatefulKnowledgeSession getStatefulSession(InjectionPoint ip, Instance<KnowledgeBase> kbase) throws Exception
- {
- StatefulKnowledgeSession ksession = kbase.select(ip.getQualifiers().toArray(new Annotation[0])).get().newStatefulKnowledgeSession(getKSessionConfig(), null);
- addEventListeners(ksession);
- addWorkItemHandlers(ksession);
- addAuditLog(ksession);
- manager.fireEvent(new KnowledgeSessionCreatedEvent(ksession.getId()));
- return ksession;
- }
-
- //public void disposeStatefulSession(@Disposes StatefulKnowledgeSession statefulSession)
- //{
- // if (statefulKnowledgeLoggers.get(statefulSession.getId()) != null)
- // {
- // statefulKnowledgeLoggers.get(statefulSession.getId()).close();
- // }
- // statefulSession.dispose();
- // }
-
- @Produces
- @Any
- public StatelessKnowledgeSession getStatelessSession(InjectionPoint ip, Instance<KnowledgeBase> kbase) throws Exception
- {
- StatelessKnowledgeSession ksession = kbase.select(ip.getQualifiers().toArray(new Annotation[0])).get().newStatelessKnowledgeSession(getKSessionConfig());
- addEventListeners(ksession);
- manager.fireEvent(new KnowledgeSessionCreatedEvent(-1));
- return ksession;
- }
-
- private KnowledgeSessionConfiguration getKSessionConfig() throws Exception
- {
- KnowledgeSessionConfiguration ksessionConfig = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
- if(ksessionManagerConfig.getKnowledgeSessionConfigProp() != null) {
- ksessionConfig = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(ksessionManagerConfig.getKnowledgeSessionConfigProp());
- } else {
- // Only allow resource for .properties files
- if (ksessionManagerConfig.getKnowledgeSessionConfig() != null && ksessionManagerConfig.getKnowledgeSessionConfig().endsWith(".properties"))
- {
- Properties ksessionProp = new Properties();
- InputStream in = this.getClass().getClassLoader().getResourceAsStream(ksessionManagerConfig.getKnowledgeSessionConfig());
- if (in == null)
- {
- throw new IllegalStateException("Could not locate knowledgeSessionrConfig: " + ksessionManagerConfig.getKnowledgeSessionConfig());
- }
- ksessionProp.load(in);
- in.close();
- ksessionConfig = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(ksessionProp);
- log.debug("KnowledgeSessionConfiguration loaded: " + ksessionManagerConfig.getKnowledgeSessionConfig());
- }
- }
- return ksessionConfig;
- }
-
-
- private void addAuditLog(StatefulKnowledgeSession ksession) throws Exception {
- if(ksessionManagerConfig.getAuditLog() != null) {
- if(KnowledgeSessionManagerConfig.isFileLogger(ksessionManagerConfig.getAuditLog())) {
- String logName = KnowledgeSessionManagerConfig.getFileLoggerPath(ksessionManagerConfig.getAuditLog()) + System.currentTimeMillis();
- KnowledgeRuntimeLogger krLogger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, logName);
- statefulKnowledgeLoggers.put(ksession.getId(), krLogger);
- } else if(KnowledgeSessionManagerConfig.isConsoleLogger(ksessionManagerConfig.getAuditLog())) {
- KnowledgeRuntimeLogger krLogger = KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);
- statefulKnowledgeLoggers.put(ksession.getId(), krLogger);
- } else if(KnowledgeSessionManagerConfig.isThreadedLogger(ksessionManagerConfig.getAuditLog())) {
- String logName = KnowledgeSessionManagerConfig.getThreadedLoggerPath(ksessionManagerConfig.getAuditLog()) + System.currentTimeMillis();
- int interval = KnowledgeSessionManagerConfig.getThreadedLoggerInterval(ksessionManagerConfig.getAuditLog());
- KnowledgeRuntimeLogger krLogger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, logName, interval);
- statefulKnowledgeLoggers.put(ksession.getId(), krLogger);
- } else {
- log.warn("Invalid logger specified: " + ksessionManagerConfig.getAuditLog());
- }
- }
- }
-
- public void addEventListeners(StatefulKnowledgeSession ksession) throws Exception {
- if(ksessionManagerConfig.getEventListeners() != null) {
- for(String eventListener : ksessionManagerConfig.getEventListeners()) {
- 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);
- }
- }
- }
- }
-
- public void addEventListeners(StatelessKnowledgeSession ksession) throws Exception{
- if(ksessionManagerConfig.getEventListeners() != null) {
- for(String eventListener : ksessionManagerConfig.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);
- }
- }
- }
- }
-
- public void addWorkItemHandlers(StatefulKnowledgeSession ksession) {
- if(ksessionManagerConfig.getWorkItemHandlers() != null) {
- for(String workItemHandlerStr : ksessionManagerConfig.getWorkItemHandlers()) {
- if(KnowledgeSessionManagerConfig.isValidWorkItemHandler(workItemHandlerStr)) {
- @SuppressWarnings("unchecked")
- Bean<WorkItemHandler> workItemHandlerBean = (Bean<WorkItemHandler>) manager.getBeans(KnowledgeSessionManagerConfig.getWorkItemHandlerType(workItemHandlerStr)).iterator().next();
- WorkItemHandler handler = (WorkItemHandler) manager.getReference(workItemHandlerBean, Configuration.class, manager.createCreationalContext(workItemHandlerBean));
- log.debug("Registering new WorkItemHandler: " + KnowledgeSessionManagerConfig.getWorkItemHandlerName(workItemHandlerStr));
- ksession.getWorkItemManager().registerWorkItemHandler(KnowledgeSessionManagerConfig.getWorkItemHandlerName(workItemHandlerStr), handler);
- }
- }
- }
- }
-
-
-**/}
+ /**
+ * private static final Logger log =
+ * LoggerFactory.getLogger(KnowledgeSessionManager.class);
+ *
+ * private KnowledgeSessionManagerConfig ksessionManagerConfig; private
+ * Map<Integer, KnowledgeRuntimeLogger> statefulKnowledgeLoggers = new
+ * Hashtable<Integer, KnowledgeRuntimeLogger>();
+ *
+ * @Inject BeanManager manager;
+ * @Inject public KnowledgeSessionManager(KnowledgeSessionManagerConfig
+ * ksessionManagerConfig) { this.ksessionManagerConfig =
+ * ksessionManagerConfig; }
+ *
+ * //@Produces //@Any public StatefulKnowledgeSession
+ * getStatefulSession(InjectionPoint ip, Instance<KnowledgeBase>
+ * kbase) throws Exception { StatefulKnowledgeSession ksession =
+ * kbase.select(ip.getQualifiers().toArray(new
+ * Annotation[0])).get().newStatefulKnowledgeSession
+ * (getKSessionConfig(), null); addEventListeners(ksession);
+ * addWorkItemHandlers(ksession); addAuditLog(ksession);
+ * manager.fireEvent(new
+ * KnowledgeSessionCreatedEvent(ksession.getId())); return ksession;
+ * }
+ *
+ * //public void disposeStatefulSession(@Disposes
+ * StatefulKnowledgeSession statefulSession) //{ // if
+ * (statefulKnowledgeLoggers.get(statefulSession.getId()) != null) //
+ * { //
+ * statefulKnowledgeLoggers.get(statefulSession.getId()).close(); //
+ * } // statefulSession.dispose(); // }
+ * @Produces
+ * @Any public StatelessKnowledgeSession getStatelessSession(InjectionPoint
+ * ip, Instance<KnowledgeBase> kbase) throws Exception {
+ * StatelessKnowledgeSession ksession =
+ * kbase.select(ip.getQualifiers().toArray(new
+ * Annotation[0])).get().newStatelessKnowledgeSession
+ * (getKSessionConfig()); addEventListeners(ksession);
+ * manager.fireEvent(new KnowledgeSessionCreatedEvent(-1)); return
+ * ksession; }
+ *
+ * private KnowledgeSessionConfiguration getKSessionConfig() throws
+ * Exception { KnowledgeSessionConfiguration ksessionConfig =
+ * KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
+ * if(ksessionManagerConfig.getKnowledgeSessionConfigProp() != null) {
+ * ksessionConfig =
+ * KnowledgeBaseFactory.newKnowledgeSessionConfiguration
+ * (ksessionManagerConfig.getKnowledgeSessionConfigProp()); } else { //
+ * Only allow resource for .properties files if
+ * (ksessionManagerConfig.getKnowledgeSessionConfig() != null &&
+ * ksessionManagerConfig
+ * .getKnowledgeSessionConfig().endsWith(".properties")) { Properties
+ * ksessionProp = new Properties(); InputStream in =
+ * this.getClass().getClassLoader
+ * ().getResourceAsStream(ksessionManagerConfig
+ * .getKnowledgeSessionConfig()); if (in == null) { throw new
+ * IllegalStateException("Could not locate knowledgeSessionrConfig: " +
+ * ksessionManagerConfig.getKnowledgeSessionConfig()); }
+ * ksessionProp.load(in); in.close(); ksessionConfig =
+ * KnowledgeBaseFactory.newKnowledgeSessionConfiguration(ksessionProp);
+ * log.debug("KnowledgeSessionConfiguration loaded: " +
+ * ksessionManagerConfig.getKnowledgeSessionConfig()); } } return
+ * ksessionConfig; }
+ *
+ *
+ * private void addAuditLog(StatefulKnowledgeSession ksession) throws
+ * Exception { if(ksessionManagerConfig.getAuditLog() != null) {
+ * if(KnowledgeSessionManagerConfig
+ * .isFileLogger(ksessionManagerConfig.getAuditLog())) { String logName
+ * = KnowledgeSessionManagerConfig.getFileLoggerPath(
+ * ksessionManagerConfig.getAuditLog()) + System.currentTimeMillis();
+ * KnowledgeRuntimeLogger krLogger =
+ * KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, logName);
+ * statefulKnowledgeLoggers.put(ksession.getId(), krLogger); } else
+ * if(KnowledgeSessionManagerConfig
+ * .isConsoleLogger(ksessionManagerConfig.getAuditLog())) {
+ * KnowledgeRuntimeLogger krLogger =
+ * KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);
+ * statefulKnowledgeLoggers.put(ksession.getId(), krLogger); } else
+ * if(KnowledgeSessionManagerConfig
+ * .isThreadedLogger(ksessionManagerConfig.getAuditLog())) { String
+ * logName = KnowledgeSessionManagerConfig.getThreadedLoggerPath(
+ * ksessionManagerConfig.getAuditLog()) + System.currentTimeMillis();
+ * int interval =
+ * KnowledgeSessionManagerConfig.getThreadedLoggerInterval
+ * (ksessionManagerConfig.getAuditLog()); KnowledgeRuntimeLogger
+ * krLogger =
+ * KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession,
+ * logName, interval); statefulKnowledgeLoggers.put(ksession.getId(),
+ * krLogger); } else { log.warn("Invalid logger specified: " +
+ * ksessionManagerConfig.getAuditLog()); } } }
+ *
+ * public void addEventListeners(StatefulKnowledgeSession ksession)
+ * throws Exception { if(ksessionManagerConfig.getEventListeners() !=
+ * null) { for(String eventListener :
+ * ksessionManagerConfig.getEventListeners()) { 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); } } } }
+ *
+ * public void addEventListeners(StatelessKnowledgeSession ksession)
+ * throws Exception{ if(ksessionManagerConfig.getEventListeners() !=
+ * null) { for(String eventListener :
+ * ksessionManagerConfig.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); } } } }
+ *
+ * public void
+ * addWorkItemHandlers(StatefulKnowledgeSession
+ * ksession) {
+ * if(ksessionManagerConfig.getWorkItemHandlers
+ * () != null) { for(String workItemHandlerStr
+ * : ksessionManagerConfig.getWorkItemHandlers
+ * ()) {
+ * if(KnowledgeSessionManagerConfig.isValidWorkItemHandler
+ * (workItemHandlerStr)) {
+ * @SuppressWarnings("unchecked") Bean<WorkItemHandler> workItemHandlerBean =
+ * (Bean<WorkItemHandler>) manager.getBeans(
+ * KnowledgeSessionManagerConfig
+ * .getWorkItemHandlerType
+ * (workItemHandlerStr)).iterator().next();
+ * WorkItemHandler handler = (WorkItemHandler)
+ * manager.getReference(workItemHandlerBean,
+ * Configuration.class,
+ * manager.createCreationalContext
+ * (workItemHandlerBean));
+ * log.debug("Registering new WorkItemHandler: "
+ * + KnowledgeSessionManagerConfig.
+ * getWorkItemHandlerName
+ * (workItemHandlerStr));
+ * ksession.getWorkItemManager
+ * ().registerWorkItemHandler
+ * (KnowledgeSessionManagerConfig
+ * .getWorkItemHandlerName
+ * (workItemHandlerStr), handler); } } } }
+ **/
+}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/old/KnowledgeSessionManagerConfig.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/old/KnowledgeSessionManagerConfig.java 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/old/KnowledgeSessionManagerConfig.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -9,98 +9,62 @@
* @author Tihomir Surdilovic
*/
public class KnowledgeSessionManagerConfig
-{
- /** private static final Pattern DIVIDER = Pattern.compile(";");
- private static final int WORKITEMHANDLER_NAME = 0;
- private static final int WORKITEMHANDLER_TYPE = 1;
- private static final int AUDIT_LOG_TYPE = 0;
- private static final int AUDIT_LOG_INFO = 1;
- private static final int AUDIT_LOG_INTERVAL = 2;
- private static final String AUDIT_LOG_TYPE_FILE = "file";
- private static final String AUDIT_LOG_TYPE_CONSOLE = "console";
- private static final String AUDIT_LOG_TYPE_THREADED = "threaded";
-
- private String[] eventListeners;
- private String[] workItemHandlers;
- private String knowledgeSessionConfig;
- private Properties knowledgeSessionConfigProp;
- private String auditLog;
-
- public static String getWorkItemHandlerName(String workItemHandlerStr) {
- return DIVIDER.split(workItemHandlerStr.trim())[WORKITEMHANDLER_NAME];
- }
-
- public static String getWorkItemHandlerType(String workItemHandlerStr) {
- return DIVIDER.split(workItemHandlerStr.trim())[WORKITEMHANDLER_TYPE];
- }
-
- public static boolean isValidWorkItemHandler(String workItemHandlerStr) {
- return DIVIDER.split(workItemHandlerStr.trim()).length == 2;
- }
-
- public static boolean isFileLogger(String auditLog) {
- return DIVIDER.split(auditLog.trim())[AUDIT_LOG_TYPE] == AUDIT_LOG_TYPE_FILE;
- }
-
- public static boolean isConsoleLogger(String auditLog) {
- return DIVIDER.split(auditLog.trim())[AUDIT_LOG_TYPE] == AUDIT_LOG_TYPE_CONSOLE;
- }
-
- public static boolean isThreadedLogger(String auditLog) {
- return DIVIDER.split(auditLog.trim())[AUDIT_LOG_TYPE] == AUDIT_LOG_TYPE_THREADED;
- }
-
- public static String getFileLoggerPath(String auditLog) {
- return DIVIDER.split(auditLog.trim())[AUDIT_LOG_INFO];
- }
-
- public static String getThreadedLoggerPath(String auditLog) {
- return DIVIDER.split(auditLog.trim())[AUDIT_LOG_INFO];
- }
-
- public static int getThreadedLoggerInterval(String auditLog) {
- return Integer.parseInt(DIVIDER.split(auditLog.trim())[AUDIT_LOG_INTERVAL]);
- }
-
- 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 getAuditLog()
- {
- return auditLog;
- }
- public void setAuditLog(String auditLog)
- {
- this.auditLog = auditLog;
- }
- public Properties getKnowledgeSessionConfigProp()
- {
- return knowledgeSessionConfigProp;
- }
- public void setKnowledgeSessionConfigProp(Properties knowledgeSessionConfigProp)
- {
- this.knowledgeSessionConfigProp = knowledgeSessionConfigProp;
- }
-
-**/}
+{
+ /**
+ * private static final Pattern DIVIDER = Pattern.compile(";"); private
+ * static final int WORKITEMHANDLER_NAME = 0; private static final int
+ * WORKITEMHANDLER_TYPE = 1; private static final int AUDIT_LOG_TYPE = 0;
+ * private static final int AUDIT_LOG_INFO = 1; private static final int
+ * AUDIT_LOG_INTERVAL = 2; private static final String AUDIT_LOG_TYPE_FILE =
+ * "file"; private static final String AUDIT_LOG_TYPE_CONSOLE = "console";
+ * private static final String AUDIT_LOG_TYPE_THREADED = "threaded";
+ *
+ * private String[] eventListeners; private String[] workItemHandlers;
+ * private String knowledgeSessionConfig; private Properties
+ * knowledgeSessionConfigProp; private String auditLog;
+ *
+ * public static String getWorkItemHandlerName(String workItemHandlerStr) {
+ * return DIVIDER.split(workItemHandlerStr.trim())[WORKITEMHANDLER_NAME]; }
+ *
+ * public static String getWorkItemHandlerType(String workItemHandlerStr) {
+ * return DIVIDER.split(workItemHandlerStr.trim())[WORKITEMHANDLER_TYPE]; }
+ *
+ * public static boolean isValidWorkItemHandler(String workItemHandlerStr) {
+ * return DIVIDER.split(workItemHandlerStr.trim()).length == 2; }
+ *
+ * public static boolean isFileLogger(String auditLog) { return
+ * DIVIDER.split(auditLog.trim())[AUDIT_LOG_TYPE] == AUDIT_LOG_TYPE_FILE; }
+ *
+ * public static boolean isConsoleLogger(String auditLog) { return
+ * DIVIDER.split(auditLog.trim())[AUDIT_LOG_TYPE] == AUDIT_LOG_TYPE_CONSOLE;
+ * }
+ *
+ * public static boolean isThreadedLogger(String auditLog) { return
+ * DIVIDER.split(auditLog.trim())[AUDIT_LOG_TYPE] == AUDIT_LOG_TYPE_THREADED;
+ * }
+ *
+ * public static String getFileLoggerPath(String auditLog) { return
+ * DIVIDER.split(auditLog.trim())[AUDIT_LOG_INFO]; }
+ *
+ * public static String getThreadedLoggerPath(String auditLog) { return
+ * DIVIDER.split(auditLog.trim())[AUDIT_LOG_INFO]; }
+ *
+ * public static int getThreadedLoggerInterval(String auditLog) { return
+ * Integer.parseInt(DIVIDER.split(auditLog.trim())[AUDIT_LOG_INTERVAL]); }
+ *
+ * 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
+ * getAuditLog() { return auditLog; } public void setAuditLog(String
+ * auditLog) { this.auditLog = auditLog; } public Properties
+ * getKnowledgeSessionConfigProp() { return knowledgeSessionConfigProp; }
+ * public void setKnowledgeSessionConfigProp(Properties
+ * knowledgeSessionConfigProp) { this.knowledgeSessionConfigProp =
+ * knowledgeSessionConfigProp; }
+ **/
+}
Deleted: 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 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KAgentProduced.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -1,28 +0,0 @@
-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
- */
- at Qualifier
- at Target({TYPE, METHOD, FIELD, PARAMETER})
- at Documented
- at Retention(RUNTIME)
- at Inherited
-public @interface KAgentProduced
-{
-
-}
Deleted: 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/KBase.java 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KBase.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -1,28 +0,0 @@
-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;
-
-/**
- *
- * @author Tihomir Surdilovic
- */
- at Qualifier
- at Target({TYPE, METHOD, FIELD, PARAMETER})
- at Documented
- at Retention(RUNTIME)
- at Inherited
-public @interface KBase
-{
- String value() default "";
-}
Deleted: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KBaseConfig.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KBaseConfig.java 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KBaseConfig.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -1,28 +0,0 @@
-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 KBaseConfig
-{
- String value() default "";
-}
Deleted: 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 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/KSession.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -1,28 +0,0 @@
-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 KSession
-{
- String value() default "";
-}
Added: 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 (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/config/DroolsConfig.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -0,0 +1,21 @@
+package org.jboss.seam.drools.qualifiers.config;
+
+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;
+
+ at Qualifier
+ at Target( { TYPE })
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface DroolsConfig
+{
+
+}
Copied: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/kbase/KAgentConfigured.java (from rev 12409, 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/kbase/KAgentConfigured.java (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/kbase/KAgentConfigured.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -0,0 +1,29 @@
+package org.jboss.seam.drools.qualifiers.kbase;
+
+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
+{
+
+}
Added: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/kbase/KBaseConfigured.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/kbase/KBaseConfigured.java (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/qualifiers/kbase/KBaseConfigured.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -0,0 +1,29 @@
+package org.jboss.seam.drools.qualifiers.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.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
+{
+
+}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/utils/ConfigUtils.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/utils/ConfigUtils.java 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/utils/ConfigUtils.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -1,15 +1,19 @@
package org.jboss.seam.drools.utils;
+import java.io.InputStream;
+import java.util.Properties;
import java.util.regex.Pattern;
+import org.jboss.weld.extensions.resources.ResourceProvider;
+
/**
*
* @author Tihomir Surdilovic
*/
public class ConfigUtils
{
- private static final Pattern DIVIDER = Pattern.compile(":");
- // KBase config
+ 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;
@@ -49,7 +53,6 @@
return DIVIDER.split(resource.trim())[RESOURCE_PATH];
}
- // KSession config
private static final int WORKITEMHANDLER_NAME = 0;
private static final int WORKITEMHANDLER_TYPE = 1;
@@ -68,6 +71,17 @@
return DIVIDER.split(workItemHandlerStr.trim()).length == 2;
}
- // KAgent config
+ public static Properties loadProperties(ResourceProvider resourceProvider, String path) throws Exception
+ {
+ Properties prop = new Properties();
+ InputStream in = resourceProvider.loadResourceStream(path);
+ if (in == null)
+ {
+ throw new IllegalStateException("Could not locate: " + path);
+ }
+ prop.load(in);
+ in.close();
+ return prop;
+ }
}
Deleted: modules/drools/trunk/impl/src/main/resources/META-INF/javax.enterprise.inject.spi.Extension
===================================================================
Copied: modules/drools/trunk/impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension (from rev 12409, modules/drools/trunk/impl/src/main/resources/META-INF/javax.enterprise.inject.spi.Extension)
===================================================================
Modified: 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/InsertInterceptorTest.java 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/insertion/InsertInterceptorTest.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -22,18 +22,18 @@
public static JavaArchive createTestArchive()
{
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"));
+ 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;
-
+
+ @Inject
+ InsertionBean insertionBean;
+
@Test
- public void testInsertFactHappens() {
+ public void testInsertFactHappens()
+ {
String result = insertionBean.insertResultAsFact();
- assertTrue(result.equals("abc")); //TODO finish this test
+ assertTrue(result.equals("abc")); // TODO finish this test
}
}
Modified: 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/insertion/InsertionBean.java 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/insertion/InsertionBean.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -4,8 +4,9 @@
public class InsertionBean
{
- @InsertFact(ksessionId=123)
- public String insertResultAsFact() {
+ @InsertFact(ksessionId = 123)
+ public String insertResultAsFact()
+ {
return "abc";
}
}
Modified: 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 2010-04-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/ForKBaseTest.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -15,7 +15,7 @@
import javax.inject.Qualifier;
@Qualifier
- at Target({TYPE, METHOD, FIELD, PARAMETER})
+ at Target( { TYPE, METHOD, FIELD, PARAMETER })
@Documented
@Retention(RUNTIME)
@Inherited
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-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/KBaseTest.java 2010-04-11 07:32:02 UTC (rev 12427)
@@ -1,20 +1,15 @@
package org.jboss.seam.drools.test.kbase;
-import javax.enterprise.inject.Any;
-import javax.enterprise.inject.Instance;
import static org.junit.Assert.assertNotNull;
-import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Inject;
-import junit.framework.Assert;
import org.drools.KnowledgeBase;
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.drools.KnowledgeBaseProducer;
import org.jboss.seam.drools.config.KnowledgeBaseConfig;
-import org.jboss.seam.drools.qualifiers.KBase;
-import org.jboss.seam.drools.qualifiers.KBaseConfig;
+import org.jboss.seam.drools.qualifiers.kbase.KBaseConfigured;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.Archives;
import org.jboss.shrinkwrap.api.formatter.Formatters;
@@ -30,46 +25,49 @@
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).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;
- @Inject @ForKBaseTest KnowledgeBase kbase;
-
+ // @Inject @Any Instance<KnowledgeBaseConfig> kbaseConfigResolver;
+ @Inject
+ @ForKBaseTest
+ KnowledgeBaseConfig config;
+ @Inject
+ @ForKBaseTest
+ @KBaseConfigured
+ KnowledgeBase kbase;
+
@Test
- public void testKBaseConfig() {
- //Assert.assertFalse(kbaseConfigResolver.select(new KBaseConfigBinding("kbaseconfig1")).isUnsatisfied());
- //KnowledgeBaseConfig kbaseConfig = kbaseConfigResolver.select(new KBaseConfigBinding("kbaseconfig1")).get();
+ public void testKBaseConfig()
+ {
+ // 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() {
+ public void testKBase()
+ {
assertNotNull(kbase);
System.out.println("KBASE: " + kbase.toString());
}
-
-// static class KBaseConfigBinding extends AnnotationLiteral<ForKBaseTest> 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;
+ // }
+ // }
}
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-09 23:06:00 UTC (rev 12426)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/KBaseTest-beans.xml 2010-04-11 07:32:02 UTC (rev 12427)
@@ -7,10 +7,10 @@
<drools:KnowledgeBaseConfig>
<s:overrides/>
<test:ForKBaseTest/>
- <drools:knowledgeBuilderConfig>kbuilderconfig.properties</drools:knowledgeBuilderConfig>
- <drools:knowledgeBaseConfig>kbaseconfig.properties</drools:knowledgeBaseConfig>
+ <drools:knowledgeBuilderConfigPath>kbuilderconfig.properties</drools:knowledgeBuilderConfigPath>
+ <drools:knowledgeBaseConfigPath>kbaseconfig.properties</drools:knowledgeBaseConfigPath>
<drools:ruleResources>
- <s:value>classpath:kbasetest.drl:DRL</s:value>
+ <s:value>classpath;kbasetest.drl;DRL</s:value>
</drools:ruleResources>
<drools:eventListeners>
<s:value>org.drools.event.knowledgebase.DefaultKnowledgeBaseEventListener</s:value>
More information about the seam-commits
mailing list