[seam-commits] Seam SVN: r10736 - in modules/trunk/drools: src/main/java/org/jboss/seam/drools and 1 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Thu Apr 30 20:58:23 EDT 2009
Author: shane.bryzak at jboss.com
Date: 2009-04-30 20:58:23 -0400 (Thu, 30 Apr 2009)
New Revision: 10736
Modified:
modules/trunk/drools/pom.xml
modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsActionHandler.java
modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsAssignmentHandler.java
modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsDecisionHandler.java
modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsHandler.java
modules/trunk/drools/src/main/java/org/jboss/seam/drools/ManagedWorkingMemory.java
modules/trunk/drools/src/main/java/org/jboss/seam/drools/RuleBase.java
modules/trunk/drools/src/main/java/org/jboss/seam/drools/SeamGlobalResolver.java
modules/trunk/drools/src/main/java/org/jboss/seam/drools/util/Resources.java
Log:
get drools module to compilable state
Modified: modules/trunk/drools/pom.xml
===================================================================
--- modules/trunk/drools/pom.xml 2009-04-30 20:56:30 UTC (rev 10735)
+++ modules/trunk/drools/pom.xml 2009-05-01 00:58:23 UTC (rev 10736)
@@ -16,22 +16,26 @@
<dependencies>
<dependency>
- <groupId>org.jboss.webbeans</groupId>
+ <groupId>${webbeans.groupId}</groupId>
<artifactId>jsr299-api</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss.webbeans</groupId>
+ <groupId>${webbeans.groupId}</groupId>
<artifactId>webbeans-logging</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam</groupId>
+ </dependency>
+ <!--dependency>
+ <groupId>${seam.groupId}</groupId>
<artifactId>seam-bpm</artifactId>
- </dependency>
+ </dependency-->
<dependency>
- <groupId>org.jboss.seam</groupId>
+ <groupId>${seam.groupId}</groupId>
<artifactId>seam-el</artifactId>
</dependency>
<dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
</dependency>
Modified: modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsActionHandler.java
===================================================================
--- modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsActionHandler.java 2009-04-30 20:56:30 UTC (rev 10735)
+++ modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsActionHandler.java 2009-05-01 00:58:23 UTC (rev 10736)
@@ -19,10 +19,12 @@
public List<String> assertObjects;
public String workingMemoryName;
-
+
public void execute(ExecutionContext executionContext) throws Exception
{
- getWorkingMemory(workingMemoryName, assertObjects, executionContext).fireAllRules();
+ // Disabled BPM support for now
+
+ //getWorkingMemory(workingMemoryName, assertObjects, executionContext).fireAllRules();
}
}
\ No newline at end of file
Modified: modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsAssignmentHandler.java
===================================================================
--- modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsAssignmentHandler.java 2009-04-30 20:56:30 UTC (rev 10735)
+++ modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsAssignmentHandler.java 2009-05-01 00:58:23 UTC (rev 10736)
@@ -24,9 +24,12 @@
public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception
{
+ // Disabled BPM support for now
+ /*
WorkingMemory workingMemory = getWorkingMemory(workingMemoryName, assertObjects, executionContext);
workingMemory.setGlobal( "assignable", assignable );
workingMemory.fireAllRules();
+ */
}
}
\ No newline at end of file
Modified: modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsDecisionHandler.java
===================================================================
--- modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsDecisionHandler.java 2009-04-30 20:56:30 UTC (rev 10735)
+++ modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsDecisionHandler.java 2009-05-01 00:58:23 UTC (rev 10736)
@@ -23,10 +23,15 @@
public String decide(ExecutionContext executionContext) throws Exception
{
+ // Disabled BPM support for now
+ /*
WorkingMemory workingMemory = getWorkingMemory(workingMemoryName, assertObjects, executionContext);
workingMemory.setGlobal( "decision", new Decision() );
workingMemory.fireAllRules();
return ( (Decision) workingMemory.getGlobal("decision") ).getOutcome();
+ */
+
+ return null;
}
}
\ No newline at end of file
Modified: modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsHandler.java
===================================================================
--- modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsHandler.java 2009-04-30 20:56:30 UTC (rev 10735)
+++ modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsHandler.java 2009-05-01 00:58:23 UTC (rev 10736)
@@ -4,9 +4,6 @@
import org.drools.FactHandle;
import org.drools.WorkingMemory;
-import org.jboss.seam.Component;
-import org.jboss.seam.bpm.Actor;
-import org.jboss.seam.core.Expressions;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.jpdl.el.ELException;
@@ -19,6 +16,9 @@
*/
public class DroolsHandler
{
+ // Disabled BPM support for now
+
+ /*
protected WorkingMemory getWorkingMemory(String workingMemoryName, List<String> expressions, ExecutionContext executionContext)
throws ELException
{
@@ -45,7 +45,7 @@
workingMemory.insert(Actor.instance());
return workingMemory;
- }
+ }*/
private void assertObject(WorkingMemory workingMemory, Object element)
{
Modified: modules/trunk/drools/src/main/java/org/jboss/seam/drools/ManagedWorkingMemory.java
===================================================================
--- modules/trunk/drools/src/main/java/org/jboss/seam/drools/ManagedWorkingMemory.java 2009-04-30 20:56:30 UTC (rev 10735)
+++ modules/trunk/drools/src/main/java/org/jboss/seam/drools/ManagedWorkingMemory.java 2009-05-01 00:58:23 UTC (rev 10736)
@@ -11,7 +11,7 @@
import org.drools.RuleBase;
import org.drools.StatefulSession;
import org.drools.spi.GlobalResolver;
-import org.jboss.seam.core.Mutable;
+//import org.jboss.seam.core.Mutable;
import org.jboss.seam.el.Expressions.ValueExpression;
/**
@@ -21,7 +21,8 @@
*
*/
@ConversationScoped
-public class ManagedWorkingMemory implements Mutable, Serializable
+//TODO implement mutable
+public class ManagedWorkingMemory implements /*Mutable, */Serializable
{
private static final long serialVersionUID = -1746942080571374743L;
Modified: modules/trunk/drools/src/main/java/org/jboss/seam/drools/RuleBase.java
===================================================================
--- modules/trunk/drools/src/main/java/org/jboss/seam/drools/RuleBase.java 2009-04-30 20:56:30 UTC (rev 10735)
+++ modules/trunk/drools/src/main/java/org/jboss/seam/drools/RuleBase.java 2009-05-01 00:58:23 UTC (rev 10736)
@@ -5,15 +5,17 @@
import java.io.Reader;
import javax.context.ApplicationScoped;
+import javax.inject.Current;
import javax.inject.Initializer;
import javax.inject.Produces;
+import javax.servlet.ServletContext;
import org.drools.RuleBaseFactory;
import org.drools.compiler.DroolsError;
import org.drools.compiler.PackageBuilder;
import org.drools.compiler.PackageBuilderConfiguration;
import org.drools.compiler.RuleError;
-import org.jboss.seam.core.ResourceLoader;
+import org.jboss.seam.drools.util.Resources;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -32,6 +34,8 @@
private String dslFile;
private org.drools.RuleBase ruleBase;
+ @Current ServletContext servletContext;
+
@Initializer
public void compileRuleBase() throws Exception
{
@@ -43,7 +47,7 @@
for (String ruleFile: ruleFiles)
{
log.info("parsing rules: " + ruleFile);
- InputStream stream = ResourceLoader.instance().getResourceAsStream(ruleFile);
+ InputStream stream = getResourceAsStream(ruleFile);
if (stream==null)
{
throw new IllegalStateException("could not locate rule file: " + ruleFile);
@@ -57,7 +61,7 @@
}
else
{
- Reader dslReader = new InputStreamReader( ResourceLoader.instance().getResourceAsStream(dslFile) );
+ Reader dslReader = new InputStreamReader( getResourceAsStream(dslFile) );
builder.addPackageFromDrl(drlReader, dslReader);
}
@@ -111,4 +115,8 @@
this.dslFile = dslFile;
}
+ public InputStream getResourceAsStream(String resource)
+ {
+ return Resources.getResourceAsStream( resource, servletContext );
+ }
}
Modified: modules/trunk/drools/src/main/java/org/jboss/seam/drools/SeamGlobalResolver.java
===================================================================
--- modules/trunk/drools/src/main/java/org/jboss/seam/drools/SeamGlobalResolver.java 2009-04-30 20:56:30 UTC (rev 10735)
+++ modules/trunk/drools/src/main/java/org/jboss/seam/drools/SeamGlobalResolver.java 2009-05-01 00:58:23 UTC (rev 10736)
@@ -1,9 +1,6 @@
package org.jboss.seam.drools;
import org.drools.spi.GlobalResolver;
-import org.jboss.seam.Component;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.core.Init;
/**
* Resolves Seam context variables as Drools globals
@@ -13,6 +10,8 @@
*/
public class SeamGlobalResolver implements GlobalResolver
{
+ private static final long serialVersionUID = -2274336299784922069L;
+
private GlobalResolver delegate;
public SeamGlobalResolver(GlobalResolver delegate)
@@ -29,6 +28,10 @@
public Object resolveGlobal(String name)
{
+ return delegate.resolveGlobal(name);
+
+ // TODO enable contextual variable resolution
+ /*
if ( !Contexts.isApplicationContextActive() )
{
return delegate.resolveGlobal(name);
@@ -48,5 +51,6 @@
return instance;
}
}
+ */
}
}
\ No newline at end of file
Modified: modules/trunk/drools/src/main/java/org/jboss/seam/drools/util/Resources.java
===================================================================
--- modules/trunk/drools/src/main/java/org/jboss/seam/drools/util/Resources.java 2009-04-30 20:56:30 UTC (rev 10735)
+++ modules/trunk/drools/src/main/java/org/jboss/seam/drools/util/Resources.java 2009-05-01 00:58:23 UTC (rev 10736)
@@ -4,13 +4,40 @@
import java.io.InputStream;
import java.net.URL;
+import javax.servlet.ServletContext;
+
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
public class Resources
{
private static final LogProvider log = Logging.getLogProvider(Resources.class);
+
+ public static InputStream getResourceAsStream(String resource, ServletContext servletContext)
+ {
+ String stripped = resource.startsWith("/") ?
+ resource.substring(1) : resource;
+
+ InputStream stream = null;
+ if (servletContext!=null) {
+ try {
+ stream = servletContext.getResourceAsStream(resource);
+ if (stream!=null) {
+ log.debug("Loaded resource from servlet context: " + resource);
+ }
+ } catch (Exception e) {
+ //
+ }
+ }
+
+ if (stream==null) {
+ stream = getResourceAsStream(resource, stripped);
+ }
+
+ return stream;
+ }
+
public static InputStream getResourceAsStream(String resource)
{
String stripped = resource.startsWith("/") ? resource.substring(1) : resource;
More information about the seam-commits
mailing list