[jboss-svn-commits] JBL Code SVN: r24484 - in labs/jbossrules/trunk: drools-api/src/main/java/org/drools/builder and 53 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Dec 23 13:58:19 EST 2008
Author: mark.proctor at jboss.com
Date: 2008-12-23 13:58:19 -0500 (Tue, 23 Dec 2008)
New Revision: 24484
Added:
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/builder/help/
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/builder/help/DroolsJaxbHelperProvider.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/builder/help/KnowledgeBuilderHelper.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Action.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Adapter.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/CorePipelineProvider.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Emitter.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Expression.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Feeder.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Filter.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/JaxbPipelineProvider.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/PipelineFactory.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Receiver.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/SmooksPipelineProvider.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Splitter.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Stage.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/StageExceptionHandler.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Transformer.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/ExitPoint.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/dataloader/
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/dataloader/DataLoaderFactory.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/dataloader/DataLoaderProvider.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/dataloader/StatefulKnowledgeSessionDataLoader.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/dataloader/StatelessKnowledgeSessionDataLoader.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/pipeline/
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/pipeline/PipelineContext.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/DataLoaderProviderImpl.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatefulKnowledgeSessionDataLoaderImpl.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatefulKnowledgeSessionPipelineContext.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatefulKnowledgeSessionReceiverAdapter.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatelessKnowledgeSessionDataLoaderImpl.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatelessKnowledgeSessionPipelineContext.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatelessKnowledgeSessionReceiverAdapter.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/BaseEmitter.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/BasePipelineContext.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/BaseStage.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/CorePipelineProviderImpl.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/IterateSplitter.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/MvelExpression.java
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline/impl/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline/impl/DroolsJaxbHelperProviderImpl.java
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbTransformer.java
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/java/org/drools/runtime/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/java/org/drools/runtime/pipeline/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/java/org/drools/runtime/pipeline/impl/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/java/org/drools/runtime/pipeline/impl/DroolsJaxbTest.java
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/data.xml
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/order.xml
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/order.xsd
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/test.xsd
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/test_Jaxb.drl
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/impl/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/impl/DroolsSmooksConfiguration.java
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/impl/Root.java
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/impl/SmooksTransformer.java
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/pipeline/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/pipeline/impl/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/pipeline/impl/DroolsSmookStatefulSessionTest.java
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/pipeline/impl/DroolsSmookStatelessSessionTest.java
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/SmooksDirectRoot.xml
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/SmooksNestedIterable.xml
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/smooks-config.xml
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/test_SmooksDirectRoot.drl
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/test_SmooksNestedIterable.drl
Removed:
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/definition/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/dataloaders/jaxb/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline/DroolsJaxbConfiguration.java
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline/DroolsJaxbHelper.java
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline/DroolsJaxbStatefulSession.java
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/java/org/drools/dataloaders/jaxb/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/java/org/drools/runtime/pipeline/DroolsJaxbTest.java
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/dataloaders/jaxb/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/data.xml
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/order.xml
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/order.xsd
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/test.xsd
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/test_Jaxb.drl
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/dataloaders/smooks/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/DroolsSmooksConfiguration.java
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/DroolsSmooksStatefulSession.java
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/DroolsSmooksStatelessSession.java
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/Root.java
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/dataloaders/smooks/
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/pipeline/DroolsSmookStatefulSessionTest.java
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/pipeline/DroolsSmookStatelessSessionTest.java
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/SmooksDirectRoot.xml
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/SmooksNestedIterable.xml
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/smooks-config.xml
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/test_SmooksDirectRoot.drl
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/test_SmooksNestedIterable.drl
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/SmooksDirectRoot.xml
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/SmooksNestedIterable.xml
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/smooks-config.xml
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/test_SmooksDirectRoot.drl
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/test_SmooksNestedIterable.drl
Modified:
labs/jbossrules/trunk/drools-api/.classpath
labs/jbossrules/trunk/drools-api/pom.xml
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/KnowledgeRuntime.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/StatefulKnowledgeSession.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/process/ProcessRuntime.java
labs/jbossrules/trunk/drools-compiler/.classpath
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/builder/impl/KnowledgeBuilderImpl.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/testframework/MockWorkingMemory.java
labs/jbossrules/trunk/drools-core/.classpath
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/KnowledgeBaseImpl.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/StatefulKnowledgeSessionImpl.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/.classpath
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/.classpath
labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/pom.xml
Log:
JBRULES-1903 Pipeline support for DataLoaders and Feeders
Modified: labs/jbossrules/trunk/drools-api/.classpath
===================================================================
--- labs/jbossrules/trunk/drools-api/.classpath 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-api/.classpath 2008-12-23 18:58:19 UTC (rev 24484)
@@ -5,8 +5,21 @@
<classpathentry kind="src" path="src/test/resources" output="target/test-classes" including="**" excluding="**/*.java"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.3/commons-lang-2.3.jar"/>
+ <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1/commons-logging-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/freemarker/freemarker/2.3.9/freemarker-2.3.9.jar"/>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/com/sun/xml/bind/jaxb-xjc/2.0.3/jaxb-xjc-2.0.3.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.5.0.1/jmock-2.5.0.1.jar"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.13/log4j-1.2.13.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-commons/1.1/milyn-commons-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-smooks-core/1.1/milyn-smooks-core-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-smooks-javabean/1.1/milyn-smooks-javabean-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/mvel/mvel/1.3.12-java1.5/mvel-1.3.12-java1.5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.8.0/xercesImpl-2.8.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/2.0.2/xml-apis-2.0.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar"/>
+ <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.3/xstream-1.3.jar"/>
</classpath>
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-api/pom.xml
===================================================================
--- labs/jbossrules/trunk/drools-api/pom.xml 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-api/pom.xml 2008-12-23 18:58:19 UTC (rev 24484)
@@ -13,6 +13,19 @@
<name>Drools :: API</name>
<dependencies>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-xjc</artifactId>
+ <version>2.0.3</version>
+ <scope>optional</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.milyn</groupId>
+ <artifactId>milyn-smooks-javabean</artifactId>
+ <version>1.1</version>
+ <scope>optional</scope>
+ </dependency>
</dependencies>
<build>
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/builder/help/DroolsJaxbHelperProvider.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/builder/help/DroolsJaxbHelperProvider.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/builder/help/DroolsJaxbHelperProvider.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,26 @@
+package org.drools.builder.help;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Map;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+
+import org.drools.KnowledgeBase;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.io.Resource;
+
+import com.sun.tools.xjc.Options;
+
+public interface DroolsJaxbHelperProvider {
+
+ public String[] addXsdModel(Resource resource,
+ KnowledgeBuilder kbuilder,
+ Options xjcOpts,
+ String systemId) throws IOException;
+
+ public JAXBContext newJAXBContext(String[] classNames,
+ Map<String, ? > properties,
+ KnowledgeBase kbase) throws JAXBException ;
+}
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/builder/help/KnowledgeBuilderHelper.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/builder/help/KnowledgeBuilderHelper.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/builder/help/KnowledgeBuilderHelper.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,64 @@
+package org.drools.builder.help;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Collections;
+import java.util.Map;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+
+import org.drools.KnowledgeBase;
+import org.drools.ProviderInitializationException;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.KnowledgeBuilderProvider;
+import org.drools.io.Resource;
+
+import com.sun.tools.xjc.Options;
+
+public class KnowledgeBuilderHelper {
+
+ private static DroolsJaxbHelperProvider provider;
+
+ public static String[] addXsdModel(Resource resource,
+ KnowledgeBuilder kbuilder,
+ Options xjcOpts,
+ String systemId) throws IOException {
+ return getDroolsJaxbHelperProvider().addXsdModel( resource, kbuilder, xjcOpts, systemId );
+ }
+
+ public static JAXBContext newJAXBContext(String[] classNames,
+ KnowledgeBase kbase) throws JAXBException {
+ return newJAXBContext( classNames,
+ Collections.<String, Object> emptyMap(),
+ kbase );
+ }
+
+ public static JAXBContext newJAXBContext(String[] classNames,
+ Map<String, ? > properties,
+ KnowledgeBase kbase) throws JAXBException {
+ return getDroolsJaxbHelperProvider().newJAXBContext( classNames, properties, kbase );
+ }
+
+ public static synchronized DroolsJaxbHelperProvider getDroolsJaxbHelperProvider() {
+ if ( provider == null ) {
+ loadProvider();
+ }
+ return provider;
+ }
+
+ private static synchronized void setDroolsJaxbHelperProvider(DroolsJaxbHelperProvider provider){
+ KnowledgeBuilderHelper.provider = provider;
+ }
+
+ private static void loadProvider() {
+ try {
+ Class<DroolsJaxbHelperProvider> cls = (Class<DroolsJaxbHelperProvider>) Class.forName( "org.drools.runtime.pipeline.impl.DroolsJaxbHelperProviderImpl" );
+ setDroolsJaxbHelperProvider( cls.newInstance() );
+ } catch ( Exception e2 ) {
+ throw new ProviderInitializationException( "Provider org.drools.runtime.pipeline.impl.DroolsJaxbHelperProviderImpl could not be set.",
+ e2 );
+ }
+ }
+
+}
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Action.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Action.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Action.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,5 @@
+package org.drools.definition.pipeline;
+
+public interface Action extends Emitter, Receiver, Stage {
+
+}
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Adapter.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Adapter.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Adapter.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,4 @@
+package org.drools.definition.pipeline;
+
+public interface Adapter extends Receiver, Stage {
+}
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/CorePipelineProvider.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/CorePipelineProvider.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/CorePipelineProvider.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,11 @@
+package org.drools.definition.pipeline;
+
+public interface CorePipelineProvider {
+ public Expression newMvelExpression(String expression);
+
+ public Splitter newIterateSplitter();
+
+ public Adapter newStatefulKnowledgeSessionReceiverAdapter();
+
+ public Adapter newStatelessKnowledgeSessionReceiverAdapter();
+}
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Emitter.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Emitter.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Emitter.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,12 @@
+package org.drools.definition.pipeline;
+
+import java.util.Collection;
+
+public interface Emitter {
+ void addReceiver(Receiver receiver);
+
+ void removeReceiver(Receiver receiver);
+
+ Collection<Receiver> getReceivers();
+
+}
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Expression.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Expression.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Expression.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,4 @@
+package org.drools.definition.pipeline;
+
+public interface Expression extends Emitter, Receiver, Stage {
+}
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Feeder.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Feeder.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Feeder.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,5 @@
+package org.drools.definition.pipeline;
+
+public interface Feeder extends Emitter, Stage {
+
+}
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Filter.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Filter.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Filter.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,5 @@
+package org.drools.definition.pipeline;
+
+public interface Filter extends Emitter, Receiver, Stage {
+
+}
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/JaxbPipelineProvider.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/JaxbPipelineProvider.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/JaxbPipelineProvider.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,7 @@
+package org.drools.definition.pipeline;
+
+import javax.xml.bind.Unmarshaller;
+
+public interface JaxbPipelineProvider {
+ Transformer newJaxbTransformer(Unmarshaller unmarshaller);
+}
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/PipelineFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/PipelineFactory.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/PipelineFactory.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,105 @@
+package org.drools.definition.pipeline;
+
+import javax.xml.bind.Unmarshaller;
+
+import org.drools.ProviderInitializationException;
+import org.milyn.Smooks;
+
+public class PipelineFactory {
+
+ private static CorePipelineProvider corePipelineProvider;
+
+ private static JaxbPipelineProvider jaxbPipelineProvider;
+
+ private static SmooksPipelineProvider smooksPipelineProvider;
+
+ public static Transformer newSmooksTransformer(Smooks smooks,
+ String rootId) {
+ return getSmooksPipelineProvider().newSmooksTransformer( smooks,
+ rootId );
+ }
+
+ public static Transformer newJaxbTransformer(Unmarshaller unmarshaller) {
+ return getJaxbPipelineProvider().newJaxbTransformer( unmarshaller );
+ }
+
+ public static Expression newMvelExpression(String expression) {
+ return getCorePipelineProvider().newMvelExpression( expression );
+ }
+
+ public static Splitter newIterateSplitter() {
+ return getCorePipelineProvider().newIterateSplitter();
+ }
+
+ public static Adapter newStatefulKnowledgeSessionReceiverAdapter() {
+ return getCorePipelineProvider().newStatefulKnowledgeSessionReceiverAdapter();
+ }
+
+ public static Adapter newStatelessKnowledgeSessionReceiverAdapter() {
+ return getCorePipelineProvider().newStatelessKnowledgeSessionReceiverAdapter();
+ }
+
+ private static synchronized void setCorePipelineProvider(CorePipelineProvider provider) {
+ PipelineFactory.corePipelineProvider = provider;
+ }
+
+ private static synchronized CorePipelineProvider getCorePipelineProvider() {
+ if ( corePipelineProvider == null ) {
+ loadCorePipelineProvider();
+ }
+ return corePipelineProvider;
+ }
+
+ private static void loadCorePipelineProvider() {
+ try {
+ Class<CorePipelineProvider> cls = (Class<CorePipelineProvider>) Class.forName( "org.drools.runtime.pipeline.impl.CorePipelineProviderImpl" );
+ setCorePipelineProvider( cls.newInstance() );
+ } catch ( Exception e2 ) {
+ throw new ProviderInitializationException( "org.drools.runtime.pipeline.impl.CorePipelineProviderImpl could not be set.",
+ e2 );
+ }
+ }
+
+ private static synchronized void setJaxbPipelineProvider(JaxbPipelineProvider provider) {
+ PipelineFactory.jaxbPipelineProvider = provider;
+ }
+
+ private static synchronized JaxbPipelineProvider getJaxbPipelineProvider() {
+ if ( jaxbPipelineProvider == null ) {
+ loadJaxbPipelineProvider();
+ }
+ return jaxbPipelineProvider;
+ }
+
+ private static void loadJaxbPipelineProvider() {
+ try {
+ Class<JaxbPipelineProvider> cls = (Class<JaxbPipelineProvider>) Class.forName( "org.drools.runtime.pipeline.impl.JaxbTransformer$JaxbPipelineProviderImpl" );
+ setJaxbPipelineProvider( cls.newInstance() );
+ } catch ( Exception e2 ) {
+ throw new ProviderInitializationException( "Provider org.drools.runtime.pipeline.impl.JaxbTransformer$JaxbPipelineProviderImpl could not be set.",
+ e2 );
+ }
+ }
+
+ private static synchronized void setSmooksPipelineProvider(SmooksPipelineProvider provider) {
+ PipelineFactory.smooksPipelineProvider = provider;
+ }
+
+ private static synchronized SmooksPipelineProvider getSmooksPipelineProvider() {
+ if ( smooksPipelineProvider == null ) {
+ loadSmooksPipelineProvider();
+ }
+ return smooksPipelineProvider;
+ }
+
+ private static void loadSmooksPipelineProvider() {
+ try {
+ Class<SmooksPipelineProvider> cls = (Class<SmooksPipelineProvider>) Class.forName( "org.drools.runtime.pipeline.impl.SmooksTransformer$SmooksPipelineProviderImpl" );
+ setSmooksPipelineProvider( cls.newInstance() );
+ } catch ( Exception e2 ) {
+ throw new ProviderInitializationException( "Provider org.drools.runtime.pipeline.impl.SmooksTransformer$SmooksPipelineProviderImpl could not be set.",
+ e2 );
+ }
+ }
+
+}
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Receiver.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Receiver.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Receiver.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,7 @@
+package org.drools.definition.pipeline;
+
+import org.drools.runtime.pipeline.PipelineContext;
+
+public interface Receiver {
+ void signal(Object object, PipelineContext context);
+}
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/SmooksPipelineProvider.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/SmooksPipelineProvider.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/SmooksPipelineProvider.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,8 @@
+package org.drools.definition.pipeline;
+
+import org.milyn.Smooks;
+
+public interface SmooksPipelineProvider {
+ Transformer newSmooksTransformer(Smooks smooks,
+ String rootId);
+}
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Splitter.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Splitter.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Splitter.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,5 @@
+package org.drools.definition.pipeline;
+
+public interface Splitter extends Emitter, Receiver, Stage {
+
+}
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Stage.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Stage.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Stage.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,5 @@
+package org.drools.definition.pipeline;
+
+public interface Stage {
+ public void setStageExceptionHandler(StageExceptionHandler exceptionHandler);
+}
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/StageExceptionHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/StageExceptionHandler.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/StageExceptionHandler.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,5 @@
+package org.drools.definition.pipeline;
+
+public interface StageExceptionHandler {
+ public void handleException(Stage stage, Object object, Exception exception);
+}
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Transformer.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Transformer.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/definition/pipeline/Transformer.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,5 @@
+package org.drools.definition.pipeline;
+
+public interface Transformer extends Emitter, Receiver, Stage {
+
+}
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/ExitPoint.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/ExitPoint.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/ExitPoint.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,5 @@
+package org.drools.runtime;
+
+public interface ExitPoint {
+ void insert(Object object);
+}
Modified: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/KnowledgeRuntime.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/KnowledgeRuntime.java 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/KnowledgeRuntime.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,5 +1,6 @@
package org.drools.runtime;
+import org.drools.KnowledgeBase;
import org.drools.event.KnowledgeRuntimeEventManager;
import org.drools.runtime.process.ProcessRuntime;
import org.drools.runtime.rule.WorkingMemory;
@@ -10,4 +11,28 @@
ProcessRuntime,
KnowledgeRuntimeEventManager {
+ /**
+ * Sets a global value on the internal collection
+ * @param identifer the global identifier
+ * @param value the value assigned to the global identifier
+ */
+ void setGlobal(String identifier,
+ Object object);
+
+ /**
+ * Delegate used to resolve any global names not found in the global map.
+ * @param globalResolver
+ */
+ void setGlobalResolver(GlobalResolver globalResolver);
+
+ /**
+ * Returns the KnowledgeBase reference from which this stateful session was created.
+ *
+ * @return
+ */
+ KnowledgeBase getKnowledgeBase();
+
+ void registerExitPoint(String name, ExitPoint exitPoint);
+
+ void unregisterExitPoint(String name);
}
Modified: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/StatefulKnowledgeSession.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/StatefulKnowledgeSession.java 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/StatefulKnowledgeSession.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -64,28 +64,8 @@
StatefulProcessSession,
KnowledgeRuntime {
- /**
- * Sets a global value on the internal collection
- * @param identifer the global identifier
- * @param value the value assigned to the global identifier
- */
- void setGlobal(String identifier,
- Object object);
/**
- * Delegate used to resolve any global names not found in the global map.
- * @param globalResolver
- */
- void setGlobalResolver(GlobalResolver globalResolver);
-
- /**
- * Returns the KnowledgeBase reference from which this stateful session was created.
- *
- * @return
- */
- KnowledgeBase getKnowledgeBase();
-
- /**
* Releases all the current session resources, setting up the session for garbage collection.
* This method <b>must</b> always be called after finishing using the session, or the engine
* will not free the memory used by the session.
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/dataloader/DataLoaderFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/dataloader/DataLoaderFactory.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/dataloader/DataLoaderFactory.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,41 @@
+package org.drools.runtime.dataloader;
+
+import org.drools.ProviderInitializationException;
+import org.drools.definition.pipeline.Receiver;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.StatelessKnowledgeSession;
+
+public class DataLoaderFactory {
+ private static volatile DataLoaderProvider provider;
+
+ public static StatefulKnowledgeSessionDataLoader newStatefulKnowledgeSessionDataLoader(StatefulKnowledgeSession ksession,
+ Receiver pipeline) {
+ return getDataLoaderProvider().newStatefulKnowledgeSessionDataLoader( ksession, pipeline );
+ }
+
+ public static StatelessKnowledgeSessionDataLoader newStatelessKnowledgeSessionDataLoader(StatelessKnowledgeSession ksession,
+ Receiver pipeline) {
+ return getDataLoaderProvider().newStatelessKnowledgeSessionDataLoader( ksession, pipeline );
+ }
+
+ private static synchronized void setDataLoaderProvider(DataLoaderProvider provider) {
+ DataLoaderFactory.provider = provider;
+ }
+
+ private static synchronized DataLoaderProvider getDataLoaderProvider() {
+ if ( provider == null ) {
+ loadProvider();
+ }
+ return DataLoaderFactory.provider;
+ }
+
+ private static void loadProvider() {
+ try {
+ Class<DataLoaderProvider> cls = (Class<DataLoaderProvider>) Class.forName( "org.drools.runtime.dataloader.impl.DataLoaderProviderImpl" );
+ setDataLoaderProvider( cls.newInstance() );
+ } catch ( Exception e2 ) {
+ throw new ProviderInitializationException( "Provider org.drools.runtime.dataloader.impl.DataLoaderProviderImpl could not be set.",
+ e2 );
+ }
+ }
+}
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/dataloader/DataLoaderProvider.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/dataloader/DataLoaderProvider.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/dataloader/DataLoaderProvider.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,13 @@
+package org.drools.runtime.dataloader;
+
+import org.drools.definition.pipeline.Receiver;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.StatelessKnowledgeSession;
+
+public interface DataLoaderProvider {
+ StatefulKnowledgeSessionDataLoader newStatefulKnowledgeSessionDataLoader(StatefulKnowledgeSession ksession,
+ Receiver pipeline);
+
+ StatelessKnowledgeSessionDataLoader newStatelessKnowledgeSessionDataLoader(StatelessKnowledgeSession ksession,
+ Receiver pipeline);
+}
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/dataloader/StatefulKnowledgeSessionDataLoader.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/dataloader/StatefulKnowledgeSessionDataLoader.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/dataloader/StatefulKnowledgeSessionDataLoader.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,9 @@
+package org.drools.runtime.dataloader;
+
+import java.util.Map;
+
+import org.drools.runtime.rule.FactHandle;
+
+public interface StatefulKnowledgeSessionDataLoader {
+ Map<FactHandle, Object> insert(Object object);
+}
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/dataloader/StatelessKnowledgeSessionDataLoader.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/dataloader/StatelessKnowledgeSessionDataLoader.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/dataloader/StatelessKnowledgeSessionDataLoader.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,18 @@
+package org.drools.runtime.dataloader;
+
+import org.drools.runtime.Parameters;
+import org.drools.runtime.StatelessKnowledgeSessionResults;
+
+public interface StatelessKnowledgeSessionDataLoader {
+
+ void executeObject(Object object);
+
+ void executeIterable(Object object);
+
+ StatelessKnowledgeSessionResults executeObjectWithParameters(Object object,
+ Parameters parameters);
+
+ StatelessKnowledgeSessionResults executeIterableWithParameters(Object object,
+ Parameters parameters);
+
+}
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/pipeline/PipelineContext.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/pipeline/PipelineContext.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/pipeline/PipelineContext.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,5 @@
+package org.drools.runtime.pipeline;
+
+public interface PipelineContext {
+ ClassLoader getClassLoader();
+}
Modified: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/process/ProcessRuntime.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/process/ProcessRuntime.java 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/process/ProcessRuntime.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -3,8 +3,6 @@
import java.util.Collection;
import java.util.Map;
-import org.drools.event.process.ProcessEventManager;
-
public interface ProcessRuntime {
ProcessInstance startProcess(String processId);
Modified: labs/jbossrules/trunk/drools-compiler/.classpath
===================================================================
--- labs/jbossrules/trunk/drools-compiler/.classpath 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-compiler/.classpath 2008-12-23 18:58:19 UTC (rev 24484)
@@ -8,16 +8,27 @@
<classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.7/antlr-2.7.7.jar"/>
<classpathentry kind="var" path="M2_REPO/org/antlr/antlr/3.1.1/antlr-3.1.1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.1.1/antlr-runtime-3.1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.3/commons-lang-2.3.jar"/>
+ <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1/commons-logging-1.1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/core/3.4.2.v_883_R34x/core-3.4.2.v_883_R34x.jar"/>
<classpathentry kind="src" path="/drools-api"/>
<classpathentry kind="src" path="/drools-core"/>
+ <classpathentry kind="var" path="M2_REPO/org/freemarker/freemarker/2.3.9/freemarker-2.3.9.jar"/>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar"/>
<classpathentry kind="var" path="M2_REPO/janino/janino/2.5.15/janino-2.5.15.jar"/>
+ <classpathentry kind="var" path="M2_REPO/com/sun/xml/bind/jaxb-xjc/2.0.3/jaxb-xjc-2.0.3.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.5.0.1/jmock-2.5.0.1.jar"/>
<classpathentry kind="var" path="M2_REPO/joda-time/joda-time/1.5.2/joda-time-1.5.2.jar"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.13/log4j-1.2.13.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-commons/1.1/milyn-commons-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-smooks-core/1.1/milyn-smooks-core-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-smooks-javabean/1.1/milyn-smooks-javabean-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/mvel/mvel/1.3.12-java1.5/mvel-1.3.12-java1.5.jar"/>
<classpathentry kind="var" path="M2_REPO/org/mvel/mvel2/2.0.4-SNAPSHOT/mvel2-2.0.4-SNAPSHOT.jar"/>
+ <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.8.0/xercesImpl-2.8.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/2.0.2/xml-apis-2.0.2.jar"/>
<classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar"/>
<classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.3/xstream-1.3.jar"/>
</classpath>
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/builder/impl/KnowledgeBuilderImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/builder/impl/KnowledgeBuilderImpl.java 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/builder/impl/KnowledgeBuilderImpl.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -20,7 +20,7 @@
import org.drools.rule.Package;
public class KnowledgeBuilderImpl implements KnowledgeBuilder {
- private PackageBuilder pkgBuilder;
+ public PackageBuilder pkgBuilder;
public KnowledgeBuilderImpl(PackageBuilder pkgBuilder) {
this.pkgBuilder = pkgBuilder;
@@ -59,4 +59,8 @@
public KnowledgeBuilderErrors getErrors() {
return this.pkgBuilder.getErrors();
}
+
+ public PackageBuilder getPackageBuilder() {
+ return this.pkgBuilder;
+ }
}
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -140,7 +140,7 @@
private Resource resource;
private List<DSLTokenizedMappingFile> dslFiles;
-
+
private TimeIntervalParser timeParser;
/**
@@ -355,7 +355,7 @@
final Reader dsl) throws DroolsParserException,
IOException {
this.resource = new ReaderResource( source );
-
+
final DrlParser parser = new DrlParser();
final PackageDescr pkg = parser.parse( source,
dsl );
@@ -432,7 +432,7 @@
public void addProcessFromXml(Reader processSource) {
this.resource = new ReaderResource( processSource );
-
+
ProcessBuilder processBuilder = new ProcessBuilder( this );
try {
processBuilder.addProcessFromFile( processSource,
@@ -456,33 +456,33 @@
try {
switch ( type ) {
case DRL : {
- ((InternalResource)resource).setResourceType( type );
+ ((InternalResource) resource).setResourceType( type );
addPackageFromDrl( resource );
break;
}
case DSLR : {
- ((InternalResource)resource).setResourceType( type );
+ ((InternalResource) resource).setResourceType( type );
addPackageFromDslr( resource );
break;
}
case DSL : {
- ((InternalResource)resource).setResourceType( type );
+ ((InternalResource) resource).setResourceType( type );
addDsl( resource );
break;
}
case XDRL : {
- ((InternalResource)resource).setResourceType( type );
+ ((InternalResource) resource).setResourceType( type );
addPackageFromXml( resource );
break;
}
case DRF : {
- ((InternalResource)resource).setResourceType( type );
+ ((InternalResource) resource).setResourceType( type );
addProcessFromXml( resource );
break;
}
case DTABLE : {
- ((InternalResource)resource).setResourceType( type );
+ ((InternalResource) resource).setResourceType( type );
DecisionTableConfiguration dtableConfiguration = (DecisionTableConfiguration) configuration;
String string = DecisionTableFactory.loadFromInputStream( resource.getInputStream(),
@@ -490,18 +490,18 @@
addPackageFromDrl( new StringReader( string ) );
break;
}
- case PKG : {
+ case PKG : {
InputStream is = resource.getInputStream();
- Package pkg = (Package) DroolsStreamUtils.streamIn( is );
+ Package pkg = (Package) DroolsStreamUtils.streamIn( is );
is.close();
addPackage( pkg );
break;
}
case ChangeSet : {
- ((InternalResource)resource).setResourceType( type );
+ ((InternalResource) resource).setResourceType( type );
XmlChangeSetReader reader = new XmlChangeSetReader( this.configuration.getSemanticModules() );
if ( resource instanceof ClassPathResource ) {
- reader.setClassLoader( ((ClassPathResource )resource).getClassLoader() );
+ reader.setClassLoader( ((ClassPathResource) resource).getClassLoader() );
} else {
reader.setClassLoader( this.configuration.getClassLoader() );
}
@@ -510,18 +510,22 @@
// @TODO should log an error
}
for ( Resource nestedResource : chageSet.getResourcesAdded() ) {
- InternalResource iNestedResourceResource = (InternalResource) nestedResource;
+ InternalResource iNestedResourceResource = (InternalResource) nestedResource;
if ( iNestedResourceResource.isDirectory() ) {
this.resourceDirectories.add( iNestedResourceResource );
for ( Resource childResource : iNestedResourceResource.listResources() ) {
- if ( ((InternalResource)childResource).isDirectory() ) {
- continue; // ignore sub directories
+ if ( ((InternalResource) childResource).isDirectory() ) {
+ continue; // ignore sub directories
}
- ((InternalResource)childResource).setResourceType( iNestedResourceResource.getResourceType() );
- addKnowledgeResource( childResource, iNestedResourceResource.getResourceType(), iNestedResourceResource.getConfiguration() );
+ ((InternalResource) childResource).setResourceType( iNestedResourceResource.getResourceType() );
+ addKnowledgeResource( childResource,
+ iNestedResourceResource.getResourceType(),
+ iNestedResourceResource.getConfiguration() );
}
} else {
- addKnowledgeResource( iNestedResourceResource, iNestedResourceResource.getResourceType(), iNestedResourceResource.getConfiguration() );
+ addKnowledgeResource( iNestedResourceResource,
+ iNestedResourceResource.getResourceType(),
+ iNestedResourceResource.getConfiguration() );
}
}
}
@@ -532,9 +536,9 @@
throw new RuntimeException( e );
}
}
-
+
private Set<Resource> resourceDirectories = new HashSet<Resource>();
-
+
/**
* This adds a package from a Descr/AST This will also trigger a compile, if
* there are any generated classes to compile of course.
@@ -644,8 +648,6 @@
}
}
}
-
-
/**
* This checks to see if it should all be in the one namespace.
@@ -684,56 +686,60 @@
}
return results;
}
-
+
public synchronized void addPackage(final Package newPkg) {
- Package pkg = this.pkgRegistryMap.get( newPkg.getName() ).getPackage();
+ PackageRegistry pkgRegistry = this.pkgRegistryMap.get( newPkg.getName() );
+ Package pkg = null;
+ if ( pkgRegistry != null ) {
+ pkg = pkgRegistry.getPackage();
+ }
+ // // create new base package if it doesn't exist, as we always merge the newPkg into the existing one,
+ // // to isolate the base package from further possible changes to newPkg.
+ // if ( pkg == null ) {
+ // // create a new package, use the same parent classloader as the incoming new package
+ // pkg = new Package( newPkg.getName(),
+ // new MapBackedClassLoader( newPkg.getPackageScopeClassLoader().getParent() ) );
+ // //newPkg.getPackageScopeClassLoader() );
+ // pkgs.put( pkg.getName(),
+ // pkg );
+ // // add the dialect registry composite classloader (which uses the above classloader as it's parent)
+ // this.packageClassLoader.addClassLoader( pkg.getDialectRuntimeRegistry().getClassLoader() );
+ // }
- // // create new base package if it doesn't exist, as we always merge the newPkg into the existing one,
- // // to isolate the base package from further possible changes to newPkg.
- // if ( pkg == null ) {
- // // create a new package, use the same parent classloader as the incoming new package
- // pkg = new Package( newPkg.getName(),
- // new MapBackedClassLoader( newPkg.getPackageScopeClassLoader().getParent() ) );
- // //newPkg.getPackageScopeClassLoader() );
- // pkgs.put( pkg.getName(),
- // pkg );
- // // add the dialect registry composite classloader (which uses the above classloader as it's parent)
- // this.packageClassLoader.addClassLoader( pkg.getDialectRuntimeRegistry().getClassLoader() );
- // }
+ if ( pkg == null ) {
+ pkg = newPackage( new PackageDescr( newPkg.getName() ) ).getPackage();
+ }
- if ( pkg == null ) {
- pkg = newPackage( new PackageDescr( newPkg.getName() ) ).getPackage();
- }
-
- // first merge anything related to classloader re-wiring
- pkg.getDialectRuntimeRegistry().merge( newPkg.getDialectRuntimeRegistry(), this.rootClassLoader );
- if ( newPkg.getFunctions() != null ) {
- for ( Map.Entry<String, Function> entry : newPkg.getFunctions().entrySet() ) {
- pkg.addFunction( entry.getValue() );
+ // first merge anything related to classloader re-wiring
+ pkg.getDialectRuntimeRegistry().merge( newPkg.getDialectRuntimeRegistry(),
+ this.rootClassLoader );
+ if ( newPkg.getFunctions() != null ) {
+ for ( Map.Entry<String, Function> entry : newPkg.getFunctions().entrySet() ) {
+ pkg.addFunction( entry.getValue() );
+ }
+ }
+ pkg.getClassFieldAccessorStore().merge( newPkg.getClassFieldAccessorStore() );
+ pkg.getDialectRuntimeRegistry().onBeforeExecute();
+
+ // we have to do this before the merging, as it does some classloader resolving
+ TypeDeclaration lastType = null;
+ try {
+ // Add the type declarations to the RuleBase
+ if ( newPkg.getTypeDeclarations() != null ) {
+ // add type declarations
+ for ( TypeDeclaration type : newPkg.getTypeDeclarations().values() ) {
+ lastType = type;
+ type.setTypeClass( this.rootClassLoader.loadClass( pkg.getName() + "." + type.getTypeName() ) );
}
- }
- pkg.getClassFieldAccessorStore().merge( newPkg.getClassFieldAccessorStore() );
- pkg.getDialectRuntimeRegistry().onBeforeExecute();
-
- // we have to do this before the merging, as it does some classloader resolving
- TypeDeclaration lastType = null;
- try {
- // Add the type declarations to the RuleBase
- if ( newPkg.getTypeDeclarations() != null ) {
- // add type declarations
- for ( TypeDeclaration type : newPkg.getTypeDeclarations().values() ) {
- lastType = type;
- type.setTypeClass( this.rootClassLoader.loadClass( pkg.getName() + "." + type.getTypeName() ) );
- }
- }
- } catch ( ClassNotFoundException e ) {
- throw new RuntimeDroolsException( "unable to resolve Type Declaration class '" + lastType.getTypeName()+"'" );
- }
+ }
+ } catch ( ClassNotFoundException e ) {
+ throw new RuntimeDroolsException( "unable to resolve Type Declaration class '" + lastType.getTypeName() + "'" );
+ }
- // now merge the new package into the existing one
- mergePackage( pkg,
- newPkg );
+ // now merge the new package into the existing one
+ mergePackage( pkg,
+ newPkg );
}
@@ -800,10 +806,9 @@
final Process flow = (Process) iter.next();
pkg.addProcess( flow );
}
- }
+ }
}
-
//
// private void validatePackageName(final PackageDescr packageDescr) {
@@ -933,7 +938,7 @@
}
TypeDeclaration type = new TypeDeclaration( typeDescr.getTypeName() );
- if ( resource != null && ((InternalResource)resource).hasURL() ) {
+ if ( resource != null && ((InternalResource) resource).hasURL() ) {
type.setResource( this.resource );
}
@@ -1009,7 +1014,7 @@
}
String expiration = typeDescr.getMetaAttribute( TypeDeclaration.ATTR_EXPIRE );
if ( expiration != null ) {
- if( timeParser == null ) {
+ if ( timeParser == null ) {
timeParser = new TimeIntervalParser();
}
type.setExpirationOffset( timeParser.parse( expiration )[0].longValue() );
@@ -1159,7 +1164,7 @@
this.results.addAll( context.getErrors() );
- if ( resource != null && (( InternalResource ) resource).hasURL() ) {
+ if ( resource != null && ((InternalResource) resource).hasURL() ) {
context.getRule().setResource( resource );
}
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/testframework/MockWorkingMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/testframework/MockWorkingMemory.java 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/testframework/MockWorkingMemory.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -43,6 +43,7 @@
import org.drools.reteoo.PartitionTaskManager;
import org.drools.rule.Rule;
import org.drools.rule.TimeMachine;
+import org.drools.runtime.ExitPoint;
import org.drools.runtime.KnowledgeRuntime;
import org.drools.spi.Activation;
import org.drools.spi.AgendaFilter;
@@ -502,4 +503,9 @@
}
+ public Map<String, ExitPoint> getExitPoints() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
Modified: labs/jbossrules/trunk/drools-core/.classpath
===================================================================
--- labs/jbossrules/trunk/drools-core/.classpath 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-core/.classpath 2008-12-23 18:58:19 UTC (rev 24484)
@@ -5,13 +5,24 @@
<classpathentry kind="src" path="src/test/resources" output="target/test-classes" including="**" excluding="**/*.java"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.3/commons-lang-2.3.jar"/>
+ <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1/commons-logging-1.1.jar"/>
<classpathentry kind="src" path="/drools-api"/>
+ <classpathentry kind="var" path="M2_REPO/org/freemarker/freemarker/2.3.9/freemarker-2.3.9.jar"/>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/com/sun/xml/bind/jaxb-xjc/2.0.3/jaxb-xjc-2.0.3.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.5.0.1/jmock-2.5.0.1.jar"/>
<classpathentry kind="var" path="M2_REPO/joda-time/joda-time/1.5.2/joda-time-1.5.2.jar"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.13/log4j-1.2.13.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-commons/1.1/milyn-commons-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-smooks-core/1.1/milyn-smooks-core-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-smooks-javabean/1.1/milyn-smooks-javabean-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/mvel/mvel/1.3.12-java1.5/mvel-1.3.12-java1.5.jar"/>
<classpathentry kind="var" path="M2_REPO/org/mvel/mvel2/2.0.4-SNAPSHOT/mvel2-2.0.4-SNAPSHOT.jar"/>
+ <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.8.0/xercesImpl-2.8.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/2.0.2/xml-apis-2.0.2.jar"/>
<classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar"/>
<classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.3/xstream-1.3.jar"/>
</classpath>
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -405,7 +405,7 @@
this.wms = null;
}
-
+
/**
* Add a <code>Package</code> to the network. Iterates through the
* <code>Package</code> adding Each individual <code>Rule</code> to the
@@ -414,106 +414,99 @@
*
* @param newPkg
* The package to add.
- */
- public synchronized void addPackage(final Package newPkg) {
- newPkg.checkValidity();
+ */
+ public synchronized void addPackages(final Collection<Package> newPkgs) {
synchronized ( this.pkgs ) {
- Package pkg = this.pkgs.get( newPkg.getName() );
-
// only acquire the lock if it hasn't been done explicitely
boolean doUnlock = false;
if ( !this.lock.isHeldByCurrentThread() && (this.wms == null || this.wms.length == 0) ) {
lock();
doUnlock = true;
}
- this.additionsSinceLock++;
-
- this.eventSupport.fireBeforePackageAdded( newPkg );
-
- // // create new base package if it doesn't exist, as we always merge the newPkg into the existing one,
- // // to isolate the base package from further possible changes to newPkg.
- // if ( pkg == null ) {
- // // create a new package, use the same parent classloader as the incoming new package
- // pkg = new Package( newPkg.getName(),
- // new MapBackedClassLoader( newPkg.getPackageScopeClassLoader().getParent() ) );
- // //newPkg.getPackageScopeClassLoader() );
- // pkgs.put( pkg.getName(),
- // pkg );
- // // add the dialect registry composite classloader (which uses the above classloader as it's parent)
- // this.packageClassLoader.addClassLoader( pkg.getDialectRuntimeRegistry().getClassLoader() );
- // }
-
- if ( pkg == null ) {
- pkg = new Package( newPkg.getName() );
+
+ // we need to merge all byte[] first, so that the root classloader can resolve classes
+ for ( Package newPkg : newPkgs ) {
+ newPkg.checkValidity();
+ this.additionsSinceLock++;
+ this.eventSupport.fireBeforePackageAdded( newPkg );
- // @TODO we really should have a single root cache
- pkg.setClassFieldAccessorCache( this.classFieldAccessorCache );
- pkgs.put( pkg.getName(),
- pkg );
- }
+ Package pkg = this.pkgs.get( newPkg.getName() );
+ if ( pkg == null ) {
+ pkg = new Package( newPkg.getName() );
+
+ // @TODO we really should have a single root cache
+ pkg.setClassFieldAccessorCache( this.classFieldAccessorCache );
+ pkgs.put( pkg.getName(),
+ pkg );
+ }
+
+ // first merge anything related to classloader re-wiring
+ pkg.getDialectRuntimeRegistry().merge( newPkg.getDialectRuntimeRegistry(), this.rootClassLoader );
+ }
- // first merge anything related to classloader re-wiring
- pkg.getDialectRuntimeRegistry().merge( newPkg.getDialectRuntimeRegistry(), this.rootClassLoader );
- if ( newPkg.getFunctions() != null ) {
- for ( Map.Entry<String, Function> entry : newPkg.getFunctions().entrySet() ) {
- pkg.addFunction( entry.getValue() );
- }
- }
- pkg.getClassFieldAccessorStore().merge( newPkg.getClassFieldAccessorStore() );
- pkg.getDialectRuntimeRegistry().onBeforeExecute();
-
- // we have to do this before the merging, as it does some classloader resolving
- TypeDeclaration lastType = null;
- try {
- // Add the type declarations to the RuleBase
- if ( newPkg.getTypeDeclarations() != null ) {
- // add type declarations
- for ( TypeDeclaration type : newPkg.getTypeDeclarations().values() ) {
- lastType = type;
- type.setTypeClass( this.rootClassLoader.loadClass( pkg.getName() + "." + type.getTypeName() ) );
- // @TODO should we allow overrides? only if the class is not in use.
- if ( !this.classTypeDeclaration.containsKey( type.getTypeClass() ) ) {
- // add to rulebase list of type declarations
- this.classTypeDeclaration.put( type.getTypeClass(),
- type );
+ for ( Package newPkg : newPkgs ) {
+ Package pkg = this.pkgs.get( newPkg.getName() );
+
+ if ( newPkg.getFunctions() != null ) {
+ for ( Map.Entry<String, Function> entry : newPkg.getFunctions().entrySet() ) {
+ pkg.addFunction( entry.getValue() );
+ }
+ }
+ pkg.getClassFieldAccessorStore().merge( newPkg.getClassFieldAccessorStore() );
+ pkg.getDialectRuntimeRegistry().onBeforeExecute();
+
+ // we have to do this before the merging, as it does some classloader resolving
+ TypeDeclaration lastType = null;
+ try {
+ // Add the type declarations to the RuleBase
+ if ( newPkg.getTypeDeclarations() != null ) {
+ // add type declarations
+ for ( TypeDeclaration type : newPkg.getTypeDeclarations().values() ) {
+ lastType = type;
+ type.setTypeClass( this.rootClassLoader.loadClass( pkg.getName() + "." + type.getTypeName() ) );
+ // @TODO should we allow overrides? only if the class is not in use.
+ if ( !this.classTypeDeclaration.containsKey( type.getTypeClass() ) ) {
+ // add to rulebase list of type declarations
+ this.classTypeDeclaration.put( type.getTypeClass(),
+ type );
+ }
}
}
- }
- } catch ( ClassNotFoundException e ) {
- throw new RuntimeDroolsException( "unable to resolve Type Declaration class '" + lastType.getTypeName()+"'" );
- }
+ } catch ( ClassNotFoundException e ) {
+ throw new RuntimeDroolsException( "unable to resolve Type Declaration class '" + lastType.getTypeName()+"'" );
+ }
- // now merge the new package into the existing one
- mergePackage( pkg,
- newPkg );
+ // now merge the new package into the existing one
+ mergePackage( pkg,
+ newPkg );
- // add the rules to the RuleBase
- final Rule[] rules = newPkg.getRules();
- for ( int i = 0; i < rules.length; ++i ) {
- addRule( newPkg,
- rules[i] );
- }
+ // add the rules to the RuleBase
+ final Rule[] rules = newPkg.getRules();
+ for ( int i = 0; i < rules.length; ++i ) {
+ addRule( newPkg,
+ rules[i] );
+ }
- // add the flows to the RuleBase
- if ( newPkg.getRuleFlows() != null ) {
- final Map flows = newPkg.getRuleFlows();
- for ( final Object object : newPkg.getRuleFlows().entrySet() ) {
- final Entry flow = (Entry) object;
- this.processes.put( flow.getKey(),
- flow.getValue() );
+ // add the flows to the RuleBase
+ if ( newPkg.getRuleFlows() != null ) {
+ final Map flows = newPkg.getRuleFlows();
+ for ( final Object object : newPkg.getRuleFlows().entrySet() ) {
+ final Entry flow = (Entry) object;
+ this.processes.put( flow.getKey(),
+ flow.getValue() );
+ }
}
- }
- this.eventSupport.fireAfterPackageAdded( newPkg );
-
+ this.eventSupport.fireAfterPackageAdded( newPkg );
+ }
// only unlock if it had been acquired implicitely
if ( doUnlock ) {
unlock();
}
}
+
+ }
- }
-
/**
* Merge a new package with an existing package.
* Most of the work is done by the concrete implementations,
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -84,6 +84,7 @@
import org.drools.rule.Rule;
import org.drools.rule.TimeMachine;
import org.drools.ruleflow.core.RuleFlowProcess;
+import org.drools.runtime.ExitPoint;
import org.drools.runtime.KnowledgeRuntime;
import org.drools.runtime.process.EventListener;
import org.drools.runtime.process.WorkItemHandler;
@@ -205,6 +206,8 @@
private Map<InternalFactHandle, PropagationContext> modifyContexts;
private KnowledgeRuntime kruntime;
+
+ private Map<String, ExitPoint> exitPoints;
// ------------------------------------------------------------
// Constructors
@@ -301,7 +304,8 @@
this.entryPoint = EntryPoint.DEFAULT;
this.firing = new AtomicBoolean( false );
this.modifyContexts = new HashMap<InternalFactHandle, PropagationContext>();
-
+ this.exitPoints = new ConcurrentHashMap<String, ExitPoint>();
+ //setGlobal( "exitPoints", Collections.unmodifiableMap( this.exitPoints ) );
initProcessEventListeners();
initPartitionManagers();
initTransient();
@@ -1806,5 +1810,17 @@
public KnowledgeRuntime getKnowledgeRuntime() {
return this.kruntime;
}
+
+ public void registerExitPoint(String name, ExitPoint exitPoint) {
+ this.exitPoints.put(name, exitPoint);
+ }
+ public void unregisterExitPoint(String name) {
+ this.exitPoints.remove( name );
+ }
+
+ public Map<String, ExitPoint> getExitPoints() {
+ return this.exitPoints;
+ }
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,5 +1,6 @@
package org.drools.common;
+import java.util.Map;
import java.util.concurrent.locks.Lock;
import org.drools.FactException;
@@ -15,6 +16,7 @@
import org.drools.reteoo.PartitionTaskManager;
import org.drools.rule.Rule;
import org.drools.rule.TimeMachine;
+import org.drools.runtime.ExitPoint;
import org.drools.runtime.KnowledgeRuntime;
import org.drools.spi.Activation;
import org.drools.spi.FactHandleFactory;
@@ -113,4 +115,6 @@
public void setKnowledgeRuntime(KnowledgeRuntime kruntime);
public KnowledgeRuntime getKnowledgeRuntime();
+
+ public Map<String, ExitPoint> getExitPoints();
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/KnowledgeBaseImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/KnowledgeBaseImpl.java 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/KnowledgeBaseImpl.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -108,9 +108,11 @@
}
public void addKnowledgePackages(Collection<KnowledgePackage> knowledgePackages) {
+ List<Package> list = new ArrayList<Package>();
for ( KnowledgePackage knowledgePackage : knowledgePackages ) {
- ruleBase.addPackage( ((KnowledgePackageImp) knowledgePackage).pkg );
+ list.add( ((KnowledgePackageImp) knowledgePackage).pkg );
}
+ ((ReteooRuleBase)ruleBase).addPackages( list);
}
public Collection<KnowledgePackage> getKnowledgePackages() {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/StatefulKnowledgeSessionImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/StatefulKnowledgeSessionImpl.java 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/StatefulKnowledgeSessionImpl.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -45,6 +45,7 @@
import org.drools.event.rule.impl.ObjectRetractedEventImpl;
import org.drools.event.rule.impl.ObjectUpdatedEventImpl;
import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.ExitPoint;
import org.drools.runtime.GlobalResolver;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.process.ProcessInstance;
@@ -558,4 +559,12 @@
return new AgendaImpl( ( InternalAgenda ) this.session.getAgenda() );
}
+ public void registerExitPoint(String name, ExitPoint exitPoint) {
+ this.session.registerExitPoint(name, exitPoint);
+ }
+
+ public void unregisterExitPoint(String name) {
+ this.session.unregisterExitPoint(name);
+ }
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -21,7 +21,12 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import org.drools.FactException;
import org.drools.RuleBaseConfiguration;
@@ -376,13 +381,17 @@
}
public void addPackages(Package[] pkgs ) {
- for (Package pkg : pkgs) {
- addPackage( pkg );
- }
+ addPackages( Arrays.asList( pkgs ) );
}
+
+ public void addPackages(Collection<Package> pkgs ) {
+ super.addPackages( pkgs );
+ }
public synchronized void addPackage(final Package newPkg) {
- super.addPackage( newPkg );
+ List<Package> list = new ArrayList<Package>();
+ list.add( newPkg );
+ super.addPackages( list );
if ( this.config.isSequential() ) {
this.reteooBuilder.setOrdered( false );
}
Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/DataLoaderProviderImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/DataLoaderProviderImpl.java (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/DataLoaderProviderImpl.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,24 @@
+package org.drools.runtime.dataloader.impl;
+
+import org.drools.definition.pipeline.Receiver;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.StatelessKnowledgeSession;
+import org.drools.runtime.dataloader.DataLoaderProvider;
+import org.drools.runtime.dataloader.StatefulKnowledgeSessionDataLoader;
+import org.drools.runtime.dataloader.StatelessKnowledgeSessionDataLoader;
+
+public class DataLoaderProviderImpl
+ implements
+ DataLoaderProvider {
+
+ public StatefulKnowledgeSessionDataLoader newStatefulKnowledgeSessionDataLoader(StatefulKnowledgeSession ksession,
+ Receiver pipeline) {
+ return new StatefulKnowledgeSessionDataLoaderImpl(ksession, pipeline);
+ }
+
+ public StatelessKnowledgeSessionDataLoader newStatelessKnowledgeSessionDataLoader(StatelessKnowledgeSession ksession,
+ Receiver pipeline) {
+ return newStatelessKnowledgeSessionDataLoader(ksession, pipeline);
+ }
+
+}
Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatefulKnowledgeSessionDataLoaderImpl.java (from rev 24377, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/dataloaders/smooks/DroolsSmooksStatefulSession.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatefulKnowledgeSessionDataLoaderImpl.java (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatefulKnowledgeSessionDataLoaderImpl.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,35 @@
+package org.drools.runtime.dataloader.impl;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.drools.definition.pipeline.Emitter;
+import org.drools.definition.pipeline.Receiver;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.dataloader.StatefulKnowledgeSessionDataLoader;
+
+public class StatefulKnowledgeSessionDataLoaderImpl
+ implements
+ StatefulKnowledgeSessionDataLoader {
+ private StatefulKnowledgeSession ksession;
+
+ private Receiver pipeline;
+
+ public StatefulKnowledgeSessionDataLoaderImpl(StatefulKnowledgeSession ksession,
+ Receiver pipeline) {
+ this.ksession = ksession;
+ this.pipeline = pipeline;
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.dataloaders.smooks.StatefulKnowledgeSessionDataLoader#insert(java.lang.Object)
+ */
+ public Map insert(Object object) {
+ StatefulKnowledgeSessionPipelineContext context = new StatefulKnowledgeSessionPipelineContext( this.ksession );
+ this.pipeline.signal( object,
+ context );
+
+ return context.getHandles();
+ }
+
+}
Property changes on: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatefulKnowledgeSessionDataLoaderImpl.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatefulKnowledgeSessionPipelineContext.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatefulKnowledgeSessionPipelineContext.java (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatefulKnowledgeSessionPipelineContext.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,36 @@
+/**
+ *
+ */
+package org.drools.runtime.dataloader.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.common.InternalRuleBase;
+import org.drools.impl.KnowledgeBaseImpl;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.pipeline.PipelineContext;
+import org.drools.runtime.pipeline.impl.BasePipelineContext;
+import org.drools.runtime.rule.FactHandle;
+
+public class StatefulKnowledgeSessionPipelineContext extends BasePipelineContext
+ implements
+ PipelineContext {
+ private Map handles;
+ private StatefulKnowledgeSession ksession;
+
+ public StatefulKnowledgeSessionPipelineContext(StatefulKnowledgeSession ksession) {
+ super( ((InternalRuleBase)((KnowledgeBaseImpl)((StatefulKnowledgeSessionImpl)ksession).getKnowledgeBase()).getRuleBase()).getRootClassLoader() );
+ this.handles = new HashMap<FactHandle, Object>();
+ this.ksession = ksession;
+ }
+
+ public Map getHandles() {
+ return handles;
+ }
+
+ public StatefulKnowledgeSession getKsession() {
+ return ksession;
+ }
+}
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatefulKnowledgeSessionReceiverAdapter.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatefulKnowledgeSessionReceiverAdapter.java (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatefulKnowledgeSessionReceiverAdapter.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,23 @@
+/**
+ *
+ */
+package org.drools.runtime.dataloader.impl;
+
+import org.drools.definition.pipeline.Adapter;
+import org.drools.runtime.pipeline.PipelineContext;
+import org.drools.runtime.pipeline.impl.BaseStage;
+import org.drools.runtime.rule.FactHandle;
+
+public class StatefulKnowledgeSessionReceiverAdapter extends BaseStage
+ implements
+ Adapter {
+ public void signal(Object object,
+ PipelineContext context) {
+ StatefulKnowledgeSessionPipelineContext pContext = (StatefulKnowledgeSessionPipelineContext) context;
+
+ FactHandle handle = ((pContext).getKsession()).insert( object );
+ ((pContext).getHandles()).put( handle,
+ object );
+ }
+
+}
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatelessKnowledgeSessionDataLoaderImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatelessKnowledgeSessionDataLoaderImpl.java (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatelessKnowledgeSessionDataLoaderImpl.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,72 @@
+package org.drools.runtime.dataloader.impl;
+
+import org.drools.definition.pipeline.Receiver;
+import org.drools.runtime.Parameters;
+import org.drools.runtime.StatelessKnowledgeSession;
+import org.drools.runtime.StatelessKnowledgeSessionResults;
+import org.drools.runtime.dataloader.StatelessKnowledgeSessionDataLoader;
+
+public class StatelessKnowledgeSessionDataLoaderImpl implements StatelessKnowledgeSessionDataLoader {
+ private StatelessKnowledgeSession ksession;
+
+ private Receiver pipeline;
+
+ public StatelessKnowledgeSessionDataLoaderImpl(StatelessKnowledgeSession ksession,
+ Receiver pipeline) {
+ this.ksession = ksession;
+ this.pipeline = pipeline;
+ }
+
+ // public Map insert(Object object) {
+ // StatefulKnowledgeSessionPipelineContext context = new StatefulKnowledgeSessionPipelineContext( this.ksession );
+ // this.pipeline.signal( object,
+ // context );
+ //
+ // return context.getHandles();
+ // }
+
+ /* (non-Javadoc)
+ * @see org.drools.dataloaders.smooks.StatelessKnowledeSessionDataLoader#executeObject(java.lang.Object)
+ */
+ public void executeObject(Object object) {
+ StatelessKnowledgeSessionPipelineContext context = new StatelessKnowledgeSessionPipelineContext( this.ksession );
+ this.pipeline.signal( object,
+ context );
+ this.ksession.executeObject( context.getResult().get( 0 ) );
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.dataloaders.smooks.StatelessKnowledeSessionDataLoader#executeIterable(java.lang.Object)
+ */
+ public void executeIterable(Object object) {
+ StatelessKnowledgeSessionPipelineContext context = new StatelessKnowledgeSessionPipelineContext( this.ksession );
+ this.pipeline.signal( object,
+ context );
+ this.ksession.executeIterable( (Iterable) context.getResult() );
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.dataloaders.smooks.StatelessKnowledeSessionDataLoader#executeObjectWithParameters(java.lang.Object, org.drools.runtime.Parameters)
+ */
+ public StatelessKnowledgeSessionResults executeObjectWithParameters(Object object,
+ Parameters parameters) {
+ StatelessKnowledgeSessionPipelineContext context = new StatelessKnowledgeSessionPipelineContext( this.ksession );
+ this.pipeline.signal( object,
+ context );
+ return this.ksession.executeObjectWithParameters( context.getResult().get( 0 ),
+ parameters );
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.dataloaders.smooks.StatelessKnowledeSessionDataLoader#executeIterableWithParameters(java.lang.Object, org.drools.runtime.Parameters)
+ */
+ public StatelessKnowledgeSessionResults executeIterableWithParameters(Object object,
+ Parameters parameters) {
+ StatelessKnowledgeSessionPipelineContext context = new StatelessKnowledgeSessionPipelineContext( this.ksession );
+ this.pipeline.signal( object,
+ context );
+ return this.ksession.executeIterableWithParameters( (Iterable) context.getResult(),
+ parameters );
+ }
+
+}
Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatelessKnowledgeSessionPipelineContext.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatelessKnowledgeSessionPipelineContext.java (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatelessKnowledgeSessionPipelineContext.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,32 @@
+/**
+ *
+ */
+package org.drools.runtime.dataloader.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.common.InternalRuleBase;
+import org.drools.impl.StatelessKnowledgeSessionImpl;
+import org.drools.runtime.StatelessKnowledgeSession;
+import org.drools.runtime.pipeline.PipelineContext;
+import org.drools.runtime.pipeline.impl.BasePipelineContext;
+
+public class StatelessKnowledgeSessionPipelineContext extends BasePipelineContext
+ implements
+ PipelineContext {
+ private List results = new ArrayList();
+
+ public StatelessKnowledgeSessionPipelineContext(StatelessKnowledgeSession ksession) {
+ super( ((InternalRuleBase) ((StatelessKnowledgeSessionImpl) ksession).getRuleBase()).getRootClassLoader() );
+ }
+
+ public List getResult() {
+ return this.results;
+ }
+
+ public void addResult(Object result) {
+ this.results.add( result );
+ }
+
+}
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatelessKnowledgeSessionReceiverAdapter.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatelessKnowledgeSessionReceiverAdapter.java (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/dataloader/impl/StatelessKnowledgeSessionReceiverAdapter.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,19 @@
+/**
+ *
+ */
+package org.drools.runtime.dataloader.impl;
+
+import org.drools.definition.pipeline.Adapter;
+import org.drools.runtime.pipeline.PipelineContext;
+import org.drools.runtime.pipeline.impl.BaseStage;
+
+public class StatelessKnowledgeSessionReceiverAdapter extends BaseStage
+ implements
+ Adapter {
+ public void signal(Object object,
+ PipelineContext context) {
+ StatelessKnowledgeSessionPipelineContext pContext = (StatelessKnowledgeSessionPipelineContext) context;
+ pContext.addResult( object );
+ }
+
+}
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/BaseEmitter.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/BaseEmitter.java (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/BaseEmitter.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,41 @@
+package org.drools.runtime.pipeline.impl;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.drools.definition.pipeline.Emitter;
+import org.drools.definition.pipeline.Receiver;
+import org.drools.runtime.pipeline.PipelineContext;
+
+public class BaseEmitter extends BaseStage
+ implements
+ Emitter {
+ protected List<Receiver> receivers;
+
+ public BaseEmitter() {
+ this.receivers = new CopyOnWriteArrayList<Receiver>();
+ }
+
+ public void addReceiver(Receiver receiver) {
+ this.receivers.add( receiver );
+ }
+
+ public void removeReceiver(Receiver receiver) {
+ this.receivers.remove( receiver );
+ }
+
+ public Collection<Receiver> getReceivers() {
+ return Collections.unmodifiableCollection( this.receivers );
+ }
+
+ protected void emit(Object object,
+ PipelineContext context) {
+ for ( Receiver receiver : this.receivers ) {
+ receiver.signal( object,
+ context );
+ }
+ }
+
+}
Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/BasePipelineContext.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/BasePipelineContext.java (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/BasePipelineContext.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,15 @@
+package org.drools.runtime.pipeline.impl;
+
+import org.drools.runtime.pipeline.PipelineContext;
+
+public class BasePipelineContext implements PipelineContext {
+ private ClassLoader rootClassLoader;
+
+ public BasePipelineContext(ClassLoader rootClassLoader) {
+ this.rootClassLoader = rootClassLoader;
+ }
+
+ public ClassLoader getClassLoader() {
+ return this.rootClassLoader;
+ }
+}
Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/BaseStage.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/BaseStage.java (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/BaseStage.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,25 @@
+package org.drools.runtime.pipeline.impl;
+
+import org.drools.definition.pipeline.Stage;
+import org.drools.definition.pipeline.StageExceptionHandler;
+
+public class BaseStage implements Stage {
+ private StageExceptionHandler exceptionHandler;
+
+ public BaseStage() {
+ super();
+ }
+
+ public void setStageExceptionHandler(StageExceptionHandler exceptionHandler) {
+ this.exceptionHandler = exceptionHandler;
+ }
+
+ protected void handleException(Stage stage, Object object, Exception exception) {
+ if ( this.exceptionHandler != null ) {
+ this.exceptionHandler.handleException( stage, object, exception );
+ } else {
+ throw new RuntimeException( exception );
+ }
+ }
+
+}
Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/CorePipelineProviderImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/CorePipelineProviderImpl.java (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/CorePipelineProviderImpl.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,26 @@
+package org.drools.runtime.pipeline.impl;
+
+import org.drools.definition.pipeline.Adapter;
+import org.drools.definition.pipeline.CorePipelineProvider;
+import org.drools.definition.pipeline.Expression;
+import org.drools.definition.pipeline.Splitter;
+import org.drools.runtime.dataloader.impl.StatefulKnowledgeSessionReceiverAdapter;
+import org.drools.runtime.dataloader.impl.StatelessKnowledgeSessionReceiverAdapter;
+
+public class CorePipelineProviderImpl implements CorePipelineProvider {
+ public Expression newMvelExpression(String expression) {
+ return new MvelExpression(expression);
+ }
+
+ public Splitter newIterateSplitter() {
+ return new IterateSplitter();
+ }
+
+ public Adapter newStatefulKnowledgeSessionReceiverAdapter() {
+ return new StatefulKnowledgeSessionReceiverAdapter();
+ }
+
+ public Adapter newStatelessKnowledgeSessionReceiverAdapter() {
+ return new StatelessKnowledgeSessionReceiverAdapter();
+ }
+}
Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/IterateSplitter.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/IterateSplitter.java (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/IterateSplitter.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,23 @@
+package org.drools.runtime.pipeline.impl;
+
+import org.drools.definition.pipeline.Splitter;
+import org.drools.runtime.pipeline.PipelineContext;
+
+public class IterateSplitter extends BaseEmitter
+ implements
+ Splitter {
+
+ public void signal(Object object,
+ PipelineContext context) {
+ if ( object instanceof Iterable ) {
+ for ( Object result : ((Iterable) object) ) {
+ emit( result,
+ context );
+ }
+ } else {
+ emit( object,
+ context );
+ }
+ }
+
+}
Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/MvelExpression.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/MvelExpression.java (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/pipeline/impl/MvelExpression.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,41 @@
+package org.drools.runtime.pipeline.impl;
+
+import java.io.Serializable;
+
+import org.drools.definition.pipeline.Expression;
+import org.drools.definition.pipeline.Receiver;
+import org.drools.runtime.pipeline.PipelineContext;
+import org.mvel2.MVEL;
+import org.mvel2.ParserContext;
+import org.mvel2.compiler.ExpressionCompiler;
+
+public class MvelExpression extends BaseEmitter
+ implements
+ Expression,
+ Receiver {
+ private Serializable expr;
+
+ public MvelExpression(String text) {
+ final ParserContext parserContext = new ParserContext();
+ parserContext.setStrictTypeEnforcement( false );
+
+ ExpressionCompiler compiler = new ExpressionCompiler( text );
+ this.expr = compiler.compile( parserContext );
+ }
+
+ public void signal(Object object,
+ PipelineContext context) {
+ Object result = null;
+ try {
+ result = MVEL.executeExpression( this.expr,
+ object );
+ } catch ( Exception e ) {
+ handleException( this,
+ object,
+ e );
+ }
+ emit( result,
+ context );
+ }
+
+}
Modified: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/.classpath
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/.classpath 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/.classpath 2008-12-23 18:58:19 UTC (rev 24484)
@@ -7,10 +7,13 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1/activation-1.1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.1.1/antlr-runtime-3.1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.3/commons-lang-2.3.jar"/>
+ <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1/commons-logging-1.1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/core/3.4.2.v_883_R34x/core-3.4.2.v_883_R34x.jar"/>
<classpathentry kind="src" path="/drools-api"/>
<classpathentry kind="src" path="/drools-compiler"/>
<classpathentry kind="src" path="/drools-core"/>
+ <classpathentry kind="var" path="M2_REPO/org/freemarker/freemarker/2.3.9/freemarker-2.3.9.jar"/>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar"/>
<classpathentry kind="var" path="M2_REPO/janino/janino/2.5.15/janino-2.5.15.jar"/>
@@ -21,5 +24,14 @@
<classpathentry kind="var" path="M2_REPO/joda-time/joda-time/1.5.2/joda-time-1.5.2.jar"/>
<classpathentry kind="var" path="M2_REPO/javax/xml/bind/jsr173_api/1.0/jsr173_api-1.0.jar"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.13/log4j-1.2.13.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-commons/1.1/milyn-commons-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-smooks-core/1.1/milyn-smooks-core-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-smooks-javabean/1.1/milyn-smooks-javabean-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/mvel/mvel/1.3.12-java1.5/mvel-1.3.12-java1.5.jar"/>
<classpathentry kind="var" path="M2_REPO/org/mvel/mvel2/2.0.4-SNAPSHOT/mvel2-2.0.4-SNAPSHOT.jar"/>
+ <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.8.0/xercesImpl-2.8.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/2.0.2/xml-apis-2.0.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar"/>
+ <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.3/xstream-1.3.jar"/>
</classpath>
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline (from rev 24469, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/dataloaders/jaxb)
Property changes on: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline/DroolsJaxbConfiguration.java
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/dataloaders/jaxb/DroolsJaxbConfiguration.java 2008-12-22 20:42:13 UTC (rev 24469)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline/DroolsJaxbConfiguration.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,22 +0,0 @@
-package org.drools.dataloaders.jaxb;
-
-public class DroolsJaxbConfiguration {
- private String iterableGetter;
-
- public DroolsJaxbConfiguration() {
- this.iterableGetter = null;
- }
-
- public DroolsJaxbConfiguration(String iterableGetter) {
- this.iterableGetter = iterableGetter;
- }
-
- public String getIterableGetter() {
- return iterableGetter;
- }
-
- public void setIterableGetter(String iterableGetter) {
- this.iterableGetter = iterableGetter;
- }
-
-}
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline/DroolsJaxbHelper.java
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/dataloaders/jaxb/DroolsJaxbHelper.java 2008-12-22 20:42:13 UTC (rev 24469)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline/DroolsJaxbHelper.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,293 +0,0 @@
-package org.drools.dataloaders.jaxb;
-
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.ByteArrayOutputStream;
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-
-import org.drools.RuleBase;
-import org.drools.common.InternalRuleBase;
-import org.drools.compiler.PackageBuilder;
-import org.drools.compiler.PackageRegistry;
-import org.drools.lang.descr.PackageDescr;
-import org.drools.rule.builder.dialect.java.JavaDialect;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXParseException;
-
-import com.sun.codemodel.CodeWriter;
-import com.sun.codemodel.JCodeModel;
-import com.sun.codemodel.JPackage;
-import com.sun.tools.xjc.BadCommandLineException;
-import com.sun.tools.xjc.ErrorReceiver;
-import com.sun.tools.xjc.ModelLoader;
-import com.sun.tools.xjc.Options;
-import com.sun.tools.xjc.model.Model;
-import com.sun.tools.xjc.outline.Outline;
-
-public class DroolsJaxbHelper {
- public static String[] addModel(Reader reader,
- PackageBuilder pkgBuilder,
- Options xjcOpts,
- String systemId) throws IOException {
- InputSource source = new InputSource( new CachingRewindableReader( reader ) );
- source.setSystemId( systemId.trim().startsWith( "." ) ? systemId : "." + systemId );
-
- xjcOpts.addGrammar( source );
-
- try {
- xjcOpts.parseArguments( new String[] { "-npa" } );
- } catch ( BadCommandLineException e ) {
- throw new IllegalArgumentException("Unable to parse arguments", e);
- }
-
- ErrorReceiver errorReceiver = new JaxbErrorReceiver4Drools();
-
- Model model = ModelLoader.load( xjcOpts,
- new JCodeModel(),
- errorReceiver );
-
- final Outline outline = model.generateCode( xjcOpts,
- errorReceiver );
-
- MapVfsCodeWriter codeWriter = new MapVfsCodeWriter();
- model.codeModel.build( xjcOpts.createCodeWriter( codeWriter ) );
-
- Set<JavaDialect> dialects = new HashSet<JavaDialect>();
- List<String> classNames = new ArrayList<String>();
- for ( Entry<String, byte[]> entry : codeWriter.getMap().entrySet() ) {
- String name = entry.getKey();
-
- String pkgName = null;
- int dotPos = name.lastIndexOf( '.' );
- pkgName = name.substring( 0,
- dotPos );
-
- if ( !name.endsWith( "package-info.java" ) ) {
- classNames.add( pkgName );
- }
-
- dotPos = pkgName.lastIndexOf( '.' );
- if ( dotPos != -1 ) {
- pkgName = pkgName.substring( 0,
- dotPos );
- }
-
- PackageRegistry pkgReg = pkgBuilder.getPackageRegistry( pkgName );
- if ( pkgReg == null ) {
- pkgBuilder.addPackage( new PackageDescr( pkgName ) );
- pkgReg = pkgBuilder.getPackageRegistry( pkgName );
- }
-
- JavaDialect dialect = (JavaDialect) pkgReg.getDialectCompiletimeRegistry().getDialect( "java" );
- dialects.add( dialect );
- dialect.addSrc( convertToResource( entry.getKey() ),
- entry.getValue() );
- }
-
- pkgBuilder.compileAll();
- pkgBuilder.updateResults();
-
- return (String[]) classNames.toArray( new String[classNames.size()] );
- }
-
- public static JAXBContext newInstance(String[] classNames,
- RuleBase rb) throws JAXBException {
- return newInstance( classNames,
- Collections.<String, Object> emptyMap(),
- rb );
- }
-
- public static JAXBContext newInstance(String[] classNames,
- Map<String, ? > properties,
- RuleBase rb) throws JAXBException {
- ClassLoader classLoader = ((InternalRuleBase) rb).getRootClassLoader();
-
- Class[] classes = new Class[classNames.length];
- int i = 0;
- try {
- for ( i = 0; i < classNames.length; i++ ) {
- classes[i] = classLoader.loadClass( classNames[i] );
- }
- } catch ( ClassNotFoundException e ) {
- throw new JAXBException( "Unable to resolve class '" + classNames[i] + "'",
- e );
- }
-
- return JAXBContext.newInstance( classes,
- properties );
- }
-
- private static String convertToResource(String string) {
- int lastDot = string.lastIndexOf( '.' );
- return string.substring( 0,
- lastDot ).replace( '.',
- '/' ) + string.substring( lastDot,
- string.length() );
- }
-
- public static class MapVfsCodeWriter extends CodeWriter {
-
- private final Map<String, byte[]> map;
-
- private ByteArrayOutputStream currentBaos;
- private String currentPath;
-
- public MapVfsCodeWriter() {
- this.map = new LinkedHashMap<String, byte[]>();
- }
-
- public OutputStream openBinary(JPackage pkg,
- String fileName) throws IOException {
- String pkgName = pkg.name();
-
- if ( pkgName.length() != 0 ) {
- pkgName += '.';
- }
-
- if ( this.currentBaos != null ) {
- this.currentBaos.close();
- this.map.put( this.currentPath,
- this.currentBaos.toByteArray() );
- }
-
- this.currentPath = pkgName + fileName;
- this.currentBaos = new ByteArrayOutputStream();
-
- return new FilterOutputStream( this.currentBaos ) {
- public void close() {
- // don't let this stream close
- }
- };
- }
-
- public void close() throws IOException {
- if ( this.currentBaos != null ) {
- this.currentBaos.close();
- this.map.put( this.currentPath,
- this.currentBaos.toByteArray() );
- }
- }
-
- public Map<String, byte[]> getMap() {
- return this.map;
- }
-
- }
-
- public static class JaxbErrorReceiver4Drools extends ErrorReceiver {
-
- public String stage = "processing";
-
- public void warning(SAXParseException e) {
- e.printStackTrace();
- }
-
- public void error(SAXParseException e) {
- e.printStackTrace();
- }
-
- public void fatalError(SAXParseException e) {
- e.printStackTrace();
- }
-
- public void info(SAXParseException e) {
- e.printStackTrace();
- }
- }
-
- public static class CachingRewindableReader extends Reader {
- private Reader source;
- private boolean sourceClosed;
- private RewindableStringReader cache;
- private StringBuilder strBuilder;
-
- public CachingRewindableReader(Reader source) {
- this.source = source;
- this.strBuilder = new StringBuilder();
- }
-
- public int read(char[] cbuf,
- int off,
- int len) throws IOException {
- int value = 0;
- if ( this.cache == null ) {
- value = this.source.read( cbuf,
- off,
- len );
- if ( value != -1 ) {
- // keep appening to the stringBuilder until we are at the end
- this.strBuilder.append( cbuf,
- off,
- value );
- } else {
- // we are at the end, so switch to cache
- this.cache = new RewindableStringReader( strBuilder.toString() );
- }
- } else {
- value = this.cache.read( cbuf,
- off,
- len );
- }
- return value;
- }
-
- public void close() throws IOException {
- if ( !sourceClosed ) {
- // close the source, we only do this once.
- this.source.close();
- this.sourceClosed = true;
- }
-
- if ( cache == null ) {
- // switch to cache if we haven't already
- this.cache = new RewindableStringReader( strBuilder.toString() );
- } else {
- // reset the cache, so it can be read again.
- this.cache.reset();
- }
- }
- }
-
- public static class RewindableStringReader extends StringReader {
- public RewindableStringReader(String s) {
- super( s );
- }
-
- public void close() {
- try {
- reset();
- } catch ( IOException e ) {
- e.printStackTrace();
- }
- }
- }
-}
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline/DroolsJaxbStatefulSession.java
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/dataloaders/jaxb/DroolsJaxbStatefulSession.java 2008-12-22 20:42:13 UTC (rev 24469)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline/DroolsJaxbStatefulSession.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,94 +0,0 @@
-package org.drools.dataloaders.jaxb;
-
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.Reader;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-
-import org.drools.StatefulSession;
-import org.drools.runtime.rule.FactHandle;
-import org.mvel2.MVEL;
-import org.mvel2.ParserContext;
-import org.mvel2.compiler.ExpressionCompiler;
-
-public class DroolsJaxbStatefulSession {
- private Unmarshaller unmarshaller;
- private StatefulSession session;
- private DroolsJaxbConfiguration configuration;
- private Serializable getterExpr;
-
- public DroolsJaxbStatefulSession(StatefulSession session,
- Unmarshaller unmarshaller) {
- this( session,
- unmarshaller,
- new DroolsJaxbConfiguration() );
- }
-
- public DroolsJaxbStatefulSession(StatefulSession session,
- Unmarshaller unmarshaller,
- DroolsJaxbConfiguration configuration) {
- this.session = session;
- this.unmarshaller = unmarshaller;
- this.configuration = configuration;
-
- if ( this.configuration.getIterableGetter() != null ) {
- final ParserContext parserContext = new ParserContext();
- parserContext.setStrictTypeEnforcement( false );
-
- ExpressionCompiler compiler = new ExpressionCompiler( this.configuration.getIterableGetter() );
- this.getterExpr = compiler.compile( parserContext );
- }
- }
-
- public Map insertUnmarshalled(Reader reader) throws JAXBException {
-
- Object object = this.unmarshaller.unmarshal( reader );
- if ( object instanceof JAXBElement ) {
- object = ((JAXBElement)object).getValue().getClass().getName();
- }
- Map handles = new HashMap<FactHandle, Object>();
- if ( object == null ) {
- return handles;
- }
-
- if ( this.getterExpr != null ) {
- Iterable it = (Iterable) MVEL.executeExpression( this.getterExpr,
- object );
- if ( it != null ) {
- for ( Object item : it ) {
- FactHandle handle = this.session.insert( item );
- handles.put( handle,
- object );
- }
- }
- } else {
- FactHandle handle = this.session.insert( object );
- handles.put( handle,
- object );
-
- }
-
- return handles;
- }
-
-}
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline/impl/DroolsJaxbHelperProviderImpl.java (from rev 24469, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/dataloaders/jaxb/DroolsJaxbHelper.java)
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline/impl/DroolsJaxbHelperProviderImpl.java (rev 0)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline/impl/DroolsJaxbHelperProviderImpl.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,304 @@
+package org.drools.runtime.pipeline.impl;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.ByteArrayOutputStream;
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+
+import org.drools.KnowledgeBase;
+import org.drools.RuleBase;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.help.DroolsJaxbHelperProvider;
+import org.drools.builder.impl.KnowledgeBuilderImpl;
+import org.drools.common.InternalRuleBase;
+import org.drools.compiler.PackageBuilder;
+import org.drools.compiler.PackageRegistry;
+import org.drools.impl.KnowledgeBaseImpl;
+import org.drools.io.Resource;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.rule.builder.dialect.java.JavaDialect;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXParseException;
+
+import com.sun.codemodel.CodeWriter;
+import com.sun.codemodel.JCodeModel;
+import com.sun.codemodel.JPackage;
+import com.sun.tools.xjc.BadCommandLineException;
+import com.sun.tools.xjc.ErrorReceiver;
+import com.sun.tools.xjc.ModelLoader;
+import com.sun.tools.xjc.Options;
+import com.sun.tools.xjc.model.Model;
+import com.sun.tools.xjc.outline.Outline;
+
+public class DroolsJaxbHelperProviderImpl
+ implements
+ DroolsJaxbHelperProvider {
+ public String[] addXsdModel(Resource resource,
+ KnowledgeBuilder kbuilder,
+ Options xjcOpts,
+ String systemId) throws IOException {
+ PackageBuilder pkgBuilder = ((KnowledgeBuilderImpl) kbuilder).pkgBuilder;
+
+ InputSource source = new InputSource( new CachingRewindableReader( resource.getReader() ) );
+ source.setSystemId( systemId.trim().startsWith( "." ) ? systemId : "." + systemId );
+
+ xjcOpts.addGrammar( source );
+
+ try {
+ xjcOpts.parseArguments( new String[]{"-npa"} );
+ } catch ( BadCommandLineException e ) {
+ throw new IllegalArgumentException( "Unable to parse arguments",
+ e );
+ }
+
+ ErrorReceiver errorReceiver = new JaxbErrorReceiver4Drools();
+
+ Model model = ModelLoader.load( xjcOpts,
+ new JCodeModel(),
+ errorReceiver );
+
+ final Outline outline = model.generateCode( xjcOpts,
+ errorReceiver );
+
+ MapVfsCodeWriter codeWriter = new MapVfsCodeWriter();
+ model.codeModel.build( xjcOpts.createCodeWriter( codeWriter ) );
+
+ Set<JavaDialect> dialects = new HashSet<JavaDialect>();
+ List<String> classNames = new ArrayList<String>();
+ for ( Entry<String, byte[]> entry : codeWriter.getMap().entrySet() ) {
+ String name = entry.getKey();
+
+ String pkgName = null;
+ int dotPos = name.lastIndexOf( '.' );
+ pkgName = name.substring( 0,
+ dotPos );
+
+ if ( !name.endsWith( "package-info.java" ) ) {
+ classNames.add( pkgName );
+ }
+
+ dotPos = pkgName.lastIndexOf( '.' );
+ if ( dotPos != -1 ) {
+ pkgName = pkgName.substring( 0,
+ dotPos );
+ }
+
+ PackageRegistry pkgReg = pkgBuilder.getPackageRegistry( pkgName );
+ if ( pkgReg == null ) {
+ pkgBuilder.addPackage( new PackageDescr( pkgName ) );
+ pkgReg = pkgBuilder.getPackageRegistry( pkgName );
+ }
+
+ JavaDialect dialect = (JavaDialect) pkgReg.getDialectCompiletimeRegistry().getDialect( "java" );
+ dialects.add( dialect );
+ dialect.addSrc( convertToResource( entry.getKey() ),
+ entry.getValue() );
+ }
+
+ pkgBuilder.compileAll();
+ pkgBuilder.updateResults();
+
+ return (String[]) classNames.toArray( new String[classNames.size()] );
+ }
+
+ public JAXBContext newJAXBContext(String[] classNames,
+ KnowledgeBase kbase) throws JAXBException {
+ return newJAXBContext( classNames,
+ Collections.<String, Object> emptyMap(),
+ kbase );
+ }
+
+ public JAXBContext newJAXBContext(String[] classNames,
+ Map<String, ? > properties,
+ KnowledgeBase kbase) throws JAXBException {
+ ClassLoader classLoader = ((InternalRuleBase) ((KnowledgeBaseImpl) kbase).getRuleBase()).getRootClassLoader();
+
+ Class[] classes = new Class[classNames.length];
+ int i = 0;
+ try {
+ for ( i = 0; i < classNames.length; i++ ) {
+ classes[i] = classLoader.loadClass( classNames[i] );
+ }
+ } catch ( ClassNotFoundException e ) {
+ throw new JAXBException( "Unable to resolve class '" + classNames[i] + "'",
+ e );
+ }
+
+ return JAXBContext.newInstance( classes,
+ properties );
+ }
+
+ private static String convertToResource(String string) {
+ int lastDot = string.lastIndexOf( '.' );
+ return string.substring( 0,
+ lastDot ).replace( '.',
+ '/' ) + string.substring( lastDot,
+ string.length() );
+ }
+
+ public static class MapVfsCodeWriter extends CodeWriter {
+
+ private final Map<String, byte[]> map;
+
+ private ByteArrayOutputStream currentBaos;
+ private String currentPath;
+
+ public MapVfsCodeWriter() {
+ this.map = new LinkedHashMap<String, byte[]>();
+ }
+
+ public OutputStream openBinary(JPackage pkg,
+ String fileName) throws IOException {
+ String pkgName = pkg.name();
+
+ if ( pkgName.length() != 0 ) {
+ pkgName += '.';
+ }
+
+ if ( this.currentBaos != null ) {
+ this.currentBaos.close();
+ this.map.put( this.currentPath,
+ this.currentBaos.toByteArray() );
+ }
+
+ this.currentPath = pkgName + fileName;
+ this.currentBaos = new ByteArrayOutputStream();
+
+ return new FilterOutputStream( this.currentBaos ) {
+ public void close() {
+ // don't let this stream close
+ }
+ };
+ }
+
+ public void close() throws IOException {
+ if ( this.currentBaos != null ) {
+ this.currentBaos.close();
+ this.map.put( this.currentPath,
+ this.currentBaos.toByteArray() );
+ }
+ }
+
+ public Map<String, byte[]> getMap() {
+ return this.map;
+ }
+
+ }
+
+ public static class JaxbErrorReceiver4Drools extends ErrorReceiver {
+
+ public String stage = "processing";
+
+ public void warning(SAXParseException e) {
+ e.printStackTrace();
+ }
+
+ public void error(SAXParseException e) {
+ e.printStackTrace();
+ }
+
+ public void fatalError(SAXParseException e) {
+ e.printStackTrace();
+ }
+
+ public void info(SAXParseException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static class CachingRewindableReader extends Reader {
+ private Reader source;
+ private boolean sourceClosed;
+ private RewindableStringReader cache;
+ private StringBuilder strBuilder;
+
+ public CachingRewindableReader(Reader source) {
+ this.source = source;
+ this.strBuilder = new StringBuilder();
+ }
+
+ public int read(char[] cbuf,
+ int off,
+ int len) throws IOException {
+ int value = 0;
+ if ( this.cache == null ) {
+ value = this.source.read( cbuf,
+ off,
+ len );
+ if ( value != -1 ) {
+ // keep appening to the stringBuilder until we are at the end
+ this.strBuilder.append( cbuf,
+ off,
+ value );
+ } else {
+ // we are at the end, so switch to cache
+ this.cache = new RewindableStringReader( strBuilder.toString() );
+ }
+ } else {
+ value = this.cache.read( cbuf,
+ off,
+ len );
+ }
+ return value;
+ }
+
+ public void close() throws IOException {
+ if ( !sourceClosed ) {
+ // close the source, we only do this once.
+ this.source.close();
+ this.sourceClosed = true;
+ }
+
+ if ( cache == null ) {
+ // switch to cache if we haven't already
+ this.cache = new RewindableStringReader( strBuilder.toString() );
+ } else {
+ // reset the cache, so it can be read again.
+ this.cache.reset();
+ }
+ }
+ }
+
+ public static class RewindableStringReader extends StringReader {
+ public RewindableStringReader(String s) {
+ super( s );
+ }
+
+ public void close() {
+ try {
+ reset();
+ } catch ( IOException e ) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
Property changes on: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline/impl/DroolsJaxbHelperProviderImpl.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbTransformer.java
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbTransformer.java (rev 0)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbTransformer.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,61 @@
+package org.drools.runtime.pipeline.impl;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.Reader;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.Source;
+
+import org.drools.definition.pipeline.JaxbPipelineProvider;
+import org.drools.definition.pipeline.Transformer;
+import org.drools.runtime.pipeline.PipelineContext;
+import org.drools.runtime.pipeline.impl.BaseEmitter;
+import org.drools.runtime.pipeline.impl.BaseStage;
+import org.xml.sax.InputSource;
+
+public class JaxbTransformer extends BaseEmitter
+ implements
+ Transformer {
+ private Unmarshaller unmarshaller;
+
+ public JaxbTransformer(Unmarshaller unmarshaller) {
+ this.unmarshaller = unmarshaller;
+ }
+
+ public void signal(Object object,
+ PipelineContext context) {
+ Object result = null;
+ try {
+ if ( object instanceof File ) {
+ result = this.unmarshaller.unmarshal( (File) object );
+ } else if ( object instanceof InputStream ) {
+ result = this.unmarshaller.unmarshal( (InputStream) object );
+ } else if ( object instanceof Reader ) {
+ result = this.unmarshaller.unmarshal( (Reader) object );
+ } else if ( object instanceof Source ) {
+ result = this.unmarshaller.unmarshal( (Source) object );
+ } else if ( object instanceof InputSource ) {
+ result = this.unmarshaller.unmarshal( (InputSource) object );
+ }
+ } catch ( Exception e ) {
+ handleException( this,
+ object,
+ e );
+ if ( result instanceof JAXBElement ) {
+ result = ((JAXBElement) object).getValue().getClass().getName();
+ }
+ }
+ emit( result,
+ context );
+
+ }
+
+ public static class JaxbPipelineProviderImpl implements JaxbPipelineProvider {
+ public Transformer newJaxbTransformer(Unmarshaller unmarshaller) {
+ return new JaxbTransformer( unmarshaller );
+ }
+ }
+
+}
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/java/org/drools/runtime/pipeline (from rev 24469, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/java/org/drools/dataloaders/jaxb)
Property changes on: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/java/org/drools/runtime/pipeline
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/java/org/drools/runtime/pipeline/DroolsJaxbTest.java
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/java/org/drools/dataloaders/jaxb/DroolsJaxbTest.java 2008-12-22 20:42:13 UTC (rev 24469)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/java/org/drools/runtime/pipeline/DroolsJaxbTest.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,166 +0,0 @@
-package org.drools.dataloaders.jaxb;
-
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.Unmarshaller;
-
-import junit.framework.TestCase;
-
-import org.drools.FactHandle;
-import org.drools.RuleBase;
-import org.drools.RuleBaseFactory;
-import org.drools.StatefulSession;
-import org.drools.compiler.PackageBuilder;
-
-import com.sun.tools.xjc.Language;
-import com.sun.tools.xjc.Options;
-
-public class DroolsJaxbTest extends TestCase {
-
- public void testModelLoad() throws Exception {
- Options xjcOpts = new Options();
- xjcOpts.setSchemaLanguage( Language.XMLSCHEMA );
- PackageBuilder pkgBuilder = new PackageBuilder();
-
- InputStream stream = getClass().getResourceAsStream( "test.xsd" );
- String[] classNames = DroolsJaxbHelper.addModel( new InputStreamReader( stream ),
- pkgBuilder,
- xjcOpts,
- "xsd" );
-
- assertFalse( pkgBuilder.hasErrors() );
-
- RuleBase rb = RuleBaseFactory.newRuleBase();
- rb.addPackage( pkgBuilder.getPackage() );
-
- JAXBContext jaxbCtx = DroolsJaxbHelper.newInstance( classNames,
- rb );
- Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
- JAXBElement elm = ( JAXBElement ) unmarshaller.unmarshal( getClass().getResourceAsStream( "data.xml" ) );
-
- assertEquals( "com.oracle.sample3.USAddress",
- elm.getValue().getClass().getName() );
- }
-
- public void testDirectRoot() throws Exception {
- Options xjcOpts = new Options();
- xjcOpts.setSchemaLanguage( Language.XMLSCHEMA );
- PackageBuilder pkgBuilder = new PackageBuilder();
-
- InputStream stream = getClass().getResourceAsStream( "order.xsd" );
- String[] classNames = DroolsJaxbHelper.addModel( new InputStreamReader( stream ),
- pkgBuilder,
- xjcOpts,
- "xsd" );
-
- assertFalse( pkgBuilder.hasErrors() );
-
- pkgBuilder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Jaxb.drl" ) ) );
-
- RuleBase rb = RuleBaseFactory.newRuleBase();
- rb.addPackages( pkgBuilder.getPackages() );
-
- JAXBContext jaxbCtx = DroolsJaxbHelper.newInstance( classNames,
- rb );
- //
- Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
-
- StatefulSession session = rb.newStatefulSession();
- List list1 = new ArrayList();
- session.setGlobal( "list1", list1 );
-
- DroolsJaxbStatefulSession dataLoader = new DroolsJaxbStatefulSession( session,
- unmarshaller );
-
- Map<FactHandle, Object> handles = dataLoader.insertUnmarshalled( new InputStreamReader( getClass().getResourceAsStream( "order.xml" ) ) );
-
- session.fireAllRules();
-
- assertEquals( 1,
- handles.size() );
- assertEquals( 1,
- list1.size() );
-
- assertEquals( "org.drools.model.order.Order",
- list1.get( 0 ).getClass().getName() );
- }
-
-
- public void testNestedIterable() throws Exception {
- Options xjcOpts = new Options();
- xjcOpts.setSchemaLanguage( Language.XMLSCHEMA );
- PackageBuilder pkgBuilder = new PackageBuilder();
-
- InputStream stream = getClass().getResourceAsStream( "order.xsd" );
- String[] classNames = DroolsJaxbHelper.addModel( new InputStreamReader( stream ),
- pkgBuilder,
- xjcOpts,
- "xsd" );
-
- assertFalse( pkgBuilder.hasErrors() );
-
- pkgBuilder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Jaxb.drl" ) ) );
-
- RuleBase rb = RuleBaseFactory.newRuleBase();
- rb.addPackages( pkgBuilder.getPackages() );
-
- JAXBContext jaxbCtx = DroolsJaxbHelper.newInstance( classNames,
- rb );
- //
- Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
-
- StatefulSession session = rb.newStatefulSession();
- List list1 = new ArrayList();
- List list2 = new ArrayList();
- session.setGlobal( "list1", list1 );
- session.setGlobal( "list2", list2 );
-
- DroolsJaxbConfiguration configuration = new DroolsJaxbConfiguration();
- configuration.setIterableGetter( "this.orderItem" );
-
- DroolsJaxbStatefulSession dataLoader = new DroolsJaxbStatefulSession( session,
- unmarshaller,
- configuration );
-
- Map<FactHandle, Object> handles = dataLoader.insertUnmarshalled( new InputStreamReader( getClass().getResourceAsStream( "order.xml" ) ) );
-
- session.fireAllRules();
-
- assertEquals( 2,
- handles.size() );
- assertEquals( 1,
- list1.size() );
- assertEquals( 1,
- list2.size() );
-
- assertEquals( "org.drools.model.order.Order$OrderItem",
- list1.get( 0 ).getClass().getName() );
-
- assertEquals( "org.drools.model.order.Order$OrderItem",
- list2.get( 0 ).getClass().getName() );
-
- assertNotSame( list1.get(0), list2.get(0) );
- }
-}
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/java/org/drools/runtime/pipeline/impl/DroolsJaxbTest.java (from rev 24469, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/java/org/drools/dataloaders/jaxb/DroolsJaxbTest.java)
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/java/org/drools/runtime/pipeline/impl/DroolsJaxbTest.java (rev 0)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/java/org/drools/runtime/pipeline/impl/DroolsJaxbTest.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,180 @@
+package org.drools.runtime.pipeline.impl;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseFactory;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.KnowledgeBuilderFactory;
+import org.drools.builder.ResourceType;
+import org.drools.builder.help.KnowledgeBuilderHelper;
+import org.drools.definition.pipeline.Expression;
+import org.drools.definition.pipeline.PipelineFactory;
+import org.drools.definition.pipeline.Splitter;
+import org.drools.definition.pipeline.Transformer;
+import org.drools.io.ResourceFactory;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.dataloader.StatefulKnowledgeSessionDataLoader;
+import org.drools.runtime.dataloader.impl.StatefulKnowledgeSessionDataLoaderImpl;
+import org.drools.runtime.rule.FactHandle;
+
+import com.sun.tools.xjc.Language;
+import com.sun.tools.xjc.Options;
+
+public class DroolsJaxbTest extends TestCase {
+
+ // public void testModelLoad() throws Exception {
+ // Options xjcOpts = new Options();
+ // xjcOpts.setSchemaLanguage( Language.XMLSCHEMA );
+ // PackageBuilder pkgBuilder = new PackageBuilder();
+ //
+ // InputStream stream = getClass().getResourceAsStream( "test.xsd" );
+ // String[] classNames = DroolsJaxbHelper.addModel( new InputStreamReader( stream ),
+ // pkgBuilder,
+ // xjcOpts,
+ // "xsd" );
+ //
+ // assertFalse( pkgBuilder.hasErrors() );
+ //
+ // RuleBase rb = RuleBaseFactory.newRuleBase();
+ // rb.addPackage( pkgBuilder.getPackage() );
+ //
+ // JAXBContext jaxbCtx = DroolsJaxbHelper.newInstance( classNames,
+ // rb );
+ // Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
+ // JAXBElement elm = ( JAXBElement ) unmarshaller.unmarshal( getClass().getResourceAsStream( "data.xml" ) );
+ //
+ // assertEquals( "com.oracle.sample3.USAddress",
+ // elm.getValue().getClass().getName() );
+ // }
+
+ public void testDirectRoot() throws Exception {
+ Options xjcOpts = new Options();
+ xjcOpts.setSchemaLanguage( Language.XMLSCHEMA );
+ KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+
+ String[] classNames = KnowledgeBuilderHelper.addXsdModel( ResourceFactory.newClassPathResource( "order.xsd",
+ getClass() ),
+ kbuilder,
+ xjcOpts,
+ "xsd" );
+
+ assertFalse( kbuilder.hasErrors() );
+
+ kbuilder.add( ResourceFactory.newClassPathResource( "test_Jaxb.drl",
+ getClass() ),
+ ResourceType.DRL );
+
+ KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
+ kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
+
+ StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
+ List list1 = new ArrayList();
+ ksession.setGlobal( "list1",
+ list1 );
+
+ JAXBContext jaxbCtx = KnowledgeBuilderHelper.newJAXBContext( classNames,
+ kbase );
+ Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
+ Transformer transformer = PipelineFactory.newJaxbTransformer( unmarshaller );
+ transformer.addReceiver( PipelineFactory.newStatefulKnowledgeSessionReceiverAdapter() );
+
+ StatefulKnowledgeSessionDataLoader dataLoader = new StatefulKnowledgeSessionDataLoaderImpl( ksession,
+ transformer );
+ Map<FactHandle, Object> handles = dataLoader.insert( new StreamSource( getClass().getResourceAsStream( "order.xml" ) ) );
+
+ ksession.fireAllRules();
+
+ assertEquals( 1,
+ handles.size() );
+ assertEquals( 1,
+ list1.size() );
+
+ assertEquals( "org.drools.model.order.Order",
+ list1.get( 0 ).getClass().getName() );
+ }
+
+ public void testNestedIterable() throws Exception {
+ Options xjcOpts = new Options();
+ xjcOpts.setSchemaLanguage( Language.XMLSCHEMA );
+ KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+
+ String[] classNames = KnowledgeBuilderHelper.addXsdModel( ResourceFactory.newClassPathResource( "order.xsd",
+ getClass() ),
+ kbuilder,
+ xjcOpts,
+ "xsd" );
+
+ assertFalse( kbuilder.hasErrors() );
+
+ kbuilder.add( ResourceFactory.newClassPathResource( "test_Jaxb.drl",
+ getClass() ),
+ ResourceType.DRL );
+
+ KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
+ kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
+
+ StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
+ List list1 = new ArrayList();
+ List list2 = new ArrayList();
+ ksession.setGlobal( "list1",
+ list1 );
+ ksession.setGlobal( "list2",
+ list2 );
+
+ JAXBContext jaxbCtx = KnowledgeBuilderHelper.newJAXBContext( classNames,
+ kbase );
+ Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
+ Transformer transformer = PipelineFactory.newJaxbTransformer( unmarshaller );
+ Expression expression = PipelineFactory.newMvelExpression( "this.orderItem" );
+ transformer.addReceiver( expression );
+ Splitter splitter = PipelineFactory.newIterateSplitter();
+ expression.addReceiver( splitter );
+ splitter.addReceiver( PipelineFactory.newStatefulKnowledgeSessionReceiverAdapter() );
+ StatefulKnowledgeSessionDataLoader dataLoader = new StatefulKnowledgeSessionDataLoaderImpl( ksession,
+ transformer );
+ Map<FactHandle, Object> handles = dataLoader.insert( new StreamSource( getClass().getResourceAsStream( "order.xml" ) ) );
+
+ ksession.fireAllRules();
+
+ assertEquals( 2,
+ handles.size() );
+ assertEquals( 1,
+ list1.size() );
+ assertEquals( 1,
+ list2.size() );
+
+ assertEquals( "org.drools.model.order.Order$OrderItem",
+ list1.get( 0 ).getClass().getName() );
+
+ assertEquals( "org.drools.model.order.Order$OrderItem",
+ list2.get( 0 ).getClass().getName() );
+
+ assertNotSame( list1.get( 0 ),
+ list2.get( 0 ) );
+ }
+}
Property changes on: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/java/org/drools/runtime/pipeline/impl/DroolsJaxbTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline (from rev 24469, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/dataloaders/jaxb)
Property changes on: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/data.xml
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/dataloaders/jaxb/data.xml 2008-12-22 20:42:13 UTC (rev 24469)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/data.xml 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,12 +0,0 @@
-<?xml version="1.0"?>
-<myAddress xmlns="http://www.oracle.com/sample3/"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.oracle.com/sample3 sample3.xsd">
- <name>James Bond</name>
- <doorNumber>420</doorNumber>
- <street>Oracle parkway</street>
- <city>Redwood shores</city>
- <state>CA</state>
- <zip>94065</zip>
- <country>United States</country>
-</myAddress>
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/data.xml (from rev 24469, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/dataloaders/jaxb/data.xml)
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/data.xml (rev 0)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/data.xml 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<myAddress xmlns="http://www.oracle.com/sample3/"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.oracle.com/sample3 sample3.xsd">
+ <name>James Bond</name>
+ <doorNumber>420</doorNumber>
+ <street>Oracle parkway</street>
+ <city>Redwood shores</city>
+ <state>CA</state>
+ <zip>94065</zip>
+ <country>United States</country>
+</myAddress>
\ No newline at end of file
Property changes on: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/data.xml
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/order.xml (from rev 24469, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/dataloaders/jaxb/order.xml)
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/order.xml (rev 0)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/order.xml 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<order xmlns="http://drools.org/model/order"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://drools.org/model/order order.xsd">
+ <order-item>
+ <product-id>111</product-id>
+ <quantity>2</quantity>
+ <price>8.90</price>
+ </order-item>
+ <order-item>
+ <product-id>222</product-id>
+ <quantity>7</quantity>
+ <price>5.20</price>
+ </order-item>
+</order>
\ No newline at end of file
Property changes on: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/order.xml
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/order.xsd (from rev 24469, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/dataloaders/jaxb/order.xsd)
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/order.xsd (rev 0)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/order.xsd 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,43 @@
+<xsd:schema xmlns:order="http://drools.org/model/order"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://drools.org/model/order"
+ elementFormDefault="qualified" >
+
+
+ <xsd:element name="order">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="order-item" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="product-id" type="xsd:long" />
+ <xsd:element name="quantity" type="xsd:integer" />
+ <xsd:element name="price" type="xsd:decimal" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+<!--
+
+ <xsd:element name="order" type="order:OrderType" />
+
+ <xsd:complexType name="OrderType">
+ <xsd:sequence>
+ <xsd:element name="orderItem" type="order:orderItemType" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="orderItem">
+ <xsd:sequence>
+ <xsd:element name="product-id" type="xsd:long" />
+ <xsd:element name="quantity" type="xsd:integer" />
+ <xsd:element name="price" type="xsd:decimal" />
+ </xsd:sequence>
+ </xsd:complexType>
+-->
+
+</xsd:schema>
\ No newline at end of file
Property changes on: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/order.xsd
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/test.xsd (from rev 24469, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/dataloaders/jaxb/test.xsd)
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/test.xsd (rev 0)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/test.xsd 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,29 @@
+<schema xmlns = "http://www.w3.org/2001/XMLSchema"
+ xmlns:exp="http://www.oracle.com/sample3/"
+ targetNamespace="http://www.oracle.com/sample3/"
+ elementFormDefault="qualified">
+
+ <complexType name="Address">
+ <sequence>
+ <element name="name" type="string"/>
+ <element name="doorNumber" type="short"/>
+ <element name="street" type="string"/>
+ <element name="city" type="string"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="USAddress">
+ <complexContent>
+ <extension base="exp:Address">
+ <sequence>
+ <element name="state" type="string"/>
+ <element name="zip" type="integer"/>
+ <element name="country" type="string"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <element name="myAddress" type="exp:USAddress"/>
+
+</schema>
Property changes on: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/test.xsd
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/test_Jaxb.drl (from rev 24469, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/dataloaders/jaxb/test_Jaxb.drl)
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/test_Jaxb.drl (rev 0)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/test_Jaxb.drl 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,29 @@
+package org.drools.xxx
+
+import org.drools.model.order.Order
+import org.drools.model.order.Order.OrderItem
+
+global java.util.List list1;
+global java.util.List list2;
+
+
+rule orderRule
+when
+ $i : Order()
+then
+ list1.add( $i );
+end
+
+rule orderItemRule1
+when
+ $i : OrderItem( price > 6)
+then
+ list1.add( $i );
+end
+
+rule orderItemRule2
+when
+ $i : OrderItem( price < 6)
+then
+ list2.add( $i );
+end
\ No newline at end of file
Property changes on: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/impl/test_Jaxb.drl
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/order.xml
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/dataloaders/jaxb/order.xml 2008-12-22 20:42:13 UTC (rev 24469)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/order.xml 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,15 +0,0 @@
-<?xml version="1.0"?>
-<order xmlns="http://drools.org/model/order"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://drools.org/model/order order.xsd">
- <order-item>
- <product-id>111</product-id>
- <quantity>2</quantity>
- <price>8.90</price>
- </order-item>
- <order-item>
- <product-id>222</product-id>
- <quantity>7</quantity>
- <price>5.20</price>
- </order-item>
-</order>
\ No newline at end of file
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/order.xsd
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/dataloaders/jaxb/order.xsd 2008-12-22 20:42:13 UTC (rev 24469)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/order.xsd 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,43 +0,0 @@
-<xsd:schema xmlns:order="http://drools.org/model/order"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- targetNamespace="http://drools.org/model/order"
- elementFormDefault="qualified" >
-
-
- <xsd:element name="order">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="order-item" minOccurs="0" maxOccurs="unbounded">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="product-id" type="xsd:long" />
- <xsd:element name="quantity" type="xsd:integer" />
- <xsd:element name="price" type="xsd:decimal" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
-
-<!--
-
- <xsd:element name="order" type="order:OrderType" />
-
- <xsd:complexType name="OrderType">
- <xsd:sequence>
- <xsd:element name="orderItem" type="order:orderItemType" minOccurs="0" maxOccurs="unbounded" />
- </xsd:sequence>
- </xsd:complexType>
-
-
- <xsd:complexType name="orderItem">
- <xsd:sequence>
- <xsd:element name="product-id" type="xsd:long" />
- <xsd:element name="quantity" type="xsd:integer" />
- <xsd:element name="price" type="xsd:decimal" />
- </xsd:sequence>
- </xsd:complexType>
--->
-
-</xsd:schema>
\ No newline at end of file
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/test.xsd
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/dataloaders/jaxb/test.xsd 2008-12-22 20:42:13 UTC (rev 24469)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/test.xsd 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,29 +0,0 @@
-<schema xmlns = "http://www.w3.org/2001/XMLSchema"
- xmlns:exp="http://www.oracle.com/sample3/"
- targetNamespace="http://www.oracle.com/sample3/"
- elementFormDefault="qualified">
-
- <complexType name="Address">
- <sequence>
- <element name="name" type="string"/>
- <element name="doorNumber" type="short"/>
- <element name="street" type="string"/>
- <element name="city" type="string"/>
- </sequence>
- </complexType>
-
- <complexType name="USAddress">
- <complexContent>
- <extension base="exp:Address">
- <sequence>
- <element name="state" type="string"/>
- <element name="zip" type="integer"/>
- <element name="country" type="string"/>
- </sequence>
- </extension>
- </complexContent>
- </complexType>
-
- <element name="myAddress" type="exp:USAddress"/>
-
-</schema>
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/test_Jaxb.drl
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/dataloaders/jaxb/test_Jaxb.drl 2008-12-22 20:42:13 UTC (rev 24469)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-jaxb/src/test/resources/org/drools/runtime/pipeline/test_Jaxb.drl 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,29 +0,0 @@
-package org.drools.xxx
-
-import org.drools.model.order.Order
-import org.drools.model.order.Order.OrderItem
-
-global java.util.List list1;
-global java.util.List list2;
-
-
-rule orderRule
-when
- $i : Order()
-then
- list1.add( $i );
-end
-
-rule orderItemRule1
-when
- $i : OrderItem( price > 6)
-then
- list1.add( $i );
-end
-
-rule orderItemRule2
-when
- $i : OrderItem( price < 6)
-then
- list2.add( $i );
-end
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/.classpath
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/.classpath 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/.classpath 2008-12-23 18:58:19 UTC (rev 24484)
@@ -15,17 +15,19 @@
<classpathentry kind="var" path="M2_REPO/org/freemarker/freemarker/2.3.9/freemarker-2.3.9.jar"/>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/hsqldb/hsqldb/1.8.0.2/hsqldb-1.8.0.2.jar"/>
<classpathentry kind="var" path="M2_REPO/janino/janino/2.5.15/janino-2.5.15.jar"/>
+ <classpathentry kind="var" path="M2_REPO/com/sun/xml/bind/jaxb-xjc/2.0.3/jaxb-xjc-2.0.3.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.5.0.1/jmock-2.5.0.1.jar"/>
<classpathentry kind="var" path="M2_REPO/joda-time/joda-time/1.5.2/joda-time-1.5.2.jar"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
<classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.13/log4j-1.2.13.jar"/>
- <classpathentry kind="var" path="M2_REPO/milyn/milyn-commons/1.0/milyn-commons-1.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/milyn/milyn-smooks-core/1.0.1/milyn-smooks-core-1.0.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/milyn/milyn-smooks-javabean/1.0.1/milyn-smooks-javabean-1.0.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/mvel/mvel/1.3.3-java1.5/mvel-1.3.3-java1.5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-commons/1.1/milyn-commons-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-smooks-core/1.1/milyn-smooks-core-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-smooks-javabean/1.1/milyn-smooks-javabean-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/mvel/mvel/1.3.12-java1.5/mvel-1.3.12-java1.5.jar"/>
<classpathentry kind="var" path="M2_REPO/org/mvel/mvel2/2.0.4-SNAPSHOT/mvel2-2.0.4-SNAPSHOT.jar"/>
+ <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.8.0/xercesImpl-2.8.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/2.0.2/xml-apis-2.0.2.jar"/>
<classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar"/>
<classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.3/xstream-1.3.jar"/>
</classpath>
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/pom.xml
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/pom.xml 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/pom.xml 2008-12-23 18:58:19 UTC (rev 24484)
@@ -27,9 +27,9 @@
</dependency>
<dependency>
- <groupId>milyn</groupId>
+ <groupId>org.milyn</groupId>
<artifactId>milyn-smooks-javabean</artifactId>
- <version>1.0.1</version>
+ <version>1.1</version>
</dependency>
</dependencies>
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline (from rev 24433, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/dataloaders/smooks)
Property changes on: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/DroolsSmooksConfiguration.java
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/dataloaders/smooks/DroolsSmooksConfiguration.java 2008-12-19 09:30:00 UTC (rev 24433)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/DroolsSmooksConfiguration.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,40 +0,0 @@
-package org.drools.dataloaders.smooks;
-
-public class DroolsSmooksConfiguration {
- private String rootId;
-
- private String iterableGetter;
- //private String
-
- public DroolsSmooksConfiguration() {
- this.rootId = "root";
- this.iterableGetter = null;
- }
-
- public DroolsSmooksConfiguration(String rootId, String iterableGetter) {
- this.iterableGetter = iterableGetter;
- this.rootId = rootId;
- }
-
- public void setRootId(String roodId) {
- this.rootId = rootId;
- }
-
- public String getRoodId() {
- return this.rootId;
- }
-
- public String getIterableGetter() {
- return iterableGetter;
- }
-
- public void setIterableGetter(String iterableGetter) {
- this.iterableGetter = iterableGetter;
- }
-
- public String getRootId() {
- return rootId;
- }
-
-
-}
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/DroolsSmooksStatefulSession.java
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/dataloaders/smooks/DroolsSmooksStatefulSession.java 2008-12-19 09:30:00 UTC (rev 24433)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/DroolsSmooksStatefulSession.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,92 +0,0 @@
-package org.drools.dataloaders.smooks;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.transform.Source;
-
-import org.drools.StatefulSession;
-import org.drools.common.InternalRuleBase;
-import org.drools.runtime.rule.FactHandle;
-import org.milyn.Smooks;
-import org.milyn.container.ExecutionContext;
-import org.milyn.payload.JavaResult;
-import org.mvel2.MVEL;
-import org.mvel2.ParserContext;
-import org.mvel2.compiler.ExpressionCompiler;
-
-public class DroolsSmooksStatefulSession {
- private Smooks smooks;
- private StatefulSession session;
- private DroolsSmooksConfiguration configuration;
- private Serializable getterExpr;
-
- public DroolsSmooksStatefulSession(StatefulSession session,
- Smooks smooks) {
- this( session,
- smooks,
- new DroolsSmooksConfiguration() );
-
- }
-
- public DroolsSmooksStatefulSession(StatefulSession session,
- Smooks smooks,
- DroolsSmooksConfiguration configuration) {
- this.smooks = smooks;
- this.configuration = configuration;
- this.session = session;
-
- if ( this.configuration.getIterableGetter() != null ) {
- final ParserContext parserContext = new ParserContext();
- parserContext.setStrictTypeEnforcement( false );
-
- ExpressionCompiler compiler = new ExpressionCompiler( this.configuration.getIterableGetter() );
- this.getterExpr = compiler.compile( parserContext );
- }
-
- }
-
- public Map insertFilter(Source source) {
- JavaResult result = new JavaResult();
-
- // preserve the previous classloader, While we make Smooks aware of the Drools classloader
- ClassLoader previousClassLoader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader( ((InternalRuleBase) this.session.getRuleBase()).getRootClassLoader() );
-
- ExecutionContext executionContext = this.smooks.createExecutionContext();
-
- // Filter the input message to extract, using the execution context...
- smooks.filter( source,
- result,
- executionContext );
-
- Thread.currentThread().setContextClassLoader( previousClassLoader );
-
- Map handles = new HashMap<FactHandle, Object>();
-
- Object object = result.getBean( this.configuration.getRoodId() );
- if ( object == null ) {
- return handles;
- }
-
- if ( this.getterExpr != null ) {
- Iterable it = (Iterable) MVEL.executeExpression( this.getterExpr,
- object );
- if ( it != null ) {
- for ( Object item : it ) {
- FactHandle handle = this.session.insert( item );
- handles.put( handle,
- object );
- }
- }
- } else {
- FactHandle handle = this.session.insert( object );
- handles.put( handle,
- object );
-
- }
-
- return handles;
- }
-}
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/DroolsSmooksStatelessSession.java
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/dataloaders/smooks/DroolsSmooksStatelessSession.java 2008-12-19 09:30:00 UTC (rev 24433)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/DroolsSmooksStatelessSession.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,93 +0,0 @@
-package org.drools.dataloaders.smooks;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.transform.Source;
-
-import org.drools.StatelessSession;
-import org.drools.common.InternalRuleBase;
-import org.drools.common.InternalStatelessSession;
-import org.milyn.Smooks;
-import org.milyn.container.ExecutionContext;
-import org.milyn.payload.JavaResult;
-import org.mvel2.MVEL;
-import org.mvel2.ParserContext;
-import org.mvel2.compiler.ExpressionCompiler;
-
-public class DroolsSmooksStatelessSession {
- private Smooks smooks;
- private InternalStatelessSession session;
- private DroolsSmooksConfiguration configuration;
- private Serializable getterExpr;
-
- public DroolsSmooksStatelessSession(StatelessSession session,
- Smooks smooks) {
- this( session,
- smooks,
- new DroolsSmooksConfiguration() );
-
- }
-
- public DroolsSmooksStatelessSession(StatelessSession session,
- Smooks smooks,
- DroolsSmooksConfiguration configuration) {
- this.smooks = smooks;
- this.configuration = configuration;
- this.session = ( InternalStatelessSession ) session;
-
- if ( this.configuration.getIterableGetter() != null ) {
- final ParserContext parserContext = new ParserContext();
- parserContext.setStrictTypeEnforcement( false );
-
- ExpressionCompiler compiler = new ExpressionCompiler( this.configuration.getIterableGetter() );
- this.getterExpr = compiler.compile( parserContext );
- }
-
- }
-
- public void executeFilter(Source source) {
- JavaResult result = new JavaResult();
-
- // preserve the previous classloader, While we make Smooks aware of the Drools classloader
- ClassLoader previousClassLoader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader( ((InternalRuleBase) this.session.getRuleBase()).getRootClassLoader() );
-
- ExecutionContext executionContext = this.smooks.createExecutionContext();
-
- // Filter the input message to extract, using the execution context...
- smooks.filter( source,
- result,
- executionContext );
-
- Thread.currentThread().setContextClassLoader( previousClassLoader );
-
-
- Object object = result.getBean( this.configuration.getRoodId() );
- if ( object == null ) {
- return;
- }
-
- if ( this.getterExpr != null ) {
- Iterable it = (Iterable) MVEL.executeExpression( this.getterExpr,
- object );
-
- if ( it != null ) {
- this.session.execute( toList( it ) );
- }
- } else {
- this.session.execute( object );
-
- }
- }
-
- private List toList( Iterable it) {
- List list = new ArrayList();
- for ( Object o : it ) {
- list.add( o );
- }
-
- return list;
- }
-}
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/Root.java
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/dataloaders/smooks/Root.java 2008-12-19 09:30:00 UTC (rev 24433)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/Root.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,21 +0,0 @@
-package org.drools.dataloaders.smooks;
-
-import java.util.List;
-
-public class Root {
- private List children;
-
- public Root() {
-
- }
-
- public List getChildren() {
- return children;
- }
-
- public void setChildren(List children) {
- this.children = children;
- }
-
-
-}
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/impl/DroolsSmooksConfiguration.java (from rev 24433, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/dataloaders/smooks/DroolsSmooksConfiguration.java)
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/impl/DroolsSmooksConfiguration.java (rev 0)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/impl/DroolsSmooksConfiguration.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,23 @@
+package org.drools.runtime.pipeline.impl;
+
+public class DroolsSmooksConfiguration {
+ private String rootId;
+
+ public DroolsSmooksConfiguration() {
+ this.rootId = "root";
+ }
+
+ public DroolsSmooksConfiguration(String rootId) {
+ this.rootId = rootId;
+ }
+
+ public void setRootId(String rootId) {
+ this.rootId = rootId;
+ }
+
+ public String getRootId() {
+ return rootId;
+ }
+
+
+}
Property changes on: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/impl/DroolsSmooksConfiguration.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/impl/Root.java (from rev 24433, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/dataloaders/smooks/Root.java)
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/impl/Root.java (rev 0)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/impl/Root.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,21 @@
+package org.drools.runtime.pipeline.impl;
+
+import java.util.List;
+
+public class Root {
+ private List children;
+
+ public Root() {
+
+ }
+
+ public List getChildren() {
+ return children;
+ }
+
+ public void setChildren(List children) {
+ this.children = children;
+ }
+
+
+}
Property changes on: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/impl/Root.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/impl/SmooksTransformer.java
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/impl/SmooksTransformer.java (rev 0)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/main/java/org/drools/runtime/pipeline/impl/SmooksTransformer.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,57 @@
+package org.drools.runtime.pipeline.impl;
+
+import javax.xml.transform.Source;
+
+import org.drools.definition.pipeline.SmooksPipelineProvider;
+import org.drools.definition.pipeline.Transformer;
+import org.drools.runtime.pipeline.PipelineContext;
+import org.drools.runtime.pipeline.impl.BaseEmitter;
+import org.milyn.Smooks;
+import org.milyn.container.ExecutionContext;
+import org.milyn.payload.JavaResult;
+
+public class SmooksTransformer extends BaseEmitter
+ implements
+ Transformer {
+ private Smooks smooks;
+ private DroolsSmooksConfiguration configuration;
+
+ public SmooksTransformer(Smooks smooks,
+ DroolsSmooksConfiguration configuration) {
+ this.smooks = smooks;
+ this.configuration = configuration;
+
+ }
+
+ public void signal(Object object,
+ PipelineContext context) {
+ this.smooks.setClassLoader( context.getClassLoader() );
+ Object result = null;
+ try {
+ JavaResult javaResult = new JavaResult();
+ ExecutionContext executionContext = this.smooks.createExecutionContext();
+
+ this.smooks.filter( (Source) object,
+ javaResult,
+ executionContext );
+
+ result = javaResult.getBean( this.configuration.getRootId() );
+ } catch ( Exception e ) {
+ handleException( this,
+ object,
+ e );
+ }
+ emit( result,
+ context );
+ }
+
+ public static class SmooksPipelineProviderImpl implements SmooksPipelineProvider {
+ public Transformer newSmooksTransformer(Smooks smooks,
+ String rootId) {
+ DroolsSmooksConfiguration conf = new DroolsSmooksConfiguration( rootId );
+ return new SmooksTransformer( smooks,
+ conf );
+ }
+ }
+
+}
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/pipeline (from rev 24433, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/dataloaders/smooks)
Property changes on: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/pipeline
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/pipeline/DroolsSmookStatefulSessionTest.java
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/dataloaders/smooks/DroolsSmookStatefulSessionTest.java 2008-12-19 09:30:00 UTC (rev 24433)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/pipeline/DroolsSmookStatefulSessionTest.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,100 +0,0 @@
-package org.drools.dataloaders.smooks;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.transform.stream.StreamSource;
-
-import junit.framework.TestCase;
-
-import org.drools.FactHandle;
-import org.drools.RuleBase;
-import org.drools.RuleBaseFactory;
-import org.drools.StatefulSession;
-import org.drools.compiler.PackageBuilder;
-import org.milyn.Smooks;
-import org.milyn.io.StreamUtils;
-
-public class DroolsSmookStatefulSessionTest extends TestCase {
- public void testDirectRoot() throws Exception {
- PackageBuilder pkgBuilder = new PackageBuilder();
-
- pkgBuilder.addPackageFromDrl( new InputStreamReader( DroolsSmookStatefulSessionTest.class.getResourceAsStream( "test_SmooksDirectRoot.drl" ) ) );
-
- assertFalse( pkgBuilder.hasErrors() );
-
- RuleBase ruleBase = RuleBaseFactory.newRuleBase();
- ruleBase.addPackage( pkgBuilder.getPackage() );
-
- StatefulSession session = ruleBase.newStatefulSession();
- List list = new ArrayList();
- session.setGlobal( "list", list );
-
- // Instantiate Smooks with the config...
- Smooks smooks = new Smooks( getClass().getResourceAsStream( "smooks-config.xml" ) );
-
-
- DroolsSmooksConfiguration conf = new DroolsSmooksConfiguration( "orderItem", null );
- //
- DroolsSmooksStatefulSession dataLoader = new DroolsSmooksStatefulSession( session,
- smooks,
- conf );
- Map<FactHandle, Object> handles = dataLoader.insertFilter( new StreamSource( getClass().getResourceAsStream( "SmooksDirectRoot.xml") ) );
- //
- session.fireAllRules();
-
- assertEquals(1, handles.size() );
- assertEquals(1, list.size());
-
- assertEquals( "example.OrderItem", list.get( 0 ).getClass().getName() );
- }
-
- public void testNestedIterable() throws Exception {
- PackageBuilder pkgBuilder = new PackageBuilder();
-
- pkgBuilder.addPackageFromDrl( new InputStreamReader( DroolsSmookStatefulSessionTest.class.getResourceAsStream( "test_SmooksNestedIterable.drl" ) ) );
-
- assertFalse( pkgBuilder.hasErrors() );
-
- RuleBase ruleBase = RuleBaseFactory.newRuleBase();
- ruleBase.addPackage( pkgBuilder.getPackage() );
-
- StatefulSession session = ruleBase.newStatefulSession();
- List list = new ArrayList();
- session.setGlobal( "list", list );
-
- // Instantiate Smooks with the config...
- Smooks smooks = new Smooks( getClass().getResourceAsStream( "smooks-config.xml" ) );
-
- DroolsSmooksConfiguration conf = new DroolsSmooksConfiguration( "root",
- "children" );
- //
- DroolsSmooksStatefulSession dataLoader = new DroolsSmooksStatefulSession( session,
- smooks,
- conf );
- Map<FactHandle, Object> handles = dataLoader.insertFilter( new StreamSource( getClass().getResourceAsStream( "SmooksNestedIterable.xml") ) );
- //
- session.fireAllRules();
-
- assertEquals(2, handles.size() );
- assertEquals(2, list.size());
-
- assertEquals( "example.OrderItem", list.get( 0 ).getClass().getName() );
- assertEquals( "example.OrderItem", list.get( 1 ).getClass().getName() );
-
- assertNotSame( list.get( 0 ), list.get( 1 ) );
- }
-
- private static byte[] readInputMessage(InputStream stream) {
- try {
- return StreamUtils.readStream( stream );
- } catch ( IOException e ) {
- e.printStackTrace();
- return "<no-message/>".getBytes();
- }
- }
-}
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/pipeline/DroolsSmookStatelessSessionTest.java
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/dataloaders/smooks/DroolsSmookStatelessSessionTest.java 2008-12-19 09:30:00 UTC (rev 24433)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/pipeline/DroolsSmookStatelessSessionTest.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,96 +0,0 @@
-package org.drools.dataloaders.smooks;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.transform.stream.StreamSource;
-
-import junit.framework.TestCase;
-
-import org.drools.RuleBase;
-import org.drools.RuleBaseFactory;
-import org.drools.StatelessSession;
-import org.drools.compiler.PackageBuilder;
-import org.milyn.Smooks;
-import org.milyn.io.StreamUtils;
-
-public class DroolsSmookStatelessSessionTest extends TestCase {
- public void testSmooksNestedIterable() throws Exception {
- PackageBuilder pkgBuilder = new PackageBuilder();
-
- pkgBuilder.addPackageFromDrl( new InputStreamReader( DroolsSmookStatelessSessionTest.class.getResourceAsStream( "test_SmooksNestedIterable.drl" ) ) );
-
- assertFalse( pkgBuilder.hasErrors() );
-
- RuleBase ruleBase = RuleBaseFactory.newRuleBase();
- ruleBase.addPackage( pkgBuilder.getPackage() );
-
- StatelessSession session = ruleBase.newStatelessSession();
- List list = new ArrayList();
- session.setGlobal( "list", list );
-
- // Instantiate Smooks with the config...
- Smooks smooks = new Smooks( getClass().getResourceAsStream( "smooks-config.xml" ) );
-
- DroolsSmooksConfiguration conf = new DroolsSmooksConfiguration( "root",
- "children" );
- //
- DroolsSmooksStatelessSession dataLoader = new DroolsSmooksStatelessSession( session,
- smooks,
- conf );
- dataLoader.executeFilter( new StreamSource( getClass().getResourceAsStream( "SmooksNestedIterable.xml") ) );
- //
-
- assertEquals(2, list.size());
-
- assertEquals( "example.OrderItem", list.get( 0 ).getClass().getName() );
- assertEquals( "example.OrderItem", list.get( 1 ).getClass().getName() );
-
- assertNotSame( list.get( 0 ), list.get( 1 ) );
- }
-
- public void testSmooksDirectRoot() throws Exception {
- PackageBuilder pkgBuilder = new PackageBuilder();
-
- pkgBuilder.addPackageFromDrl( new InputStreamReader( DroolsSmookStatelessSessionTest.class.getResourceAsStream( "test_SmooksDirectRoot.drl" ) ) );
-
- assertFalse( pkgBuilder.hasErrors() );
-
- RuleBase ruleBase = RuleBaseFactory.newRuleBase();
- ruleBase.addPackage( pkgBuilder.getPackage() );
-
- StatelessSession session = ruleBase.newStatelessSession();
- List list = new ArrayList();
- session.setGlobal( "list", list );
-
- // Instantiate Smooks with the config...
- Smooks smooks = new Smooks( getClass().getResourceAsStream( "smooks-config.xml" ) );
-
-
- DroolsSmooksConfiguration conf = new DroolsSmooksConfiguration( "orderItem", null );
- //
- DroolsSmooksStatelessSession dataLoader = new DroolsSmooksStatelessSession( session,
- smooks,
- conf );
- dataLoader.executeFilter( new StreamSource( getClass().getResourceAsStream( "SmooksDirectRoot.xml") ) );
-
- assertEquals(1, list.size());
-
- assertEquals( "example.OrderItem", list.get( 0 ).getClass().getName() );
- }
-
-
-
-
- private static byte[] readInputMessage(InputStream stream) {
- try {
- return StreamUtils.readStream( stream );
- } catch ( IOException e ) {
- e.printStackTrace();
- return "<no-message/>".getBytes();
- }
- }
-}
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/pipeline/impl/DroolsSmookStatefulSessionTest.java (from rev 24433, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/dataloaders/smooks/DroolsSmookStatefulSessionTest.java)
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/pipeline/impl/DroolsSmookStatefulSessionTest.java (rev 0)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/pipeline/impl/DroolsSmookStatefulSessionTest.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,129 @@
+package org.drools.runtime.pipeline.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseFactory;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.KnowledgeBuilderFactory;
+import org.drools.builder.ResourceType;
+import org.drools.definition.pipeline.Expression;
+import org.drools.definition.pipeline.PipelineFactory;
+import org.drools.definition.pipeline.Splitter;
+import org.drools.definition.pipeline.Transformer;
+import org.drools.io.ResourceFactory;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.dataloader.DataLoaderFactory;
+import org.drools.runtime.dataloader.StatefulKnowledgeSessionDataLoader;
+import org.drools.runtime.dataloader.impl.StatefulKnowledgeSessionDataLoaderImpl;
+import org.drools.runtime.dataloader.impl.StatefulKnowledgeSessionReceiverAdapter;
+import org.drools.runtime.pipeline.impl.DroolsSmooksConfiguration;
+import org.drools.runtime.pipeline.impl.IterateSplitter;
+import org.drools.runtime.pipeline.impl.MvelExpression;
+import org.drools.runtime.rule.FactHandle;
+import org.milyn.Smooks;
+import org.milyn.io.StreamUtils;
+
+public class DroolsSmookStatefulSessionTest extends TestCase {
+
+ public void testDirectRoot() throws Exception {
+ KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+
+ kbuilder.add( ResourceFactory.newClassPathResource( "test_SmooksDirectRoot.drl",
+ DroolsSmookStatefulSessionTest.class ),
+ ResourceType.DRL );
+
+ assertFalse( kbuilder.hasErrors() );
+
+ KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
+ kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
+
+ StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
+ List list = new ArrayList();
+ ksession.setGlobal( "list",
+ list );
+
+ // Instantiate Smooks with the config...
+ Smooks smooks = new Smooks( getClass().getResourceAsStream( "smooks-config.xml" ) );
+
+ Transformer transformer = PipelineFactory.newSmooksTransformer( smooks, "orderItem" );
+ transformer.addReceiver( PipelineFactory.newStatefulKnowledgeSessionReceiverAdapter() );
+
+ StatefulKnowledgeSessionDataLoader dataLoader = DataLoaderFactory.newStatefulKnowledgeSessionDataLoader( ksession,
+ transformer );
+ Map<FactHandle, Object> handles = dataLoader.insert( new StreamSource( getClass().getResourceAsStream( "SmooksDirectRoot.xml" ) ) );
+ ksession.fireAllRules();
+
+ assertEquals( 1,
+ handles.size() );
+ assertEquals( 1,
+ list.size() );
+
+ assertEquals( "example.OrderItem",
+ list.get( 0 ).getClass().getName() );
+ }
+
+ public void testNestedIterable() throws Exception {
+ KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+
+ kbuilder.add( ResourceFactory.newClassPathResource( "test_SmooksNestedIterable.drl",
+ DroolsSmookStatefulSessionTest.class ),
+ ResourceType.DRL );
+
+ assertFalse( kbuilder.hasErrors() );
+
+ KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
+ kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
+
+ StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
+ List list = new ArrayList();
+ ksession.setGlobal( "list",
+ list );
+
+ // Instantiate Smooks with the config...
+ Smooks smooks = new Smooks( getClass().getResourceAsStream( "smooks-config.xml" ) );
+
+ Transformer transformer = PipelineFactory.newSmooksTransformer( smooks, "root" );
+ Expression expression = PipelineFactory.newMvelExpression( "children" );
+ transformer.addReceiver( expression );
+ Splitter splitter = PipelineFactory.newIterateSplitter();
+ expression.addReceiver( splitter );
+ splitter.addReceiver( PipelineFactory.newStatefulKnowledgeSessionReceiverAdapter() );
+
+ StatefulKnowledgeSessionDataLoader dataLoader = DataLoaderFactory.newStatefulKnowledgeSessionDataLoader( ksession,
+ transformer );
+
+ Map<FactHandle, Object> handles = dataLoader.insert( new StreamSource( getClass().getResourceAsStream( "SmooksNestedIterable.xml" ) ) );
+ ksession.fireAllRules();
+
+ assertEquals( 2,
+ handles.size() );
+ assertEquals( 2,
+ list.size() );
+
+ assertEquals( "example.OrderItem",
+ list.get( 0 ).getClass().getName() );
+ assertEquals( "example.OrderItem",
+ list.get( 1 ).getClass().getName() );
+
+ assertNotSame( list.get( 0 ),
+ list.get( 1 ) );
+ }
+
+ private static byte[] readInputMessage(InputStream stream) {
+ try {
+ return StreamUtils.readStream( stream );
+ } catch ( IOException e ) {
+ e.printStackTrace();
+ return "<no-message/>".getBytes();
+ }
+ }
+}
Property changes on: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/pipeline/impl/DroolsSmookStatefulSessionTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/pipeline/impl/DroolsSmookStatelessSessionTest.java (from rev 24433, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/dataloaders/smooks/DroolsSmookStatelessSessionTest.java)
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/pipeline/impl/DroolsSmookStatelessSessionTest.java (rev 0)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/pipeline/impl/DroolsSmookStatelessSessionTest.java 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,115 @@
+package org.drools.runtime.pipeline.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseFactory;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.KnowledgeBuilderFactory;
+import org.drools.builder.ResourceType;
+import org.drools.definition.pipeline.Expression;
+import org.drools.definition.pipeline.PipelineFactory;
+import org.drools.definition.pipeline.Splitter;
+import org.drools.definition.pipeline.Transformer;
+import org.drools.io.ResourceFactory;
+import org.drools.runtime.StatelessKnowledgeSession;
+import org.drools.runtime.dataloader.StatelessKnowledgeSessionDataLoader;
+import org.drools.runtime.dataloader.impl.StatelessKnowledgeSessionDataLoaderImpl;
+import org.milyn.Smooks;
+import org.milyn.io.StreamUtils;
+
+public class DroolsSmookStatelessSessionTest extends TestCase {
+
+ public void testSmooksDirectRoot() throws Exception {
+ KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+
+ kbuilder.add( ResourceFactory.newClassPathResource( "test_SmooksDirectRoot.drl",
+ DroolsSmookStatefulSessionTest.class ),
+ ResourceType.DRL );
+
+ assertFalse( kbuilder.hasErrors() );
+
+ KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
+ kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
+
+ StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
+ List list = new ArrayList();
+ ksession.setGlobal( "list",
+ list );
+
+ // Instantiate Smooks with the config...
+ Smooks smooks = new Smooks( getClass().getResourceAsStream( "smooks-config.xml" ) );
+
+ Transformer transformer = PipelineFactory.newSmooksTransformer( smooks, "orderItem" );
+ transformer.addReceiver( PipelineFactory.newStatelessKnowledgeSessionReceiverAdapter() );
+
+ StatelessKnowledgeSessionDataLoader dataLoader = new StatelessKnowledgeSessionDataLoaderImpl( ksession,
+ transformer );
+ dataLoader.executeObject( new StreamSource( getClass().getResourceAsStream( "SmooksDirectRoot.xml" ) ) );
+
+ assertEquals( 1,
+ list.size() );
+
+ assertEquals( "example.OrderItem",
+ list.get( 0 ).getClass().getName() );
+ }
+
+ public void testSmooksNestedIterable() throws Exception {
+ KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+
+ kbuilder.add( ResourceFactory.newClassPathResource( "test_SmooksNestedIterable.drl",
+ DroolsSmookStatefulSessionTest.class ),
+ ResourceType.DRL );
+
+ assertFalse( kbuilder.hasErrors() );
+
+ KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
+ kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
+
+ StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
+ List list = new ArrayList();
+ ksession.setGlobal( "list",
+ list );
+
+ // Instantiate Smooks with the config...
+ Smooks smooks = new Smooks( getClass().getResourceAsStream( "smooks-config.xml" ) );
+
+ Transformer transformer = PipelineFactory.newSmooksTransformer( smooks, "root" );
+ Expression expression = PipelineFactory.newMvelExpression( "children" );
+ transformer.addReceiver( expression );
+ Splitter splitter = PipelineFactory.newIterateSplitter();
+ expression.addReceiver( splitter );
+ splitter.addReceiver( PipelineFactory.newStatelessKnowledgeSessionReceiverAdapter() );
+
+ StatelessKnowledgeSessionDataLoader dataLoader = new StatelessKnowledgeSessionDataLoaderImpl( ksession,
+ transformer );
+ dataLoader.executeIterable( new StreamSource( getClass().getResourceAsStream( "SmooksNestedIterable.xml" ) ) );
+
+ assertEquals( 2,
+ list.size() );
+
+ assertEquals( "example.OrderItem",
+ list.get( 0 ).getClass().getName() );
+ assertEquals( "example.OrderItem",
+ list.get( 1 ).getClass().getName() );
+
+ assertNotSame( list.get( 0 ),
+ list.get( 1 ) );
+ }
+
+ private static byte[] readInputMessage(InputStream stream) {
+ try {
+ return StreamUtils.readStream( stream );
+ } catch ( IOException e ) {
+ e.printStackTrace();
+ return "<no-message/>".getBytes();
+ }
+ }
+}
Property changes on: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/java/org/drools/runtime/pipeline/impl/DroolsSmookStatelessSessionTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/SmooksDirectRoot.xml
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/SmooksDirectRoot.xml 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/SmooksDirectRoot.xml 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,5 +0,0 @@
-<order-item>
- <product>222</product>
- <quantity>7</quantity>
- <price>5.20</price>
-</order-item>
\ No newline at end of file
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/SmooksNestedIterable.xml
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/SmooksNestedIterable.xml 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/SmooksNestedIterable.xml 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,12 +0,0 @@
-<root>
- <order-item>
- <product>111</product>
- <quantity>2</quantity>
- <price>8.90</price>
- </order-item>
- <order-item>
- <product>222</product>
- <quantity>7</quantity>
- <price>5.20</price>
- </order-item>
-</root>
\ No newline at end of file
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/smooks-config.xml
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/smooks-config.xml 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/smooks-config.xml 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,46 +0,0 @@
-<?xml version="1.0"?>
-<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">
-
- <!--
- Create an "example.beans.Order" bean instance when we visit the start of the <order> element.
- Assign the new bean instance to the beanId of "order".
- -->
- <resource-config selector="root">
- <resource>org.milyn.javabean.BeanPopulator</resource>
- <param name="beanId">root</param>
- <param name="beanClass">org.drools.dataloaders.smooks.Root</param>
- <param name="bindings">
- <binding property="children" selector="${children}" />
- </param>
- </resource-config>
-
- <!--
- Create an ArrayList bean instance when we visit the start of the <order> element.
- Call it "orderItems" and seet it on the "order".
- -->
- <resource-config selector="root">
- <resource>org.milyn.javabean.BeanPopulator</resource>
- <param name="beanId">children</param>
- <param name="beanClass">java.util.ArrayList</param>
- <param name="bindings">
- <binding selector="${orderItem}" />
- </param>
- </resource-config>
-
- <!--
- Create an "example.beans.OrderItem" bean instance when we visit the start of the <order-item> element.
- Set the OrderItem instances on the "orderItem".
- -->
- <resource-config selector="order-item">
- <resource>org.milyn.javabean.BeanPopulator</resource>
- <param name="beanClass">example.OrderItem</param>
- <param name="bindings">
- <!-- OrderItem bindings... -->
- <binding property="productId" type="Long" selector="order-item product" />
- <binding property="quantity" type="Integer" selector="order-item quantity" />
- <binding property="price" type="Double" selector="order-item price" />
- </param>
- </resource-config>
-
-
-</smooks-resource-list>
\ No newline at end of file
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/test_SmooksDirectRoot.drl
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/test_SmooksDirectRoot.drl 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/test_SmooksDirectRoot.drl 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,16 +0,0 @@
-package example
-
-global java.util.List list;
-
-declare OrderItem
- productId : long
- quantity : Integer
- price : double
-end
-
-rule someRule
-when
- $i : OrderItem()
-then
- list.add( $i );
-end
\ No newline at end of file
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/test_SmooksNestedIterable.drl
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/test_SmooksNestedIterable.drl 2008-12-23 18:51:02 UTC (rev 24483)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/test_SmooksNestedIterable.drl 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,16 +0,0 @@
-package example
-
-global java.util.List list;
-
-declare OrderItem
- productId : long
- quantity : Integer
- price : double
-end
-
-rule someRule
-when
- $i : OrderItem()
-then
- list.add( $i );
-end
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline (from rev 24433, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks)
Property changes on: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/SmooksDirectRoot.xml
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/SmooksDirectRoot.xml 2008-12-19 09:30:00 UTC (rev 24433)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/SmooksDirectRoot.xml 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,5 +0,0 @@
-<order-item>
- <product>222</product>
- <quantity>7</quantity>
- <price>5.20</price>
-</order-item>
\ No newline at end of file
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/SmooksNestedIterable.xml
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/SmooksNestedIterable.xml 2008-12-19 09:30:00 UTC (rev 24433)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/SmooksNestedIterable.xml 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,12 +0,0 @@
-<root>
- <order-item>
- <product>111</product>
- <quantity>2</quantity>
- <price>8.90</price>
- </order-item>
- <order-item>
- <product>222</product>
- <quantity>7</quantity>
- <price>5.20</price>
- </order-item>
-</root>
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/SmooksDirectRoot.xml (from rev 24433, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/SmooksDirectRoot.xml)
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/SmooksDirectRoot.xml (rev 0)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/SmooksDirectRoot.xml 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,5 @@
+<order-item>
+ <product>222</product>
+ <quantity>7</quantity>
+ <price>5.20</price>
+</order-item>
\ No newline at end of file
Property changes on: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/SmooksDirectRoot.xml
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/SmooksNestedIterable.xml (from rev 24433, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/SmooksNestedIterable.xml)
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/SmooksNestedIterable.xml (rev 0)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/SmooksNestedIterable.xml 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,12 @@
+<root>
+ <order-item>
+ <product>111</product>
+ <quantity>2</quantity>
+ <price>8.90</price>
+ </order-item>
+ <order-item>
+ <product>222</product>
+ <quantity>7</quantity>
+ <price>5.20</price>
+ </order-item>
+</root>
\ No newline at end of file
Property changes on: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/SmooksNestedIterable.xml
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/smooks-config.xml (from rev 24433, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/smooks-config.xml)
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/smooks-config.xml (rev 0)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/smooks-config.xml 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,46 @@
+<?xml version="1.0"?>
+<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">
+
+ <!--
+ Create an "example.beans.Order" bean instance when we visit the start of the <order> element.
+ Assign the new bean instance to the beanId of "order".
+ -->
+ <resource-config selector="root">
+ <resource>org.milyn.javabean.BeanPopulator</resource>
+ <param name="beanId">root</param>
+ <param name="beanClass">org.drools.runtime.pipeline.impl.Root</param>
+ <param name="bindings">
+ <binding property="children" selector="${children}" />
+ </param>
+ </resource-config>
+
+ <!--
+ Create an ArrayList bean instance when we visit the start of the <order> element.
+ Call it "orderItems" and seet it on the "order".
+ -->
+ <resource-config selector="root">
+ <resource>org.milyn.javabean.BeanPopulator</resource>
+ <param name="beanId">children</param>
+ <param name="beanClass">java.util.ArrayList</param>
+ <param name="bindings">
+ <binding selector="${orderItem}" />
+ </param>
+ </resource-config>
+
+ <!--
+ Create an "example.beans.OrderItem" bean instance when we visit the start of the <order-item> element.
+ Set the OrderItem instances on the "orderItem".
+ -->
+ <resource-config selector="order-item">
+ <resource>org.milyn.javabean.BeanPopulator</resource>
+ <param name="beanClass">example.OrderItem</param>
+ <param name="bindings">
+ <!-- OrderItem bindings... -->
+ <binding property="productId" type="Long" selector="order-item product" />
+ <binding property="quantity" type="Integer" selector="order-item quantity" />
+ <binding property="price" type="Double" selector="order-item price" />
+ </param>
+ </resource-config>
+
+
+</smooks-resource-list>
\ No newline at end of file
Property changes on: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/smooks-config.xml
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/test_SmooksDirectRoot.drl (from rev 24433, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/test_SmooksDirectRoot.drl)
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/test_SmooksDirectRoot.drl (rev 0)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/test_SmooksDirectRoot.drl 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,16 @@
+package example
+
+global java.util.List list;
+
+declare OrderItem
+ productId : long
+ quantity : Integer
+ price : double
+end
+
+rule someRule
+when
+ $i : OrderItem()
+then
+ list.add( $i );
+end
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/test_SmooksNestedIterable.drl (from rev 24433, labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/test_SmooksNestedIterable.drl)
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/test_SmooksNestedIterable.drl (rev 0)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/impl/test_SmooksNestedIterable.drl 2008-12-23 18:58:19 UTC (rev 24484)
@@ -0,0 +1,16 @@
+package example
+
+global java.util.List list;
+
+declare OrderItem
+ productId : long
+ quantity : Integer
+ price : double
+end
+
+rule someRule
+when
+ $i : OrderItem()
+then
+ list.add( $i );
+end
\ No newline at end of file
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/smooks-config.xml
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/smooks-config.xml 2008-12-19 09:30:00 UTC (rev 24433)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/smooks-config.xml 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,46 +0,0 @@
-<?xml version="1.0"?>
-<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">
-
- <!--
- Create an "example.beans.Order" bean instance when we visit the start of the <order> element.
- Assign the new bean instance to the beanId of "order".
- -->
- <resource-config selector="root">
- <resource>org.milyn.javabean.BeanPopulator</resource>
- <param name="beanId">root</param>
- <param name="beanClass">org.drools.dataloaders.smooks.Root</param>
- <param name="bindings">
- <binding property="children" selector="${children}" />
- </param>
- </resource-config>
-
- <!--
- Create an ArrayList bean instance when we visit the start of the <order> element.
- Call it "orderItems" and seet it on the "order".
- -->
- <resource-config selector="root">
- <resource>org.milyn.javabean.BeanPopulator</resource>
- <param name="beanId">children</param>
- <param name="beanClass">java.util.ArrayList</param>
- <param name="bindings">
- <binding selector="${orderItem}" />
- </param>
- </resource-config>
-
- <!--
- Create an "example.beans.OrderItem" bean instance when we visit the start of the <order-item> element.
- Set the OrderItem instances on the "orderItem".
- -->
- <resource-config selector="order-item">
- <resource>org.milyn.javabean.BeanPopulator</resource>
- <param name="beanClass">example.OrderItem</param>
- <param name="bindings">
- <!-- OrderItem bindings... -->
- <binding property="productId" type="Long" selector="order-item product" />
- <binding property="quantity" type="Integer" selector="order-item quantity" />
- <binding property="price" type="Double" selector="order-item price" />
- </param>
- </resource-config>
-
-
-</smooks-resource-list>
\ No newline at end of file
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/test_SmooksDirectRoot.drl
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/test_SmooksDirectRoot.drl 2008-12-19 09:30:00 UTC (rev 24433)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/test_SmooksDirectRoot.drl 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,16 +0,0 @@
-package example
-
-global java.util.List list;
-
-declare OrderItem
- productId : long
- quantity : Integer
- price : double
-end
-
-rule someRule
-when
- $i : OrderItem()
-then
- list.add( $i );
-end
\ No newline at end of file
Deleted: labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/test_SmooksNestedIterable.drl
===================================================================
--- labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/dataloaders/smooks/test_SmooksNestedIterable.drl 2008-12-19 09:30:00 UTC (rev 24433)
+++ labs/jbossrules/trunk/drools-dataloaders/drools-dataloaders-smooks/src/test/resources/org/drools/runtime/pipeline/test_SmooksNestedIterable.drl 2008-12-23 18:58:19 UTC (rev 24484)
@@ -1,16 +0,0 @@
-package example
-
-global java.util.List list;
-
-declare OrderItem
- productId : long
- quantity : Integer
- price : double
-end
-
-rule someRule
-when
- $i : OrderItem()
-then
- list.add( $i );
-end
\ No newline at end of file
More information about the jboss-svn-commits
mailing list