You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ge...@apache.org on 2008/12/09 11:10:37 UTC
svn commit: r724655 - in
/servicemix/components/engines/servicemix-drools/trunk/src:
main/java/org/apache/servicemix/drools/
main/java/org/apache/servicemix/drools/model/
test/java/org/apache/servicemix/drools/ test/resources/
Author: gertv
Date: Tue Dec 9 02:10:33 2008
New Revision: 724655
URL: http://svn.apache.org/viewvc?rev=724655&view=rev
Log:
SM-1683: Allow setting XML attributes in servicemix-drools + provide auto-reply for handling unanswered exchanges
Added:
servicemix/components/engines/servicemix-drools/trunk/src/test/java/org/apache/servicemix/drools/DroolsAutoReplyEndpointTest.java (with props)
servicemix/components/engines/servicemix-drools/trunk/src/test/resources/AutoReply.drl
servicemix/components/engines/servicemix-drools/trunk/src/test/resources/XPathAttrMod-StringValue.drl
servicemix/components/engines/servicemix-drools/trunk/src/test/resources/XPathAttrMod-XPathAttr.drl
Modified:
servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/DroolsComponent.java
servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/DroolsEndpoint.java
servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/DroolsExecutionContext.java
servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/model/Exchange.java
servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/model/Message.java
servicemix/components/engines/servicemix-drools/trunk/src/test/java/org/apache/servicemix/drools/DroolsComponentTest.java
Modified: servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/DroolsComponent.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/DroolsComponent.java?rev=724655&r1=724654&r2=724655&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/DroolsComponent.java (original)
+++ servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/DroolsComponent.java Tue Dec 9 02:10:33 2008
@@ -40,7 +40,7 @@
}
protected Class[] getEndpointClasses() {
- return new Class[] {DroolsEndpoint.class };
+ return new Class[] {DroolsEndpoint.class};
}
/**
Modified: servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/DroolsEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/DroolsEndpoint.java?rev=724655&r1=724654&r2=724655&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/DroolsEndpoint.java (original)
+++ servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/DroolsEndpoint.java Tue Dec 9 02:10:33 2008
@@ -27,9 +27,13 @@
import javax.jbi.JBIException;
import javax.jbi.management.DeploymentException;
import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.Fault;
import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.InOptionalOut;
+import javax.jbi.messaging.InOut;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
import javax.jbi.messaging.MessageExchange.Role;
import javax.jbi.servicedesc.ServiceEndpoint;
import javax.xml.namespace.NamespaceContext;
@@ -40,6 +44,7 @@
import org.apache.servicemix.common.ServiceUnit;
import org.apache.servicemix.common.endpoints.ProviderEndpoint;
import org.apache.servicemix.common.util.MessageUtil;
+import org.apache.servicemix.drools.model.Exchange;
import org.drools.RuleBase;
import org.drools.compiler.RuleBaseLoader;
import org.springframework.core.io.Resource;
@@ -60,6 +65,7 @@
private String defaultTargetURI;
private Map<String, Object> globals;
private List<Object> assertedObjects;
+ private boolean autoReply;
@SuppressWarnings("serial")
private ConcurrentMap<String, DroolsExecutionContext> pending = new ConcurrentHashMap<String, DroolsExecutionContext>() {
@@ -155,6 +161,25 @@
public void setGlobals(Map<String, Object> variables) {
this.globals = variables;
}
+
+ /**
+ * Will this endpoint automatically reply to any exchanges not handled by the Drools rulebase?
+ *
+ * @return <code>true</code> if the endpoint replies to any unanswered exchanges
+ */
+ public boolean isAutoReply() {
+ return autoReply;
+ }
+
+ /**
+ * Set auto-reply to <code>true</code> to ensure that every exchange is being replied to.
+ * This way, you can avoid having to end every Drools rule with jbi.answer()
+ *
+ * @param autoReply <code>true</code> for auto-replying on incoming exchanges
+ */
+ public void setAutoReply(boolean autoReply) {
+ this.autoReply = autoReply;
+ }
public void validate() throws DeploymentException {
super.validate();
@@ -234,7 +259,7 @@
drools(exchange);
} else {
//must be a DONE/ERROR so removing any pending contexts
- DroolsExecutionContext drools = pending.remove(exchange.getExchangeId());
+ pending.remove(exchange.getExchangeId());
}
}
@@ -248,7 +273,22 @@
}
protected void drools(MessageExchange exchange) throws Exception {
- DroolsExecutionContext drools = startDroolsExecutionContext(exchange);
+ DroolsExecutionContext drools1 = startDroolsExecutionContext(exchange);
+ if (drools1.getRulesFired() < 1) {
+ fail(exchange, new Exception("No rules have handled the exchange. Check your rule base."));
+ } else {
+ //the exchange has been answered or faulted by the drools endpoint
+ if (drools1.isExchangeHandled() && exchange instanceof InOnly) {
+ //only removing InOnly
+ pending.remove(exchange.getExchangeId());
+ }
+ if (!drools1.isExchangeHandled() && autoReply) {
+ reply(exchange, drools1);
+ }
+ }
+ }
+
+ protected void drools(MessageExchange exchange, DroolsExecutionContext drools) throws Exception {
if (drools.getRulesFired() < 1) {
fail(exchange, new Exception("No rules have handled the exchange. Check your rule base."));
} else {
@@ -257,9 +297,33 @@
//only removing InOnly
pending.remove(exchange.getExchangeId());
}
+ if (!drools.isExchangeHandled() && autoReply) {
+ reply(exchange, drools);
+ }
}
}
+ private void reply(MessageExchange exchange, DroolsExecutionContext drools) throws Exception {
+ Fault fault = exchange.getFault();
+ if (fault != null) {
+ drools.getHelper().fault(fault.getContent());
+ } else if (isOutCapable(exchange)) {
+ NormalizedMessage message = exchange.getMessage(Exchange.OUT_MESSAGE);
+ if (message == null) {
+ // send back the 'in' message if no 'out' message is available
+ message = exchange.getMessage(Exchange.IN_MESSAGE);
+ }
+ drools.getHelper().answer(message.getContent());
+ } else if (exchange instanceof InOnly) {
+ // just send back the done
+ done(exchange);
+ }
+ }
+
+ private boolean isOutCapable(MessageExchange exchange) {
+ return exchange instanceof InOptionalOut || exchange instanceof InOut;
+ }
+
private DroolsExecutionContext startDroolsExecutionContext(MessageExchange exchange) {
DroolsExecutionContext drools = new DroolsExecutionContext(this, exchange);
pending.put(exchange.getExchangeId(), drools);
Modified: servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/DroolsExecutionContext.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/DroolsExecutionContext.java?rev=724655&r1=724654&r2=724655&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/DroolsExecutionContext.java (original)
+++ servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/DroolsExecutionContext.java Tue Dec 9 02:10:33 2008
@@ -36,8 +36,10 @@
private int rulesFired;
private MessageExchange exchange;
+ public static final String JBI_HELPER_KEY = "jbi";
+
/**
- * Start a new execution for the specified exchange.
+ * Start a new execution context for the specified exchange.
*
* This will create and fill {@link WorkingMemory} and register listeners on it to keep track of things.
*
@@ -54,7 +56,7 @@
}
private void populateWorkingMemory(DroolsEndpoint endpoint) {
- memory.setGlobal("jbi", helper);
+ memory.setGlobal(JBI_HELPER_KEY, helper);
if (endpoint.getAssertedObjects() != null) {
for (Object o : endpoint.getAssertedObjects()) {
memory.insert(o);
@@ -117,4 +119,11 @@
public void activationCreated(ActivationCreatedEvent event, WorkingMemory workingMemory) {
rulesFired++;
}
+
+ /**
+ * Access the JbiHelper object that is being exposed to the .drl file
+ */
+ public JbiHelper getHelper() {
+ return helper;
+ }
}
Modified: servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/model/Exchange.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/model/Exchange.java?rev=724655&r1=724654&r2=724655&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/model/Exchange.java (original)
+++ servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/model/Exchange.java Tue Dec 9 02:10:33 2008
@@ -36,6 +36,9 @@
public static final String ERROR = "Error";
public static final String DONE = "Done";
+ public static final String IN_MESSAGE = "in";
+ public static final String OUT_MESSAGE = "out";
+
private final MessageExchange exchange;
private Message in;
private Message out;
Modified: servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/model/Message.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/model/Message.java?rev=724655&r1=724654&r2=724655&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/model/Message.java (original)
+++ servicemix/components/engines/servicemix-drools/trunk/src/main/java/org/apache/servicemix/drools/model/Message.java Tue Dec 9 02:10:33 2008
@@ -20,8 +20,14 @@
import javax.xml.namespace.NamespaceContext;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+import org.w3c.dom.DOMException;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
import org.apache.servicemix.expression.JAXPBooleanXPathExpression;
import org.apache.servicemix.expression.JAXPStringXPathExpression;
@@ -83,5 +89,32 @@
public Element getContent() {
return (Element) ((DOMSource) message.getContent()).getNode();
}
+
+ public Object getXPath(String path) throws XPathExpressionException {
+ Element msgXML = getContent();
+ if(msgXML!=null) {
+ XPath xpath = XPathFactory.newInstance().newXPath();
+ Node value = (Node) xpath.evaluate(path, getContent(), XPathConstants.NODE);
+ if(value == null || value.getNodeType() != Node.ATTRIBUTE_NODE) {
+ throw new DOMException(DOMException.NOT_FOUND_ERR, "Attribute not found in message with XPath: " + path);
+ }
+ return value.getNodeValue();
+ } else {
+ return null;
+ }
+ }
+
+ public void setXPath(String path, Object value) throws XPathExpressionException {
+ Element msgXML = getContent();
+ if(msgXML!=null) {
+ XPath xpath = XPathFactory.newInstance().newXPath();
+ Node node = (Node) xpath.evaluate(path, getContent(), XPathConstants.NODE);
+ if (node == null || node.getNodeType() != Node.ATTRIBUTE_NODE) {
+ throw new DOMException(DOMException.NOT_FOUND_ERR, "Attribute not found in message with xpath: "+ path);
+ } else {
+ node.setNodeValue(value.toString());
+ }
+ }
+ }
}
Added: servicemix/components/engines/servicemix-drools/trunk/src/test/java/org/apache/servicemix/drools/DroolsAutoReplyEndpointTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-drools/trunk/src/test/java/org/apache/servicemix/drools/DroolsAutoReplyEndpointTest.java?rev=724655&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-drools/trunk/src/test/java/org/apache/servicemix/drools/DroolsAutoReplyEndpointTest.java (added)
+++ servicemix/components/engines/servicemix-drools/trunk/src/test/java/org/apache/servicemix/drools/DroolsAutoReplyEndpointTest.java Tue Dec 9 02:10:33 2008
@@ -0,0 +1,153 @@
+/*
+ * 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.drools;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.client.ServiceMixClient;
+import org.apache.servicemix.common.JbiConstants;
+import org.apache.servicemix.drools.model.Exchange;
+import org.apache.servicemix.expression.JAXPStringXPathExpression;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.tck.ReceiverComponent;
+import org.springframework.core.io.ClassPathResource;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for {@link DroolsEndpoint} configured with auto-reply set to <code>true</code>
+ */
+public class DroolsAutoReplyEndpointTest extends TestCase {
+
+ private JBIContainer jbi;
+ private DroolsComponent drools;
+ private ServiceMixClient client;
+ private final SourceTransformer transformer = new SourceTransformer();
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ jbi = new JBIContainer();
+ jbi.setEmbedded(true);
+ jbi.init();
+ client = new DefaultServiceMixClient(jbi);
+ drools = new DroolsComponent();
+ }
+
+ protected void tearDown() throws Exception {
+ jbi.shutDown();
+ }
+
+ public void testAutoReply() throws Exception {
+ DroolsEndpoint endpoint = new DroolsEndpoint(drools.getServiceUnit(),
+ new QName("smx", "drools"), "endpoint");
+ endpoint.setRuleBaseResource(new ClassPathResource("AutoReply.drl"));
+ endpoint.setAutoReply(true);
+
+ drools.setEndpoints(new DroolsEndpoint[] {endpoint});
+ jbi.activateComponent(drools, "servicemix-drools");
+
+ jbi.start();
+
+ InOut me = client.createInOutExchange();
+ me.setService(new QName("smx", "drools"));
+ me.setOperation(new QName("smx", "process"));
+ String inMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><test/>";
+ String outMessage = "Never Initialized";
+ me.getInMessage().setContent(new StringSource(inMessage));
+ if (client.sendSync(me,10000)) {
+ outMessage = transformer.toString(me.getOutMessage().getContent());
+ assertEquals(inMessage, outMessage);
+ } else {
+ fail ("No response from drools in time...");
+ }
+
+ client.done(me);
+
+ Thread.sleep(50);
+ }
+
+ public void testModifyXMLWithAValue() throws Exception {
+ DroolsEndpoint endpoint = new DroolsEndpoint(drools.getServiceUnit(),
+ new QName("smx", "drools"), "endpoint");
+ endpoint.setRuleBaseResource(new ClassPathResource("XPathAttrMod-StringValue.drl"));
+ endpoint.setAutoReply(true);
+
+ drools.setEndpoints(new DroolsEndpoint[] {endpoint});
+ jbi.activateComponent(drools, "servicemix-drools");
+
+ ReceiverComponent target = new ReceiverComponent();
+ target.setService(new QName("smx", "target"));
+ target.setEndpoint("endpoint");
+
+ jbi.activateComponent(target, "target");
+
+ jbi.start();
+
+ InOut me = client.createInOutExchange();
+ me.setService(new QName("smx", "drools"));
+ me.setOperation(new QName("smx", "process"));
+ me.getInMessage().setContent(new StringSource("<test id=\"1234\" />"));
+ me.setProperty(JbiConstants.CORRELATION_ID, "TEST");
+ if (client.sendSync(me, 10000)) {
+ assertEquals(ExchangeStatus.ACTIVE, me.getStatus());
+ String id = (String)(new JAXPStringXPathExpression("/test/@id")
+ .evaluate(null, me.getMessage(Exchange.OUT_MESSAGE)));
+ assertEquals("0",id);
+ client.done(me);
+ } else {
+ fail ("No response from drools in time...");
+ }
+ }
+
+ public void testModifyXMLWithAnAttribute() throws Exception {
+ DroolsEndpoint endpoint = new DroolsEndpoint(drools.getServiceUnit(),
+ new QName("smx", "drools"), "endpoint");
+ endpoint.setRuleBaseResource(new ClassPathResource("XPathAttrMod-XPathAttr.drl"));
+ endpoint.setAutoReply(true);
+
+ drools.setEndpoints(new DroolsEndpoint[] {endpoint});
+ jbi.activateComponent(drools, "servicemix-drools");
+
+ ReceiverComponent target = new ReceiverComponent();
+ target.setService(new QName("smx", "target"));
+ target.setEndpoint("endpoint");
+
+ jbi.activateComponent(target, "target");
+
+ jbi.start();
+
+ InOut me = client.createInOutExchange();
+ me.setService(new QName("smx", "drools"));
+ me.setOperation(new QName("smx", "process"));
+ me.getInMessage().setContent(new StringSource("<test id=\"1234\"><child parentId=\"0\"/></test>"));
+ me.setProperty(JbiConstants.CORRELATION_ID, "TEST");
+ if (client.sendSync(me, 10000)) {
+ assertEquals(ExchangeStatus.ACTIVE, me.getStatus());
+ String childId = (String)(new JAXPStringXPathExpression("/test/child/@parentId")
+ .evaluate(me, me.getMessage(Exchange.OUT_MESSAGE)));
+ assertEquals("1234",childId);
+ client.done(me);
+ } else {
+ fail ("No response from drools in time...");
+ }
+ }
+}
Propchange: servicemix/components/engines/servicemix-drools/trunk/src/test/java/org/apache/servicemix/drools/DroolsAutoReplyEndpointTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: servicemix/components/engines/servicemix-drools/trunk/src/test/java/org/apache/servicemix/drools/DroolsComponentTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-drools/trunk/src/test/java/org/apache/servicemix/drools/DroolsComponentTest.java?rev=724655&r1=724654&r2=724655&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-drools/trunk/src/test/java/org/apache/servicemix/drools/DroolsComponentTest.java (original)
+++ servicemix/components/engines/servicemix-drools/trunk/src/test/java/org/apache/servicemix/drools/DroolsComponentTest.java Tue Dec 9 02:10:33 2008
@@ -231,5 +231,5 @@
client.done(me);
Thread.sleep(50);
- }
+ }
}
Added: servicemix/components/engines/servicemix-drools/trunk/src/test/resources/AutoReply.drl
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-drools/trunk/src/test/resources/AutoReply.drl?rev=724655&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-drools/trunk/src/test/resources/AutoReply.drl (added)
+++ servicemix/components/engines/servicemix-drools/trunk/src/test/resources/AutoReply.drl Tue Dec 9 02:10:33 2008
@@ -0,0 +1,25 @@
+/*
+ * 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.drools
+
+import org.apache.servicemix.drools.model.Exchange;
+
+global org.apache.servicemix.drools.model.JbiHelper jbi;
+
+rule "Do Nothing"
+ then
+end
\ No newline at end of file
Added: servicemix/components/engines/servicemix-drools/trunk/src/test/resources/XPathAttrMod-StringValue.drl
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-drools/trunk/src/test/resources/XPathAttrMod-StringValue.drl?rev=724655&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-drools/trunk/src/test/resources/XPathAttrMod-StringValue.drl (added)
+++ servicemix/components/engines/servicemix-drools/trunk/src/test/resources/XPathAttrMod-StringValue.drl Tue Dec 9 02:10:33 2008
@@ -0,0 +1,28 @@
+/*
+ * 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.drools
+
+import org.apache.servicemix.drools.model.Exchange;
+
+global org.apache.servicemix.drools.model.JbiHelper jbi;
+
+rule "Set XPath Attribute /test/@id to 0"
+ when
+ me : Exchange( status == Exchange.ACTIVE, $in : in != null )
+ then
+ $in.setXPath("/test/@id", "0");
+end
\ No newline at end of file
Added: servicemix/components/engines/servicemix-drools/trunk/src/test/resources/XPathAttrMod-XPathAttr.drl
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-drools/trunk/src/test/resources/XPathAttrMod-XPathAttr.drl?rev=724655&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-drools/trunk/src/test/resources/XPathAttrMod-XPathAttr.drl (added)
+++ servicemix/components/engines/servicemix-drools/trunk/src/test/resources/XPathAttrMod-XPathAttr.drl Tue Dec 9 02:10:33 2008
@@ -0,0 +1,28 @@
+/*
+ * 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.drools
+
+import org.apache.servicemix.drools.model.Exchange;
+
+global org.apache.servicemix.drools.model.JbiHelper jbi;
+
+rule "Set /test/child/@id to /test/@id"
+ when
+ me : Exchange( status == Exchange.ACTIVE, $in : in != null )
+ then
+ $in.setXPath("/test/child/@parentId", $in.getXPath("/test/@id"));
+end