[jboss-svn-commits] JBL Code SVN: r36708 - in labs/jbossrules/tags/5.2.0.M1: drools-jsr94 and 32 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Feb 24 12:25:59 EST 2011
Author: ge0ffrey
Date: 2011-02-24 12:25:58 -0500 (Thu, 24 Feb 2011)
New Revision: 36708
Added:
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/.gitignore
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/pom.xml
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/AbstractRuleSessionImpl.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/Constants.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/IteratorToList.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/Jsr94EventFactHandle.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/Jsr94FactHandle.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/Jsr94FactHandleFactory.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/ObjectFilterAdapter.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/RuleExecutionSetMetadataImpl.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/RuleRuntimeImpl.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/RuleServiceProviderImpl.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/StatefulRuleSessionImpl.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/StatelessRuleSessionImpl.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/LocalRuleExecutionSetProviderImpl.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/RuleAdministratorImpl.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/RuleExecutionSetImpl.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/RuleExecutionSetProviderImpl.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/RuleImpl.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/package.html
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/package.html
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/DefaultRuleExecutionSetRepository.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/RuleExecutionSetRepository.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/RuleExecutionSetRepositoryException.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/RuleExecutionSetRepositoryLoader.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/package.html
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/decisiontable/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/decisiontable/Cheese.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/decisiontable/Person.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/decisiontable/SpreadsheetIntegrationTest.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/ExampleRuleEngineFacade.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/JSR94TestBase.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/MultipleRepositoryTest.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/Person.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/RuleEngineTestBase.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/RuleRuntimeTest.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/RuleServiceProviderTest.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/StatefulRuleSessionTest.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/StatelessRuleSessionTest.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/LocalRuleExecutionSetProviderTest.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/RuleAdministratorTest.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/RuleExecutionSetProviderTest.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/RuleExecutionSetTest.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/RuleTest.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/repository/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/repository/RuleExecutionSetRepositoryLoaderTest.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/repository/TestRuleExecutionSetRepository.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/jcp/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/jcp/jsr94/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/jcp/jsr94/tck/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/jcp/jsr94/tck/AllTests.java
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/decisiontable/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/decisiontable/IntegrationExampleTest.xls
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/multiple-engine1.drl
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/multiple-engine2.drl
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/sisters.drl
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/sisters.xml
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/sisters_expander.drl
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/sisters_expander.dsl
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/sisters_globals.drl
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/javarules/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/javarules/jsr94/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/javarules/jsr94/testagent.drl
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/jaxrules.sig
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/jaxrules14.sig
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/tck.conf
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/tck_res_1.xml
labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/tck_res_2.xml
Log:
All monolothic build versions (<= 5.2.0.M1) stay in subversion
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/.gitignore
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/.gitignore (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/.gitignore 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,10 @@
+/target
+/local
+
+# Eclipse, Netbeans and IntelliJ files
+/.*
+!.gitignore
+/nbproject
+/*.ipr
+/*.iws
+/*.iml
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/pom.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/pom.xml (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/pom.xml 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.drools</groupId>
+ <artifactId>drools</artifactId>
+ <version>5.2.0.M1</version>
+ </parent>
+
+ <artifactId>drools-jsr94</artifactId>
+ <packaging>jar</packaging>
+ <name>Drools :: JSR-94 API Module</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>jsr94.tck.configuration</name>
+ <value>${basedir}/target/test-classes/org/drools/jsr94/tck</value>
+ </property>
+ </systemProperties>
+ <includes>
+ <include>**/*Tests.java</include>
+ <include>**/*Test.java</include>
+ </includes>
+ <excludes>
+ <exclude>**/ClassLoaderTest.java</exclude>
+ <exclude>**/RuleExecutionSetProviderTest.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <!-- Internal dependencies -->
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-compiler</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-decisiontables</artifactId>
+ </dependency>
+
+ <!-- External dependencies -->
+ <dependency>
+ <groupId>jsr94</groupId>
+ <artifactId>jsr94</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jsr94</groupId>
+ <artifactId>jsr94-tck</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jsr94</groupId>
+ <artifactId>jsr94-sigtest</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/AbstractRuleSessionImpl.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/AbstractRuleSessionImpl.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/AbstractRuleSessionImpl.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,168 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.rules.InvalidRuleSessionException;
+import javax.rules.RuleExecutionSetMetadata;
+import javax.rules.RuleSession;
+import javax.rules.admin.RuleExecutionSet;
+
+import org.drools.jsr94.rules.admin.RuleExecutionSetImpl;
+import org.drools.jsr94.rules.repository.RuleExecutionSetRepository;
+import org.drools.jsr94.rules.repository.RuleExecutionSetRepositoryException;
+
+/**
+ * The Drools implementation of the <code>RuleSession</code> interface which is
+ * a representation of a client session with a rules engine. A rules engine
+ * session serves as an entry point into an underlying rules engine. The
+ * <code>RuleSession</code> is bound to a rules engine instance and exposes a
+ * vendor-neutral rule processing API for executing <code>Rule</code>s within a
+ * bound <code>RuleExecutionSet</code>.
+ * <p/>
+ * Note: the <code>release</code> method must be called to clean up all
+ * resources used by the <code>RuleSession</code>. Calling <code>release</code>
+ * may make the <code>RuleSession</code> eligible to be returned to a
+ * <code>RuleSession</code> pool.
+ *
+ * @see RuleSession
+ *
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ */
+abstract class AbstractRuleSessionImpl
+ implements
+ RuleSession {
+ private RuleExecutionSetRepository repository;
+
+ public AbstractRuleSessionImpl(final RuleExecutionSetRepository repository) {
+ this.repository = repository;
+ }
+
+ /**
+ * The Drools <code>RuleExecutionSet</code> associated
+ * with this <code>RuleSession</code>.
+ */
+ private RuleExecutionSetImpl ruleExecutionSet;
+
+ /**
+ * A <code>Map</code> of <code>String</code>/<code>Object</code> pairs
+ * passed as application data to the Drools <code>WorkingMemory</code>.
+ */
+ private Map properties;
+
+ /**
+ * Sets additional properties used to create this <code>RuleSession</code>.
+ *
+ * @param properties additional properties used to create the
+ * <code>RuleSession</code> implementation.
+ */
+ protected void setProperties(final Map properties) {
+ this.properties = properties;
+ }
+
+ /**
+ * Returns the additional properties used to create this
+ * <code>RuleSession</code>.
+ *
+ * @return the additional properties used to create this
+ * <code>RuleSession</code>.
+ */
+ protected Map getProperties() {
+ return this.properties;
+ }
+
+ /**
+ * Sets the Drools <code>RuleExecutionSet</code> associated
+ * with this <code>RuleSession</code>.
+ *
+ * @param ruleExecutionSet the Drools <code>RuleExecutionSet</code> to associate
+ * with this <code>RuleSession</code>.
+ */
+ protected void setRuleExecutionSet(final RuleExecutionSetImpl ruleExecutionSet) {
+ this.ruleExecutionSet = ruleExecutionSet;
+ }
+
+ /**
+ * Returns the Drools <code>RuleExecutionSet</code> associated
+ * with this <code>RuleSession</code>.
+ *
+ * @return the Drools <code>RuleExecutionSet</code> associated
+ * with this <code>RuleSession</code>.
+ */
+ protected RuleExecutionSetImpl getRuleExecutionSet() {
+ return this.ruleExecutionSet;
+ }
+
+ protected abstract void checkRuleSessionValidity() throws InvalidRuleSessionException;
+
+
+ // JSR94 interface methods start here -------------------------------------
+
+ /**
+ * Returns the meta data for the rule execution set bound to this rule
+ * session.
+ *
+ * @return the RuleExecutionSetMetaData bound to this rule session.
+ */
+ public RuleExecutionSetMetadata getRuleExecutionSetMetadata() {
+ String theBindUri = null;
+ List registrations = null;
+
+ try {
+ registrations = this.repository.getRegistrations();
+ } catch (RuleExecutionSetRepositoryException e) {
+ String s = "Error while retrieving rule execution set registrations";
+ throw new RuntimeException(s, e);
+ }
+
+ for ( final Iterator i = registrations.iterator(); i.hasNext(); ) {
+ final String aBindUri = (String) i.next();
+ // FIXME: provide the correct properties
+ RuleExecutionSet aRuleSet = null;
+
+ try {
+ aRuleSet = this.repository.getRuleExecutionSet( aBindUri, null );
+ } catch (RuleExecutionSetRepositoryException e) {
+ String s = "Error while retrieving rule execution set bound to: " + aBindUri;
+ throw new RuntimeException(s, e);
+ }
+
+ if ( aRuleSet == this.ruleExecutionSet ) {
+ theBindUri = aBindUri;
+ break;
+ }
+ }
+
+ return new RuleExecutionSetMetadataImpl( theBindUri,
+ this.ruleExecutionSet.getName(),
+ this.ruleExecutionSet.getDescription() );
+ }
+
+ /**
+ * Releases all resources used by this rule session.
+ * This method renders this rule session unusable until
+ * it is reacquired through the <code>RuleRuntime</code>.
+ */
+ public void release() {
+ setProperties( null );
+ setRuleExecutionSet( null );
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/Constants.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/Constants.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/Constants.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules;
+
+/**
+ * This class provides a list of constant values which can be used as keys in
+ * the various property maps that are passed around between the javax.rules and
+ * javax.rules.admin objects.
+ * <p/>
+ * This helps us enforce proper key values at compile time and eliminate the
+ * risk of spelling errors.
+ *
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ */
+public final class Constants {
+ /** Private constructor because all public access is static. */
+ private Constants() {
+ // hidden constructor
+ }
+
+ /** <code>RuleExecutionSet</code> name constant. */
+ public static final String RES_NAME = "javax.rules.admin.RuleExecutionSet.name";
+
+ /** <code>RuleExecutionSet</code> description constant. */
+ public static final String RES_DESCRIPTION = "javax.rules.admin.RuleExecutionSet.description";
+
+ public static final String RES_SOURCE = "javax.rules.admin.RuleExecutionSet.source";
+
+ public static final String RES_SOURCE_TYPE_XML = "javax.rules.admin.RuleExecutionSet.source.xml";
+
+ public static final String RES_SOURCE_TYPE_DECISION_TABLE = "javax.rules.admin.RuleExecutionSet.source.decisiontable";
+
+ public static final String RES_DSL = "javax.rules.admin.RuleExecutionSet.dsl";
+
+ /** <code>RuleExecutionSet</code> rulebase config constant. */
+ public static final String RES_RULEBASE_CONFIG = "javax.rules.admin.RuleExecutionSet.ruleBaseConfiguration";
+
+ /** <code>RuleExecutionSet</code> package builder config constant. */
+ public static final String RES_PACKAGEBUILDER_CONFIG = "javax.rules.admin.RuleExecutionSet.packageBuilderConfiguration";
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/IteratorToList.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/IteratorToList.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/IteratorToList.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,31 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+class IteratorToList {
+ public static List convert(Iterator it) {
+ List list = new ArrayList();
+ while ( it.hasNext() ) {
+ list.add( it.next() );
+ }
+ return list;
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/Jsr94EventFactHandle.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/Jsr94EventFactHandle.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/Jsr94EventFactHandle.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,91 @@
+package org.drools.jsr94.rules;
+
+/*
+ * $Id: Jsr94FactHandle.java,v 1.14 2005/02/04 02:13:38 mproctor Exp $
+ *
+ * Copyright 2003-2004 (C) The Werken Company. All Rights Reserved.
+ *
+ * Redistribution and use of this software and associated documentation
+ * ("Software"), with or without modification, are permitted provided that the
+ * following conditions are met:
+ *
+ * 1. Redistributions of source code must retain copyright statements and
+ * notices. Redistributions must also contain a copy of this document.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name "drools" must not be used to endorse or promote products derived
+ * from this Software without prior written permission of The Werken Company.
+ * For written permission, please contact bob at werken.com.
+ *
+ * 4. Products derived from this Software may not be called "drools" nor may
+ * "drools" appear in their names without prior written permission of The Werken
+ * Company. "drools" is a registered trademark of The Werken Company.
+ *
+ * 5. Due credit should be given to The Werken Company.
+ * (http://drools.werken.com/).
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+import javax.rules.Handle;
+
+import org.drools.common.EventFactHandle;
+import org.drools.runtime.rule.WorkingMemoryEntryPoint;
+
+/**
+ * The Drools implementation of the <code>Handle</code> interface which provides
+ * a marker interface for Drools-specific object identity mechanism. When using
+ * the <code>StatefulRuleSession</code> objects that are added to rule session
+ * state are identified using a Drools-supplied <code>Handle</code>
+ * implementation.
+ * <p/>
+ * <code>Handle</code>s are used to unambigiously identify objects within the
+ * rule session state and should not suffer many of the object identity issues
+ * that arise when using muliple class loaders, serializing
+ * <code>StatefulRuleSessions</code>, or using <code>Object.equals</code> or
+ * <code>object1 == object2</code> reference equality.
+ */
+public class Jsr94EventFactHandle extends EventFactHandle
+ implements
+ Handle {
+
+ private static final long serialVersionUID = 510l;
+
+ /**
+ * Creates a new event fact handle.
+ *
+ * @param id this event fact handle ID
+ * @param object the event object encapsulated in this event fact handle
+ * @param recency the recency of this event fact handle
+ * @param timestamp the timestamp of the occurence of this event
+ * @param duration the duration of this event. May be 0 (zero) in case this is a primitive event.
+ */
+ public Jsr94EventFactHandle(final long id,
+ final Object object,
+ final long recency,
+ final long timestamp,
+ final long duration,
+ final WorkingMemoryEntryPoint entryPoint) {
+ super( (int) id,
+ object,
+ recency,
+ timestamp,
+ duration,
+ entryPoint );
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/Jsr94FactHandle.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/Jsr94FactHandle.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/Jsr94FactHandle.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,87 @@
+package org.drools.jsr94.rules;
+
+/*
+ * $Id: Jsr94FactHandle.java,v 1.14 2005/02/04 02:13:38 mproctor Exp $
+ *
+ * Copyright 2003-2004 (C) The Werken Company. All Rights Reserved.
+ *
+ * Redistribution and use of this software and associated documentation
+ * ("Software"), with or without modification, are permitted provided that the
+ * following conditions are met:
+ *
+ * 1. Redistributions of source code must retain copyright statements and
+ * notices. Redistributions must also contain a copy of this document.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name "drools" must not be used to endorse or promote products derived
+ * from this Software without prior written permission of The Werken Company.
+ * For written permission, please contact bob at werken.com.
+ *
+ * 4. Products derived from this Software may not be called "drools" nor may
+ * "drools" appear in their names without prior written permission of The Werken
+ * Company. "drools" is a registered trademark of The Werken Company.
+ *
+ * 5. Due credit should be given to The Werken Company.
+ * (http://drools.werken.com/).
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+import javax.rules.Handle;
+
+import org.drools.common.DefaultFactHandle;
+import org.drools.runtime.rule.WorkingMemoryEntryPoint;
+
+/**
+ * The Drools implementation of the <code>Handle</code> interface which provides
+ * a marker interface for Drools-specific object identity mechanism. When using
+ * the <code>StatefulRuleSession</code> objects that are added to rule session
+ * state are identified using a Drools-supplied <code>Handle</code>
+ * implementation.
+ * <p/>
+ * <code>Handle</code>s are used to unambigiously identify objects within the
+ * rule session state and should not suffer many of the object identity issues
+ * that arise when using muliple class loaders, serializing
+ * <code>StatefulRuleSessions</code>, or using <code>Object.equals</code> or
+ * <code>object1 == object2</code> reference equality.
+ */
+public class Jsr94FactHandle extends DefaultFactHandle
+ implements
+ Handle {
+
+ private static final long serialVersionUID = 510l;
+
+ /**
+ * Constructs a new <code>Handle</code>.
+ *
+ * @param id A unique <code>Handle</code> id.
+ * @param recency A value indicating the recency of this <code>Handle</code>
+ * (more recently created <code>Handle</code>s have greater values
+ * than <code>Handle</code>s created further in the past)
+ *
+ * @see org.drools.conflict.RecencyConflictResolver
+ */
+ Jsr94FactHandle(final long id,
+ final Object object,
+ final long recency,
+ final WorkingMemoryEntryPoint entryPoint) {
+ super( (int) id,
+ object,
+ recency,
+ entryPoint );
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/Jsr94FactHandleFactory.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/Jsr94FactHandleFactory.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/Jsr94FactHandleFactory.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+package org.drools.jsr94.rules;
+
+import org.drools.common.AbstractFactHandleFactory;
+import org.drools.common.InternalFactHandle;
+import org.drools.common.InternalWorkingMemory;
+import org.drools.reteoo.ObjectTypeConf;
+import org.drools.rule.TypeDeclaration;
+import org.drools.runtime.rule.WorkingMemoryEntryPoint;
+import org.drools.spi.FactHandleFactory;
+
+/**
+ * A factory for creating <code>Handle</code>s.
+ *
+ * @author <a href="mailto:michael.frandsen at syngenio.de">michael frandsen </a>
+ */
+public final class Jsr94FactHandleFactory extends AbstractFactHandleFactory {
+
+ private static final long serialVersionUID = 510l;
+
+ protected final InternalFactHandle newFactHandle(final int id,
+ final Object object,
+ final long recency,
+ final ObjectTypeConf conf,
+ final InternalWorkingMemory workingMemory,
+ final WorkingMemoryEntryPoint entryPoint) {
+ if ( conf != null && conf.isEvent() ) {
+ // later we need to centralize the following code snippet in a common method
+ // shared by all fact handle factory implementations
+ TypeDeclaration type = conf.getTypeDeclaration();
+ long timestamp = workingMemory.getSessionClock().getCurrentTime();
+ long duration = 0;
+ if ( type.getDurationExtractor() != null ) {
+ duration = type.getDurationExtractor().getLongValue( workingMemory,
+ object );
+ }
+ return new Jsr94EventFactHandle( id,
+ object,
+ recency,
+ timestamp,
+ duration,
+ entryPoint );
+ } else {
+ return new Jsr94FactHandle( id,
+ object,
+ recency,
+ entryPoint );
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.drools.reteoo.FactHandleFactory#newInstance()
+ */
+ public FactHandleFactory newInstance() {
+ return new Jsr94FactHandleFactory();
+ }
+
+ public Class getFactHandleType() {
+ return Jsr94FactHandle.class;
+ }
+
+ public FactHandleFactory newInstance(int id,
+ long counter) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/ObjectFilterAdapter.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/ObjectFilterAdapter.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/ObjectFilterAdapter.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,36 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules;
+
+import javax.rules.ObjectFilter;
+
+/**
+ * Adaptor class, that makes JSR94 ObjectFilters work from a delegating Drools ObjectFilter
+ * @author mproctor
+ *
+ */
+public class ObjectFilterAdapter implements org.drools.runtime.ObjectFilter {
+ private ObjectFilter filter;
+
+ public ObjectFilterAdapter(ObjectFilter filter) {
+ this.filter = filter;
+ }
+
+ public boolean accept(Object object) {
+ return ( this.filter == null || this.filter.filter( object ) != null );
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/RuleExecutionSetMetadataImpl.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/RuleExecutionSetMetadataImpl.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/RuleExecutionSetMetadataImpl.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+package org.drools.jsr94.rules;
+
+import javax.rules.RuleExecutionSetMetadata;
+
+/**
+ * The Drools implementation of the <code>RuleExecutionSetMetadata</code>
+ * interface which exposes some simple properties of the
+ * <code>RuleExecutionSet</code> to the runtime user.
+ *
+ * @see RuleExecutionSetMetadata
+ */
+public class RuleExecutionSetMetadataImpl
+ implements
+ RuleExecutionSetMetadata {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 510l;
+
+ /** The URI for this <code>RuleExecutionSet</code>. */
+ private final String uri;
+
+ /** The name of this RuleExecutionSet. */
+ private final String name;
+
+ /** The description of this <code>RuleExecutionSet</code>. */
+ private final String description;
+
+ /**
+ * Constructs an instance of <code>RuleExecutionSetMetadata</code>.
+ *
+ * @param uri The URI for this <code>RuleExecutionSet</code>.
+ * @param name The name of this <code>RuleExecutionSet</code>.
+ * @param description The description of this <code>RuleExecutionSet</code>.
+ */
+ public RuleExecutionSetMetadataImpl(final String uri,
+ final String name,
+ final String description) {
+ this.uri = uri;
+ this.name = name;
+ this.description = description;
+ }
+
+ /**
+ * Get the URI for this <code>RuleExecutionSet</code>.
+ *
+ * @return The URI for this <code>RuleExecutionSet</code>.
+ */
+ public String getUri() {
+ return this.uri;
+ }
+
+ /**
+ * Get the name of this <code>RuleExecutionSet</code>.
+ *
+ * @return The name of this <code>RuleExecutionSet</code>.
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Get a short description about this <code>RuleExecutionSet</code>.
+ *
+ * @return The description of this <code>RuleExecutionSet</code>
+ * or <code>null</code>.
+ */
+ public String getDescription() {
+ return this.description;
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/RuleRuntimeImpl.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/RuleRuntimeImpl.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/RuleRuntimeImpl.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,123 @@
+/*
+ * 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.
+ */
+
+package org.drools.jsr94.rules;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.rules.RuleExecutionSetNotFoundException;
+import javax.rules.RuleRuntime;
+import javax.rules.RuleSession;
+import javax.rules.RuleSessionCreateException;
+import javax.rules.RuleSessionTypeUnsupportedException;
+
+import org.drools.jsr94.rules.repository.RuleExecutionSetRepository;
+import org.drools.jsr94.rules.repository.RuleExecutionSetRepositoryException;
+
+/**
+ * The Drools implementation of the <code>RuleRuntime</code> interface which
+ * is the access point for runtime execution of <code>RuleExecutionSet</code>s.
+ * It provides methods to create <code>RuleSession</code> implementation as
+ * well as methods to retrieve <code>RuleExecutionSet</code>s that have been
+ * previously registered using the <code>RuleAdministrator</code>. <p/> The
+ * <code>RuleRuntime</code> should be accessed through the
+ * <code>RuleServiceProvider</code>. An instance of the
+ * <code>RuleRuntime</code> can be retrieved by calling: <p/> <code>
+ * RuleServiceProvider ruleServiceProvider =
+ * RuleServiceProvider.newInstance();<br/>
+ * RuleRuntime ruleRuntime = ruleServiceProvider.getRuleRuntime();
+ * </code>
+ * <p/> Note: the release method must be called on the <code>RuleSession</code>
+ * to clean up all resources used by the <code>RuleSession</code>.
+ *
+ * @see RuleRuntime
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ */
+public class RuleRuntimeImpl
+ implements
+ RuleRuntime {
+ private static final long serialVersionUID = 510l;
+
+ private RuleExecutionSetRepository repository;
+
+ /**
+ * Create a new <code>RuleRuntimeImpl</code>.
+ */
+ public RuleRuntimeImpl(final RuleExecutionSetRepository repository) {
+ this.repository = repository;
+ // no special initialization required
+ }
+
+ /**
+ * Creates a <code>RuleSession</code> implementation using the supplied
+ * Drools-specific rule execution set registration URI.
+ *
+ * @param uri
+ * the URI for the <code>RuleExecutionSet</code>
+ * @param properties
+ * additional properties used to create the
+ * <code>RuleSession</code> implementation.
+ * @param ruleSessionType
+ * the type of rule session to create.
+ *
+ * @throws RuleSessionTypeUnsupportedException
+ * if the ruleSessionType is not supported by Drools or the
+ * RuleExecutionSet
+ * @throws RuleExecutionSetNotFoundException
+ * if the URI could not be resolved into a
+ * <code>RuleExecutionSet</code>
+ *
+ * @return The created <code>RuleSession</code>.
+ */
+ public RuleSession createRuleSession(final String uri,
+ final Map properties,
+ final int ruleSessionType)
+ throws RuleSessionTypeUnsupportedException,
+ RuleSessionCreateException,
+ RuleExecutionSetNotFoundException {
+
+ if ( ruleSessionType == RuleRuntime.STATELESS_SESSION_TYPE ) {
+ final StatelessRuleSessionImpl session = new StatelessRuleSessionImpl( uri,
+ properties,
+ this.repository );
+ return session;
+ } else if ( ruleSessionType == RuleRuntime.STATEFUL_SESSION_TYPE ) {
+ final StatefulRuleSessionImpl session = new StatefulRuleSessionImpl( uri,
+ properties,
+ this.repository );
+ return session;
+ }
+
+ throw new RuleSessionTypeUnsupportedException( "invalid session type: " + ruleSessionType );
+ }
+
+ /**
+ * Retrieves a <code>List</code> of the URIs that currently have
+ * <code>RuleExecutionSet</code>s associated with them. An empty list is
+ * returned is there are no associations.
+ *
+ * @return a <code>List</code> of <code>String</code>s (URIs)
+ */
+ public List getRegistrations() {
+ try {
+ return this.repository.getRegistrations();
+ } catch (RuleExecutionSetRepositoryException e) {
+ String s = "Error while retrieving list of registrations";
+ throw new RuntimeException(s, e);
+ }
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/RuleServiceProviderImpl.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/RuleServiceProviderImpl.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/RuleServiceProviderImpl.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,125 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules;
+
+import javax.rules.ConfigurationException;
+import javax.rules.RuleRuntime;
+import javax.rules.RuleServiceProvider;
+import javax.rules.RuleServiceProviderManager;
+import javax.rules.admin.RuleAdministrator;
+
+import org.drools.jsr94.rules.admin.RuleAdministratorImpl;
+import org.drools.jsr94.rules.repository.RuleExecutionSetRepository;
+import org.drools.jsr94.rules.repository.RuleExecutionSetRepositoryLoader;
+
+/**
+ * This class provides access to the <code>RuleRuntime</code> and
+ * <code>RuleAdministrator</code> implementation supplied by Drools when
+ * running under J2SE. <p/> This class should be used in environments without a
+ * JNDI provider - typically when writing standalone J2SE clients. Within the
+ * J2EE environment the <code>RuleServiceProvider</code> implementation class
+ * provided by Drools should be retrieved using a JNDI lookup. <p/> This class
+ * should be constructed using the
+ * <code>RuleServiceProviderManager.getRuleServiceProvider</code> method.
+ * This class is automatically registered to "http://drools.org/" on startup,
+ * via the static block.
+ *
+ * @see RuleRuntimeImpl
+ * @see RuleAdministratorImpl
+ * @see RuleServiceProvider
+ * @see javax.rules.RuleServiceProviderManager#getRuleServiceProvider(String)
+ *
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ */
+public class RuleServiceProviderImpl extends RuleServiceProvider implements java.io.Serializable {
+ public static final String RULE_SERVICE_PROVIDER = "http://drools.org/";
+
+ /** An instance of <code>RuleRuntimeImpl</code>. */
+ private RuleRuntime ruleRuntime;
+
+ /** An instance of <code>RuleAdministratorImpl</code>. */
+ private RuleAdministrator ruleAdministrator;
+
+ private RuleExecutionSetRepository repository;
+
+ static {
+ try {
+ RuleServiceProviderManager.registerRuleServiceProvider( RULE_SERVICE_PROVIDER,
+ RuleServiceProviderImpl.class );
+ } catch ( ConfigurationException e ) {
+ System.err.println( "Unable to regiser Rule Service Provider " + RULE_SERVICE_PROVIDER );
+ }
+ }
+
+ /**
+ * Create a new <code>RuleServiceProviderImpl</code>.
+ */
+ public RuleServiceProviderImpl() {
+ // no special initialization required
+ }
+
+ /**
+ * Returns the RuleExecutionSetRepository
+ * @return
+ */
+ public synchronized RuleExecutionSetRepository getRepository() {
+ // Lazy loaded
+ if ( this.repository == null ) {
+ this.repository = createRuleExecutionSetRepository();
+ }
+ return this.repository;
+ }
+
+ /**
+ * Returns a class instance of <code>RuleRuntime</code>. Specifically an
+ * instance of the Drools <code>RuleRuntimeImpl</code> is returned.
+ *
+ * @return an instance of <code>RuleRuntime</code>
+ */
+ public synchronized RuleRuntime getRuleRuntime() {
+ if ( this.ruleRuntime == null ) {
+ this.ruleRuntime = new RuleRuntimeImpl( getRepository() );
+ }
+
+ return this.ruleRuntime;
+ }
+
+ /**
+ * Returns a class instance of <code>RuleAdministrator</code>.
+ * Specifically an instance of the Drools <code>RuleAdministratorImpl</code>
+ * is returned.
+ *
+ * @return an instance of <code>RuleAdministrator</code>
+ */
+ public synchronized RuleAdministrator getRuleAdministrator() {
+ // Lazy instantiate
+ if ( this.ruleAdministrator == null ) {
+ this.ruleAdministrator = new RuleAdministratorImpl( getRepository() );
+ }
+ return this.ruleAdministrator;
+ }
+
+ /**
+ * Creates the RuleExecutionSetRepository.
+ *
+ * @return
+ */
+ protected RuleExecutionSetRepository createRuleExecutionSetRepository() {
+ String defaultFactoryName = "org.drools.jsr94.rules.repository.DefaultRuleExecutionSetRepository";
+ return RuleExecutionSetRepositoryLoader.loadRuleExecutionSetRepository(defaultFactoryName);
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/StatefulRuleSessionImpl.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/StatefulRuleSessionImpl.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/StatefulRuleSessionImpl.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,386 @@
+/*
+ * 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.
+ */
+
+package org.drools.jsr94.rules;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.rules.Handle;
+import javax.rules.InvalidHandleException;
+import javax.rules.InvalidRuleSessionException;
+import javax.rules.ObjectFilter;
+import javax.rules.RuleExecutionSetNotFoundException;
+import javax.rules.RuleRuntime;
+import javax.rules.RuleSessionCreateException;
+import javax.rules.StatefulRuleSession;
+
+import org.drools.FactHandle;
+import org.drools.SessionConfiguration;
+import org.drools.StatefulSession;
+import org.drools.jsr94.rules.admin.RuleExecutionSetImpl;
+import org.drools.jsr94.rules.repository.RuleExecutionSetRepository;
+import org.drools.jsr94.rules.repository.RuleExecutionSetRepositoryException;
+
+/**
+ * The Drools implementation of the <code>StatefulRuleSession</code> interface
+ * which is a representation of a stateful rules engine session. A stateful
+ * rules engine session exposes a stateful rule execution API to an underlying
+ * rules engine. The session allows arbitrary objects to be added and removed to
+ * and from the rule session state. Additionally, objects currently part of the
+ * rule session state may be updated. <p/> There are inherently side-effects to
+ * adding objects to the rule session state. The execution of a RuleExecutionSet
+ * can add, remove and update objects in the rule session state. The objects in
+ * the rule session state are therefore dependent on the rules within the
+ * <code>RuleExecutionSet</code> as well as the rule engine vendor's specific
+ * rule engine behavior. <p/> <code>Handle</code> instances are used by the
+ * rule engine vendor to track <code>Object</code>s added to the rule session
+ * state. This allows multiple instances of equivalent <code>Object</code>s
+ * to be added to the session state and identified, even after serialization.
+ *
+ * @see StatefulRuleSession
+ *
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ */
+public class StatefulRuleSessionImpl extends AbstractRuleSessionImpl
+ implements
+ StatefulRuleSession {
+ // ----------------------------------------------------------------------
+ // Constructors
+ // ----------------------------------------------------------------------
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 510l;
+
+ private StatefulSession session;
+
+ /**
+ * Gets the <code>RuleExecutionSet</code> for this URI and associates it
+ * with a RuleBase.
+ *
+ * @param bindUri
+ * the URI the <code>RuleExecutionSet</code> has been bound to
+ * @param properties
+ * additional properties used to create the
+ * <code>RuleSession</code> implementation.
+ *
+ * @throws RuleExecutionSetNotFoundException
+ * if there is no rule set under the given URI
+ * @throws RuleSessionCreateException
+ */
+ StatefulRuleSessionImpl(final String bindUri,
+ final Map properties,
+ final RuleExecutionSetRepository repository)
+ throws RuleExecutionSetNotFoundException, RuleSessionCreateException {
+
+ super( repository );
+ setProperties( properties );
+
+ RuleExecutionSetImpl ruleSet = null;
+
+ try {
+ ruleSet = (RuleExecutionSetImpl)
+ repository.getRuleExecutionSet(bindUri, properties);
+ } catch (RuleExecutionSetRepositoryException e) {
+ String s = "Error while retrieving rule execution set bound to: " + bindUri;
+ throw new RuleSessionCreateException(s, e);
+ }
+
+ if ( ruleSet == null ) {
+ throw new RuleExecutionSetNotFoundException( "no execution set bound to: " + bindUri );
+ }
+
+ this.setRuleExecutionSet( ruleSet );
+
+ SessionConfiguration conf = new SessionConfiguration();
+ conf.setKeepReference( true );
+ initSession( conf );
+ }
+
+ /**
+ * Initialize this <code>RuleSession</code>
+ * with a new <code>WorkingMemory</code>.
+ */
+ protected void initSession(SessionConfiguration conf) {
+ this.session = this.getRuleExecutionSet().newStatefulSession( conf );
+
+ final Map props = this.getProperties();
+ if ( props != null ) {
+ for ( final Iterator iterator = props.entrySet().iterator(); iterator.hasNext(); ) {
+ final Map.Entry entry = (Map.Entry) iterator.next();
+ this.session.setGlobal( (String) entry.getKey(),
+ entry.getValue() );
+ }
+ }
+ }
+
+ // ----------------------------------------------------------------------
+ // Instance methods
+ // ----------------------------------------------------------------------
+
+ /**
+ * Returns <code>true</code> if the given object is contained within
+ * rulesession state of this rule session.
+ *
+ * @param objectHandle
+ * the handle to the target object.
+ *
+ * @return <code>true</code> if the given object is contained within the
+ * rule session state of this rule session.
+ */
+ public boolean containsObject(final Handle objectHandle) {
+ if ( objectHandle instanceof FactHandle ) {
+ return this.session.getObject( (FactHandle) objectHandle ) != null;
+ }
+
+ return false;
+ }
+
+ /**
+ * Adds a given object to the rule session state of this rule session. The
+ * argument to this method is Object because in the non-managed env. not all
+ * objects should have to implement Serializable. If the
+ * <code>RuleSession</code> is <code>Serializable</code> and it contains
+ * non-serializable fields a runtime exception will be thrown.
+ *
+ * @param object
+ * the object to be added.
+ *
+ * @return the Handle for the newly added Object
+ *
+ * @throws InvalidRuleSessionException
+ * on illegal rule session state.
+ */
+ public Handle addObject(final Object object) throws InvalidRuleSessionException {
+ checkRuleSessionValidity();
+ return (Handle) this.session.insert( object );
+ }
+
+ /**
+ * Adds a <code>List</code> of <code>Object</code>s to the rule session
+ * state of this rule session.
+ *
+ * @param objList
+ * the objects to be added.
+ *
+ * @return a <code>List</code> of <code>Handle</code>s, one for each
+ * added <code>Object</code>. The <code>List</code> must be
+ * ordered in the same order as the input <code>objList</code>.
+ *
+ * @throws InvalidRuleSessionException
+ * on illegal rule session state.
+ */
+ public List addObjects(final List objList) throws InvalidRuleSessionException {
+ checkRuleSessionValidity();
+
+ final List handles = new ArrayList();
+
+ for ( final Iterator objectIter = objList.iterator(); objectIter.hasNext(); ) {
+ handles.add( addObject( objectIter.next() ) );
+ }
+ return handles;
+ }
+
+ /**
+ * Notifies the rules engine that a given object in the rule session state
+ * has changed. <p/> The semantics of this call are equivalent to calling
+ * <code>removeObject</code> followed by <code>addObject</code>. The
+ * original <code>Handle</code> is rebound to the new value for the
+ * <code>Object</code> however.
+ *
+ * @param objectHandle
+ * the handle to the original object.
+ * @param newObject
+ * the new object to bind to the handle.
+ *
+ * @throws InvalidRuleSessionException
+ * on illegal rule session state.
+ * @throws InvalidHandleException
+ * if the input <code>Handle</code> is no longer valid
+ */
+ public void updateObject(final Handle objectHandle,
+ final Object newObject) throws InvalidRuleSessionException,
+ InvalidHandleException {
+ checkRuleSessionValidity();
+
+ if ( objectHandle instanceof FactHandle ) {
+ this.session.update( (FactHandle) objectHandle,
+ newObject );
+ } else {
+ throw new InvalidHandleException( "invalid handle" );
+
+ }
+ }
+
+ /**
+ * Removes a given object from the rule session state of this rule session.
+ *
+ * @param handleObject
+ * the handle to the object to be removed from the rule session
+ * state.
+ *
+ * @throws InvalidRuleSessionException
+ * on illegal rule session state.
+ * @throws InvalidHandleException
+ * if the input <code>Handle</code> is no longer valid
+ */
+ public void removeObject(final Handle handleObject) throws InvalidRuleSessionException,
+ InvalidHandleException {
+ checkRuleSessionValidity();
+
+ if ( handleObject instanceof FactHandle ) {
+ this.session.retract( (FactHandle) handleObject );
+ } else {
+ throw new InvalidHandleException( "invalid handle" );
+ }
+ }
+
+ /**
+ * Executes the rules in the bound rule execution set using the objects
+ * present in the rule session state. This will typically modify the rule
+ * session state - and may add, remove or update <code>Object</code>s
+ * bound to <code>Handle</code>s.
+ *
+ * @throws InvalidRuleSessionException
+ * on illegal rule session state.
+ */
+ public void executeRules() throws InvalidRuleSessionException {
+ checkRuleSessionValidity();
+ this.session.fireAllRules();
+ }
+
+ /**
+ * @see StatefulRuleSessionImpl
+ */
+ public Object getObject(final Handle handle) throws InvalidRuleSessionException,
+ InvalidHandleException {
+ checkRuleSessionValidity();
+
+ if ( handle instanceof FactHandle ) {
+ return this.session.getObject( (FactHandle) handle );
+ } else {
+ throw new InvalidHandleException( "invalid handle" );
+ }
+ }
+
+ /**
+ * Returns a <code>List</code> of the <code>Handle</code>s being used
+ * for object identity.
+ *
+ * @return a <code>List</code> of <code>Handle</code>s present in the
+ * currect state of the rule session.
+ */
+ public List getHandles() {
+ return IteratorToList.convert( this.session.iterateFactHandles() );
+ }
+
+ /**
+ * Returns a List of all objects in the rule session state of this rule
+ * session. The objects should pass the default filter test of the default
+ * <code>RuleExecutionSet</code> filter (if present). <p/> This may not
+ * neccessarily include all objects added by calls to <code>addObject</code>,
+ * and may include <code>Object</code>s created by side-effects. The
+ * execution of a <code>RuleExecutionSet</code> can add, remove and update
+ * objects as part of the rule session state. Therefore the rule session
+ * state is dependent on the rules that are part of the executed
+ * <code>RuleExecutionSet</code> as well as the rule vendor's specific
+ * rule engine behavior.
+ *
+ * @return a <code>List</code> of all objects part of the rule session
+ * state.
+ *
+ * @throws InvalidRuleSessionException
+ * on illegal rule session state.
+ */
+ public List getObjects() throws InvalidRuleSessionException {
+ checkRuleSessionValidity();
+ return getObjects( getRuleExecutionSet().getObjectFilter() );
+ }
+
+ /**
+ * Returns a <code>List</code> over the objects in rule session state of
+ * this rule session. The objects should pass the filter test on the
+ * specified <code>ObjectFilter</code>. <p/> This may not neccessarily
+ * include all objects added by calls to <code>addObject</code>, and may
+ * include <code>Object</code>s created by side-effects. The execution of
+ * a <code>RuleExecutionSet</code> can add, remove and update objects as
+ * part of the rule session state. Therefore the rule session state is
+ * dependent on the rules that are part of the executed
+ * <code>RuleExecutionSet</code> as well as the rule vendor's specific
+ * rule engine behavior.
+ *
+ * @param filter
+ * the object filter.
+ *
+ * @return a <code>List</code> of all the objects in the rule session
+ * state of this rule session based upon the given object filter.
+ *
+ * @throws InvalidRuleSessionException
+ * on illegal rule session state.
+ */
+ public List getObjects(final ObjectFilter filter) throws InvalidRuleSessionException {
+ checkRuleSessionValidity();
+
+ return IteratorToList.convert( this.session.iterateObjects( new ObjectFilterAdapter( filter ) ) );
+ }
+
+ /**
+ * Resets this rule session. Calling this method will bring the rule session
+ * state to its initial state for this rule session and will reset any other
+ * state associated with this rule session.
+ * <p/>
+ * A reset will not reset the state on the default object filter for a
+ * <code>RuleExecutionSet</code>.
+ */
+ public void reset() {
+ // stateful rule sessions should not be high load, thus safe to keep references
+ initSession( new SessionConfiguration() );
+ }
+
+ public int getType() throws InvalidRuleSessionException {
+ return RuleRuntime.STATEFUL_SESSION_TYPE;
+ }
+
+ /**
+ * Releases all resources used by this rule session.
+ * This method renders this rule session unusable until
+ * it is reacquired through the <code>RuleRuntime</code>.
+ */
+ public void release() {
+ if ( this.session != null ) {
+ this.session.dispose();
+ }
+ this.session = null;
+ super.release();
+ }
+
+ /**
+ * Ensures this <code>RuleSession</code> is not
+ * in an illegal rule session state.
+ *
+ * @throws InvalidRuleSessionException on illegal rule session state.
+ */
+ protected void checkRuleSessionValidity() throws InvalidRuleSessionException {
+ if ( this.session == null ) {
+ throw new InvalidRuleSessionException( "invalid rule session" );
+ }
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/StatelessRuleSessionImpl.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/StatelessRuleSessionImpl.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/StatelessRuleSessionImpl.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,181 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.rules.InvalidRuleSessionException;
+import javax.rules.ObjectFilter;
+import javax.rules.RuleExecutionSetNotFoundException;
+import javax.rules.RuleRuntime;
+import javax.rules.RuleSessionCreateException;
+import javax.rules.StatelessRuleSession;
+
+import org.drools.StatelessSession;
+import org.drools.StatelessSessionResult;
+import org.drools.jsr94.rules.admin.RuleExecutionSetImpl;
+import org.drools.jsr94.rules.repository.RuleExecutionSetRepository;
+import org.drools.jsr94.rules.repository.RuleExecutionSetRepositoryException;
+
+/**
+ * The Drools implementation of the <code>StatelessRuleSession</code>
+ * interface which is a representation of a stateless rules engine session. A
+ * stateless rules engine session exposes a stateless rule execution API to an
+ * underlying rules engine.
+ *
+ * @see StatelessRuleSession
+ *
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ */
+public class StatelessRuleSessionImpl extends AbstractRuleSessionImpl
+ implements
+ StatelessRuleSession {
+ /**
+ * Gets the <code>RuleExecutionSet</code> for this URI and associates it
+ * with a RuleBase.
+ *
+ * @param bindUri
+ * the URI the <code>RuleExecutionSet</code> has been bound to
+ * @param properties
+ * additional properties used to create the
+ * <code>RuleSession</code> implementation.
+ *
+ * @throws RuleExecutionSetNotFoundException
+ * if there is no rule set under the given URI
+ * @throws RuleSessionCreateException
+ */
+ StatelessRuleSessionImpl(final String bindUri,
+ final Map properties,
+ final RuleExecutionSetRepository repository)
+ throws RuleExecutionSetNotFoundException, RuleSessionCreateException {
+
+ super( repository );
+ setProperties( properties );
+
+ RuleExecutionSetImpl ruleSet = null;
+
+ try {
+ ruleSet = (RuleExecutionSetImpl)
+ repository.getRuleExecutionSet(bindUri, properties);
+ } catch (RuleExecutionSetRepositoryException e) {
+ String s = "Error while retrieving rule execution set bound to: " + bindUri;
+ throw new RuleSessionCreateException(s, e);
+ }
+
+ if ( ruleSet == null ) {
+ throw new RuleExecutionSetNotFoundException( "RuleExecutionSet unbound: " + bindUri );
+ }
+
+ setRuleExecutionSet( ruleSet );
+ }
+
+ /**
+ * Initialize this <code>RuleSession</code>
+ * with a new <code>WorkingMemory</code>.
+ */
+ protected StatelessSession newStatelessSession() {
+ final StatelessSession session = this.getRuleExecutionSet().newStatelessSession();
+
+ final Map props = this.getProperties();
+ if ( props != null ) {
+ for ( final Iterator iterator = props.entrySet().iterator(); iterator.hasNext(); ) {
+ final Map.Entry entry = (Map.Entry) iterator.next();
+ session.setGlobal( (String) entry.getKey(),
+ entry.getValue() );
+ }
+ }
+ return session;
+ }
+
+ /**
+ * Executes the rules in the bound rule execution set using the supplied
+ * list of objects. A <code>List</code> is returned containing the objects
+ * created by (or passed into the rule session) the executed rules that pass
+ * the filter test of the default <code>RuleExecutionSet</code>
+ * <code>ObjectFilter</code>
+ * (if present). <p/> The returned list may not neccessarily include all
+ * objects passed, and may include <code>Object</code>s created by
+ * side-effects. The execution of a <code>RuleExecutionSet</code> can add,
+ * remove and update objects. Therefore the returned object list is
+ * dependent on the rules that are part of the executed
+ * <code>RuleExecutionSet</code> as well as Drools specific rule engine
+ * behavior.
+ *
+ * @param objects
+ * the objects used to execute rules.
+ *
+ * @return a <code>List</code> containing the objects as a result of
+ * executing the rules.
+ *
+ * @throws InvalidRuleSessionException
+ * on illegal rule session state.
+ */
+ public List executeRules(final List objects) throws InvalidRuleSessionException {
+ return executeRules( objects,
+ this.getRuleExecutionSet().getObjectFilter() );
+ }
+
+ /**
+ * Executes the rules in the bound rule execution set using the supplied
+ * list of objects. A <code>List</code> is returned containing the objects
+ * created by (or passed into the rule engine) the executed rules and
+ * filtered with the supplied object filter. <p/> The returned list may not
+ * neccessarily include all objects passed, and may include
+ * <code>Object</code>s created by side-effects. The execution of a
+ * <code>RuleExecutionSet</code> can add, remove and update objects.
+ * Therefore the returned object list is dependent on the rules that are
+ * part of the executed <code>RuleExecutionSet</code> as well as Drools
+ * specific rule engine behavior.
+ *
+ * @param objects
+ * the objects used to execute rules.
+ * @param filter
+ * the object filter.
+ *
+ * @return a <code>List</code> containing the objects as a result of
+ * executing rules, after passing through the supplied object
+ * filter.
+ *
+ * @throws InvalidRuleSessionException
+ * on illegal rule session state.
+ */
+ public List executeRules(final List objects,
+ final ObjectFilter filter) throws InvalidRuleSessionException {
+ StatelessSession session = newStatelessSession();
+ StatelessSessionResult results = session.executeWithResults( objects );
+
+ return IteratorToList.convert( results.iterateObjects( new ObjectFilterAdapter( filter ) ) );
+ }
+
+ public int getType() throws InvalidRuleSessionException {
+ return RuleRuntime.STATELESS_SESSION_TYPE;
+ }
+
+ /**
+ * Ensures this <code>RuleSession</code> is not
+ * in an illegal rule session state.
+ *
+ * @throws InvalidRuleSessionException on illegal rule session state.
+ */
+ protected void checkRuleSessionValidity() throws InvalidRuleSessionException {
+ if ( getRuleExecutionSet() == null ) {
+ throw new InvalidRuleSessionException( "invalid rule session" );
+ }
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/LocalRuleExecutionSetProviderImpl.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/LocalRuleExecutionSetProviderImpl.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/LocalRuleExecutionSetProviderImpl.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,240 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules.admin;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.Map;
+
+import javax.rules.admin.LocalRuleExecutionSetProvider;
+import javax.rules.admin.RuleExecutionSet;
+import javax.rules.admin.RuleExecutionSetCreateException;
+
+import org.drools.IntegrationException;
+import org.drools.compiler.DroolsParserException;
+import org.drools.compiler.PackageBuilder;
+import org.drools.compiler.PackageBuilderConfiguration;
+import org.drools.decisiontable.InputType;
+import org.drools.decisiontable.SpreadsheetCompiler;
+import org.drools.jsr94.rules.Constants;
+import org.drools.rule.Package;
+
+/**
+ * The Drools implementation of the <code>LocalRuleExecutionSetProvider</code>
+ * interface which defines <code>RuleExecutionSet</code> creation methods for
+ * defining <code>RuleExecutionSet</code>s from local (non-serializable)
+ * resources.
+ *
+ * @see LocalRuleExecutionSetProvider
+ *
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ * @author <a href="mailto:michael.frandsen at syngenio.de">michael frandsen </a>
+ */
+public class LocalRuleExecutionSetProviderImpl
+ implements
+ LocalRuleExecutionSetProvider {
+ /** Default constructor. */
+ public LocalRuleExecutionSetProviderImpl() {
+ super();
+ }
+
+ /**
+ * Creates a <code>RuleExecutionSet</code> implementation using a supplied
+ * input stream and additional Drools-specific properties. A Drools-specific
+ * rule execution set is read from the supplied InputStream. The method
+ * <code>createRuleExecutionSet</code> taking a Reader instance should be
+ * used if the source is a character stream and encoding conversion should
+ * be performed.
+ *
+ * @param ruleExecutionSetStream
+ * an input stream used to read the rule execution set.
+ * @param properties
+ * additional properties used to create the
+ * <code>RuleExecutionSet</code> implementation. May be
+ * <code>null</code>.
+ *
+ * @throws RuleExecutionSetCreateException
+ * on rule execution set creation error.
+ *
+ * @return The created <code>RuleExecutionSet</code>.
+ */
+ public RuleExecutionSet createRuleExecutionSet(final InputStream ruleExecutionSetStream,
+ final Map properties) throws RuleExecutionSetCreateException {
+ if ( properties != null ) {
+ String source = ( String ) properties.get( Constants.RES_SOURCE );
+ if ( source == null ) {
+ // support legacy name
+ source = ( String ) properties.get( "source" );
+ }
+ if ( source != null && source.equals( Constants.RES_SOURCE_TYPE_DECISION_TABLE ) ) {
+ final SpreadsheetCompiler converter = new SpreadsheetCompiler();
+ final String drl = converter.compile( ruleExecutionSetStream,
+ InputType.XLS );
+ return createRuleExecutionSet( new StringReader( drl ), properties );
+ } else {
+ return createRuleExecutionSet( new InputStreamReader( ruleExecutionSetStream ), properties);
+ }
+ } else
+ return createRuleExecutionSet( new InputStreamReader( ruleExecutionSetStream ), properties);
+ }
+
+
+
+ /**
+ * Creates a <code>RuleExecutionSet</code> implementation using a supplied
+ * character stream Reader and additional Drools-specific properties. A
+ * Drools-specific rule execution set is read from the supplied Reader.
+ *
+ * @param ruleExecutionSetReader
+ * a Reader used to read the rule execution set.
+ * @param properties
+ * additional properties used to create the
+ * <code>RuleExecutionSet</code> implementation. May be
+ * <code>null</code>.
+ *
+ * @throws RuleExecutionSetCreateException
+ * on rule execution set creation error.
+ *
+ * @return The created <code>RuleExecutionSet</code>.
+ */
+ public RuleExecutionSet createRuleExecutionSet(final Reader ruleExecutionSetReader,
+ final Map properties) throws RuleExecutionSetCreateException {
+ try {
+ PackageBuilderConfiguration config= null;
+
+ if ( properties != null ) {
+ config = (PackageBuilderConfiguration) properties.get( Constants.RES_PACKAGEBUILDER_CONFIG );
+ }
+
+ PackageBuilder builder = null;
+ if ( config != null ) {
+ builder = new PackageBuilder(config);
+ } else {
+ builder = new PackageBuilder();
+ }
+
+ Object dsrl = null;
+ String source = null;
+
+ if ( properties != null ) {
+ dsrl = properties.get( Constants.RES_DSL );
+ if ( dsrl == null ) {
+ // check for old legacy name ending
+ dsrl = properties.get( "dsl" );
+ }
+ source = ( String ) properties.get( Constants.RES_SOURCE );
+ if ( source == null ) {
+ // check for old legacy name ending
+ source = ( String ) properties.get( "source" );
+ }
+ }
+
+ if ( source == null ) {
+ source = "drl";
+ }
+
+ if ( dsrl == null ) {
+ if ( source.equals( Constants.RES_SOURCE_TYPE_XML ) || source.equals( "xml" ) ) {
+ builder.addPackageFromXml( ruleExecutionSetReader );
+ } else {
+ builder.addPackageFromDrl( ruleExecutionSetReader );
+ }
+ } else {
+ if ( source.equals( Constants.RES_SOURCE_TYPE_XML ) || source.equals( "xml" ) ) {
+ // xml cannot specify a dsl
+ builder.addPackageFromXml( ruleExecutionSetReader );
+ } else {
+ if ( dsrl instanceof Reader ) {
+ builder.addPackageFromDrl( ruleExecutionSetReader,
+ (Reader) dsrl );
+ } else {
+ builder.addPackageFromDrl( ruleExecutionSetReader,
+ new StringReader( (String) dsrl ) );
+ }
+ }
+ }
+
+ final Package pkg = builder.getPackage();
+ return createRuleExecutionSet( pkg,
+ properties );
+ } catch ( final IOException e ) {
+ throw new RuleExecutionSetCreateException( "cannot create rule execution set",
+ e );
+ } catch ( final DroolsParserException e ) {
+ throw new RuleExecutionSetCreateException( "cannot create rule execution set",
+ e );
+ }
+ }
+
+
+ /**
+ * Creates a <code>RuleExecutionSet</code> implementation from a
+ * Drools-specific AST representation and Drools-specific properties.
+ *
+ * @param ruleExecutionSetAst
+ * the vendor representation of a rule execution set
+ * @param properties
+ * additional properties used to create the
+ * <code>RuleExecutionSet</code> implementation. May be
+ * <code>null</code>.
+ *
+ * @throws RuleExecutionSetCreateException
+ * on rule execution set creation error.
+ *
+ * @return The created <code>RuleExecutionSet</code>.
+ */
+ public RuleExecutionSet createRuleExecutionSet(final Object ruleExecutionSetAst,
+ final Map properties) throws RuleExecutionSetCreateException {
+ if ( ruleExecutionSetAst instanceof Package ) {
+ final Package pkg = (Package) ruleExecutionSetAst;
+ return this.createRuleExecutionSet( pkg,
+ properties );
+ }
+ throw new RuleExecutionSetCreateException( " Incoming AST object must be an org.drools.rule.Package. Was " + ruleExecutionSetAst.getClass() );
+ }
+
+ /**
+ * Creates a <code>RuleExecutionSet</code> implementation from a
+ * <code>RuleSet</code> and Drools-specific properties.
+ *
+ * @param pkg
+ * a Drools <code>org.drools.rule.Package</code> representation
+ * of a rule execution set.
+ * @param properties
+ * additional properties used to create the RuleExecutionSet
+ * implementation. May be <code>null</code>.
+ *
+ * @throws RuleExecutionSetCreateException
+ * on rule execution set creation error.
+ *
+ * @return The created <code>RuleExecutionSet</code>.
+ */
+ private RuleExecutionSet createRuleExecutionSet(final Package pkg,
+ final Map properties) throws RuleExecutionSetCreateException {
+ try {
+ return new RuleExecutionSetImpl( pkg,
+ properties );
+ } catch ( final IntegrationException e ) {
+ throw new RuleExecutionSetCreateException( "Failed to create RuleExecutionSet",
+ e );
+ }
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/RuleAdministratorImpl.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/RuleAdministratorImpl.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/RuleAdministratorImpl.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,146 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules.admin;
+
+import java.util.Map;
+
+import javax.rules.admin.LocalRuleExecutionSetProvider;
+import javax.rules.admin.RuleAdministrator;
+import javax.rules.admin.RuleExecutionSet;
+import javax.rules.admin.RuleExecutionSetDeregistrationException;
+import javax.rules.admin.RuleExecutionSetProvider;
+import javax.rules.admin.RuleExecutionSetRegisterException;
+
+import org.drools.jsr94.rules.repository.RuleExecutionSetRepository;
+import org.drools.jsr94.rules.repository.RuleExecutionSetRepositoryException;
+
+/**
+ * The Drools implementation of the <code>RuleAdministrator</code> interface
+ * which is used by rule execution set administrators to load rule execution
+ * sets from external sources and create a <code>RuleExecutionSet</code>
+ * runtime object. <p/> The <code>RuleAdministrator</code> should be accessed
+ * by calling: <p/> <code>
+ * RuleServiceProvider ruleServiceProvider =
+ * RuleServiceProvider.newInstance();<br/>
+ * RuleAdministrator ruleAdministration =
+ * ruleServiceProvider.getRuleAdministrator();
+ * </code>
+ * <p/> In an additional step the administrator may also choose to bind the
+ * <code>RuleExecutionSet</code> instance to a URI so that it is globally
+ * accessible and <code>RuleSession</code>s can be created for the
+ * <code>RuleExecutionSet</code> through the RuleRuntime.
+ *
+ * @see RuleAdministrator
+ *
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ */
+public class RuleAdministratorImpl
+ implements
+ RuleAdministrator, java.io.Serializable {
+ private RuleExecutionSetRepository repository;
+
+ /** Default constructor. */
+ public RuleAdministratorImpl(final RuleExecutionSetRepository repository) {
+ super();
+ this.repository = repository;
+ }
+
+ /**
+ * Returns a <code>RuleExecutionSetProvider</code> implementation.
+ *
+ * @param properties
+ * additional properties
+ *
+ * @return The created <code>RuleExecutionSetProvider</code>.
+ */
+ public RuleExecutionSetProvider getRuleExecutionSetProvider(final Map properties) {
+ return new RuleExecutionSetProviderImpl();
+ }
+
+ /**
+ * Returns a <code>LocalRuleExecutionSetProvider</code> implementation.
+ *
+ * Returns a <code>LocalRuleExecutionSetProvider</code> implementation or
+ * null if this implementation does not support creating a
+ * <code>RuleExecutionSet</code> from non-serializable resources.
+ *
+ * @param properties
+ * additional properties
+ *
+ * @return The created <code>LocalRuleExecutionSetProvider</code>.
+ */
+ public LocalRuleExecutionSetProvider getLocalRuleExecutionSetProvider(final Map properties) {
+ return new LocalRuleExecutionSetProviderImpl();
+ }
+
+ /**
+ * Registers a <code>RuleExecutionSet</code> and associates it with a
+ * given URI. Once a <code>RuleExecutionSet</code> has been registered it
+ * is accessible to runtime clients through the <code>RuleRuntime</code>.
+ * If a <code>RuleExecutionSet</code> has already been associated with the
+ * URI it should be deregistered (as if
+ * <code>deregisterRuleExecutionSet/</code> had been called) and the URI
+ * should be associated with the new <code>RuleExecutionSet</code>.
+ *
+ * @param bindUri
+ * the URI to associate with the <code>RuleExecutionSet</code>.
+ * @param set
+ * the <code>RuleExecutionSet</code> to associate with the URI
+ * @param properties
+ * additional properties used to perform the registration
+ *
+ * @throws RuleExecutionSetRegisterException
+ * if an error occurred that prevented registration
+ */
+ public void registerRuleExecutionSet(final String bindUri,
+ final RuleExecutionSet set,
+ final Map properties)
+ throws RuleExecutionSetRegisterException {
+
+ // Note: an existing RuleExecutionSet is simply replaced
+ repository.registerRuleExecutionSet(bindUri, set, properties);
+ }
+
+ /**
+ * Unregisters a previously registered <code>RuleExecutionSet</code> from
+ * a URI.
+ *
+ * @param bindUri
+ * the URI to disassociate with the <code>RuleExecutionSet</code>.
+ * @param properties
+ * additional properties used to perform the deregistration
+ *
+ * @throws RuleExecutionSetDeregistrationException
+ * if an error occurred that prevented unregistration
+ */
+ public void deregisterRuleExecutionSet(final String bindUri,
+ final Map properties)
+ throws RuleExecutionSetDeregistrationException {
+
+ try {
+ if ( this.repository.getRuleExecutionSet(bindUri, properties) == null ) {
+ throw new RuleExecutionSetDeregistrationException( "no execution set bound to: " + bindUri );
+ }
+ } catch (RuleExecutionSetRepositoryException e) {
+ String s = "Error while retrieving rule execution set bound to: " + bindUri;
+ throw new RuleExecutionSetDeregistrationException(s, e);
+ }
+
+ repository.unregisterRuleExecutionSet(bindUri, properties);
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/RuleExecutionSetImpl.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/RuleExecutionSetImpl.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/RuleExecutionSetImpl.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,272 @@
+/**
+ * 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.
+ */
+
+package org.drools.jsr94.rules.admin;
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.rules.ObjectFilter;
+import javax.rules.admin.RuleExecutionSet;
+
+import org.drools.IntegrationException;
+import org.drools.RuleBase;
+import org.drools.RuleBaseConfiguration;
+import org.drools.RuleIntegrationException;
+import org.drools.SessionConfiguration;
+import org.drools.StatefulSession;
+import org.drools.StatelessSession;
+import org.drools.jsr94.rules.Constants;
+import org.drools.jsr94.rules.Jsr94FactHandleFactory;
+import org.drools.rule.Package;
+import org.drools.rule.Rule;
+
+/**
+ * The Drools implementation of the <code>RuleExecutionSet</code> interface
+ * which defines a named set of executable <code>Rule</code> instances. A
+ * <code>RuleExecutionSet</code> can be executed by a rules engine via the
+ * <code>RuleSession</code> interface.
+ *
+ * @see RuleExecutionSet
+ *
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ * @author <a href="mailto:michael.frandsen at syngenio.de">michael frandsen </a>
+ */
+public class RuleExecutionSetImpl
+ implements
+ RuleExecutionSet {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 510l;
+
+ /**
+ * A description of this rule execution set or null if no
+ * description is specified.
+ */
+ private String description;
+
+ /**
+ * The default ObjectFilter class name
+ * associated with this rule execution set.
+ */
+ private String defaultObjectFilterClassName;
+
+ /** A <code>Map</code> of user-defined and Drools-defined properties. */
+ private Map properties;
+
+ /**
+ * The <code>RuleBase</code> associated with this
+ * <code>RuleExecutionSet</code>.
+ */
+ private RuleBase ruleBase;
+
+ /**
+ * The <code>Package</code> associated with this
+ * <code>RuleExecutionSet</code>.
+ */
+ private Package pkg;
+
+ /**
+ * The default ObjectFilter class name
+ * associated with this rule execution set.
+ */
+ private ObjectFilter objectFilter;
+
+ /**
+ * Instances of this class should be obtained from the
+ * <code>LocalRuleExecutionSetProviderImpl</code>. Each
+ * <code>RuleExecutionSetImpl</code> corresponds with an
+ * <code>org.drools.Package</code> object.
+ *
+ * @param package The <code>Package</code> to associate with this
+ * <code>RuleExecutionSet</code>.
+ * @param properties A <code>Map</code> of user-defined and
+ * Drools-defined properties. May be <code>null</code>.
+ *
+ * @throws RuleIntegrationException if an error occurs integrating
+ * a <code>Rule</code> or <code>Package</code>
+ * into the <code>RuleBase</code>
+ * @throws RuleSetIntegrationException if an error occurs integrating
+ * a <code>Rule</code> or <code>Package</code>
+ * into the <code>RuleBase</code>
+ */
+ RuleExecutionSetImpl(final Package pkg,
+ final Map properties) throws IntegrationException {
+ if ( null == properties ) {
+ this.properties = new HashMap();
+ } else {
+ this.properties = properties;
+ }
+ this.pkg = pkg;
+ this.description = pkg.getName();//..getDocumentation( );
+
+ RuleBaseConfiguration config = ( RuleBaseConfiguration ) this.properties.get( Constants.RES_RULEBASE_CONFIG );
+ org.drools.reteoo.ReteooRuleBase ruleBase;
+ if ( config != null ) {
+ ruleBase = new org.drools.reteoo.ReteooRuleBase( null,
+ config,
+ new Jsr94FactHandleFactory() );
+ } else {
+ ruleBase = new org.drools.reteoo.ReteooRuleBase( null,
+ new Jsr94FactHandleFactory() );
+ }
+ ruleBase.addPackage( pkg );
+
+ this.ruleBase = ruleBase;
+ }
+
+ /**
+ * Get an instance of the default filter, or null.
+ *
+ * @return An instance of the default filter, or null.
+ */
+ public synchronized ObjectFilter getObjectFilter() {
+ if ( this.objectFilter != null ) {
+ return this.objectFilter;
+ }
+
+ if ( this.defaultObjectFilterClassName != null ) {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+
+ if ( cl == null ) {
+ cl = RuleExecutionSetImpl.class.getClassLoader();
+ }
+
+ try {
+ final Class filterClass = cl.loadClass( this.defaultObjectFilterClassName );
+ this.objectFilter = (ObjectFilter) filterClass.newInstance();
+ } catch ( final ClassNotFoundException e ) {
+ throw new RuntimeException( e.toString() );
+ } catch ( final InstantiationException e ) {
+ throw new RuntimeException( e.toString() );
+ } catch ( final IllegalAccessException e ) {
+ throw new RuntimeException( e.toString() );
+ }
+ }
+
+ return this.objectFilter;
+ }
+
+ /**
+ * Returns a new WorkingMemory object.
+ *
+ * @return A new WorkingMemory object.
+ */
+ public StatefulSession newStatefulSession(SessionConfiguration conf) {
+ return this.ruleBase.newStatefulSession(conf, null);
+ }
+
+ /**
+ * Returns a new WorkingMemory object.
+ *
+ * @return A new WorkingMemory object.
+ */
+ public StatelessSession newStatelessSession() {
+ return this.ruleBase.newStatelessSession();
+ }
+
+ // JSR94 interface methods start here -------------------------------------
+
+ /**
+ * Get the name of this rule execution set.
+ *
+ * @return The name of this rule execution set.
+ */
+ public String getName() {
+ return this.pkg.getName();
+ }
+
+ /**
+ * Get a description of this rule execution set.
+ *
+ * @return A description of this rule execution set or null of no
+ * description is specified.
+ */
+ public String getDescription() {
+ return this.description;
+ }
+
+ /**
+ * Get a user-defined or Drools-defined property.
+ *
+ * @param key the key to use to retrieve the property
+ *
+ * @return the value bound to the key or null
+ */
+ public Object getProperty(final Object key) {
+ return this.properties.get( key );
+ }
+
+ /**
+ * Set a user-defined or Drools-defined property.
+ *
+ * @param key the key for the property value
+ * @param value the value to associate with the key
+ */
+ public void setProperty(final Object key,
+ final Object value) {
+ this.properties.put( key,
+ value );
+ }
+
+ /**
+ * Set the default <code>ObjectFilter</code> class. This class is
+ * instantiated at runtime and used to filter result objects unless
+ * another filter is specified using the available APIs in the runtime
+ * view of a rule engine.
+ * <p/>
+ * Setting the class name to null removes the default
+ * <code>ObjectFilter</code>.
+ *
+ * @param objectFilterClassname the default <code>ObjectFilter</code> class
+ */
+ public void setDefaultObjectFilter(final String objectFilterClassname) {
+ this.defaultObjectFilterClassName = objectFilterClassname;
+ }
+
+ /**
+ * Returns the default ObjectFilter class name
+ * associated with this rule execution set.
+ *
+ * @return the default ObjectFilter class name
+ */
+ public String getDefaultObjectFilter() {
+ return this.defaultObjectFilterClassName;
+ }
+
+ /**
+ * Return a list of all <code>Rule</code>s that are part of the
+ * <code>RuleExecutionSet</code>.
+ *
+ * @return a list of all <code>Rule</code>s that are part of the
+ * <code>RuleExecutionSet</code>.
+ */
+ public List getRules() {
+ final List jsr94Rules = new ArrayList();
+
+ final Rule[] rules = (this.pkg.getRules());
+ for ( int i = 0; i < rules.length; ++i ) {
+ jsr94Rules.add( new RuleImpl( rules[i] ) );
+ }
+
+ return jsr94Rules;
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/RuleExecutionSetProviderImpl.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/RuleExecutionSetProviderImpl.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/RuleExecutionSetProviderImpl.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,172 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules.admin;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.Serializable;
+import java.net.URL;
+import java.util.Map;
+
+import javax.rules.admin.RuleExecutionSet;
+import javax.rules.admin.RuleExecutionSetCreateException;
+import javax.rules.admin.RuleExecutionSetProvider;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXResult;
+
+import org.drools.compiler.PackageBuilder;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.rule.Package;
+import org.drools.xml.SemanticModules;
+import org.drools.compiler.xml.XmlPackageReader;
+import org.w3c.dom.Element;
+
+/**
+ * The Drools implementation of the <code>RuleExecutionSetProvider</code>
+ * interface which defines <code>RuleExecutionSet</code> creation methods for
+ * defining <code>RuleExecutionSet</code>s from potentially serializable
+ * resources.
+ *
+ * @see RuleExecutionSetProvider
+ *
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ * @author <a href="mailto:michael.frandsen at syngenio.de">michael frandsen </a>
+ */
+public class RuleExecutionSetProviderImpl
+ implements
+ RuleExecutionSetProvider {
+ /**
+ * Creates a <code>RuleExecutionSet</code> implementation from an XML
+ * Document and additional Drools-specific properties. A Drools-specific
+ * rule execution set is read from the supplied XML Document.
+ *
+ * @param ruleExecutionSetElement the XML element that is the source of the
+ * rule execution set
+ * @param properties additional properties used to create the
+ * <code>RuleExecutionSet</code> implementation.
+ * May be <code>null</code>.
+ *
+ * @throws RuleExecutionSetCreateException on rule execution set creation
+ * error.
+ *
+ * @return The created <code>RuleExecutionSet</code>.
+ */
+ public RuleExecutionSet createRuleExecutionSet(final Element ruleExecutionSetElement,
+ final Map properties) throws RuleExecutionSetCreateException {
+ try {
+ // Prepare the DOM source
+ final Source source = new DOMSource( ruleExecutionSetElement );
+
+ final XmlPackageReader xmlPackageReader = new XmlPackageReader( new SemanticModules() );
+ // Prepare the result
+ final SAXResult result = new SAXResult( xmlPackageReader.getParser() );
+
+ // Create a transformer
+ final Transformer xformer = TransformerFactory.newInstance().newTransformer();
+
+ // Traverse the DOM tree
+ xformer.transform( source,
+ result );
+
+ final PackageDescr packageDescr = xmlPackageReader.getPackageDescr();
+
+ // pre build the package
+ final PackageBuilder builder = new PackageBuilder();
+ builder.addPackage( packageDescr );
+ final Package pkg = builder.getPackage();
+
+ final LocalRuleExecutionSetProviderImpl localRuleExecutionSetProvider = new LocalRuleExecutionSetProviderImpl();
+ return localRuleExecutionSetProvider.createRuleExecutionSet( pkg,
+ properties );
+ } catch ( final TransformerException e ) {
+ throw new RuleExecutionSetCreateException( "could not create RuleExecutionSet: " + e );
+ }
+
+ }
+
+ /**
+ * Creates a <code>RuleExecutionSet</code> implementation from a
+ * Drools-specific Abstract Syntax Tree (AST) representation and
+ * Drools-specific properties.
+ * <p/>
+ * This method accepts a <code>org.drools.RuleBase</code> object as its
+ * vendor-specific AST representation.
+ *
+ * @param ruleExecutionSetAst the Drools representation of a
+ * rule execution set
+ * @param properties additional properties used to create the
+ * <code>RuleExecutionSet</code> implementation.
+ * May be <code>null</code>.
+ *
+ * @throws RuleExecutionSetCreateException on rule execution set creation
+ * error.
+ *
+ * @return The created <code>RuleExecutionSet</code>.
+ */
+ public RuleExecutionSet createRuleExecutionSet(final Serializable ruleExecutionSetAst,
+ final Map properties) throws RuleExecutionSetCreateException {
+ if ( ruleExecutionSetAst instanceof Package ) {
+ final LocalRuleExecutionSetProviderImpl localRuleExecutionSetProvider = new LocalRuleExecutionSetProviderImpl();
+ return localRuleExecutionSetProvider.createRuleExecutionSet( ruleExecutionSetAst,
+ properties );
+ } else {
+ throw new IllegalArgumentException( "Serializable object must be " + "an instance of org.drools.rule.RuleSet. It was " + ruleExecutionSetAst.getClass().getName() );
+ }
+ }
+
+ /**
+ * Creates a <code>RuleExecutionSet</code> implementation from a URI.
+ * The URI is opaque to the specification and may be used to refer to the
+ * file system, a database, or Drools-specific datasource.
+ *
+ * @param ruleExecutionSetUri the URI to load the rule execution set from
+ * @param properties additional properties used to create the
+ * <code>RuleExecutionSet</code> implementation.
+ * May be <code>null</code>.
+ *
+ * @throws RuleExecutionSetCreateException on rule execution set creation
+ * error.
+ * @throws IOException if an I/O error occurs while accessing the URI
+ *
+ * @return The created <code>RuleExecutionSet</code>.
+ */
+ public RuleExecutionSet createRuleExecutionSet(final String ruleExecutionSetUri,
+ final Map properties) throws RuleExecutionSetCreateException,
+ IOException {
+ InputStream in = null;
+ try {
+ final LocalRuleExecutionSetProviderImpl localRuleExecutionSetProvider = new LocalRuleExecutionSetProviderImpl();
+ in = new URL( ruleExecutionSetUri ).openStream();
+ final Reader reader = new InputStreamReader( in );
+ return localRuleExecutionSetProvider.createRuleExecutionSet( reader,
+ properties );
+ } catch ( final IOException ex ) {
+ throw ex;
+ } finally {
+ if ( in != null ) {
+ in.close();
+ }
+ }
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/RuleImpl.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/RuleImpl.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/RuleImpl.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,128 @@
+/**
+ * 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.
+ */
+
+package org.drools.jsr94.rules.admin;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.rules.admin.Rule;
+
+/**
+ * The Drools implementation of the <code>Rule</code> interface which provides
+ * access to simple metadata for a rule. Related <code>Rule</code>
+ * instances are assembled into <code>RuleExecutionSet</code>s, which in
+ * turn, can be executed by a rules engine via the <code>RuleSession</code>
+ * interface.
+ *
+ * @see Rule
+ *
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ * @author <a href="mailto:michael.frandsen at syngenio.de">michael frandsen </a>
+ */
+public class RuleImpl
+ implements
+ Rule {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 510l;
+
+ /** The name of this rule. */
+ private String name;
+
+ /** A description of the rule or null if no description is specified. */
+ private String description;
+
+ /** A <code>Map</code> of user-defined and Drools-defined properties. */
+ private final Map properties = new HashMap();
+
+ /**
+ * The <code>org.drools.rule.Rule</code> that lies at the core of
+ * this <code>javax.rules.admin.Rule</code> object.
+ */
+ private org.drools.rule.Rule rule;
+
+ /**
+ * Creates a <code>RuleImpl</code> object by wrapping an
+ * <code>org.drools.rule.Rule</code> object.
+ *
+ * @param rule the <code>org.drools.rule.Rule</code> object to be wrapped.
+ */
+ RuleImpl(final org.drools.rule.Rule rule) {
+ this.rule = rule;
+ this.name = rule.getName();
+ this.description = rule.getName();// the name of a rule is the only description
+ }
+
+ /**
+ * Returns the <code>org.drools.rule.Rule</code> that lies at the core of
+ * this <code>javax.rules.admin.Rule</code> object. This method is package
+ * private.
+ *
+ * @return <code>org.drools.rule.Rule</code> at the core of this object.
+ */
+ org.drools.rule.Rule getRule() {
+ return this.rule;
+ }
+
+ /* Rule interface methods */
+
+ /**
+ * Get the name of this rule.
+ *
+ * @return The name of this rule.
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Get a description of the rule.
+ *
+ * @return A description of the rule or null of no description is specified.
+ */
+ public String getDescription() {
+ return this.description;
+ }
+
+ /**
+ * Get a user-defined or Drools-defined property.
+ *
+ * @param key the key to use to retrieve the property
+ *
+ * @return the value bound to the key or <code>null</code>
+ */
+ public Object getProperty(final Object key) {
+ // TODO certain keys should reference internal rule accessor methods
+ return this.properties.get( key );
+ }
+
+ /**
+ * Set a user-defined or Drools-defined property.
+ *
+ * @param key the key for the property value
+ * @param value the value to associate with the key
+ */
+ public void setProperty(final Object key,
+ final Object value) {
+ // TODO certain keys should alter internal rule accessor methods
+ this.properties.put( key,
+ value );
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/package.html
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/package.html (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/admin/package.html 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+/*
+ * 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.
+ */
+-->
+</head>
+<body>
+Provides the APIs for rule administration.
+ at see javax.rules.admin
+</body>
+</html>
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/package.html
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/package.html (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/package.html 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+/*
+ * 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.
+ */
+-->
+</head>
+<body>
+Provides the core client APIs for using a rule engine.
+Administration APIs are in the <code>javax.rules.admin</code> package.
+ at see javax.rules
+</body>
+</html>
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/DefaultRuleExecutionSetRepository.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/DefaultRuleExecutionSetRepository.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/DefaultRuleExecutionSetRepository.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,104 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules.repository;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.rules.admin.RuleExecutionSet;
+import javax.rules.admin.RuleExecutionSetDeregistrationException;
+import javax.rules.admin.RuleExecutionSetRegisterException;
+
+/**
+ * Stores the registered <code>RuleExecutionSet</code> objects.
+ *
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ */
+public class DefaultRuleExecutionSetRepository
+ implements
+ RuleExecutionSetRepository
+{
+ private static final long serialVersionUID = 510l;
+
+ /**
+ * Holds the registered <code>RuleExecutionSet</code> objects.
+ */
+ private Map map = new HashMap();
+
+ /**
+ *
+ */
+ public DefaultRuleExecutionSetRepository() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.jsr94.rules.admin.RuleExecutionSetRepository#getRegistrations()
+ */
+ public List getRegistrations()
+ throws RuleExecutionSetRepositoryException {
+ List list = new ArrayList();
+ list.addAll(map.keySet());
+ return list;
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.jsr94.rules.repository.RuleExecutionSetRepository#getRuleExecutionSet(java.lang.String, java.util.Map)
+ */
+ public RuleExecutionSet getRuleExecutionSet(
+ String bindUri,
+ Map properties)
+ throws RuleExecutionSetRepositoryException {
+ return (RuleExecutionSet)map.get(bindUri);
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.jsr94.rules.admin.RuleExecutionSetRepository#registerRuleExecutionSet(java.lang.String, javax.rules.admin.RuleExecutionSet, java.util.Map)
+ */
+ public void registerRuleExecutionSet(
+ String bindUri,
+ RuleExecutionSet ruleSet,
+ Map properties)
+ throws RuleExecutionSetRegisterException {
+
+ if (bindUri == null) {
+ throw new RuleExecutionSetRegisterException("bindUri cannot be null");
+ }
+
+ if (ruleSet == null) {
+ throw new RuleExecutionSetRegisterException("ruleSet cannot be null");
+ }
+
+ map.put(bindUri, ruleSet);
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.jsr94.rules.admin.RuleExecutionSetRepository#unregisterRuleExecutionSet(java.lang.String, java.util.Map)
+ */
+ public void unregisterRuleExecutionSet(
+ String bindUri,
+ Map properties)
+ throws RuleExecutionSetDeregistrationException {
+
+ if (bindUri == null) {
+ throw new RuleExecutionSetDeregistrationException("bindUri cannot be null");
+ }
+
+ map.remove(bindUri);
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/RuleExecutionSetRepository.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/RuleExecutionSetRepository.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/RuleExecutionSetRepository.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,92 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules.repository;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+import javax.rules.admin.RuleExecutionSet;
+import javax.rules.admin.RuleExecutionSetDeregistrationException;
+import javax.rules.admin.RuleExecutionSetRegisterException;
+
+/**
+ * Stores the registered <code>RuleExecutionSet</code> objects.
+ *
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ */
+public interface RuleExecutionSetRepository extends Serializable
+{
+ /**
+ * Retrieves a <code>List</code> of the URIs that currently have
+ * <code>RuleExecutionSet</code>s associated with them.
+ *
+ * An empty list is returned if there are no associations.
+ *
+ * @return a <code>List</code> of the URIs that currently have
+ * <code>RuleExecutionSet</code>s associated with them.
+ * @throws RuleExecutionSetRepositoryException
+ */
+ List getRegistrations() throws RuleExecutionSetRepositoryException;
+
+ /**
+ * Get the <code>RuleExecutionSet</code> bound to this URI, or return
+ * <code>null</code>.
+ *
+ * @param bindUri
+ * the URI associated with the wanted
+ * <code>RuleExecutionSet</code>.
+ * @param properties
+ *
+ * @return the <code>RuleExecutionSet</code> bound to the given URI.
+ * @throws RuleExecutionSetRepositoryException
+ */
+ RuleExecutionSet getRuleExecutionSet(
+ String bindUri,
+ Map properties)
+ throws RuleExecutionSetRepositoryException;
+
+ /**
+ * Register a <code>RuleExecutionSet</code> under the given URI.
+ *
+ * @param bindUri the URI to associate with the <code>RuleExecutionSet</code>.
+ * @param ruleSet the <code>RuleExecutionSet</code> to associate with the URI
+ * @param properties
+ *
+ * @throws RuleExecutionSetRegisterException
+ * if an error occurred that prevented registration (i.e. if
+ * bindUri or ruleSet are <code>null</code>)
+ */
+ void registerRuleExecutionSet(
+ String bindUri,
+ RuleExecutionSet ruleSet,
+ Map properties)
+ throws RuleExecutionSetRegisterException;
+
+ /**
+ * Unregister a <code>RuleExecutionSet</code> from the given URI.
+ *
+ * @param bindUri the URI to disassociate with the <code>RuleExecutionSet</code>.
+ * @param properties
+ * @throws RuleExecutionSetDeregistrationException
+ * if an error occurred that prevented deregistration
+ */
+ void unregisterRuleExecutionSet(
+ String bindUri,
+ Map properties)
+ throws RuleExecutionSetDeregistrationException;
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/RuleExecutionSetRepositoryException.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/RuleExecutionSetRepositoryException.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/RuleExecutionSetRepositoryException.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules.repository;
+
+import javax.rules.RuleExecutionException;
+
+/**
+ * TODO
+ *
+ * @version $Revision$ $Date$
+ * @author <a href="mailto:rlangbehn at users.sourceforge.net">Rainer Langbehn</a>
+ */
+public class RuleExecutionSetRepositoryException extends RuleExecutionException
+{
+ /**
+ * Default serial version UID.
+ */
+ private static final long serialVersionUID = 510l;
+
+ /**
+ * TODO
+ *
+ * @param message
+ */
+ public RuleExecutionSetRepositoryException(String message) {
+ super(message);
+ }
+
+ /**
+ * TODO
+ *
+ * @param message
+ * @param exception
+ */
+ public RuleExecutionSetRepositoryException(
+ String message,
+ Exception exception) {
+ super(message, exception);
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/RuleExecutionSetRepositoryLoader.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/RuleExecutionSetRepositoryLoader.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/RuleExecutionSetRepositoryLoader.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,181 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules.repository;
+
+import java.io.BufferedReader;
+import java.io.Closeable;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Properties;
+
+/**
+ * Load the <code>RuleExecutionSetRepository</code> using the following algorithm.
+ *
+ * 1. If a resource with the name of META-INF/services/org.drools.jsr94.rules.repository.RuleExecutionSetRepository exists,
+ * then its first line, if present, is used as the UTF-8 encoded name of the implementation class.
+ *
+ * 2. If the drools.properties file exists in the classpath and it is readable by the
+ * java.util.Properties.load(InputStream) method and it contains an entry whose key is
+ * org.drools.jsr94.rules.repository.RuleExecutionSetRepository, then the value of that
+ * entry is used as the name of the implementation class.
+ *
+ * 3. If a system property with the name org.drools.jsr94.rules.repository.RuleExecutionSetRepository
+ * is defined, then its value is used as the name of the implementation class.
+ *
+ * 4. Finally, a default implementation class name, if provided, is used.
+ *
+ * @version $Revision$ $Date$
+ * @author <a href="mailto:rlangbehn at users.sourceforge.net">Rainer Langbehn</a>
+ */
+public abstract class RuleExecutionSetRepositoryLoader
+{
+ /**
+ * Loads the <code>RuleExecutionSetRepository</code> using the
+ * algorithm described above.
+ *
+ * @param defaultFactoryName the className of the default
+ * <code>RuleExecutionSetRepository</code> implementation
+ * @return
+ */
+ public static RuleExecutionSetRepository loadRuleExecutionSetRepository(
+ String defaultFactoryName) {
+
+ Object factory = null;
+ String factoryName = null;
+ ClassLoader cL = Thread.currentThread().getContextClassLoader();
+
+ // Use the Services API (as detailed in the JAR specification), if available, to determine the classname.
+ String propertyName = "org.drools.jsr94.rules.repository.RuleExecutionSetRepository";
+ String fileName = "META-INF/services/" + propertyName;
+ InputStream in = cL.getResourceAsStream(fileName);
+
+ if (in != null) {
+ BufferedReader reader = null;
+
+ try {
+ reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
+ factoryName = reader.readLine();
+
+ if (factoryName != null) {
+ factory = createFactory(cL, factoryName);
+ }
+
+ } catch (UnsupportedEncodingException e) {
+ throw new IllegalStateException("Failed to load " + propertyName + ": " + factoryName, e);
+ } catch (IOException e) {
+ throw new IllegalStateException("Failed to load " + propertyName + ": " + factoryName, e);
+ } finally {
+ close(reader);
+ }
+ }
+
+ // Use the properties file "drools.properties"
+ if (factory == null) {
+ // TODO
+ }
+
+ // Use system property
+ if (factory == null) {
+ PrivilegedAction action = new PropertyAccessAction(propertyName);
+ factoryName = (String)AccessController.doPrivileged(action);
+
+ if (factoryName != null) {
+ factory = createFactory(cL, factoryName);
+ }
+ }
+
+ // Use the default factory implementation class.
+ if (factory == null && defaultFactoryName != null) {
+ factory = createFactory(cL, defaultFactoryName);
+ }
+
+ return (RuleExecutionSetRepository)factory;
+ }
+
+ /**
+ * TODO
+ *
+ * @param closeable
+ */
+ private static void close(Closeable closeable) {
+ if (closeable != null) {
+ try {
+ closeable.close();
+ } catch (IOException e) {
+ // ignored
+ }
+ }
+ }
+
+ /**
+ * TODO
+ *
+ * @param cL
+ * @param factoryName
+ * @return
+ */
+ private static Object createFactory(ClassLoader cL, String factoryName) {
+ try {
+ Class factoryClass = cL.loadClass(factoryName);
+ return factoryClass.newInstance();
+ } catch (Throwable t) {
+ throw new IllegalStateException("Failed to load: " + factoryName, t);
+ }
+ }
+
+ private static class PropertyAccessAction implements PrivilegedAction
+ {
+ private String name;
+
+ PropertyAccessAction(String name) {
+ this.name = name;
+ }
+
+ public Object run() {
+ return System.getProperty(name);
+ }
+ }
+
+ private static class PropertyFileAccessAction implements PrivilegedAction
+ {
+ private String fileName;
+
+ PropertyFileAccessAction(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public Object run() {
+ InputStream in = null;
+
+ try {
+ in = new FileInputStream(fileName);
+ Properties props = new Properties();
+ props.load(in);
+ return props;
+ } catch (IOException e) {
+ throw new SecurityException("Cannot load properties: " + fileName, e);
+ } finally {
+ close(in);
+ }
+ }
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/package.html
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/package.html (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/package.html 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+/*
+ * 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.
+ */
+-->
+</head>
+<body>
+Provides the APIs for rule execution set repositories.
+</body>
+</html>
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/decisiontable/Cheese.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/decisiontable/Cheese.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/decisiontable/Cheese.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,45 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.decisiontable;
+
+public class Cheese {
+ private String type;
+ private int price;
+
+ public Cheese() {
+
+ }
+ public Cheese(final String type,
+ final int price) {
+ super();
+ this.type = type;
+ this.price = price;
+ }
+
+ public int getPrice() {
+ return this.price;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public void setPrice(final int price) {
+ this.price = price;
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/decisiontable/Person.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/decisiontable/Person.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/decisiontable/Person.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,93 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.decisiontable;
+
+public class Person {
+ private String name;
+ private String likes;
+ private int age;
+
+ private char sex;
+
+ private boolean alive;
+
+ private String status;
+
+ public Person() {
+
+ }
+ public Person(final String name) {
+ this( name,
+ "",
+ 0 );
+ }
+
+ public Person(final String name,
+ final String likes) {
+ this( name,
+ likes,
+ 0 );
+ }
+
+ public Person(final String name,
+ final String likes,
+ final int age) {
+ this.name = name;
+ this.likes = likes;
+ this.age = age;
+ }
+
+ public String getStatus() {
+ return this.status;
+ }
+
+ public void setStatus(final String status) {
+ this.status = status;
+ }
+
+ public String getLikes() {
+ return this.likes;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public int getAge() {
+ return this.age;
+ }
+
+ public boolean isAlive() {
+ return this.alive;
+ }
+
+ public void setAlive(final boolean alive) {
+ this.alive = alive;
+ }
+
+ public char getSex() {
+ return this.sex;
+ }
+
+ public void setSex(final char sex) {
+ this.sex = sex;
+ }
+
+ public String toString() {
+ return "[Person name='" + this.name + "']";
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/decisiontable/SpreadsheetIntegrationTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/decisiontable/SpreadsheetIntegrationTest.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/decisiontable/SpreadsheetIntegrationTest.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,85 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.decisiontable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.rules.RuleRuntime;
+import javax.rules.RuleServiceProvider;
+import javax.rules.RuleServiceProviderManager;
+import javax.rules.StatefulRuleSession;
+import javax.rules.admin.LocalRuleExecutionSetProvider;
+import javax.rules.admin.RuleAdministrator;
+import javax.rules.admin.RuleExecutionSet;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import org.drools.jsr94.rules.Constants;
+import org.drools.jsr94.rules.ExampleRuleEngineFacade;
+import org.drools.jsr94.rules.RuleServiceProviderImpl;
+
+public class SpreadsheetIntegrationTest {
+
+ @Test
+ public void testExecute() throws Exception {
+ Map properties = new HashMap();
+ properties.put( Constants.RES_SOURCE,
+ Constants.RES_SOURCE_TYPE_DECISION_TABLE );
+
+ RuleServiceProviderManager.registerRuleServiceProvider( ExampleRuleEngineFacade.RULE_SERVICE_PROVIDER,
+ RuleServiceProviderImpl.class );
+
+ RuleServiceProvider ruleServiceProvider = RuleServiceProviderManager.getRuleServiceProvider( ExampleRuleEngineFacade.RULE_SERVICE_PROVIDER );
+ RuleAdministrator ruleAdministrator = ruleServiceProvider.getRuleAdministrator();
+ LocalRuleExecutionSetProvider ruleSetProvider = ruleAdministrator.getLocalRuleExecutionSetProvider( null );
+
+ RuleExecutionSet ruleExecutionSet = ruleSetProvider.createRuleExecutionSet( SpreadsheetIntegrationTest.class.getResourceAsStream( "IntegrationExampleTest.xls" ),
+ properties );
+
+ ruleAdministrator.registerRuleExecutionSet( "IntegrationExampleTest.xls",
+ ruleExecutionSet,
+ properties );
+
+ properties.clear();
+ final List list = new ArrayList();
+ properties.put( "list",
+ list );
+
+ RuleRuntime ruleRuntime = ruleServiceProvider.getRuleRuntime();
+ StatefulRuleSession session = (StatefulRuleSession) ruleRuntime.createRuleSession( "IntegrationExampleTest.xls",
+ properties,
+ RuleRuntime.STATEFUL_SESSION_TYPE );
+
+ //ASSERT AND FIRE
+ session.addObject( new Cheese( "stilton",
+ 42 ) );
+ session.addObject( new Person( "michael",
+ "stilton",
+ 42 ) );
+
+ session.executeRules();
+ assertEquals( 1,
+ list.size() );
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/ExampleRuleEngineFacade.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/ExampleRuleEngineFacade.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/ExampleRuleEngineFacade.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,177 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules;
+
+/*
+ * $Id: ExampleRuleEngineFacade.java,v 1.5 2004/11/17 03:09:50 dbarnett Exp $
+ *
+ * Copyright 2002-2004 (C) The Werken Company. All Rights Reserved.
+ *
+ * Redistribution and use of this software and associated documentation
+ * ("Software"), with or without modification, are permitted provided that the
+ * following conditions are met:
+ *
+ * 1. Redistributions of source code must retain copyright statements and
+ * notices. Redistributions must also contain a copy of this document.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name "drools" must not be used to endorse or promote products derived
+ * from this Software without prior written permission of The Werken Company.
+ * For written permission, please contact bob at werken.com.
+ *
+ * 4. Products derived from this Software may not be called "drools" nor may
+ * "drools" appear in their names without prior written permission of The Werken
+ * Company. "drools" is a registered trademark of The Werken Company.
+ *
+ * 5. Due credit should be given to The Werken Company.
+ * (http://drools.werken.com/).
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import javax.rules.RuleRuntime;
+import javax.rules.RuleServiceProvider;
+import javax.rules.RuleServiceProviderManager;
+import javax.rules.StatefulRuleSession;
+import javax.rules.StatelessRuleSession;
+import javax.rules.admin.LocalRuleExecutionSetProvider;
+import javax.rules.admin.RuleAdministrator;
+import javax.rules.admin.RuleExecutionSet;
+
+/**
+ * Builds up the JSR94 object structure. It'll simplify the task of building a
+ * <code>RuleExecutionSet</code> and associated <code>RuntimeSession</code>
+ * objects from a given <code>InputStream</code>.
+ *
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ */
+public class ExampleRuleEngineFacade {
+ public static final String RULE_SERVICE_PROVIDER = "http://drools.org/";
+
+ private RuleAdministrator ruleAdministrator;
+
+ private RuleServiceProvider ruleServiceProvider;
+
+ private LocalRuleExecutionSetProvider ruleSetProvider;
+
+ private RuleRuntime ruleRuntime;
+
+ // configuration parameters
+ String ruleFilesDirectory;
+
+ String ruleFilesIncludes;
+
+ public ExampleRuleEngineFacade() throws Exception {
+ RuleServiceProviderManager.registerRuleServiceProvider( ExampleRuleEngineFacade.RULE_SERVICE_PROVIDER,
+ RuleServiceProviderImpl.class );
+
+ this.ruleServiceProvider = RuleServiceProviderManager.getRuleServiceProvider( ExampleRuleEngineFacade.RULE_SERVICE_PROVIDER );
+
+ this.ruleAdministrator = this.ruleServiceProvider.getRuleAdministrator();
+
+ this.ruleSetProvider = this.ruleAdministrator.getLocalRuleExecutionSetProvider( null );
+ }
+
+ public void addRuleExecutionSet(final String bindUri,
+ final InputStream resourceAsStream) throws Exception {
+ final Reader ruleReader = new InputStreamReader( resourceAsStream );
+
+ final RuleExecutionSet ruleExecutionSet = this.ruleSetProvider.createRuleExecutionSet( ruleReader,
+ null );
+
+ this.ruleAdministrator.registerRuleExecutionSet( bindUri,
+ ruleExecutionSet,
+ null );
+ }
+
+ public void addRuleExecutionSet(final String bindUri,
+ final InputStream resourceAsStream,
+ final java.util.Map properties) throws Exception {
+ final Reader ruleReader = new InputStreamReader( resourceAsStream );
+
+ final RuleExecutionSet ruleExecutionSet = this.ruleSetProvider.createRuleExecutionSet( ruleReader,
+ properties );
+
+ this.ruleAdministrator.registerRuleExecutionSet( bindUri,
+ ruleExecutionSet,
+ properties );
+ }
+
+ /**
+ * Returns a named <code>StatelessRuleSession</code>.
+ *
+ *
+ * @return StatelessRuleSession
+ * @throws Exception
+ */
+ public StatelessRuleSession getStatelessRuleSession(final String key,
+ final java.util.Map properties) throws Exception {
+ this.ruleRuntime = this.ruleServiceProvider.getRuleRuntime();
+
+ return (StatelessRuleSession) this.ruleRuntime.createRuleSession( key,
+ properties,
+ RuleRuntime.STATELESS_SESSION_TYPE );
+ }
+
+ /**
+ * Returns a named <code>StatelessRuleSession</code>.
+ *
+ * @param key
+ * @return StatelessRuleSession
+ * @throws Exception
+ */
+ public StatelessRuleSession getStatelessRuleSession(final String key) throws Exception {
+ return this.getStatelessRuleSession( key,
+ null );
+ }
+
+ public StatefulRuleSession getStatefulRuleSession(final String key) throws Exception {
+ return this.getStatefulRuleSession( key,
+ null );
+ }
+
+ public StatefulRuleSession getStatefulRuleSession(final String key,
+ final java.util.Map properties) throws Exception {
+ this.ruleRuntime = this.ruleServiceProvider.getRuleRuntime();
+
+ return (StatefulRuleSession) this.ruleRuntime.createRuleSession( key,
+ properties,
+ RuleRuntime.STATEFUL_SESSION_TYPE );
+ }
+
+ public RuleServiceProvider getRuleServiceProvider() {
+ return this.ruleServiceProvider;
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/JSR94TestBase.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/JSR94TestBase.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/JSR94TestBase.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,121 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules;
+
+/*
+ * $Id: JSR94TestBase.java,v 1.7 2004/11/17 03:09:50 dbarnett Exp $
+ *
+ * Copyright 2002-2004 (C) The Werken Company. All Rights Reserved.
+ *
+ * Redistribution and use of this software and associated documentation
+ * ("Software"), with or without modification, are permitted provided that the
+ * following conditions are met:
+ *
+ * 1. Redistributions of source code must retain copyright statements and
+ * notices. Redistributions must also contain a copy of this document.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name "drools" must not be used to endorse or promote products derived
+ * from this Software without prior written permission of The Werken Company.
+ * For written permission, please contact bob at werken.com.
+ *
+ * 4. Products derived from this Software may not be called "drools" nor may
+ * "drools" appear in their names without prior written permission of The Werken
+ * Company. "drools" is a registered trademark of The Werken Company.
+ *
+ * 5. Due credit should be given to The Werken Company.
+ * (http://drools.werken.com/).
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.rules.RuleServiceProvider;
+import javax.rules.StatefulRuleSession;
+import javax.rules.StatelessRuleSession;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Base class for all drools JSR94 test cases.
+ *
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ */
+public abstract class JSR94TestBase {
+ protected StatefulRuleSession statefulSession;
+
+ protected StatelessRuleSession statelessSession;
+
+ protected ExampleRuleEngineFacade engine;
+
+ protected String bindUri = "sisters.drl";
+
+ protected RuleServiceProvider ruleServiceProvider;
+
+ /**
+ * Setup the test case.
+ */
+ @Before
+ public void setUp() throws Exception {
+ this.engine = new ExampleRuleEngineFacade();
+ this.engine.addRuleExecutionSet( this.bindUri,
+ StatelessRuleSessionTest.class.getResourceAsStream( this.bindUri ) );
+
+ this.ruleServiceProvider = this.engine.getRuleServiceProvider();
+ this.statelessSession = this.engine.getStatelessRuleSession( this.bindUri );
+ this.statefulSession = this.engine.getStatefulRuleSession( this.bindUri );
+ }
+
+ /**
+ * Get the requested resource from the ClassLoader.
+ *
+ * @see ClassLoader#getResource
+ */
+ protected URL getResource(final String res) {
+ return getClass().getClassLoader().getResource( res );
+ }
+
+ /**
+ * Get the requested resource from the ClassLoader.
+ *
+ * @see ClassLoader#getResourceAsStream
+ */
+ protected InputStream getResourceAsStream(final String res) {
+ return getClass().getClassLoader().getResourceAsStream( res );
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/MultipleRepositoryTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/MultipleRepositoryTest.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/MultipleRepositoryTest.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,122 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules;
+
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.rules.RuleRuntime;
+import javax.rules.RuleServiceProvider;
+import javax.rules.RuleServiceProviderManager;
+import javax.rules.StatelessRuleSession;
+import javax.rules.admin.RuleAdministrator;
+import javax.rules.admin.RuleExecutionSet;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * A test for independent repository instances for different runtimes.
+ *
+ * @author jgilbert
+ * @author <a href="mailto:michael.frandsen at syngenio.de">michael frandsen </a>
+ */
+public class MultipleRepositoryTest {
+
+ /**
+ * Do the test.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testMultipleInstances() throws Exception {
+ // create 2 different runtimes with different rulesets
+ final RuleRuntime ruleRuntime1 = getServiceProvider( "engine1",
+ "multiple-engine1.drl" ).getRuleRuntime();
+ final RuleRuntime ruleRuntime2 = getServiceProvider( "engine2",
+ "multiple-engine2.drl" ).getRuleRuntime();
+
+ // there should be only 1
+ System.out.println( ruleRuntime1.getRegistrations().size() );
+ assertTrue( ruleRuntime1.getRegistrations().size() == 1 );
+
+ // there should be only 1
+ System.out.println( ruleRuntime2.getRegistrations().size() );
+ assertTrue( ruleRuntime2.getRegistrations().size() == 1 );
+
+ // execute them both for good measure...
+ execute( ruleRuntime1,
+ "Engine1",
+ new Object[]{"value1"} );
+ execute( ruleRuntime2,
+ "Engine2",
+ new Object[]{"value2"} );
+
+ }
+
+ /**
+ * Create a Provider.
+ *
+ * @param url
+ * @param rulesets
+ * @return
+ * @throws Exception
+ */
+ public RuleServiceProvider getServiceProvider(final String url,
+ final String ruleset) throws Exception {
+ // create the provider
+ final Class clazz = this.getClass().getClassLoader().loadClass( "org.drools.jsr94.rules.RuleServiceProviderImpl" );
+ RuleServiceProviderManager.registerRuleServiceProvider( url,
+ clazz );
+ final RuleServiceProvider serviceProvider = RuleServiceProviderManager.getRuleServiceProvider( url );
+ final RuleAdministrator ruleAdministrator = serviceProvider.getRuleAdministrator();
+
+ // register the ruleset
+ final InputStream inStream = this.getClass().getResourceAsStream( ruleset );
+ final RuleExecutionSet res1 = ruleAdministrator.getLocalRuleExecutionSetProvider( null ).createRuleExecutionSet( inStream,
+ null );
+
+ inStream.close();
+ final String uri = res1.getName();
+ System.out.println( uri );
+ ruleAdministrator.registerRuleExecutionSet( uri,
+ res1,
+ null );
+ return serviceProvider;
+ }
+
+ /**
+ * Execute a ruleset for the input.
+ *
+ * @param rt
+ * @param ruleset
+ * @param input
+ * @throws Exception
+ */
+ public void execute(final RuleRuntime rt,
+ final String ruleset,
+ final Object[] input) throws Exception {
+ final StatelessRuleSession srs = (StatelessRuleSession) rt.createRuleSession( ruleset,
+ null,
+ RuleRuntime.STATELESS_SESSION_TYPE );
+ final List output = srs.executeRules( Arrays.asList( input ) );
+ System.out.println( output );
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/Person.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/Person.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/Person.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,118 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules;
+
+/*
+ * $Id: Person.java,v 1.4 2004/11/17 03:09:50 dbarnett Exp $
+ *
+ * Copyright 2002-2004 (C) The Werken Company. All Rights Reserved.
+ *
+ * Redistribution and use of this software and associated documentation
+ * ("Software"), with or without modification, are permitted provided that the
+ * following conditions are met:
+ *
+ * 1. Redistributions of source code must retain copyright statements and
+ * notices. Redistributions must also contain a copy of this document.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name "drools" must not be used to endorse or promote products derived
+ * from this Software without prior written permission of The Werken Company.
+ * For written permission, please contact bob at werken.com.
+ *
+ * 4. Products derived from this Software may not be called "drools" nor may
+ * "drools" appear in their names without prior written permission of The Werken
+ * Company. "drools" is a registered trademark of The Werken Company.
+ *
+ * 5. Due credit should be given to The Werken Company.
+ * (http://drools.werken.com/).
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class Person {
+ private String name;
+
+ private Set sisters;
+
+ public Person() {
+
+ }
+
+ public Person(final String name) {
+ this.name = name;
+ this.sisters = new HashSet();
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void addSister(final String sistersName) {
+ this.sisters.add( sistersName );
+ }
+
+ public boolean hasSister(final Person person) {
+ return this.sisters.contains( person.getName() );
+ }
+
+ public String toString() {
+ return this.name;
+ }
+
+ public int hashCode() {
+ final int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + ((name == null) ? 0 : name.hashCode());
+ result = PRIME * result + ((sisters == null) ? 0 : sisters.hashCode());
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if ( this == obj ) return true;
+ if ( obj == null ) return false;
+
+ if ( !(obj instanceof Person) ) return false;
+ final Person other = (Person) obj;
+
+ if ( name == null ) {
+ if ( other.name != null ) return false;
+ } else if ( !name.equals( other.name ) ) return false;
+ if ( sisters == null ) {
+ if ( other.sisters != null ) return false;
+ } else if ( !sisters.equals( other.sisters ) ) return false;
+ return true;
+ }
+
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/RuleEngineTestBase.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/RuleEngineTestBase.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/RuleEngineTestBase.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,160 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules;
+
+/*
+ * $Id: RuleEngineTestBase.java,v 1.4 2004/11/17 03:09:50 dbarnett Exp $
+ *
+ * Copyright 2002-2004 (C) The Werken Company. All Rights Reserved.
+ *
+ * Redistribution and use of this software and associated documentation
+ * ("Software"), with or without modification, are permitted provided that the
+ * following conditions are met:
+ *
+ * 1. Redistributions of source code must retain copyright statements and
+ * notices. Redistributions must also contain a copy of this document.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name "drools" must not be used to endorse or promote products derived
+ * from this Software without prior written permission of The Werken Company.
+ * For written permission, please contact bob at werken.com.
+ *
+ * 4. Products derived from this Software may not be called "drools" nor may
+ * "drools" appear in their names without prior written permission of The Werken
+ * Company. "drools" is a registered trademark of The Werken Company.
+ *
+ * 5. Due credit should be given to The Werken Company.
+ * (http://drools.werken.com/).
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.rules.RuleServiceProvider;
+import javax.rules.StatefulRuleSession;
+import javax.rules.StatelessRuleSession;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Base class for all drools JSR94 test cases.
+ *
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ * @author <a href="mailto:michael.frandsen at syngenio.de">Michael Frandsen </a>
+ */
+public abstract class RuleEngineTestBase {
+ protected StatefulRuleSession statefulSession;
+
+ protected StatelessRuleSession statelessSession;
+
+ protected ExampleRuleEngineFacade engine;
+
+ protected String bindUri = "sisters.drl";
+ protected String bindUri_drl = "sisters_expander.drl";
+ protected String bindUri_dsl = "sisters_expander.dsl";
+ protected String bindUri_globals = "sisters_globals.drl";
+
+ protected RuleServiceProvider ruleServiceProvider;
+
+ /**
+ * Setup the test case.
+ */
+ @Before
+ public void setUp() throws Exception {
+ this.engine = new ExampleRuleEngineFacade();
+ this.engine.addRuleExecutionSet( this.bindUri,
+ RuleEngineTestBase.class.getResourceAsStream( this.bindUri ) );
+
+ final Map map = new HashMap();
+ final Reader reader = new InputStreamReader( RuleEngineTestBase.class.getResourceAsStream( this.bindUri_dsl ) );
+
+ map.put( "dsl",
+ this.getDSLText( reader ).toString() );
+ this.engine.addRuleExecutionSet( this.bindUri_drl,
+ RuleEngineTestBase.class.getResourceAsStream( this.bindUri_drl ),
+ map );
+
+ this.engine.addRuleExecutionSet( this.bindUri_globals,
+ RuleEngineTestBase.class.getResourceAsStream( this.bindUri_globals ) );
+
+ this.ruleServiceProvider = this.engine.getRuleServiceProvider();
+ // this.statelessSession = engine.getStatelessRuleSession( bindUri );
+ // this.statefulSession = engine.getStatefulRuleSession( bindUri );
+
+ }
+
+ /*
+ * Taken from DRLParser
+ */
+ private StringBuffer getDSLText(final Reader reader) throws IOException {
+ final StringBuffer text = new StringBuffer();
+
+ final char[] buf = new char[1024];
+ int len = 0;
+
+ while ( (len = reader.read( buf )) >= 0 ) {
+ text.append( buf,
+ 0,
+ len );
+ }
+ return text;
+ }
+
+ /**
+ * Get the requested resource from the ClassLoader.
+ *
+ * @see ClassLoader#getResource
+ */
+ protected URL getResource(final String res) {
+ return getClass().getClassLoader().getResource( res );
+ }
+
+ /**
+ * Get the requested resource from the ClassLoader.
+ *
+ * @see ClassLoader#getResourceAsStream
+ */
+ protected InputStream getResourceAsStream(final String res) {
+ return getClass().getClassLoader().getResourceAsStream( res );
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/RuleRuntimeTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/RuleRuntimeTest.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/RuleRuntimeTest.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,236 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules;
+
+/*
+ * $Id: RuleRuntimeTestCase.java,v 1.7 2005/02/04 02:13:38 mproctor Exp $
+ *
+ * Copyright 2002-2004 (C) The Werken Company. All Rights Reserved.
+ *
+ * Redistribution and use of this software and associated documentation
+ * ("Software"), with or without modification, are permitted provided that the
+ * following conditions are met:
+ *
+ * 1. Redistributions of source code must retain copyright statements and
+ * notices. Redistributions must also contain a copy of this document.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name "drools" must not be used to endorse or promote products derived
+ * from this Software without prior written permission of The Werken Company.
+ * For written permission, please contact bob at werken.com.
+ *
+ * 4. Products derived from this Software may not be called "drools" nor may
+ * "drools" appear in their names without prior written permission of The Werken
+ * Company. "drools" is a registered trademark of The Werken Company.
+ *
+ * 5. Due credit should be given to The Werken Company.
+ * (http://drools.werken.com/).
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.rules.RuleExecutionSetNotFoundException;
+import javax.rules.RuleRuntime;
+import javax.rules.RuleServiceProvider;
+import javax.rules.RuleServiceProviderManager;
+import javax.rules.StatefulRuleSession;
+import javax.rules.StatelessRuleSession;
+import javax.rules.admin.LocalRuleExecutionSetProvider;
+import javax.rules.admin.RuleAdministrator;
+import javax.rules.admin.RuleExecutionSet;
+
+import org.drools.RuleBaseConfiguration;
+import org.drools.decisiontable.Cheese;
+import org.drools.decisiontable.Person;
+import org.drools.decisiontable.SpreadsheetIntegrationTest;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Test the RuleRuntime implementation.
+ *
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ */
+public class RuleRuntimeTest extends RuleEngineTestBase {
+ private LocalRuleExecutionSetProvider ruleSetProvider;
+
+ private RuleAdministrator ruleAdministrator;
+
+ private String RULES_RESOURCE;
+
+ /**
+ * Setup the test case.
+ */
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ this.RULES_RESOURCE = this.bindUri;
+ this.ruleAdministrator = this.ruleServiceProvider.getRuleAdministrator();
+ this.ruleSetProvider = this.ruleAdministrator.getLocalRuleExecutionSetProvider( null );
+ }
+
+ /**
+ * Test createRuleSession.
+ */
+ @Test
+ public void testCreateRuleStatelessRuleSession() throws Exception {
+ final RuleRuntime ruleRuntime = this.ruleServiceProvider.getRuleRuntime();
+ assertNotNull( "cannot obtain RuleRuntime",
+ ruleRuntime );
+
+ // expect RuleExecutionSetNotFoundException
+ try {
+ ruleRuntime.createRuleSession( "someUri",
+ null,
+ RuleRuntime.STATELESS_SESSION_TYPE );
+ fail( "RuleExecutionSetNotFoundException expected" );
+ } catch ( final RuleExecutionSetNotFoundException ex ) {
+ // ignore exception
+ }
+
+ // read rules and register with administrator
+ final Reader ruleReader = new InputStreamReader( RuleRuntimeTest.class.getResourceAsStream( this.RULES_RESOURCE ) );
+ final RuleExecutionSet ruleSet = this.ruleSetProvider.createRuleExecutionSet( ruleReader,
+ null );
+ this.ruleAdministrator.registerRuleExecutionSet( this.RULES_RESOURCE,
+ ruleSet,
+ null );
+
+ final StatelessRuleSession statelessRuleSession = (StatelessRuleSession) ruleRuntime.createRuleSession( this.RULES_RESOURCE,
+ null,
+ RuleRuntime.STATELESS_SESSION_TYPE );
+ assertNotNull( "cannot obtain StatelessRuleSession",
+ statelessRuleSession );
+
+ this.ruleAdministrator.deregisterRuleExecutionSet( this.RULES_RESOURCE,
+ null );
+ }
+
+ /**
+ * Test createRuleSession.
+ */
+ @Test
+ public void testCreateRuleStatefulRuleSession() throws Exception {
+ final RuleRuntime ruleRuntime = this.ruleServiceProvider.getRuleRuntime();
+ assertNotNull( "cannot obtain RuleRuntime",
+ ruleRuntime );
+
+ // expect RuleExecutionSetNotFoundException
+ try {
+ ruleRuntime.createRuleSession( "someUri",
+ null,
+ RuleRuntime.STATEFUL_SESSION_TYPE );
+ fail( "RuleExecutionSetNotFoundException expected" );
+ } catch ( final RuleExecutionSetNotFoundException ex ) {
+ // ignore exception
+ }
+
+ // read rules and register with administrator
+ final Reader ruleReader = new InputStreamReader( RuleRuntimeTest.class.getResourceAsStream( this.RULES_RESOURCE ) );
+ final RuleExecutionSet ruleSet = this.ruleSetProvider.createRuleExecutionSet( ruleReader,
+ null );
+ this.ruleAdministrator.registerRuleExecutionSet( this.RULES_RESOURCE,
+ ruleSet,
+ null );
+
+ final StatefulRuleSession statefulRuleSession = (StatefulRuleSession) ruleRuntime.createRuleSession( this.RULES_RESOURCE,
+ null,
+ RuleRuntime.STATEFUL_SESSION_TYPE );
+ assertNotNull( "cannot obtain StatefulRuleSession",
+ statefulRuleSession );
+
+ this.ruleAdministrator.deregisterRuleExecutionSet( this.RULES_RESOURCE,
+ null );
+ }
+
+ /**
+ * Test getRegistrations.
+ */
+ @Test
+ public void testGetRegistrations() throws Exception {
+ final RuleRuntime ruleRuntime = this.ruleServiceProvider.getRuleRuntime();
+ assertNotNull( "cannot obtain RuleRuntime",
+ ruleRuntime );
+
+ // read rules and register with administrator
+ final Reader ruleReader = new InputStreamReader( RuleRuntimeTest.class.getResourceAsStream( this.RULES_RESOURCE ) );
+ final RuleExecutionSet ruleSet = this.ruleSetProvider.createRuleExecutionSet( ruleReader,
+ null );
+ this.ruleAdministrator.registerRuleExecutionSet( this.RULES_RESOURCE,
+ ruleSet,
+ null );
+
+ final List list = ruleRuntime.getRegistrations();
+ assertTrue( "no registrations found",
+ list.size() > 0 );
+
+ this.ruleAdministrator.deregisterRuleExecutionSet( this.RULES_RESOURCE,
+ null );
+ }
+
+ @Test
+ public void testRuleBaseConfigurationConstant() throws Exception {
+ // JBRULES-1061
+
+ Map properties = new HashMap();
+ properties.put( Constants.RES_SOURCE,
+ Constants.RES_SOURCE_TYPE_DECISION_TABLE );
+
+ properties.put( Constants.RES_RULEBASE_CONFIG,
+ new RuleBaseConfiguration() );
+
+ RuleServiceProviderManager.registerRuleServiceProvider( ExampleRuleEngineFacade.RULE_SERVICE_PROVIDER,
+ RuleServiceProviderImpl.class );
+
+ RuleServiceProvider ruleServiceProvider = RuleServiceProviderManager.getRuleServiceProvider( ExampleRuleEngineFacade.RULE_SERVICE_PROVIDER );
+ RuleAdministrator ruleAdministrator = ruleServiceProvider.getRuleAdministrator();
+ LocalRuleExecutionSetProvider ruleSetProvider = ruleAdministrator.getLocalRuleExecutionSetProvider( null );
+
+ try {
+ RuleExecutionSet ruleExecutionSet = ruleSetProvider.createRuleExecutionSet( SpreadsheetIntegrationTest.class.getResourceAsStream( "IntegrationExampleTest.xls" ),
+ properties );
+ } catch (Exception e) {
+ // fail should not throw an Excetpion
+ }
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/RuleServiceProviderTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/RuleServiceProviderTest.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/RuleServiceProviderTest.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,106 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules;
+
+/*
+ * $Id: RuleServiceProviderTestCase.java,v 1.4 2004/11/17 03:09:50 dbarnett Exp $
+ *
+ * Copyright 2002-2004 (C) The Werken Company. All Rights Reserved.
+ *
+ * Redistribution and use of this software and associated documentation
+ * ("Software"), with or without modification, are permitted provided that the
+ * following conditions are met:
+ *
+ * 1. Redistributions of source code must retain copyright statements and
+ * notices. Redistributions must also contain a copy of this document.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name "drools" must not be used to endorse or promote products derived
+ * from this Software without prior written permission of The Werken Company.
+ * For written permission, please contact bob at werken.com.
+ *
+ * 4. Products derived from this Software may not be called "drools" nor may
+ * "drools" appear in their names without prior written permission of The Werken
+ * Company. "drools" is a registered trademark of The Werken Company.
+ *
+ * 5. Due credit should be given to The Werken Company.
+ * (http://drools.werken.com/).
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+import javax.rules.RuleRuntime;
+import javax.rules.RuleServiceProvider;
+import javax.rules.RuleServiceProviderManager;
+import javax.rules.admin.RuleAdministrator;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * Test the RuleServiceProvider implementation.
+ *
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ */
+public class RuleServiceProviderTest {
+ /**
+ * Test getRuleRuntime.
+ */
+ @Test
+ public void testRuleRuntime() throws Exception {
+ Class.forName("org.drools.jsr94.rules.RuleServiceProviderImpl");
+ RuleServiceProvider ruleServiceProvider = RuleServiceProviderManager.getRuleServiceProvider("http://drools.org/");
+
+ final RuleRuntime ruleRuntime = ruleServiceProvider.getRuleRuntime();
+ assertNotNull( "cannot obtain RuleRuntime",
+ ruleRuntime );
+ assertTrue( "not a class instance",
+ ruleRuntime == ruleServiceProvider.getRuleRuntime() );
+ }
+
+ /**
+ * Test getRuleAdministrator.
+ */
+ @Test
+ public void testRuleAdministrator() throws Exception {
+ Class.forName("org.drools.jsr94.rules.RuleServiceProviderImpl");
+ RuleServiceProvider ruleServiceProvider = RuleServiceProviderManager.getRuleServiceProvider("http://drools.org/");
+
+ final RuleAdministrator ruleAdministrator = ruleServiceProvider.getRuleAdministrator();
+ assertNotNull( "cannot obtain RuleAdministrator",
+ ruleAdministrator );
+ assertTrue( "not a class instance",
+ ruleAdministrator == ruleServiceProvider.getRuleAdministrator() );
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/StatefulRuleSessionTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/StatefulRuleSessionTest.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/StatefulRuleSessionTest.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,415 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules;
+
+/*
+ * $Id: StatefulRuleSessionTestCase.java,v 1.7 2005/05/06 19:54:49 dbarnett Exp $
+ *
+ * Copyright 2002-2004 (C) The Werken Company. All Rights Reserved.
+ *
+ * Redistribution and use of this software and associated documentation
+ * ("Software"), with or without modification, are permitted provided that the
+ * following conditions are met:
+ *
+ * 1. Redistributions of source code must retain copyright statements and
+ * notices. Redistributions must also contain a copy of this document.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name "drools" must not be used to endorse or promote products derived
+ * from this Software without prior written permission of The Werken Company.
+ * For written permission, please contact bob at werken.com.
+ *
+ * 4. Products derived from this Software may not be called "drools" nor may
+ * "drools" appear in their names without prior written permission of The Werken
+ * Company. "drools" is a registered trademark of The Werken Company.
+ *
+ * 5. Due credit should be given to The Werken Company.
+ * (http://drools.werken.com/).
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.rules.Handle;
+import javax.rules.ObjectFilter;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Test the <code>StatefulRuleSession</code> implementation.
+ *
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ * @author <a href="mailto:michael.frandsen at syngenio.de">Michael Frandsen </a>
+ * @see javax.rules.StatefulRuleSession
+ */
+public class StatefulRuleSessionTest extends RuleEngineTestBase {
+
+ /**
+ * Test containsObject.
+ */
+ @Test
+ public void testContainsObject() throws Exception {
+ this.statefulSession = this.engine.getStatefulRuleSession( this.bindUri );
+ final Person bob = new Person( "bob" );
+ final Handle handle = this.statefulSession.addObject( bob );
+ assertTrue( "where is bob",
+ this.statefulSession.containsObject( handle ) );
+ }
+
+ /**
+ * Test addObject.
+ */
+ @Test
+ public void testAddObject() throws Exception {
+ // tested in testContainsObject
+ }
+
+ @Test
+ public void testJsr94FactHandleFactoryAvailable() throws ClassNotFoundException {
+ this.getClass().getClassLoader().loadClass( "org.drools.jsr94.rules.Jsr94FactHandleFactory" );
+ }
+
+ /**
+ * Test addObjects.
+ */
+ @Test
+ public void testAddObjects() throws Exception {
+ this.statefulSession = this.engine.getStatefulRuleSession( this.bindUri );
+ final List inObjects = new ArrayList();
+
+ final Person bob = new Person( "bob" );
+ inObjects.add( bob );
+
+ final Person rebecca = new Person( "rebecca" );
+ rebecca.addSister( "jeannie" );
+ inObjects.add( rebecca );
+
+ final Person jeannie = new Person( "jeannie" );
+ jeannie.addSister( "rebecca" );
+ inObjects.add( jeannie );
+
+ final List handleList = this.statefulSession.addObjects( inObjects );
+ assertEquals( "incorrect size",
+ 3,
+ handleList.size() );
+ assertEquals( "where is bob",
+ bob,
+ this.statefulSession.getObject( (Handle) handleList.get( 0 ) ) );
+ assertEquals( "where is rebecca",
+ rebecca,
+ this.statefulSession.getObject( (Handle) handleList.get( 1 ) ) );
+ assertEquals( "where is jeannie",
+ jeannie,
+ this.statefulSession.getObject( (Handle) handleList.get( 2 ) ) );
+ }
+
+ /**
+ * Test getObject.
+ */
+ @Test
+ public void testGetObject() throws Exception {
+ // tested in testAddObjects
+ }
+
+ /**
+ * Test updateObject.
+ */
+ @Test
+ public void testUpdateObject() throws Exception {
+ this.statefulSession = this.engine.getStatefulRuleSession( this.bindUri );
+ Person bob = new Person( "bob" );
+ final Handle handle = this.statefulSession.addObject( bob );
+ this.statefulSession.updateObject( handle,
+ bob = new Person( "boby" ) );
+ assertEquals( "where is boby",
+ bob,
+ this.statefulSession.getObject( handle ) );
+ }
+
+ /**
+ * Test removeObject.
+ */
+ @Test
+ public void testRemoveObject() throws Exception {
+ this.statefulSession = this.engine.getStatefulRuleSession( this.bindUri );
+ final Person bob = new Person( "bob" );
+ final Handle handle = this.statefulSession.addObject( bob );
+ assertTrue( "where is bob",
+ this.statefulSession.containsObject( handle ) );
+
+ this.statefulSession.removeObject( handle );
+ assertTrue( "bob still there",
+ !this.statefulSession.containsObject( handle ) );
+ }
+
+ /**
+ * Test getObjects.
+ */
+ @Test
+ public void testGetObjects() throws Exception {
+ this.statefulSession = this.engine.getStatefulRuleSession( this.bindUri );
+
+ final Person bob = new Person( "bob" );
+ this.statefulSession.addObject( bob );
+
+ final Person rebecca = new Person( "rebecca" );
+ rebecca.addSister( "jeannie" );
+ this.statefulSession.addObject( rebecca );
+
+ final Person jeannie = new Person( "jeannie" );
+ jeannie.addSister( "rebecca" );
+ this.statefulSession.addObject( jeannie );
+
+ // execute the rules
+ this.statefulSession.executeRules();
+ final List outList = this.statefulSession.getObjects();
+ assertEquals( "incorrect size",
+ 5,
+ outList.size() );
+
+ assertTrue( "where is bob",
+ outList.contains( bob ) );
+ assertTrue( "where is rebecca",
+ outList.contains( rebecca ) );
+ assertTrue( "where is jeannie",
+ outList.contains( jeannie ) );
+
+ assertTrue( outList.contains( "rebecca and jeannie are sisters" ) );
+ assertTrue( outList.contains( "jeannie and rebecca are sisters" ) );
+
+ this.statefulSession.release();
+ }
+
+ /**
+ * Test getObjects with ObjectFilter.
+ */
+ @Test
+ public void testGetObjectsWithFilter() throws Exception {
+ this.statefulSession = this.engine.getStatefulRuleSession( this.bindUri );
+
+ final Person bob = new Person( "bob" );
+ this.statefulSession.addObject( bob );
+
+ final Person rebecca = new Person( "rebecca" );
+ rebecca.addSister( "jeannie" );
+ this.statefulSession.addObject( rebecca );
+
+ final Person jeannie = new Person( "jeannie" );
+ jeannie.addSister( "rebecca" );
+ this.statefulSession.addObject( jeannie );
+
+ // execute the rules
+ this.statefulSession.executeRules();
+ final List outList = this.statefulSession.getObjects( new PersonFilter() );
+ assertEquals( "incorrect size",
+ 3,
+ outList.size() );
+
+ assertTrue( "where is bob",
+ outList.contains( bob ) );
+ assertTrue( "where is rebecca",
+ outList.contains( rebecca ) );
+ assertTrue( "where is jeannie",
+ outList.contains( jeannie ) );
+
+ this.statefulSession.release();
+ }
+
+ /**
+ * Test executeRules.
+ */
+ @Test
+ public void testExecuteRules() throws Exception {
+ // tested in testGetObjects, testGetObjectsWithFilter
+ }
+
+ /**
+ * Test reset.
+ */
+ @Test
+ public void testReset() throws Exception {
+ this.statefulSession = this.engine.getStatefulRuleSession( this.bindUri );
+
+ final Person bob = new Person( "bob" );
+ final Handle handle = this.statefulSession.addObject( bob );
+ assertTrue( "where is bob",
+ this.statefulSession.containsObject( handle ) );
+
+ this.statefulSession.reset();
+ assertTrue( "bob still there",
+ !this.statefulSession.containsObject( handle ) );
+ }
+
+ /**
+ * Test executeRules with globals.
+ */
+ @Test
+ public void testExecuteRulesGlobals() throws Exception {
+ final java.util.Map map = new HashMap();
+ java.util.Vector v = new java.util.Vector();
+ map.put( "vector",
+ v );
+ this.statefulSession = this.engine.getStatefulRuleSession( this.bindUri_globals,
+ map );
+
+ final Person bob = new Person( "bob" );
+ this.statefulSession.addObject( bob );
+
+ final Person rebecca = new Person( "rebecca" );
+ rebecca.addSister( "jeannie" );
+ this.statefulSession.addObject( rebecca );
+
+ final Person jeannie = new Person( "jeannie" );
+ jeannie.addSister( "rebecca" );
+ this.statefulSession.addObject( jeannie );
+
+ // execute the rules
+ this.statefulSession.executeRules();
+
+ final List outList = this.statefulSession.getObjects();
+
+ assertEquals( "incorrect size",
+ 5,
+ outList.size() );
+
+ assertContains( outList,
+ bob );
+
+ assertContains( outList,
+ rebecca );
+
+ assertContains( outList,
+ jeannie );
+
+ assertContains( outList,
+ "rebecca and jeannie are sisters" );
+
+ assertContains( outList,
+ "jeannie and rebecca are sisters" );
+
+ v = (java.util.Vector) map.get( "vector" );
+
+ assertNotNull( "Global Vector null",
+ v );
+
+ assertContains( v,
+ "rebecca and jeannie are sisters" );
+
+ assertContains( v,
+ "jeannie and rebecca are sisters" );
+
+ assertEquals( "Vector v incorrect size",
+ 2,
+ v.size() );
+
+ this.statefulSession.release();
+ }
+
+ /**
+ * Test executeRules drl with dsl.
+ */
+ @Test @Ignore
+ public void testExecuteRules_dsl() throws Exception {
+ // @FIXME
+ this.statefulSession = this.engine.getStatefulRuleSession( this.bindUri_drl );
+
+ final Person bob = new Person( "bob" );
+ this.statefulSession.addObject( bob );
+
+ final Person rebecca = new Person( "rebecca" );
+ rebecca.addSister( "jeannie" );
+ this.statefulSession.addObject( rebecca );
+
+ final Person jeannie = new Person( "jeannie" );
+ jeannie.addSister( "rebecca" );
+ this.statefulSession.addObject( jeannie );
+
+ // execute the rules
+ this.statefulSession.executeRules();
+
+ final List outList = this.statefulSession.getObjects();
+
+ assertEquals( "incorrect size",
+ 5,
+ outList.size() );
+
+ assertContains( outList,
+ bob );
+
+ assertContains( outList,
+ rebecca );
+
+ assertContains( outList,
+ jeannie );
+
+ assertContains( outList,
+ "rebecca and jeannie are sisters" );
+
+ assertContains( outList,
+ "jeannie and rebecca are sisters" );
+
+ this.statefulSession.release();
+ }
+
+ protected void assertContains(final List expected,
+ final Object object) {
+ if ( expected.contains( object ) ) {
+ return;
+ }
+
+ fail( object + " not in " + expected );
+ }
+
+ /**
+ * Filter accepts only objects of type Person.
+ */
+ static class PersonFilter
+ implements
+ ObjectFilter {
+ public Object filter(final Object object) {
+ return (object instanceof Person ? object : null);
+ }
+
+ public void reset() {
+ // nothing to reset
+ }
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/StatelessRuleSessionTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/StatelessRuleSessionTest.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/StatelessRuleSessionTest.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,467 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.rules.ConfigurationException;
+import javax.rules.ObjectFilter;
+import javax.rules.RuleServiceProvider;
+import javax.rules.RuleServiceProviderManager;
+import javax.rules.StatelessRuleSession;
+import javax.rules.admin.LocalRuleExecutionSetProvider;
+import javax.rules.admin.RuleExecutionSet;
+import javax.rules.admin.RuleExecutionSetCreateException;
+import javax.rules.admin.RuleExecutionSetRegisterException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * Test the <code>StatelessRuleSession</code> implementation.
+ *
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ * @author <a href="mailto:michael.frandsen at syngenio.de">Michael Frandsen </a>
+ * @see StatelessRuleSession
+ */
+public class StatelessRuleSessionTest {
+
+ private ExampleRuleEngineFacade sessionBuilder;
+
+ private final String bindUri = "sisters.drl";
+ private final String bindUri_drl = "sisters_expander.drl";
+ private final String bindUri_dsl = "sisters_expander.dsl";
+ private final String bindUri_xml = "sisters.xml";
+ private final String bindUri_globals = "sisters_globals.drl";
+
+ /**
+ * Setup the test case.
+ * normal drl, drl with dsl, drl with global
+ */
+ @Before
+ public void setUp() throws Exception {
+ this.sessionBuilder = new ExampleRuleEngineFacade();
+ this.sessionBuilder.addRuleExecutionSet( this.bindUri,
+ StatelessRuleSessionTest.class.getResourceAsStream( this.bindUri ) );
+
+ final Map map = new HashMap();
+ final Reader reader = new InputStreamReader( StatelessRuleSessionTest.class.getResourceAsStream( this.bindUri_dsl ) );
+
+ map.put( "dsl",
+ this.getDSLText( reader ).toString() );
+ this.sessionBuilder.addRuleExecutionSet( this.bindUri_drl,
+ StatelessRuleSessionTest.class.getResourceAsStream( this.bindUri_drl ),
+ map );
+
+ final Map map_xml = new HashMap();
+ map_xml.put( "source",
+ "xml" );
+ this.sessionBuilder.addRuleExecutionSet( this.bindUri_xml,
+ StatelessRuleSessionTest.class.getResourceAsStream( this.bindUri_xml ),
+ map_xml );
+
+ this.sessionBuilder.addRuleExecutionSet( this.bindUri_globals,
+ StatelessRuleSessionTest.class.getResourceAsStream( this.bindUri_globals ) );
+
+ }
+
+ /*
+ * Taken from DRLParser
+ */
+ private StringBuffer getDSLText(final Reader reader) throws IOException {
+ final StringBuffer text = new StringBuffer();
+
+ final char[] buf = new char[1024];
+ int len = 0;
+
+ while ( (len = reader.read( buf )) >= 0 ) {
+ text.append( buf,
+ 0,
+ len );
+ }
+ return text;
+ }
+
+ @Test
+ public void testCreateRuleExecutionSetFromStreamWithXml() {
+
+ try {
+ final Map map = new HashMap();
+ map.put( "source",
+ "xml" );
+
+ RuleServiceProvider ruleServiceProvider;
+ RuleServiceProviderManager.registerRuleServiceProvider( "http://drools.org/",
+ RuleServiceProviderImpl.class );
+
+ ruleServiceProvider = RuleServiceProviderManager.getRuleServiceProvider( "http://drools.org/" );
+
+ LocalRuleExecutionSetProvider ruleSetProvider = ruleServiceProvider.getRuleAdministrator().getLocalRuleExecutionSetProvider( null );
+ final RuleExecutionSet ruleExecutionSet = ruleSetProvider.createRuleExecutionSet( StatelessRuleSessionTest.class.getResourceAsStream( this.bindUri_xml ),
+ map );
+ assertNotNull( ruleExecutionSet );
+ } catch ( RemoteException e ) {
+ fail();
+ } catch ( ConfigurationException e ) {
+ fail();
+ } catch ( RuleExecutionSetCreateException e ) {
+ fail();
+ } catch ( IOException e ) {
+ fail();
+ }
+ }
+
+ @Test
+ public void testCreateRuleExecutionSetFromStreamReaderWithXml() {
+ try {
+ final Map map = new HashMap();
+ map.put( "source",
+ "xml" );
+
+ RuleServiceProvider ruleServiceProvider;
+ RuleServiceProviderManager.registerRuleServiceProvider( "http://drools.org/",
+ RuleServiceProviderImpl.class );
+
+ ruleServiceProvider = RuleServiceProviderManager.getRuleServiceProvider( "http://drools.org/" );
+
+ LocalRuleExecutionSetProvider ruleSetProvider = ruleServiceProvider.getRuleAdministrator().getLocalRuleExecutionSetProvider( null );
+ final Reader ruleReader = new InputStreamReader( StatelessRuleSessionTest.class.getResourceAsStream( this.bindUri_xml ) );
+ final RuleExecutionSet ruleExecutionSet = ruleSetProvider.createRuleExecutionSet( ruleReader,
+ map );
+ assertNotNull( ruleExecutionSet );
+
+ } catch ( RemoteException e ) {
+ fail();
+ } catch ( ConfigurationException e ) {
+ fail();
+ } catch ( RuleExecutionSetCreateException e ) {
+ fail();
+ } catch ( IOException e ) {
+ fail();
+ }
+ }
+
+ /**
+ * Test executeRules with globals.
+ */
+ @Test
+ public void testExecuteRulesGlobals() throws Exception {
+ final java.util.Map map = new HashMap();
+ java.util.Vector v = new java.util.Vector();
+ map.put( "vector",
+ v );
+ final StatelessRuleSession statelessSession = this.sessionBuilder.getStatelessRuleSession( this.bindUri_globals,
+ map );
+
+ final List inObjects = new ArrayList();
+
+ final Person bob = new Person( "bob" );
+ inObjects.add( bob );
+
+ final Person jeannie = new Person( "jeannie" );
+ jeannie.addSister( "rebecca" );
+ inObjects.add( jeannie );
+
+ final Person rebecca = new Person( "rebecca" );
+ rebecca.addSister( "jeannie" );
+ inObjects.add( rebecca );
+
+ // execute the rules
+ final List outList = statelessSession.executeRules( inObjects );
+
+ assertEquals( "incorrect size",
+ 5,
+ outList.size() );
+
+ assertContains( outList,
+ bob );
+
+ assertContains( outList,
+ rebecca );
+
+ assertContains( outList,
+ jeannie );
+
+ assertContains( outList,
+ "rebecca and jeannie are sisters" );
+
+ assertContains( outList,
+ "jeannie and rebecca are sisters" );
+
+ v = (java.util.Vector) map.get( "vector" );
+
+ assertNotNull( "Global Vector null",
+ v );
+
+ assertContains( v,
+ "rebecca and jeannie are sisters" );
+
+ assertContains( v,
+ "jeannie and rebecca are sisters" );
+
+ assertEquals( "Vector v incorrect size",
+ 2,
+ v.size() );
+
+ statelessSession.release();
+ }
+
+ /**
+ * Test executeRules with normal drl.
+ */
+ @Test
+ public void testExecuteRules() throws Exception {
+ final StatelessRuleSession statelessSession = this.sessionBuilder.getStatelessRuleSession( this.bindUri );
+
+ final List inObjects = new ArrayList();
+
+ final Person bob = new Person( "bob" );
+ inObjects.add( bob );
+
+ final Person jeannie = new Person( "jeannie" );
+ jeannie.addSister( "rebecca" );
+ inObjects.add( jeannie );
+
+ final Person rebecca = new Person( "rebecca" );
+ rebecca.addSister( "jeannie" );
+ inObjects.add( rebecca );
+
+ // execute the rules
+ final List outList = statelessSession.executeRules( inObjects );
+
+ assertEquals( "incorrect size",
+ 5,
+ outList.size() );
+
+ assertContains( outList,
+ bob );
+
+ assertContains( outList,
+ rebecca );
+
+ assertContains( outList,
+ jeannie );
+
+ assertContains( outList,
+ "rebecca and jeannie are sisters" );
+
+ assertContains( outList,
+ "jeannie and rebecca are sisters" );
+
+ statelessSession.release();
+ }
+
+ /**
+ * Test executeRules with normal drl.
+ */
+ @Test
+ public void testExecuteRulesWithXml() throws Exception {
+ final StatelessRuleSession statelessSession = this.sessionBuilder.getStatelessRuleSession( this.bindUri_xml );
+
+ final List inObjects = new ArrayList();
+
+ final Person bob = new Person( "bob" );
+ inObjects.add( bob );
+
+ final Person jeannie = new Person( "jeannie" );
+ jeannie.addSister( "rebecca" );
+ inObjects.add( jeannie );
+
+ final Person rebecca = new Person( "rebecca" );
+ rebecca.addSister( "jeannie" );
+ inObjects.add( rebecca );
+
+ // execute the rules
+ final List outList = statelessSession.executeRules( inObjects );
+
+ assertEquals( "incorrect size",
+ 5,
+ outList.size() );
+
+ assertContains( outList,
+ bob );
+
+ assertContains( outList,
+ rebecca );
+
+ assertContains( outList,
+ jeannie );
+
+ assertContains( outList,
+ "rebecca and jeannie are sisters" );
+
+ assertContains( outList,
+ "jeannie and rebecca are sisters" );
+
+ statelessSession.release();
+ }
+
+ /**
+ * Test executeRules drl with dsl.
+ */
+ @Test @Ignore
+ public void testExecuteRules_dsl() throws Exception {
+ // @FIXME
+ final StatelessRuleSession statelessSession = this.sessionBuilder.getStatelessRuleSession( this.bindUri_drl );
+
+ final List inObjects = new ArrayList();
+
+ final Person bob = new Person( "bob" );
+ inObjects.add( bob );
+
+ final Person jeannie = new Person( "jeannie" );
+ jeannie.addSister( "rebecca" );
+ inObjects.add( jeannie );
+
+ final Person rebecca = new Person( "rebecca" );
+ rebecca.addSister( "jeannie" );
+ inObjects.add( rebecca );
+
+ // execute the rules
+ final List outList = statelessSession.executeRules( inObjects );
+
+ assertEquals( "incorrect size",
+ 5,
+ outList.size() );
+
+ assertContains( outList,
+ bob );
+
+ assertContains( outList,
+ rebecca );
+
+ assertContains( outList,
+ jeannie );
+
+ assertContains( outList,
+ "rebecca and jeannie are sisters" );
+
+ assertContains( outList,
+ "jeannie and rebecca are sisters" );
+
+ statelessSession.release();
+ }
+
+ /**
+ * Test executeRules with ObjectFilter.
+ */
+ @Test
+ public void testExecuteRulesWithFilter() throws Exception {
+ final StatelessRuleSession statelessSession = this.sessionBuilder.getStatelessRuleSession( this.bindUri );
+
+ final List inObjects = new ArrayList();
+
+ final Person bob = new Person( "bob" );
+ inObjects.add( bob );
+
+ final Person rebecca = new Person( "rebecca" );
+ rebecca.addSister( "jeannie" );
+ inObjects.add( rebecca );
+
+ final Person jeannie = new Person( "jeannie" );
+ jeannie.addSister( "rebecca" );
+ inObjects.add( jeannie );
+
+ // execute the rules
+ final List outList = statelessSession.executeRules( inObjects,
+ new PersonFilter() );
+ assertEquals( "incorrect size",
+ 3,
+ outList.size() );
+
+ assertTrue( "where is bob",
+ outList.contains( bob ) );
+
+ assertTrue( "where is rebecca",
+ outList.contains( rebecca ) );
+
+ assertTrue( "where is jeannie",
+ outList.contains( jeannie ) );
+ }
+
+ /**
+ * Test executeRules with ObjectFilter drl with dsl.
+ */
+ @Test
+ public void testExecuteRulesWithFilter_dsl() throws Exception {
+ final StatelessRuleSession statelessSession = this.sessionBuilder.getStatelessRuleSession( this.bindUri_drl );
+
+ final List inObjects = new ArrayList();
+
+ final Person bob = new Person( "bob" );
+ inObjects.add( bob );
+
+ final Person rebecca = new Person( "rebecca" );
+ rebecca.addSister( "jeannie" );
+ inObjects.add( rebecca );
+
+ final Person jeannie = new Person( "jeannie" );
+ jeannie.addSister( "rebecca" );
+ inObjects.add( jeannie );
+
+ // execute the rules
+ final List outList = statelessSession.executeRules( inObjects,
+ new PersonFilter() );
+ assertEquals( "incorrect size",
+ 3,
+ outList.size() );
+
+ assertTrue( "where is bob",
+ outList.contains( bob ) );
+
+ assertTrue( "where is rebecca",
+ outList.contains( rebecca ) );
+
+ assertTrue( "where is jeannie",
+ outList.contains( jeannie ) );
+ }
+
+ /**
+ * Filter accepts only objects of type Person.
+ */
+ static class PersonFilter
+ implements
+ ObjectFilter {
+ public Object filter(final Object object) {
+ return (object instanceof Person ? object : null);
+ }
+
+ public void reset() {
+ // nothing to reset
+ }
+ }
+
+ protected void assertContains(final List expected,
+ final Object object) {
+ if ( expected.contains( object ) ) {
+ return;
+ }
+
+ fail( object + " not in " + expected );
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/LocalRuleExecutionSetProviderTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/LocalRuleExecutionSetProviderTest.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/LocalRuleExecutionSetProviderTest.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,113 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules.admin;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import javax.rules.admin.LocalRuleExecutionSetProvider;
+import javax.rules.admin.RuleAdministrator;
+import javax.rules.admin.RuleExecutionSet;
+
+import org.drools.compiler.PackageBuilder;
+import org.drools.jsr94.rules.RuleEngineTestBase;
+import org.drools.rule.Package;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Test the LocalRuleExecutionSetProvider implementation.
+ *
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ * @author <a href="mailto:michael.frandsen at syngenio.de">michael frandsen </a>
+ */
+public class LocalRuleExecutionSetProviderTest extends RuleEngineTestBase {
+ private RuleAdministrator ruleAdministrator;
+
+ private LocalRuleExecutionSetProvider ruleSetProvider;
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ this.ruleAdministrator = this.ruleServiceProvider.getRuleAdministrator();
+ this.ruleSetProvider = this.ruleAdministrator.getLocalRuleExecutionSetProvider( null );
+ }
+
+ @Test
+ public void testCreateFromInputStream() throws Exception {
+ final InputStream rulesStream = RuleEngineTestBase.class.getResourceAsStream( this.bindUri );
+ final RuleExecutionSet ruleSet = this.ruleSetProvider.createRuleExecutionSet( rulesStream,
+ null );
+ assertEquals( "rule set name",
+ "SistersRules",
+ ruleSet.getName() );
+ assertEquals( "number of rules",
+ 1,
+ ruleSet.getRules().size() );
+ }
+
+ @Test
+ public void testCreateFromObject() throws Exception {
+ final InputStream inputStream = null;
+ try {
+ final PackageBuilder builder = new PackageBuilder();
+ builder.addPackageFromDrl( new InputStreamReader( RuleEngineTestBase.class.getResourceAsStream( this.bindUri ) ) );
+ final Package pkg = builder.getPackage();
+ final RuleExecutionSet ruleExecutionSet = this.ruleSetProvider.createRuleExecutionSet( pkg,
+ null );
+ assertEquals( "rule set name",
+ "SistersRules",
+ ruleExecutionSet.getName() );
+ assertEquals( "number of rules",
+ 1,
+ ruleExecutionSet.getRules().size() );
+ } catch ( final IOException e ) {
+ fail( "Couldn't create the RuleExecutionSet. " + "Test threw an IOException." );
+ } finally {
+ if ( inputStream != null ) {
+ try {
+ inputStream.close();
+ } catch ( final IOException e ) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ /**
+ * Test createRuleExecutionSet from Reader.
+ */
+ @Test
+ public void testCreateFromReader() throws Exception {
+ final Reader ruleReader = new InputStreamReader( RuleEngineTestBase.class.getResourceAsStream( this.bindUri ) );
+ final RuleExecutionSet ruleSet = this.ruleSetProvider.createRuleExecutionSet( ruleReader,
+ null );
+ assertEquals( "rule set name",
+ "SistersRules",
+ ruleSet.getName() );
+ assertEquals( "number of rules",
+ 1,
+ ruleSet.getRules().size() );
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/RuleAdministratorTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/RuleAdministratorTest.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/RuleAdministratorTest.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,101 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules.admin;
+
+import javax.rules.admin.LocalRuleExecutionSetProvider;
+import javax.rules.admin.RuleAdministrator;
+import javax.rules.admin.RuleExecutionSetDeregistrationException;
+import javax.rules.admin.RuleExecutionSetProvider;
+import javax.rules.admin.RuleExecutionSetRegisterException;
+
+import org.drools.jsr94.rules.RuleEngineTestBase;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Test the RuleRuntime implementation.
+ *
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ */
+public class RuleAdministratorTest extends RuleEngineTestBase {
+ private RuleAdministrator ruleAdministrator;
+
+ /**
+ * Obtain an instance of <code>RuleAdministrator</code>.
+ */
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ this.ruleAdministrator = this.ruleServiceProvider.getRuleAdministrator();
+ }
+
+ /**
+ * Test getRuleExecutionSetProvider.
+ */
+ @Test
+ public void testRuleExecutionSetProvider() throws Exception {
+ final RuleExecutionSetProvider ruleExecutionSetProvider = this.ruleAdministrator.getRuleExecutionSetProvider( null );
+ assertNotNull( "cannot obtain RuleExecutionSetProvider",
+ ruleExecutionSetProvider );
+ }
+
+ /**
+ * Test getLocalRuleExecutionSetProvider.
+ */
+ @Test
+ public void testLocalRuleExecutionSetProvider() throws Exception {
+ final LocalRuleExecutionSetProvider localRuleExecutionSetProvider = this.ruleAdministrator.getLocalRuleExecutionSetProvider( null );
+ assertNotNull( "cannot obtain LocalRuleExecutionSetProvider",
+ localRuleExecutionSetProvider );
+ }
+
+ /**
+ * Test registerRuleExecutionSet.
+ */
+ @Test
+ public void testRegisterRuleExecutionSet() throws Exception {
+ try {
+ // that it works is tested elsewhere
+ this.ruleAdministrator.registerRuleExecutionSet( "test URI",
+ null,
+ null );
+ fail( "RuleExecutionSetRegisterException expected" );
+ } catch ( final RuleExecutionSetRegisterException ex ) {
+ // ignore exception
+ }
+ }
+
+ /**
+ * Test deregisterRuleExecutionSet.
+ */
+ @Test
+ public void testDeregisterRuleExecutionSet() throws Exception {
+ try {
+ // that it works is tested else where
+ this.ruleAdministrator.deregisterRuleExecutionSet( "test URI",
+ null );
+ fail( "RuleExecutionSetUnregisterException expected" );
+ } catch ( final RuleExecutionSetDeregistrationException ex ) {
+ // ignore exception
+ }
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/RuleExecutionSetProviderTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/RuleExecutionSetProviderTest.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/RuleExecutionSetProviderTest.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,186 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules.admin;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+
+import javax.rules.admin.RuleAdministrator;
+import javax.rules.admin.RuleExecutionSet;
+import javax.rules.admin.RuleExecutionSetProvider;
+
+import org.drools.compiler.PackageBuilder;
+import org.drools.jsr94.rules.RuleEngineTestBase;
+import org.drools.rule.Package;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Test the RuleExecutionSetProvider implementation.
+ *
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ * @author <a href="mailto:michael.frandsen at syngenio.de">michael frandsen </a>
+ */
+public class RuleExecutionSetProviderTest extends RuleEngineTestBase {
+ private RuleAdministrator ruleAdministrator;
+
+ private RuleExecutionSetProvider ruleSetProvider;
+
+ private Package pkg;
+
+ /**
+ * Setup the test case.
+ */
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ this.ruleAdministrator = this.ruleServiceProvider.getRuleAdministrator();
+ this.ruleSetProvider = this.ruleAdministrator.getRuleExecutionSetProvider( null );
+
+ initPackage();
+ }
+
+ private void initPackage() {
+ final InputStream resourceAsStream = null;
+ try {
+ final PackageBuilder builder = new PackageBuilder();
+ builder.addPackageFromDrl( new InputStreamReader( RuleEngineTestBase.class.getResourceAsStream( this.bindUri ) ) );
+ final Package pkg = builder.getPackage();
+
+ this.pkg = pkg;
+ } catch ( final IOException e ) {
+ throw new ExceptionInInitializerError( "setUp() could not init the " + "RuleSet due to an IOException in the InputStream: " + e );
+ } catch ( final Exception e ) {
+ throw new ExceptionInInitializerError( "setUp() could not init the RuleSet, " + e );
+ } finally {
+ if ( resourceAsStream != null ) {
+ try {
+ resourceAsStream.close();
+ } catch ( final IOException e ) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ @After
+ public void tearDown() {
+ this.pkg = null;
+ }
+
+ // Rule files are no XML
+ // /**
+ // * Test createRuleExecutionSet from DOM.
+ // */
+ // public void testCreateFromElement( ) throws Exception
+ // {
+ // DOMParser parser = new DOMParser( );
+ // Document doc = null;
+ // try
+ // {
+ // parser.parse( new InputSource(
+ // RuleEngineTestBase.class.getResourceAsStream( bindUri ) ) );
+ // doc = parser.getDocument( );
+ // }
+ // catch ( SAXException e )
+ // {
+ // fail( "could not parse incoming data stream: " + e );
+ // }
+ // catch ( IOException e )
+ // {
+ // fail( "could not open incoming data stream: " + e );
+ // }
+ // Element element = null;
+ // NodeList children = doc.getChildNodes( );
+ // if ( children != null )
+ // {
+ // for ( int i = 0; i < children.getLength( ); i++ )
+ // {
+ // Node child = children.item( i );
+ // if ( Node.ELEMENT_NODE == child.getNodeType( ) )
+ // {
+ // element = ( Element ) child;
+ // }
+ // }
+ // }
+ //
+ // if ( element != null )
+ // {
+ // RuleExecutionSet testRuleSet =
+ // ruleSetProvider.createRuleExecutionSet( element, null );
+ // assertEquals(
+ // "rule set name", "Sisters Rules", testRuleSet.getName( ) );
+ // assertEquals(
+ // "number of rules", 1, testRuleSet.getRules( ).size( ) );
+ // }
+ // else
+ // {
+ // fail( "could not build an org.w3c.dom.Element" );
+ // }
+ // }
+
+ /**
+ * Test createRuleExecutionSet from Serializable.
+ */
+ @Test
+ public void testCreateFromSerializable() throws Exception {
+ final RuleExecutionSet ruleExecutionSet = this.ruleSetProvider.createRuleExecutionSet( this.pkg,
+ null );
+ assertEquals( "rule set name",
+ "SistersRules",
+ ruleExecutionSet.getName() );
+ assertEquals( "number of rules",
+ 1,
+ ruleExecutionSet.getRules().size() );
+ }
+
+ /**
+ * Test createRuleExecutionSet from URI.
+ */
+ @Test
+ public void testCreateFromURI() throws Exception {
+ final String rulesUri = RuleEngineTestBase.class.getResource( this.bindUri ).toExternalForm();
+ final RuleExecutionSet testRuleSet = this.ruleSetProvider.createRuleExecutionSet( rulesUri,
+ null );
+ assertEquals( "rule set name",
+ "SistersRules",
+ testRuleSet.getName() );
+ assertEquals( "number of rules",
+ 1,
+ testRuleSet.getRules().size() );
+ }
+
+ @Test
+ public void testIncompatibleSerializableCreation() throws Exception {
+ try {
+ final RuleExecutionSet testRuleSet = this.ruleSetProvider.createRuleExecutionSet( new ArrayList(),
+ null );
+ fail( "Should have thrown an IllegalArgumentException. ArrayList " + "objects are not valid AST representations. " + testRuleSet );
+ } catch ( final IllegalArgumentException e ) {
+ /*
+ * this is supposed to happen if you pass in a serializable object
+ * that isn't a supported AST representation.
+ */
+ }
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/RuleExecutionSetTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/RuleExecutionSetTest.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/RuleExecutionSetTest.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,76 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules.admin;
+
+import java.io.InputStream;
+
+import javax.rules.admin.LocalRuleExecutionSetProvider;
+import javax.rules.admin.RuleAdministrator;
+import javax.rules.admin.RuleExecutionSet;
+
+import org.drools.jsr94.rules.RuleEngineTestBase;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Test the RuleExecutionSet implementation.
+ *
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ * @author <a href="mailto:michael.frandsen at syngenio.de">michael frandsen </a>
+ */
+public class RuleExecutionSetTest extends RuleEngineTestBase {
+
+ private RuleAdministrator ruleAdministrator;
+
+ private LocalRuleExecutionSetProvider ruleSetProvider;
+
+ /**
+ * Setup the test case.
+ */
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ this.ruleAdministrator = this.ruleServiceProvider.getRuleAdministrator();
+ this.ruleSetProvider = this.ruleAdministrator.getLocalRuleExecutionSetProvider( null );
+ }
+
+ /**
+ * Test rule set name and description.
+ */
+ @Test
+ public void testRule() throws Exception {
+ final InputStream in = RuleEngineTestBase.class.getResourceAsStream( this.bindUri );
+ final RuleExecutionSet ruleSet = this.ruleSetProvider.createRuleExecutionSet( in,
+ null );
+ assertEquals( "number of rules",
+ 1,
+ ruleSet.getRules().size() );
+
+ assertEquals( "rule set name",
+ "SistersRules",
+ ruleSet.getName() );
+ assertEquals( "SistersRules",
+ ruleSet.getDescription() );
+ assertNull( "rule set default filter",
+ ruleSet.getDefaultObjectFilter() );
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/RuleTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/RuleTest.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/admin/RuleTest.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,78 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules.admin;
+
+import java.io.InputStream;
+import java.util.List;
+
+import javax.rules.admin.LocalRuleExecutionSetProvider;
+import javax.rules.admin.Rule;
+import javax.rules.admin.RuleAdministrator;
+import javax.rules.admin.RuleExecutionSet;
+
+import org.drools.jsr94.rules.RuleEngineTestBase;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Test the LocalRuleExecutionSetProvider implementation.
+ *
+ * @author N. Alex Rupp (n_alex <at>codehaus.org)
+ * @author <a href="mailto:thomas.diesler at softcon-itec.de">thomas diesler </a>
+ * @author <a href="mailto:michael.frandsen at syngenio.de">michael frandsen </a>
+ */
+public class RuleTest extends RuleEngineTestBase {
+ private RuleAdministrator ruleAdministrator;
+
+ private LocalRuleExecutionSetProvider ruleSetProvider;
+
+ /**
+ * Setup the test case.
+ */
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ this.ruleAdministrator = this.ruleServiceProvider.getRuleAdministrator();
+ this.ruleSetProvider = this.ruleAdministrator.getLocalRuleExecutionSetProvider( null );
+ }
+
+ /**
+ * Test rule name and description.
+ */
+ @Test
+ public void testRule() throws Exception {
+ final InputStream in = RuleEngineTestBase.class.getResourceAsStream( this.bindUri );
+ final RuleExecutionSet ruleExecutionSet = this.ruleSetProvider.createRuleExecutionSet( in,
+ null );
+ final List rules = ruleExecutionSet.getRules();
+ assertEquals( "number of rules",
+ 1,
+ rules.size() );
+
+ final Rule rule01 = (Rule) ruleExecutionSet.getRules().get( 0 );
+ assertEquals( "rule name",
+ "FindSisters",
+ rule01.getName() );
+ assertEquals( "rule description",
+ "FindSisters",
+ rule01.getDescription() );
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/repository/RuleExecutionSetRepositoryLoaderTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/repository/RuleExecutionSetRepositoryLoaderTest.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/repository/RuleExecutionSetRepositoryLoaderTest.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,42 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules.repository;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * TODO
+ *
+ * @version $Revision$ $Date$
+ * @author <a href="mailto:rlangbehn at users.sourceforge.net">Rainer Langbehn</a>
+ */
+public class RuleExecutionSetRepositoryLoaderTest {
+
+ /**
+ * Test method for {@link org.drools.jsr94.rules.repository.RuleExecutionSetRepositoryLoader#loadRuleExecutionSetRepository(java.lang.String)}.
+ *
+ * @throws Exception
+ */
+ @Test @Ignore
+ public void testLoadRuleExecutionSetRepository() throws Exception {
+ // TODO
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/repository/TestRuleExecutionSetRepository.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/repository/TestRuleExecutionSetRepository.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/drools/jsr94/rules/repository/TestRuleExecutionSetRepository.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,88 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.jsr94.rules.repository;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.rules.admin.RuleExecutionSet;
+import javax.rules.admin.RuleExecutionSetDeregistrationException;
+import javax.rules.admin.RuleExecutionSetRegisterException;
+
+/**
+ * TODO
+ *
+ * @version $Revision$ $Date$
+ * @author <a href="mailto:rlangbehn at users.sourceforge.net">Rainer Langbehn</a>
+ */
+public class TestRuleExecutionSetRepository
+ implements RuleExecutionSetRepository
+{
+ /**
+ * Default serial version UID.
+ */
+ private static final long serialVersionUID = 510l;
+
+ /**
+ * Required default ctor.
+ */
+ public TestRuleExecutionSetRepository() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.jsr94.rules.repository.RuleExecutionSetRepository#getRegistrations()
+ */
+ public List getRegistrations()
+ throws RuleExecutionSetRepositoryException {
+ String s = "Implementation outstanding";
+ throw new UnsupportedOperationException(s);
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.jsr94.rules.repository.RuleExecutionSetRepository#getRuleExecutionSet(java.lang.String, java.util.Map)
+ */
+ public RuleExecutionSet getRuleExecutionSet(
+ String bindUri,
+ Map properties)
+ throws RuleExecutionSetRepositoryException {
+ String s = "Implementation outstanding";
+ throw new UnsupportedOperationException(s);
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.jsr94.rules.repository.RuleExecutionSetRepository#registerRuleExecutionSet(java.lang.String, javax.rules.admin.RuleExecutionSet, java.util.Map)
+ */
+ public void registerRuleExecutionSet(
+ String bindUri,
+ RuleExecutionSet ruleSet,
+ Map properties)
+ throws RuleExecutionSetRegisterException {
+ String s = "Implementation outstanding";
+ throw new UnsupportedOperationException(s);
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.jsr94.rules.repository.RuleExecutionSetRepository#unregisterRuleExecutionSet(java.lang.String, java.util.Map)
+ */
+ public void unregisterRuleExecutionSet(
+ String bindUri,
+ Map properties)
+ throws RuleExecutionSetDeregistrationException {
+ String s = "Implementation outstanding";
+ throw new UnsupportedOperationException(s);
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/jcp/jsr94/tck/AllTests.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/jcp/jsr94/tck/AllTests.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/java/org/jcp/jsr94/tck/AllTests.java 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,190 @@
+/**
+ * Copyright 2010 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.
+ */
+
+/*
+ * J A V A C O M M U N I T Y P R O C E S S
+ *
+ * J S R 9 4
+ *
+ * Test Compatability Kit
+ *
+ */
+package org.jcp.jsr94.tck;
+
+// java imports
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.URL;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.drools.jsr94.rules.Jsr94FactHandle;
+import org.jcp.jsr94.tck.admin.LocalRuleExecutionSetProviderTest;
+import org.jcp.jsr94.tck.admin.RuleAdministrationExceptionTest;
+import org.jcp.jsr94.tck.admin.RuleAdministratorTest;
+import org.jcp.jsr94.tck.admin.RuleExecutionSetCreateExceptionTest;
+import org.jcp.jsr94.tck.admin.RuleExecutionSetDeregistrationExceptionTest;
+import org.jcp.jsr94.tck.admin.RuleExecutionSetRegisterExceptionTest;
+import org.jcp.jsr94.tck.admin.RuleExecutionSetTest;
+import org.jcp.jsr94.tck.admin.RuleTest;
+
+/**
+ * Run all the test suites in the Test Compatability Kit.
+ * Output is directed to System.out (textui).
+ */
+public class AllTests extends TestSuite {
+
+ public static Test suite() {
+ setTckConf();
+
+ final TestSuite suite = new TestSuite( "JSR 94 Test Compatability Kit" );
+ suite.addTestSuite( ApiSignatureTest.class );
+ suite.addTestSuite( ClassLoaderTest.class );
+ suite.addTestSuite( ConfigurationExceptionTest.class );
+ suite.addTestSuite( HandleTest.class );
+ suite.addTestSuite( InvalidHandleExceptionTest.class );
+ suite.addTestSuite( InvalidRuleSessionExceptionTest.class );
+ suite.addTestSuite( ObjectFilterTest.class );
+ suite.addTestSuite( RuleExceptionTest.class );
+ suite.addTestSuite( RuleExecutionExceptionTest.class );
+ suite.addTestSuite( RuleExecutionSetMetadataTest.class );
+ suite.addTestSuite( RuleExecutionSetNotFoundExceptionTest.class );
+ suite.addTestSuite( RuleRuntimeTest.class );
+ suite.addTestSuite( RuleServiceProviderManagerTest.class );
+ suite.addTestSuite( RuleServiceProviderTest.class );
+ suite.addTestSuite( RuleSessionCreateExceptionTest.class );
+ suite.addTestSuite( RuleSessionTest.class );
+ suite.addTestSuite( RuleSessionTypeUnsupportedExceptionTest.class );
+ suite.addTestSuite( StatefulRuleSessionTest.class );
+ suite.addTestSuite( StatelessRuleSessionTest.class );
+ suite.addTestSuite( LocalRuleExecutionSetProviderTest.class );
+ suite.addTestSuite( RuleAdministrationExceptionTest.class );
+ suite.addTestSuite( RuleAdministratorTest.class );
+ suite.addTestSuite( RuleExecutionSetCreateExceptionTest.class );
+ // suite.addTestSuite(RuleExecutionSetProviderTest.class);
+ suite.addTestSuite( RuleExecutionSetRegisterExceptionTest.class );
+ suite.addTestSuite( RuleExecutionSetTest.class );
+ suite.addTestSuite( RuleExecutionSetDeregistrationExceptionTest.class );
+ suite.addTestSuite( RuleTest.class );
+ return suite;
+ }
+
+ /**
+ * Because the tck.conf relies on directory paths that are not universally the same from eclipse, maven
+ * and ant this method create a tck.conf on the fly with the correct locations, it also create a jar
+ * on the fly which it uses as the jar url location.
+ *
+ */
+ private static void setTckConf() {
+ File jarFile = null;
+ ZipOutputStream zos = null;
+ File rootDirectory = null;
+ try {
+ jarFile = File.createTempFile( "drools-jsr94",
+ ".jar" );
+
+ URL url = Jsr94FactHandle.class.getResource( "Jsr94FactHandle.class" );
+ rootDirectory = new File( url.getFile() ).getParentFile().getParentFile().getParentFile().getParentFile();
+
+ zos = new ZipOutputStream( new FileOutputStream( jarFile ) );
+ zipDir( rootDirectory,
+ zos );
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ } finally {
+ if ( zos != null ) {
+ try {
+ zos.close();
+ } catch ( IOException e ) {
+ }
+ }
+ }
+
+ String conf = "";
+ conf += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ conf += "<tck-configuration>\n";
+ conf += "<test-factory>org.jcp.jsr94.tck.util.TestFactory</test-factory>\n";
+ conf += "<rule-service-provider>org.drools.jsr94.rules.RuleServiceProviderImpl</rule-service-provider>\n";
+ conf += "<rule-service-provider-jar-url>file://" + jarFile.getAbsolutePath() + "</rule-service-provider-jar-url>\n";
+
+ URL url = AllTests.class.getResource( "AllTests.class" );
+ String setLocation = new File( url.getFile() ).getParentFile().getAbsolutePath().replaceAll( "\\\\",
+ "/" );
+ // the tck needs an asbolute path, with no drive letters
+ if ( setLocation.charAt( 1 ) == ':' ) {
+ setLocation = setLocation.substring( 2 );
+ }
+ conf += "<rule-execution-set-location>" + setLocation + "</rule-execution-set-location>\n";
+ conf += "</tck-configuration>";
+
+ url = AllTests.class.getResource( "tck.conf" );
+ File tckConf = new File( url.getFile() );
+ BufferedWriter buffWriter = null;
+ try {
+ FileWriter fileWriter = new FileWriter( tckConf );
+ buffWriter = new BufferedWriter( fileWriter );
+ buffWriter.write( conf );
+ } catch ( IOException e ) {
+ e.printStackTrace();
+ } finally {
+ try {
+ buffWriter.close();
+ } catch ( IOException e ) {
+ e.printStackTrace();
+ }
+ }
+
+ System.setProperty( "jsr94.tck.configuration",
+ tckConf.getParent() );
+
+ }
+
+ public static void zipDir(File zipDir,
+ ZipOutputStream zos) {
+ try {
+ String[] dirList = zipDir.list();
+ byte[] readBuffer = new byte[2156];
+ int bytesIn = 0;
+ for ( int i = 0; i < dirList.length; i++ ) {
+ File f = new File( zipDir,
+ dirList[i] );
+ if ( f.isDirectory() ) {
+ zipDir( f,
+ zos );
+ continue;
+ }
+ FileInputStream fis = new FileInputStream( f );
+ ZipEntry anEntry = new ZipEntry( f.getPath() );
+ zos.putNextEntry( anEntry );
+ while ( (bytesIn = fis.read( readBuffer )) != -1 ) {
+ zos.write( readBuffer,
+ 0,
+ bytesIn );
+ }
+ fis.close();
+ }
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ }
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/decisiontable/IntegrationExampleTest.xls
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/decisiontable/IntegrationExampleTest.xls
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/multiple-engine1.drl
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/multiple-engine1.drl (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/multiple-engine1.drl 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,26 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package Engine1;
+
+import java.lang.Object;
+
+rule "debug"
+ when
+ $obj : Object ( )
+ then
+ System.out.println("Engine 1 Asserted object: " + $obj);
+end
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/multiple-engine2.drl
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/multiple-engine2.drl (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/multiple-engine2.drl 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,26 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package Engine2;
+
+import java.lang.Object;
+
+rule "debug"
+ when
+ $obj : Object ( )
+ then
+ System.out.println("Engine 2 Asserted object: " + $obj);
+end
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/sisters.drl
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/sisters.drl (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/sisters.drl 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package SistersRules;
+
+import org.drools.jsr94.rules.Person;
+
+rule FindSisters
+ when
+ $person1 : Person ( $name1:name )
+ $person2 : Person ( $name2:name )
+ eval( $person1.hasSister($person2) )
+ then
+ System.out.println($person1.getName() + " and " + $person2.getName() +" are sisters");
+ insert( $person1.getName() + " and " + $person2.getName() +" are sisters");
+end
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/sisters.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/sisters.xml (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/sisters.xml 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package name="SistersRules"
+ xmlns="http://drools.org/drools-5.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:schemaLocation="http://drools.org/drools-5.0 drools-5.0.xsd">
+
+ <import name="org.drools.jsr94.rules.Person" />
+
+ <rule name="FindSisters">
+ <lhs>
+ <pattern object-type="Person" identifier="$person1">
+ <field-binding field-name="name" identifier="$name1" />
+ </pattern>
+
+ <pattern object-type="Person" identifier="$person2">
+ <field-binding field-name="name" identifier="$name2" />
+ </pattern>
+ <eval>$person1.hasSister($person2)</eval>
+ </lhs>
+
+ <rhs>
+ System.out.println($person1.getName() + " and " + $person2.getName() +" are sisters");
+ insert( $person1.getName() + " and " + $person2.getName() +" are sisters");
+ </rhs>
+ </rule>
+</package>
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/sisters_expander.drl
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/sisters_expander.drl (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/sisters_expander.drl 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,31 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package SistersRules
+
+import org.drools.jsr94.rules.Person;
+
+expander sisters_expander.dsl
+
+rule "FindSisters"
+
+ when
+ #conditions
+ There is a Person
+ There is a second Person and they are sisters
+ then
+ Leave a comment in the WorkingMemory
+end
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/sisters_expander.dsl
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/sisters_expander.dsl (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/sisters_expander.dsl 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,7 @@
+[*][]There exists a Person with name of {name}=Person(name=="{name}")
+[condition][]Person is at least {age} years old and lives in {location}=Person(age > {age}, location=="{location}")
+[consequence][]Log {message}=System.out.println("{message}");
+[condition][]There is a Person=$person1 : Person ( )
+[condition][]There is a second Person and they are sisters=$person2 : Person ( ) eval( $person2.hasSister($person1) )
+[consequence][]Tell the world they are sisters=System.out.println($person1.getName() + " and " + $person2.getName() +" are sisters");
+[consequence][]Leave a comment in the WorkingMemory=insert( $person1.getName() + " and " + $person2.getName() +" are sisters");
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/sisters_globals.drl
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/sisters_globals.drl (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/drools/jsr94/rules/sisters_globals.drl 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,31 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package SistersRules;
+
+import org.drools.jsr94.rules.Person;
+
+global java.util.Vector vector
+
+rule FindSisters
+ when
+ $person1 : Person ( $name1:name )
+ $person2 : Person ( $name2:name )
+ eval( $person1.hasSister($person2) )
+ then
+ vector.add($person1.getName() + " and " + $person2.getName() +" are sisters");
+ insert( $person1.getName() + " and " + $person2.getName() +" are sisters");
+end
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/javarules/jsr94/testagent.drl
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/javarules/jsr94/testagent.drl (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/javarules/jsr94/testagent.drl 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,46 @@
+/**
+ * Copyright 2010 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.
+ */
+
+<?xml version="1.0" encoding="UTF-8"?>
+
+<rule-set
+ name="JavaRules.org Test Agent Drools Port"
+ description="Some rules for the JavaOne demo"
+ xmlns="http://drools.org/rules"
+ xmlns:java="http://drools.org/semantics/java"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:schemaLocation="http://drools.org/rules rules.xsd
+ http://drools.org/semantics/java java.xsd">
+
+<!-- Rules -->
+ <rule name="Say hello if Mozilla User">
+ <parameter identifier="s">
+ <class>java.lang.String</class>
+ </parameter>
+ <java:condition> s.startsWith("Gecko") </java:condition>
+ <java:consequence> assertObject("Hello Mozilla user!"); </java:consequence>
+ </rule>
+
+ <rule name="Say hello if IE user">
+ <parameter identifier="s">
+ <class>java.lang.String</class>
+ </parameter>
+ <java:condition> s.startsWith("MSIE") </java:condition>
+ <java:consequence> assertObject("Hello IE user!"); </java:consequence>
+ </rule>
+
+</rule-set>
+
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/jaxrules.sig
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/jaxrules.sig (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/jaxrules.sig 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,446 @@
+#Signature file
+#Version 1.4.2_03
+CLSS public javax.rules.ConfigurationException
+cons public ConfigurationException(java.lang.String)
+cons public ConfigurationException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.RuleException
+CLSS public abstract interface javax.rules.Handle
+intf java.io.Serializable
+supr null
+CLSS public javax.rules.InvalidHandleException
+cons public InvalidHandleException(java.lang.String)
+cons public InvalidHandleException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.RuleExecutionException
+CLSS public javax.rules.InvalidRuleSessionException
+cons public InvalidRuleSessionException(java.lang.String)
+cons public InvalidRuleSessionException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.RuleExecutionException
+CLSS public abstract interface javax.rules.ObjectFilter
+intf java.io.Serializable
+meth public abstract java.lang.Object filter(java.lang.Object)
+meth public abstract void reset()
+supr null
+CLSS public javax.rules.RuleException
+cons public RuleException(java.lang.String)
+cons public RuleException(java.lang.String,java.lang.Throwable)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr java.lang.Exception
+CLSS public javax.rules.RuleExecutionException
+cons public RuleExecutionException(java.lang.String)
+cons public RuleExecutionException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.RuleException
+CLSS public abstract interface javax.rules.RuleExecutionSetMetadata
+intf java.io.Serializable
+meth public abstract java.lang.String getDescription()
+meth public abstract java.lang.String getName()
+meth public abstract java.lang.String getUri()
+supr null
+CLSS public javax.rules.RuleExecutionSetNotFoundException
+cons public RuleExecutionSetNotFoundException(java.lang.String)
+cons public RuleExecutionSetNotFoundException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.RuleExecutionException
+CLSS public abstract interface javax.rules.RuleRuntime
+fld public static final int STATEFUL_SESSION_TYPE
+fld public static final int STATELESS_SESSION_TYPE
+intf java.io.Serializable
+meth public abstract java.util.List getRegistrations() throws java.rmi.RemoteException
+meth public abstract javax.rules.RuleSession createRuleSession(java.lang.String,java.util.Map,int) throws java.rmi.RemoteException,javax.rules.RuleExecutionSetNotFoundException,javax.rules.RuleSessionCreateException,javax.rules.RuleSessionTypeUnsupportedException
+supr null
+CLSS public abstract javax.rules.RuleServiceProvider
+cons public RuleServiceProvider()
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected static java.lang.Object createInstance(java.lang.String) throws java.lang.ClassNotFoundException,java.lang.IllegalAccessException,java.lang.InstantiationException
+meth protected void finalize() throws java.lang.Throwable
+meth public abstract javax.rules.RuleRuntime getRuleRuntime() throws javax.rules.ConfigurationException
+meth public abstract javax.rules.admin.RuleAdministrator getRuleAdministrator() throws javax.rules.ConfigurationException
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String toString()
+meth public void setClassLoader(java.lang.ClassLoader)
+supr java.lang.Object
+CLSS public abstract javax.rules.RuleServiceProviderManager
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String toString()
+meth public static javax.rules.RuleServiceProvider getRuleServiceProvider(java.lang.String) throws javax.rules.ConfigurationException
+meth public static void deregisterRuleServiceProvider(java.lang.String)
+meth public static void registerRuleServiceProvider(java.lang.String,java.lang.Class) throws javax.rules.ConfigurationException
+meth public static void registerRuleServiceProvider(java.lang.String,java.lang.Class,java.lang.ClassLoader) throws javax.rules.ConfigurationException
+supr java.lang.Object
+CLSS public abstract interface javax.rules.RuleSession
+meth public abstract int getType() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract javax.rules.RuleExecutionSetMetadata getRuleExecutionSetMetadata() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract void release() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+supr null
+CLSS public javax.rules.RuleSessionCreateException
+cons public RuleSessionCreateException(java.lang.String)
+cons public RuleSessionCreateException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.RuleExecutionException
+CLSS public javax.rules.RuleSessionTypeUnsupportedException
+cons public RuleSessionTypeUnsupportedException(java.lang.String)
+cons public RuleSessionTypeUnsupportedException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.RuleExecutionException
+CLSS public abstract interface javax.rules.StatefulRuleSession
+intf java.io.Serializable
+intf javax.rules.RuleSession
+meth public abstract boolean containsObject(javax.rules.Handle) throws java.rmi.RemoteException,javax.rules.InvalidHandleException,javax.rules.InvalidRuleSessionException
+meth public abstract int getType() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract java.lang.Object getObject(javax.rules.Handle) throws java.rmi.RemoteException,javax.rules.InvalidHandleException,javax.rules.InvalidRuleSessionException
+meth public abstract java.util.List addObjects(java.util.List) throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract java.util.List getHandles() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract java.util.List getObjects() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract java.util.List getObjects(javax.rules.ObjectFilter) throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract javax.rules.Handle addObject(java.lang.Object) throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract javax.rules.RuleExecutionSetMetadata getRuleExecutionSetMetadata() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract void executeRules() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract void release() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract void removeObject(javax.rules.Handle) throws java.rmi.RemoteException,javax.rules.InvalidHandleException,javax.rules.InvalidRuleSessionException
+meth public abstract void reset() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract void updateObject(javax.rules.Handle,java.lang.Object) throws java.rmi.RemoteException,javax.rules.InvalidHandleException,javax.rules.InvalidRuleSessionException
+supr null
+CLSS public abstract interface javax.rules.StatelessRuleSession
+intf javax.rules.RuleSession
+meth public abstract int getType() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract java.util.List executeRules(java.util.List) throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract java.util.List executeRules(java.util.List,javax.rules.ObjectFilter) throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract javax.rules.RuleExecutionSetMetadata getRuleExecutionSetMetadata() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract void release() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+supr null
+CLSS public abstract interface javax.rules.admin.LocalRuleExecutionSetProvider
+meth public abstract javax.rules.admin.RuleExecutionSet createRuleExecutionSet(java.io.InputStream,java.util.Map) throws java.io.IOException,javax.rules.admin.RuleExecutionSetCreateException
+meth public abstract javax.rules.admin.RuleExecutionSet createRuleExecutionSet(java.io.Reader,java.util.Map) throws java.io.IOException,javax.rules.admin.RuleExecutionSetCreateException
+meth public abstract javax.rules.admin.RuleExecutionSet createRuleExecutionSet(java.lang.Object,java.util.Map) throws javax.rules.admin.RuleExecutionSetCreateException
+supr null
+CLSS public abstract interface javax.rules.admin.Rule
+intf java.io.Serializable
+meth public abstract java.lang.Object getProperty(java.lang.Object)
+meth public abstract java.lang.String getDescription()
+meth public abstract java.lang.String getName()
+meth public abstract void setProperty(java.lang.Object,java.lang.Object)
+supr null
+CLSS public javax.rules.admin.RuleAdministrationException
+cons public RuleAdministrationException(java.lang.String)
+cons public RuleAdministrationException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.RuleException
+CLSS public abstract interface javax.rules.admin.RuleAdministrator
+meth public abstract javax.rules.admin.LocalRuleExecutionSetProvider getLocalRuleExecutionSetProvider(java.util.Map) throws java.rmi.RemoteException
+meth public abstract javax.rules.admin.RuleExecutionSetProvider getRuleExecutionSetProvider(java.util.Map) throws java.rmi.RemoteException
+meth public abstract void deregisterRuleExecutionSet(java.lang.String,java.util.Map) throws java.rmi.RemoteException,javax.rules.admin.RuleExecutionSetDeregistrationException
+meth public abstract void registerRuleExecutionSet(java.lang.String,javax.rules.admin.RuleExecutionSet,java.util.Map) throws java.rmi.RemoteException,javax.rules.admin.RuleExecutionSetRegisterException
+supr null
+CLSS public abstract interface javax.rules.admin.RuleExecutionSet
+intf java.io.Serializable
+meth public abstract java.lang.Object getProperty(java.lang.Object)
+meth public abstract java.lang.String getDefaultObjectFilter()
+meth public abstract java.lang.String getDescription()
+meth public abstract java.lang.String getName()
+meth public abstract java.util.List getRules()
+meth public abstract void setDefaultObjectFilter(java.lang.String)
+meth public abstract void setProperty(java.lang.Object,java.lang.Object)
+supr null
+CLSS public javax.rules.admin.RuleExecutionSetCreateException
+cons public RuleExecutionSetCreateException(java.lang.String)
+cons public RuleExecutionSetCreateException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.admin.RuleAdministrationException
+CLSS public javax.rules.admin.RuleExecutionSetDeregistrationException
+cons public RuleExecutionSetDeregistrationException(java.lang.String)
+cons public RuleExecutionSetDeregistrationException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.admin.RuleAdministrationException
+CLSS public abstract interface javax.rules.admin.RuleExecutionSetProvider
+meth public abstract javax.rules.admin.RuleExecutionSet createRuleExecutionSet(java.io.Serializable,java.util.Map) throws java.rmi.RemoteException,javax.rules.admin.RuleExecutionSetCreateException
+meth public abstract javax.rules.admin.RuleExecutionSet createRuleExecutionSet(java.lang.String,java.util.Map) throws java.io.IOException,java.rmi.RemoteException,javax.rules.admin.RuleExecutionSetCreateException
+meth public abstract javax.rules.admin.RuleExecutionSet createRuleExecutionSet(org.w3c.dom.Element,java.util.Map) throws java.rmi.RemoteException,javax.rules.admin.RuleExecutionSetCreateException
+supr null
+CLSS public javax.rules.admin.RuleExecutionSetRegisterException
+cons public RuleExecutionSetRegisterException(java.lang.String)
+cons public RuleExecutionSetRegisterException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.admin.RuleAdministrationException
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/jaxrules14.sig
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/jaxrules14.sig (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/jaxrules14.sig 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,446 @@
+#Signature file
+#Version 1.4.1_02
+CLSS public javax.rules.ConfigurationException
+cons public ConfigurationException(java.lang.String)
+cons public ConfigurationException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.RuleException
+CLSS public abstract interface javax.rules.Handle
+intf java.io.Serializable
+supr null
+CLSS public javax.rules.InvalidHandleException
+cons public InvalidHandleException(java.lang.String)
+cons public InvalidHandleException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.RuleExecutionException
+CLSS public javax.rules.InvalidRuleSessionException
+cons public InvalidRuleSessionException(java.lang.String)
+cons public InvalidRuleSessionException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.RuleExecutionException
+CLSS public abstract interface javax.rules.ObjectFilter
+intf java.io.Serializable
+meth public abstract java.lang.Object filter(java.lang.Object)
+meth public abstract void reset()
+supr null
+CLSS public javax.rules.RuleException
+cons public RuleException(java.lang.String)
+cons public RuleException(java.lang.String,java.lang.Throwable)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr java.lang.Exception
+CLSS public javax.rules.RuleExecutionException
+cons public RuleExecutionException(java.lang.String)
+cons public RuleExecutionException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.RuleException
+CLSS public abstract interface javax.rules.RuleExecutionSetMetadata
+intf java.io.Serializable
+meth public abstract java.lang.String getDescription()
+meth public abstract java.lang.String getName()
+meth public abstract java.lang.String getUri()
+supr null
+CLSS public javax.rules.RuleExecutionSetNotFoundException
+cons public RuleExecutionSetNotFoundException(java.lang.String)
+cons public RuleExecutionSetNotFoundException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.RuleExecutionException
+CLSS public abstract interface javax.rules.RuleRuntime
+fld public static final int STATEFUL_SESSION_TYPE
+fld public static final int STATELESS_SESSION_TYPE
+intf java.io.Serializable
+meth public abstract java.util.List getRegistrations() throws java.rmi.RemoteException
+meth public abstract javax.rules.RuleSession createRuleSession(java.lang.String,java.util.Map,int) throws java.rmi.RemoteException,javax.rules.RuleExecutionSetNotFoundException,javax.rules.RuleSessionCreateException,javax.rules.RuleSessionTypeUnsupportedException
+supr null
+CLSS public abstract javax.rules.RuleServiceProvider
+cons public RuleServiceProvider()
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected static java.lang.Object createInstance(java.lang.String) throws java.lang.ClassNotFoundException,java.lang.IllegalAccessException,java.lang.InstantiationException
+meth protected void finalize() throws java.lang.Throwable
+meth public abstract javax.rules.RuleRuntime getRuleRuntime() throws javax.rules.ConfigurationException
+meth public abstract javax.rules.admin.RuleAdministrator getRuleAdministrator() throws javax.rules.ConfigurationException
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String toString()
+meth public void setClassLoader(java.lang.ClassLoader)
+supr java.lang.Object
+CLSS public abstract javax.rules.RuleServiceProviderManager
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String toString()
+meth public static javax.rules.RuleServiceProvider getRuleServiceProvider(java.lang.String) throws javax.rules.ConfigurationException
+meth public static void deregisterRuleServiceProvider(java.lang.String)
+meth public static void registerRuleServiceProvider(java.lang.String,java.lang.Class) throws javax.rules.ConfigurationException
+meth public static void registerRuleServiceProvider(java.lang.String,java.lang.Class,java.lang.ClassLoader) throws javax.rules.ConfigurationException
+supr java.lang.Object
+CLSS public abstract interface javax.rules.RuleSession
+meth public abstract int getType() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract javax.rules.RuleExecutionSetMetadata getRuleExecutionSetMetadata() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract void release() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+supr null
+CLSS public javax.rules.RuleSessionCreateException
+cons public RuleSessionCreateException(java.lang.String)
+cons public RuleSessionCreateException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.RuleExecutionException
+CLSS public javax.rules.RuleSessionTypeUnsupportedException
+cons public RuleSessionTypeUnsupportedException(java.lang.String)
+cons public RuleSessionTypeUnsupportedException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.RuleExecutionException
+CLSS public abstract interface javax.rules.StatefulRuleSession
+intf java.io.Serializable
+intf javax.rules.RuleSession
+meth public abstract boolean containsObject(javax.rules.Handle) throws java.rmi.RemoteException,javax.rules.InvalidHandleException,javax.rules.InvalidRuleSessionException
+meth public abstract int getType() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract java.lang.Object getObject(javax.rules.Handle) throws java.rmi.RemoteException,javax.rules.InvalidHandleException,javax.rules.InvalidRuleSessionException
+meth public abstract java.util.List addObjects(java.util.List) throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract java.util.List getHandles() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract java.util.List getObjects() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract java.util.List getObjects(javax.rules.ObjectFilter) throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract javax.rules.Handle addObject(java.lang.Object) throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract javax.rules.RuleExecutionSetMetadata getRuleExecutionSetMetadata() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract void executeRules() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract void release() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract void removeObject(javax.rules.Handle) throws java.rmi.RemoteException,javax.rules.InvalidHandleException,javax.rules.InvalidRuleSessionException
+meth public abstract void reset() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract void updateObject(javax.rules.Handle,java.lang.Object) throws java.rmi.RemoteException,javax.rules.InvalidHandleException,javax.rules.InvalidRuleSessionException
+supr null
+CLSS public abstract interface javax.rules.StatelessRuleSession
+intf javax.rules.RuleSession
+meth public abstract int getType() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract java.util.List executeRules(java.util.List) throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract java.util.List executeRules(java.util.List,javax.rules.ObjectFilter) throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract javax.rules.RuleExecutionSetMetadata getRuleExecutionSetMetadata() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+meth public abstract void release() throws java.rmi.RemoteException,javax.rules.InvalidRuleSessionException
+supr null
+CLSS public abstract interface javax.rules.admin.LocalRuleExecutionSetProvider
+meth public abstract javax.rules.admin.RuleExecutionSet createRuleExecutionSet(java.io.InputStream,java.util.Map) throws java.io.IOException,javax.rules.admin.RuleExecutionSetCreateException
+meth public abstract javax.rules.admin.RuleExecutionSet createRuleExecutionSet(java.io.Reader,java.util.Map) throws java.io.IOException,javax.rules.admin.RuleExecutionSetCreateException
+meth public abstract javax.rules.admin.RuleExecutionSet createRuleExecutionSet(java.lang.Object,java.util.Map) throws javax.rules.admin.RuleExecutionSetCreateException
+supr null
+CLSS public abstract interface javax.rules.admin.Rule
+intf java.io.Serializable
+meth public abstract java.lang.Object getProperty(java.lang.Object)
+meth public abstract java.lang.String getDescription()
+meth public abstract java.lang.String getName()
+meth public abstract void setProperty(java.lang.Object,java.lang.Object)
+supr null
+CLSS public javax.rules.admin.RuleAdministrationException
+cons public RuleAdministrationException(java.lang.String)
+cons public RuleAdministrationException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.RuleException
+CLSS public abstract interface javax.rules.admin.RuleAdministrator
+meth public abstract javax.rules.admin.LocalRuleExecutionSetProvider getLocalRuleExecutionSetProvider(java.util.Map) throws java.rmi.RemoteException
+meth public abstract javax.rules.admin.RuleExecutionSetProvider getRuleExecutionSetProvider(java.util.Map) throws java.rmi.RemoteException
+meth public abstract void deregisterRuleExecutionSet(java.lang.String,java.util.Map) throws java.rmi.RemoteException,javax.rules.admin.RuleExecutionSetDeregistrationException
+meth public abstract void registerRuleExecutionSet(java.lang.String,javax.rules.admin.RuleExecutionSet,java.util.Map) throws java.rmi.RemoteException,javax.rules.admin.RuleExecutionSetRegisterException
+supr null
+CLSS public abstract interface javax.rules.admin.RuleExecutionSet
+intf java.io.Serializable
+meth public abstract java.lang.Object getProperty(java.lang.Object)
+meth public abstract java.lang.String getDefaultObjectFilter()
+meth public abstract java.lang.String getDescription()
+meth public abstract java.lang.String getName()
+meth public abstract java.util.List getRules()
+meth public abstract void setDefaultObjectFilter(java.lang.String)
+meth public abstract void setProperty(java.lang.Object,java.lang.Object)
+supr null
+CLSS public javax.rules.admin.RuleExecutionSetCreateException
+cons public RuleExecutionSetCreateException(java.lang.String)
+cons public RuleExecutionSetCreateException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.admin.RuleAdministrationException
+CLSS public javax.rules.admin.RuleExecutionSetDeregistrationException
+cons public RuleExecutionSetDeregistrationException(java.lang.String)
+cons public RuleExecutionSetDeregistrationException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.admin.RuleAdministrationException
+CLSS public abstract interface javax.rules.admin.RuleExecutionSetProvider
+meth public abstract javax.rules.admin.RuleExecutionSet createRuleExecutionSet(java.io.Serializable,java.util.Map) throws java.rmi.RemoteException,javax.rules.admin.RuleExecutionSetCreateException
+meth public abstract javax.rules.admin.RuleExecutionSet createRuleExecutionSet(java.lang.String,java.util.Map) throws java.io.IOException,java.rmi.RemoteException,javax.rules.admin.RuleExecutionSetCreateException
+meth public abstract javax.rules.admin.RuleExecutionSet createRuleExecutionSet(org.w3c.dom.Element,java.util.Map) throws java.rmi.RemoteException,javax.rules.admin.RuleExecutionSetCreateException
+supr null
+CLSS public javax.rules.admin.RuleExecutionSetRegisterException
+cons public RuleExecutionSetRegisterException(java.lang.String)
+cons public RuleExecutionSetRegisterException(java.lang.String,java.lang.Exception)
+fld protected java.lang.Throwable embeddedException
+intf java.io.Serializable
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public [Ljava.lang.StackTraceElement; getStackTrace()
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace([Ljava.lang.StackTraceElement;)
+supr javax.rules.admin.RuleAdministrationException
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/tck.conf
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/tck.conf (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/tck.conf 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<tck-configuration>
+ <test-factory>org.jcp.jsr94.tck.util.TestFactory</test-factory>
+
+ <rule-service-provider>org.drools.jsr94.rules.RuleServiceProviderImpl</rule-service-provider>
+ <rule-service-provider-jar-url>file://c:/dev/jbossrules/trunk/drools-jsr94/target/drools-jsr94.jar</rule-service-provider-jar-url>
+ <rule-execution-set-location>/dev/jbossrules/trunk/drools-jsr94/target/test-classes/org/jcp/jsr94/tck</rule-execution-set-location>
+</tck-configuration>
+
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/tck_res_1.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/tck_res_1.xml (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/tck_res_1.xml 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,15 @@
+package RuleExecutionSet1;
+
+import org.jcp.jsr94.tck.model.Customer;
+import org.jcp.jsr94.tck.model.Invoice;
+
+rule "credit limit greater than invoice"
+ when
+ $invoice1 : Invoice ( $amount1 : amount )
+ $customer1 : Customer ( creditLimit > $amount1 )
+ then
+ $customer1.setCreditLimit($customer1.getCreditLimit() - $invoice1.getAmount());
+ $invoice1.setStatus("paid");
+ System.out.println("The credit limit of the customer is " + $customer1.getCreditLimit());
+ System.out.println("The status of the invoice is " + $invoice1.getStatus());
+end
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/tck_res_2.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/tck_res_2.xml (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-jsr94/src/test/resources/org/jcp/jsr94/tck/tck_res_2.xml 2011-02-24 17:25:58 UTC (rev 36708)
@@ -0,0 +1,15 @@
+package RuleExecutionSet1;
+
+import org.jcp.jsr94.tck.model.Customer;
+import org.jcp.jsr94.tck.model.Invoice;
+
+rule "credit limit greater than invoice"
+ when
+ $invoice1 : Invoice ( $amount1 : amount )
+ $customer1 : Customer ( creditLimit > $amount1 )
+ then
+ $customer1.setCreditLimit($customer1.getCreditLimit() - $invoice1.getAmount());
+ $invoice1.setStatus("paid");
+ System.out.println("The credit limit of the customer is " + $customer1.getCreditLimit());
+ System.out.println("The status of the invoice is " + $invoice1.getStatus());
+end
\ No newline at end of file
More information about the jboss-svn-commits
mailing list