From dedb06d3e4fbb7b1c40331a84abb0a49d298c6a4 Mon Sep 17 00:00:00 2001 From: Wim Verreydt Date: Wed, 27 Mar 2013 10:32:47 +0100 Subject: [PATCH] add camel-drools example --- .../src/main/filtered-resources/features.xml | 5 + examples/camel/camel-drools/README.txt | 219 ++++++++++++++++++ examples/camel/camel-drools/pom.xml | 109 +++++++++ .../servicemix/examples/camel/Drinks.java | 38 +++ .../examples/camel/DroolsCommandHelper.java | 49 ++++ .../servicemix/examples/camel/Person.java | 122 ++++++++++ .../examples/camel/PersonHelper.java | 44 ++++ .../apache/servicemix/examples/camel/Sex.java | 22 ++ .../META-INF/spring/camel-context.xml | 111 +++++++++ .../src/main/resources/log4j.properties | 35 +++ .../src/main/resources/testSpring.drl | 98 ++++++++ examples/camel/pom.xml | 1 + pom.xml | 7 +- 13 files changed, 854 insertions(+), 6 deletions(-) create mode 100644 examples/camel/camel-drools/README.txt create mode 100644 examples/camel/camel-drools/pom.xml create mode 100644 examples/camel/camel-drools/src/main/java/org/apache/servicemix/examples/camel/Drinks.java create mode 100644 examples/camel/camel-drools/src/main/java/org/apache/servicemix/examples/camel/DroolsCommandHelper.java create mode 100644 examples/camel/camel-drools/src/main/java/org/apache/servicemix/examples/camel/Person.java create mode 100644 examples/camel/camel-drools/src/main/java/org/apache/servicemix/examples/camel/PersonHelper.java create mode 100644 examples/camel/camel-drools/src/main/java/org/apache/servicemix/examples/camel/Sex.java create mode 100644 examples/camel/camel-drools/src/main/resources/META-INF/spring/camel-context.xml create mode 100644 examples/camel/camel-drools/src/main/resources/log4j.properties create mode 100644 examples/camel/camel-drools/src/main/resources/testSpring.drl diff --git a/assemblies/apache-servicemix/src/main/filtered-resources/features.xml b/assemblies/apache-servicemix/src/main/filtered-resources/features.xml index c5bfbbd..b09e73a 100644 --- a/assemblies/apache-servicemix/src/main/filtered-resources/features.xml +++ b/assemblies/apache-servicemix/src/main/filtered-resources/features.xml @@ -80,6 +80,11 @@ camel-blueprint mvn:org.apache.servicemix.examples/camel-blueprint/${version} + + camel-jms + mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.drools/${drools.bundle.version} + mvn:org.apache.servicemix.examples/camel-drools/${version} + cxf mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jbi-api-1.0/${servicemix.specs.version} diff --git a/examples/camel/camel-drools/README.txt b/examples/camel/camel-drools/README.txt new file mode 100644 index 0000000..69b2311 --- /dev/null +++ b/examples/camel/camel-drools/README.txt @@ -0,0 +1,219 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +CAMEL DROOLS EXAMPLE +==================== + +Purpose +------- +Deploys a Camel route which allows a Drools rules file to evaluate messages +and deliver each of them to a appropriate destination. + + +Explanation +----------- +The Camel route is defined in a Spring XML file, camel-context.xml, which can be +found in the src/main/resources/META-INF/spring directory of this example. +The route is defined in the element and can be explained as follows: + +1. A timer endpoint generates a person every second + +2. A the Person object is send to a Drools grid-node which is connected to the Drools knowledge base + +3. After the object is evaluated, It's Vip-property is inspected + +4. Based on this value, one of the two log-messages is chosen to display the result. + +The camel-context.xml file also contains the following elements: + +- A element as a reference to the Drools ruleset. + +- A element for the configuration of the knowledge base and the link to the DRL-rules file + +- A element which creates a session for the Drools evaluation + +- A personHelper bean to generate random Person objects + +- the Drools camel component bean for our camel route. + +- An illustrative definition of a route which shows an + example of passing (inserting) the Body of the message as a + POJO to Drools for execution. + +- An illustrative definition of a route which shows an example + of creating a Drools Command wrapping the Body of the message + with the help of the custom DroolsCommandHelperBean (included + in this project), and passing this Drools Command to the + ruleset for execution. + +The route and configuration are deployed in an OSGi bundle. + + + +Embedded rules +--------------- +rule "humans need water" + Every person gets water + +rule "boys go for Cola Zero" + Males older than 8 get Cola Zero + +rule "girls go for Cola Light" + Girls older than 8 get Cola Light + +rule "can you drink?" + A person older than 21 can drink alcohol + +rule "woman go for wine" + Woman who are allowed to drink, take wine + +rule "men go for beer" + Men who are allowed to drink, take beer + +rule "Vip in the house!" + Rich people are VIPs + +rule "Vip woman drink bubbles" + Female VIPs drink champagne + +rule "Vip men drink scotch" + Male VIPs drink scotch + + + +Prerequisites for Running the Example +------------------------------------- +1. You must have the following installed on your machine: + + - JDK 1.6 or higher + + - Maven 2.2.1 or higher (for building) + + For more information, see the README in the top-level examples + directory. + +2. Start ServiceMix by running the following command: + + /bin/servicemix (on UNIX) + \bin\servicemix (on Windows) + + +Running the Example +------------------- +You can run the example in two ways: + +- A. Using a Prebuilt Deployment Bundle: Quick and Easy + This option is useful if you want to see the example up and + running quickly. + +- B. Building the Example Bundle Yourself + This option is useful if you want to change the example in any way. + It tells you how to build and deploy the example. This option might + be slower than option A because, if you do not already have the + required bundles in your local Maven repository, Maven will have to + download the bundles it needs. + + +A. Using a Prebuilt Deployment Bundle: Quick and Easy +----------------------------------------------------- +To install and run a prebuilt version of this example, enter the +following command in the ServiceMix console: + + features:install examples-camel-drools + +This command makes use of the ServiceMix features facility. For more +information about the features facility, see the README.txt file in the +examples parent directory. + +Once the example is running, periodic events trigger the generation of +a Person object and his evaluation. An object can either end up in the +VIP log message or in a regular log message + +>>>> | ServeDrink | ... | Serve this old man a pint of beer +>>>> | ServeDrink VIP | ... | This old rich woman is a VIP! Give a bottle of champagne from the house + + +B. Building the Example Bundle Yourself +--------------------------------------- +To install and run the example where you build the example bundle +yourself, complete the following steps: + +1. If you have already run the example using the prebuilt version as + described above, you must first uninstall the examples-camel-drools + feature by entering the following command in the ServiceMix console: + + features:uninstall examples-camel-drools + +2. Build the example by opening a command prompt, changing directory to + examples/camel/camel-drools (this example) and entering the following Maven + command: + + mvn install + + If all of the required OSGi bundles are available in your local Maven + repository, the example will build very quickly. Otherwise it may + take some time for Maven to download everything it needs. + + The mvn install command builds the example deployment bundle and + copies it to your local Maven repository and to the target directory + of this example. + +3. Install the example by entering the following command in + the ServiceMix console: + + features:install examples-camel-drools + + It makes use of the ServiceMix features facility. For more information + about the features facility, see the README.txt file in the examples + parent directory. + +Once the example is running, periodic events trigger the generation of +a Person object and his evaluation. An object can either end up in the +VIP log message or in a regular log message + +>>>> | ServeDrink | ... | Serve this old man a pint of beer +>>>> | ServeDrink VIP | ... | This old rich woman is a VIP! Give a bottle of champagne from the house + + +Stopping and Uninstalling the Example +------------------------------------- +To stop the example, enter the following command in the ServiceMix +console: + + osgi:stop + +For information on how to find the bundle_id assigned to the example, +see step 3 in the "Updating and Redeploying the Properties File +from the Console" section above. + +To uninstall the example, enter one of the following commands in +the ServiceMix console: + + features:uninstall examples-camel-drools + +or + + osgi:uninstall + + +Viewing the Log Entries +----------------------- +You can view the entries in the log file in the data/log +directory of your ServiceMix installation, or by typing +the following command in the ServiceMix console: + + log:display \ No newline at end of file diff --git a/examples/camel/camel-drools/pom.xml b/examples/camel/camel-drools/pom.xml new file mode 100644 index 0000000..48179f6 --- /dev/null +++ b/examples/camel/camel-drools/pom.xml @@ -0,0 +1,109 @@ + + + + + + 4.0.0 + + + org.apache.servicemix.examples + camel-examples + 5.0.0-SNAPSHOT + + + camel-drools + bundle + Apache ServiceMix :: Examples :: Camel Drools + Camel Example using Drools + + + + + org.apache.felix + maven-bundle-plugin + true + + + *;resolution:=optional + org.apache.servicemix.examples.camel + + + + + + + + + org.apache.camel + camel-core + + + org.drools + drools-core + ${drools.version} + + + org.drools + drools-spring + ${drools.version} + + + spring-core + org.springframework + + + spring-beans + org.springframework + + + spring-context + org.springframework + + + + + org.drools + drools-camel + ${drools.version} + + + spring-core + org.springframework + + + spring-aop + org.springframework + + + cxf-rt-frontend-jaxws + org.apache.cxf + + + camel-cxf + org.apache.camel + + + org.apache.camel + camel-test + + + + + + + diff --git a/examples/camel/camel-drools/src/main/java/org/apache/servicemix/examples/camel/Drinks.java b/examples/camel/camel-drools/src/main/java/org/apache/servicemix/examples/camel/Drinks.java new file mode 100644 index 0000000..482a109 --- /dev/null +++ b/examples/camel/camel-drools/src/main/java/org/apache/servicemix/examples/camel/Drinks.java @@ -0,0 +1,38 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.servicemix.examples.camel; + +public enum Drinks { + WATER("glass of water"), + COLA_ZERO("bottle of Cola Zero"), + COLA_LIGHT("bottle of Cola Light with a straw"), + WINE("glass of wine"), + BEER("pint of beer"), + SCOTCH("good old scotch"), + CHAMPAGNE("bottle of champagne"); + + private String description; + + private Drinks(String description) { + this.description = description; + } + + public String getDescription() { + return description; + } +} + diff --git a/examples/camel/camel-drools/src/main/java/org/apache/servicemix/examples/camel/DroolsCommandHelper.java b/examples/camel/camel-drools/src/main/java/org/apache/servicemix/examples/camel/DroolsCommandHelper.java new file mode 100644 index 0000000..f261444 --- /dev/null +++ b/examples/camel/camel-drools/src/main/java/org/apache/servicemix/examples/camel/DroolsCommandHelper.java @@ -0,0 +1,49 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.servicemix.examples.camel; + +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.drools.command.impl.GenericCommand; +import org.drools.command.runtime.BatchExecutionCommandImpl; +import org.drools.command.runtime.rule.FireAllRulesCommand; +import org.drools.command.runtime.rule.InsertObjectCommand; + +import java.util.List; + +/** + * Class to help create wrapper Drools Expert Command for use with + * org.drools/drools-camel component. + */ +public class DroolsCommandHelper { + public void insertAndFireAll(Exchange exchange) { + final Message in = exchange.getIn(); + final Object body = in.getBody(); + + // TODO: add type checking to handle arrays of objects + + BatchExecutionCommandImpl command = new BatchExecutionCommandImpl(); + final List> commands = command.getCommands(); + commands.add(new InsertObjectCommand(body, "obj1")); + commands.add(new FireAllRulesCommand()); + + in.setBody(command); + } + + // TODO: add other command handler methods (e.g. getGlobalObject, etc.) +} diff --git a/examples/camel/camel-drools/src/main/java/org/apache/servicemix/examples/camel/Person.java b/examples/camel/camel-drools/src/main/java/org/apache/servicemix/examples/camel/Person.java new file mode 100644 index 0000000..1613af8 --- /dev/null +++ b/examples/camel/camel-drools/src/main/java/org/apache/servicemix/examples/camel/Person.java @@ -0,0 +1,122 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.servicemix.examples.camel; + +import java.lang.Override; +import java.lang.String; +import java.lang.StringBuilder; +import org.drools.definition.type.PropertyReactive; + +@PropertyReactive +public class Person { + private int age; + private boolean canDrink = false; + private Sex sex; + private int income; + private boolean isVip = false; + private Drinks drink; + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public int getIncome() { + return income; + } + + public void setIncome(int income) { + this.income = income; + } + + public Sex getSex() { + return sex; + } + + public void setSex(Sex sex) { + this.sex = sex; + } + + public boolean isCanDrink() { + return canDrink; + } + + public void setCanDrink(boolean canDrink) { + this.canDrink = canDrink; + } + + public boolean isVip() { + return isVip; + } + + public void setVip(boolean vip) { + isVip = vip; + } + + public Drinks getDrink() { + return drink; + } + + public void setDrink(Drinks drink) { + this.drink = drink; + } + + public boolean isRich(){ + return getIncome() >= 80000; + } + + public String getName() { + StringBuilder name = new StringBuilder(); + + // Age + if (getAge()>=21){ + name.append("old"); + }else{ + name.append("young"); + } + + //Income + if (isRich()){ + name.append(" rich"); + } + + //Sex + if (getSex() == Sex.MALE){ + name.append(" man"); + }else{ + name.append(" woman"); + } + + return name.toString(); + } + + @Override + public String toString() { + return "Person{" + + "age=" + age + + ", canDrink=" + canDrink + + ", sex=" + sex + + ", income=" + getIncome() + + ", isRich=" + isRich() + + ", isVip=" + isVip + + ", drink=" + drink + + '}'; + } +} diff --git a/examples/camel/camel-drools/src/main/java/org/apache/servicemix/examples/camel/PersonHelper.java b/examples/camel/camel-drools/src/main/java/org/apache/servicemix/examples/camel/PersonHelper.java new file mode 100644 index 0000000..7292f0f --- /dev/null +++ b/examples/camel/camel-drools/src/main/java/org/apache/servicemix/examples/camel/PersonHelper.java @@ -0,0 +1,44 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.servicemix.examples.camel; + +import java.util.Random; + +public class PersonHelper { + private final Random random = new Random(); + + public Person createTestPerson() { + Person person = new Person(); + + // Age + person.setAge(random.nextInt(70)); + + // Sex + if (random.nextBoolean()) { + person.setSex(Sex.MALE); + } else { + person.setSex(Sex.FEMALE); + } + + // Income + person.setIncome(random.nextInt(100000)); + + return person; + } + +} diff --git a/examples/camel/camel-drools/src/main/java/org/apache/servicemix/examples/camel/Sex.java b/examples/camel/camel-drools/src/main/java/org/apache/servicemix/examples/camel/Sex.java new file mode 100644 index 0000000..d8a5aef --- /dev/null +++ b/examples/camel/camel-drools/src/main/java/org/apache/servicemix/examples/camel/Sex.java @@ -0,0 +1,22 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.servicemix.examples.camel; + +public enum Sex { + MALE, FEMALE +} \ No newline at end of file diff --git a/examples/camel/camel-drools/src/main/resources/META-INF/spring/camel-context.xml b/examples/camel/camel-drools/src/main/resources/META-INF/spring/camel-context.xml new file mode 100644 index 0000000..c72cc3a --- /dev/null +++ b/examples/camel/camel-drools/src/main/resources/META-INF/spring/camel-context.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Example route that will regularly create a random Person and choose an appropriate drink based on the + drools rules file. After processing, it divides the people into VIPs and regular clients based on the + drools result. + + + + + valid 'action' values are: + 'execute' that takes a 'Command' object (default) + 'insertBody' that inserts the Exchange.in.body, and executes rules + 'insertMessage' that inserts the Exchange.in (type org.apache.camel.Message), and executes rules + 'insertExchange' that inserts the Exchange (type org.apache.camel.Exchange), and executes rules + + + + + ${body.isVip} + + + + + + + + + This route shows an example of passing (inserting) the Body of the message as a POJO to Drools + for execution + + + + valid 'action' values are: + 'execute' that takes a 'Command' object (default) + 'insertBody' that inserts the Exchange.in.body, and executes rules + 'insertMessage' that inserts the Exchange.in (type org.apache.camel.Message), and executes rules + 'insertExchange' that inserts the Exchange (type org.apache.camel.Exchange), and executes rules + + + + + This route shows an example of creating a Drools Command wrapping the Body of the message with + the help of the custom DroolsCommandHelperBean (included in this project), and passing this Drools + Command to the ruleset for execution. + + + + + valid 'action' values are: + 'execute' that takes a 'Command' object (default) + 'insertBody' that inserts the Exchange.in.body, and executes rules + 'insertMessage' that inserts the Exchange.in (type org.apache.camel.Message), and executes rules + 'insertExchange' that inserts the Exchange (type org.apache.camel.Exchange), and executes rules + + + + + + diff --git a/examples/camel/camel-drools/src/main/resources/log4j.properties b/examples/camel/camel-drools/src/main/resources/log4j.properties new file mode 100644 index 0000000..454d345 --- /dev/null +++ b/examples/camel/camel-drools/src/main/resources/log4j.properties @@ -0,0 +1,35 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. +# + +# +# The logging properties used +# +log4j.rootLogger=INFO, out + +# uncomment the following line to turn on Camel debugging +#log4j.logger.org.apache.camel=DEBUG + +log4j.logger.org.springframework=WARN + + +# CONSOLE appender not used by default +log4j.appender.out=org.apache.log4j.ConsoleAppender +log4j.appender.out.layout=org.apache.log4j.PatternLayout +log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n +#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n + +log4j.throwableRenderer=org.apache.log4j.EnhancedThrowableRenderer diff --git a/examples/camel/camel-drools/src/main/resources/testSpring.drl b/examples/camel/camel-drools/src/main/resources/testSpring.drl new file mode 100644 index 0000000..61579c2 --- /dev/null +++ b/examples/camel/camel-drools/src/main/resources/testSpring.drl @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.servicemix.examples.camel; + +import org.apache.servicemix.examples.camel.Person; +import org.apache.servicemix.examples.camel.Sex; +import org.apache.servicemix.examples.camel.Drinks; + + +# no alcohol + +rule "humans need water" +salience 2 +when + p : Person() +then + modify(p) {setDrink(Drinks.WATER)}; +end + +rule "boys go for Cola Zero" +salience 1 +when + p : Person(age >= 8 && sex == Sex.MALE) +then + modify(p) {setDrink(Drinks.COLA_ZERO)}; +end + +rule "girls go for Cola Light" +salience 1 +when + p : Person(age >= 8 && sex == Sex.FEMALE) +then + modify(p) {setDrink(Drinks.COLA_LIGHT)}; +end + + +#alcohol + +rule "can you drink?" +when + p : Person( age >= 21 && !canDrink) +then + modify(p) {setCanDrink(true)}; +end + +rule "woman go for wine" +when + p : Person(sex == Sex.FEMALE && canDrink ) +then + modify(p) {setDrink(Drinks.WINE)}; +end + +rule "men go for beer" +when + p : Person(sex == Sex.MALE && canDrink ) +then + modify(p) {setDrink(Drinks.BEER)}; +end + + +# VIP + +rule "Vip in the house!" +salience -1 +when + p : Person( rich && !Vip) +then + modify(p) {setVip(true)}; +end + +rule "Vip woman drink bubbles" +when + p : Person(Vip && sex == Sex.FEMALE && canDrink) +then + modify(p) {setDrink(Drinks.CHAMPAGNE)}; +end + +rule "Vip men drink Scotch" +when + p : Person(Vip && sex == Sex.MALE && canDrink) +then + modify(p) {setDrink(Drinks.SCOTCH)}; +end \ No newline at end of file diff --git a/examples/camel/pom.xml b/examples/camel/pom.xml index cfbbbff..f2d5dee 100644 --- a/examples/camel/pom.xml +++ b/examples/camel/pom.xml @@ -35,6 +35,7 @@ camel-blueprint camel-osgi + camel-drools diff --git a/pom.xml b/pom.xml index d5ab4fc..b24e204 100644 --- a/pom.xml +++ b/pom.xml @@ -165,7 +165,7 @@ 2.4 1.0_5 1.6.1_5 - ${drools.version} + ${drools.version}_1-SNAPSHOT 1.2.7_3 1.9.0_1 2.2 @@ -383,11 +383,6 @@ org.apache.servicemix.bundles.commons-vfs ${commons-vfs.bundle.version} - - org.apache.servicemix.bundles - org.apache.servicemix.bundles.drools - ${drools.bundle.version} - org.apache.servicemix.bundles org.apache.servicemix.bundles.fastinfoset