[jboss-svn-commits] JBL Code SVN: r34782 - in labs/jbossrules/trunk: drools-camel/src/main/java/org/drools/jax and 8 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Aug 18 15:36:08 EDT 2010
Author: lucazamador
Date: 2010-08-18 15:36:07 -0400 (Wed, 18 Aug 2010)
New Revision: 34782
Added:
labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/
labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/PostCxfSoap.java
labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/PostCxfSoapProcessor.java
labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/PreCxfSoap.java
labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/PreCxfSoapProcessor.java
labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfRestTest.java
labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfSoapTest.java
labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/CxfSoapSpring.xml
labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/soap.wsdl
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/management/DroolsManagementAgentBean.java
labs/jbossrules/trunk/drools-server/src/main/resources/soap.wsdl
labs/jbossrules/trunk/drools-server/src/test/java/org/drools/server/CxfSoapClientServerTest.java
Removed:
labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfTest.java
labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfTest2.java
Modified:
labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/camel/component/DroolsPolicy.java
labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/CxfRsSpring.xml
labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/Test.java
labs/jbossrules/trunk/drools-server/src/main/resources/camel-server.xml
labs/jbossrules/trunk/drools-server/src/main/resources/knowledge-services.xml
labs/jbossrules/trunk/drools-server/src/test/java/org/drools/server/CxfRsClientServerTest.java
labs/jbossrules/trunk/drools-server/src/test/resources/camel-client-test.xml
labs/jbossrules/trunk/drools-server/src/test/resources/camel-embedded-server-test.xml
Log:
JBRULES-2664 Soap support in drools-camel
-Added soap support in drools-camel & drools-server
Modified: labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/camel/component/DroolsPolicy.java
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/camel/component/DroolsPolicy.java 2010-08-18 17:28:31 UTC (rev 34781)
+++ labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/camel/component/DroolsPolicy.java 2010-08-18 19:36:07 UTC (rev 34782)
@@ -16,36 +16,25 @@
package org.drools.camel.component;
-import java.util.ArrayList;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
import org.apache.camel.Message;
-import org.apache.camel.Navigate;
import org.apache.camel.Processor;
-import org.apache.camel.Route;
import org.apache.camel.component.cxf.CxfConstants;
import org.apache.camel.model.BeanDefinition;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.model.MarshalDefinition;
-import org.apache.camel.model.PolicyDefinition;
import org.apache.camel.model.ProcessorDefinition;
import org.apache.camel.model.RouteDefinition;
-import org.apache.camel.model.SendDefinition;
import org.apache.camel.model.ToDefinition;
import org.apache.camel.model.UnmarshalDefinition;
import org.apache.camel.model.dataformat.JaxbDataFormat;
-import org.apache.camel.model.dataformat.JsonDataFormat;
import org.apache.camel.model.dataformat.XStreamDataFormat;
-import org.apache.camel.processor.DelegateProcessor;
-import org.apache.camel.processor.SendProcessor;
-import org.apache.camel.spi.DataFormat;
import org.apache.camel.spi.Policy;
import org.apache.camel.spi.RouteContext;
import org.drools.command.runtime.BatchExecutionCommandImpl;
@@ -60,16 +49,17 @@
import org.drools.command.runtime.rule.InsertElementsCommand;
import org.drools.command.runtime.rule.InsertObjectCommand;
import org.drools.command.runtime.rule.ModifyCommand;
+import org.drools.command.runtime.rule.ModifyCommand.SetterImpl;
import org.drools.command.runtime.rule.QueryCommand;
import org.drools.command.runtime.rule.RetractCommand;
-import org.drools.command.runtime.rule.ModifyCommand.SetterImpl;
import org.drools.common.DefaultFactHandle;
import org.drools.core.util.StringUtils;
+import org.drools.jax.soap.PostCxfSoap;
+import org.drools.jax.soap.PreCxfSoap;
import org.drools.runtime.CommandExecutor;
import org.drools.runtime.impl.ExecutionResultImpl;
import org.drools.runtime.rule.impl.FlatQueryResults;
import org.drools.xml.jaxb.util.JaxbListWrapper;
-import org.mvel2.optimizers.impl.refl.nodes.ArrayLength;
public class DroolsPolicy
implements
@@ -109,7 +99,7 @@
}
return toDrools;
}
-
+
public static void augmentNodes(RouteContext routeContext, ProcessorDefinition nav, Set visited) {
if ( !nav.getOutputs().isEmpty() ) {
@@ -127,77 +117,24 @@
outputs.add( i+2, beanDef ); // insert after cxfrs
i = i + 2;// adjust for the two inserts
}
-
+ else if (to.getUri().startsWith( "cxf" ) && !visited.contains( to ) ) {
+ BeanDefinition beanDef = new BeanDefinition();
+ beanDef.setBeanType( PreCxfSoap.class );
+ outputs.add( i, beanDef ); // insert before cxf
+ beanDef = new BeanDefinition();
+ beanDef.setBeanType( PostCxfSoap.class );
+ outputs.add( i+2, beanDef ); // insert after cxf
+ i = i + 2;// adjust for the two inserts
+ }
} else if ( child instanceof MarshalDefinition ) {
MarshalDefinition m = (MarshalDefinition) child;
-
DataFormatDefinition dformatDefinition = m.getDataFormatType();
-
- if ( dformatDefinition == null ) {
- String ref = m.getRef();
- if ( "json".equals( ref ) ) {
- dformatDefinition = new XStreamDataFormat();
- ((XStreamDataFormat)dformatDefinition).setDriver( "json" );
- } else if ( "xstream".equals( ref ) ) {
- dformatDefinition = new XStreamDataFormat();
- } else if ( "jaxb".equals( ref ) ) {
- dformatDefinition = new JaxbDataFormat();
- } else {
- dformatDefinition = routeContext.getCamelContext().resolveDataFormatDefinition(ref);
- }
- }
-
- // always clone before changing
- dformatDefinition = new FastCloner().deepClone( dformatDefinition );
-
- if ( dformatDefinition instanceof JaxbDataFormat ) {
- dformatDefinition = augmentJaxbDataFormatDefinition( (JaxbDataFormat) dformatDefinition );
- } else if ( dformatDefinition instanceof XStreamDataFormat ) {
- XStreamDataFormat xstreamDataFormat = ( XStreamDataFormat )dformatDefinition;
- if ( "json".equals( xstreamDataFormat.getDriver() )) {
- dformatDefinition = XStreamJson.newJSonMarshaller( xstreamDataFormat );;
- } else {
- dformatDefinition = XStreamXml.newXStreamMarshaller( (XStreamDataFormat) dformatDefinition );
- }
-
- }
+ dformatDefinition = processDataFormatType( routeContext, m.getRef(), dformatDefinition );
m.setDataFormatType( dformatDefinition ); // repoint the marshaller, if it was cloned
-
-
} else if ( child instanceof UnmarshalDefinition ) {
UnmarshalDefinition m = (UnmarshalDefinition) child;
-
DataFormatDefinition dformatDefinition = m.getDataFormatType();
-
- if ( dformatDefinition == null ) {
- String ref = m.getRef();
- if ( "json".equals( ref ) ) {
- dformatDefinition = new XStreamDataFormat();
- ((XStreamDataFormat)dformatDefinition).setDriver( "json" );
- } else if ( "xstream".equals( ref ) ) {
- dformatDefinition = new XStreamDataFormat();
- } else if ( "jaxb".equals( ref ) ) {
- dformatDefinition = new JaxbDataFormat();
- } else {
- dformatDefinition = routeContext.getCamelContext().resolveDataFormatDefinition(ref);
- }
- }
-
- // always clone before changing
- dformatDefinition = new FastCloner().deepClone( dformatDefinition );
-
- // Augment the Jaxb DataFormatDefinition, but clone first so we don't alter the original.
- if ( dformatDefinition instanceof JaxbDataFormat ) {
- dformatDefinition = augmentJaxbDataFormatDefinition( (JaxbDataFormat) dformatDefinition );
- } else if ( dformatDefinition instanceof XStreamDataFormat ) {
- XStreamDataFormat xstreamDataFormat = ( XStreamDataFormat )dformatDefinition;
- if ( "json".equals( xstreamDataFormat.getDriver() )) {
- dformatDefinition = XStreamJson.newJSonMarshaller( xstreamDataFormat );;
- } else {
- dformatDefinition = XStreamXml.newXStreamMarshaller( (XStreamDataFormat) dformatDefinition );
- }
- }
-
+ dformatDefinition = processDataFormatType( routeContext, m.getRef(), dformatDefinition );
m.setDataFormatType( dformatDefinition ); // repoint the marshaller, if it was cloned
}
}
@@ -211,6 +148,37 @@
}
}
+ private static DataFormatDefinition processDataFormatType( RouteContext routeContext, String ref, DataFormatDefinition dformatDefinition) {
+ if ( dformatDefinition == null ) {
+ if ( "json".equals( ref ) ) {
+ dformatDefinition = new XStreamDataFormat();
+ ((XStreamDataFormat)dformatDefinition).setDriver( "json" );
+ } else if ( "xstream".equals( ref ) ) {
+ dformatDefinition = new XStreamDataFormat();
+ } else if ( "jaxb".equals( ref ) ) {
+ dformatDefinition = new JaxbDataFormat();
+ } else {
+ dformatDefinition = routeContext.getCamelContext().resolveDataFormatDefinition(ref);
+ }
+ }
+
+ // always clone before changing
+ dformatDefinition = new FastCloner().deepClone( dformatDefinition );
+
+ if ( dformatDefinition instanceof JaxbDataFormat ) {
+ dformatDefinition = augmentJaxbDataFormatDefinition( (JaxbDataFormat) dformatDefinition );
+ } else if ( dformatDefinition instanceof XStreamDataFormat ) {
+ XStreamDataFormat xstreamDataFormat = ( XStreamDataFormat )dformatDefinition;
+ if ( "json".equals( xstreamDataFormat.getDriver() )) {
+ dformatDefinition = XStreamJson.newJSonMarshaller( xstreamDataFormat );;
+ } else {
+ dformatDefinition = XStreamXml.newXStreamMarshaller( (XStreamDataFormat) dformatDefinition );
+ }
+
+ }
+ return dformatDefinition;
+ }
+
private ToDefinition getDroolsNode(ProcessorDefinition nav) {
if ( !nav.getOutputs().isEmpty() ) {
List<ProcessorDefinition> children = nav.getOutputs();
Added: labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/PostCxfSoap.java
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/PostCxfSoap.java (rev 0)
+++ labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/PostCxfSoap.java 2010-08-18 19:36:07 UTC (rev 34782)
@@ -0,0 +1,50 @@
+/**
+ * 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.jax.soap;
+
+import java.io.InputStream;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPBodyElement;
+import javax.xml.soap.SOAPMessage;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.drools.core.util.StringUtils;
+
+public class PostCxfSoap implements Processor {
+
+ public void process(Exchange exchange) throws Exception {
+ InputStream is = (InputStream) exchange.getIn().getBody();
+ if (is != null) {
+ SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
+ SOAPBody body = soapMessage.getSOAPPart().getEnvelope().getBody();
+ QName payloadName = new QName("http://soap.jax.drools.org", "executeResponse", "ns1");
+ SOAPBodyElement payload = body.addBodyElement(payloadName);
+ payload.addChildElement("responseType");
+ body.addTextNode(StringUtils.toString( is ));
+ exchange.getOut().setBody( soapMessage );
+ }
+
+ }
+
+}
\ No newline at end of file
Property changes on: labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/PostCxfSoap.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/PostCxfSoapProcessor.java
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/PostCxfSoapProcessor.java (rev 0)
+++ labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/PostCxfSoapProcessor.java 2010-08-18 19:36:07 UTC (rev 34782)
@@ -0,0 +1,36 @@
+package org.drools.jax.soap;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPBodyElement;
+import javax.xml.soap.SOAPMessage;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.drools.core.util.StringUtils;
+
+public class PostCxfSoapProcessor implements Processor {
+
+ public void process(Exchange exchange) throws Exception {
+ byte[] body = (byte[]) exchange.getIn().getBody();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(body);
+
+ SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
+ SOAPBody soapBody = soapMessage.getSOAPPart().getEnvelope().getBody();
+ QName payloadName = new QName("http://soap.jax.drools.org", "executeResponse", "ns1");
+ SOAPBodyElement payload = soapBody.addBodyElement(payloadName);
+ payload.addChildElement("responseType");
+ soapBody.addTextNode(StringUtils.toString(bais));
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ soapMessage.writeTo(baos);
+
+ exchange.getOut().setBody(new String(baos.toByteArray()));
+ }
+
+}
Property changes on: labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/PostCxfSoapProcessor.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/PreCxfSoap.java
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/PreCxfSoap.java (rev 0)
+++ labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/PreCxfSoap.java 2010-08-18 19:36:07 UTC (rev 34782)
@@ -0,0 +1,43 @@
+/**
+ * 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.jax.soap;
+
+import javax.xml.soap.SOAPMessage;
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.Processor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.cxf.service.model.BindingOperationInfo;
+
+public class PreCxfSoap implements Processor {
+
+ private static final transient Log LOG = LogFactory.getLog(PreCxfSoap.class);
+
+ public void process(Exchange exchange) throws Exception {
+ exchange.setPattern(ExchangePattern.InOut);
+ BindingOperationInfo boi = (BindingOperationInfo)exchange.getProperty(BindingOperationInfo.class.toString());
+ if (boi != null) {
+ LOG.info("boi.isUnwrapped" + boi.isUnwrapped());
+ }
+ SOAPMessage soapMessage = (SOAPMessage)exchange.getIn().getBody();
+ exchange.getOut().setBody(soapMessage.getSOAPBody().getTextContent());
+ }
+}
Property changes on: labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/PreCxfSoap.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/PreCxfSoapProcessor.java
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/PreCxfSoapProcessor.java (rev 0)
+++ labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/PreCxfSoapProcessor.java 2010-08-18 19:36:07 UTC (rev 34782)
@@ -0,0 +1,26 @@
+package org.drools.jax.soap;
+
+import java.io.InputStream;
+import java.util.Map;
+
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPMessage;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+public class PreCxfSoapProcessor implements Processor {
+
+ public void process(Exchange exchange) throws Exception {
+ InputStream is = (InputStream)exchange.getIn().getBody();
+ Map<String, Object> headers = exchange.getIn().getHeaders();
+ MimeHeaders mimeHeaders = new MimeHeaders();
+ for (String header : headers.keySet()) {
+ mimeHeaders.addHeader(header, (String) headers.get(header));
+ }
+ SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(mimeHeaders, is);
+ exchange.getOut().setBody(soapMessage.getSOAPBody().getTextContent());
+ }
+
+}
Property changes on: labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/jax/soap/PreCxfSoapProcessor.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfRestTest.java
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfRestTest.java (rev 0)
+++ labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfRestTest.java 2010-08-18 19:36:07 UTC (rev 34782)
@@ -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.
+ */
+
+package org.drools.camel.component.cxf;
+
+import org.apache.camel.test.CamelSpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class CxfRestTest extends CamelSpringTestSupport {
+
+ @Override
+ protected AbstractXmlApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/drools/camel/component/CxfRsSpring.xml");
+ }
+
+ public void test1() throws Exception {
+ String cmd = "";
+ cmd += "<batch-execution lookup=\"ksession1\">\n";
+ cmd += " <insert out-identifier=\"salaboy\">\n";
+ cmd += " <org.drools.pipeline.camel.Person>\n";
+ cmd += " <name>salaboy</name>\n";
+ cmd += " </org.drools.pipeline.camel.Person>\n";
+ cmd += " </insert>\n";
+ cmd += " <fire-all-rules/>\n";
+ cmd += "</batch-execution>\n";
+
+
+ Object object = this.context.createProducerTemplate().requestBody("direct://http", cmd);
+ System.out.println( object );
+ }
+
+}
Property changes on: labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfRestTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfSoapTest.java
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfSoapTest.java (rev 0)
+++ labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfSoapTest.java 2010-08-18 19:36:07 UTC (rev 34782)
@@ -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.camel.component.cxf;
+
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPMessage;
+
+import org.apache.camel.test.CamelSpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class CxfSoapTest extends CamelSpringTestSupport {
+
+ @Override
+ protected AbstractXmlApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/drools/camel/component/CxfSoapSpring.xml");
+ }
+
+ public void test1() throws Exception {
+
+ SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
+ SOAPBody body = soapMessage.getSOAPPart().getEnvelope().getBody();
+ QName payloadName = new QName("http://soap.jax.drools.org", "execute", "ns1");
+
+ body.addBodyElement(payloadName);
+
+ String cmd = "";
+ cmd += "<batch-execution lookup=\"ksession1\">\n";
+ cmd += " <insert out-identifier=\"salaboy\" disconnected=\"true\">\n";
+ cmd += " <org.drools.pipeline.camel.Person>\n";
+ cmd += " <name>salaboy</name>\n";
+ cmd += " <age>27</age>\n";
+ cmd += " </org.drools.pipeline.camel.Person>\n";
+ cmd += " </insert>\n";
+ cmd += " <fire-all-rules/>\n";
+ cmd += "</batch-execution>\n";
+
+ body.addTextNode(cmd);
+
+ OutputStream out = new ByteArrayOutputStream();
+ soapMessage.writeTo(out);
+
+ String request = out.toString();
+ System.out.println("Request = " + request);
+
+ Object object = this.context.createProducerTemplate().requestBody("direct://http", soapMessage);
+ System.out.println(object.getClass().getCanonicalName());
+ out = new ByteArrayOutputStream();
+ soapMessage = (SOAPMessage) object;
+ soapMessage.writeTo(out);
+ String response = out.toString();
+ System.out.println("Response = "+response);
+ assertTrue(response.contains("fact-handle identifier=\"salaboy\""));
+ }
+
+}
Property changes on: labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfSoapTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted: labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfTest.java
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfTest.java 2010-08-18 17:28:31 UTC (rev 34781)
+++ labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfTest.java 2010-08-18 19:36:07 UTC (rev 34782)
@@ -1,110 +0,0 @@
-/**
- * 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.camel.component.cxf;
-
-import java.io.InputStream;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.ws.rs.core.Response;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.Message;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.CxfConstants;
-import org.apache.camel.test.CamelSpringTestSupport;
-import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
-import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
-import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
-import org.apache.cxf.jaxrs.client.WebClient;
-import org.drools.camel.component.DroolsCamelTestSupport;
-import org.drools.camel.component.DroolsPolicy;
-import org.drools.core.util.StringUtils;
-import org.junit.Test;
-
-public class CxfTest extends DroolsCamelTestSupport {
- public void test1() {
-
- }
-// private static final String REST_ENDPOINT_URI = "cxfrs://http://localhost:9002/rest"
-// + "?resourceClasses=org.drools.jax.rs.CommandExecutorImpl2";
-//
-// public static class CxfrsProducer implements Processor {
-// public void process(Exchange exchange) throws Exception {
-// exchange.setPattern(ExchangePattern.InOut);
-// Message inMessage = exchange.getIn();
-// inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.TRUE);
-// inMessage.setHeader(Exchange.HTTP_METHOD, "POST");
-// inMessage.setHeader(Exchange.HTTP_PATH, "/execute");
-// inMessage.setHeader(Exchange.ACCEPT_CONTENT_TYPE, "text/plain");
-// inMessage.setHeader(Exchange.CONTENT_TYPE, "text/plain");
-// }
-// }
-//
-// public void test1() throws Exception {
-//// Response response = (Response) this.context.createProducerTemplate().requestBody("direct://http://localhost:9002/rest", "hello world");
-////
-//// System.out.println( StringUtils.toString( (InputStream) response.getEntity() ));
-////
-// }
-//
-// @Override
-// protected void configureDroolsContext(Context jndiContext) {
-//// JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
-//// sf.setResourceClasses(CommandExecutorImpl2.class);
-//// sf.setAddress("http://localhost:9002/rest");
-//// //sf.create();
-//// try {
-//// jndiContext.bind( "rsServer", sf );
-//// } catch ( NamingException e ) {
-//// throw new RuntimeException( e );
-//// }
-//
-// }
-//
-// @Override
-// protected RouteBuilder createRouteBuilder() throws Exception {
-// return new RouteBuilder() {
-// public void configure() throws Exception {
-// from(REST_ENDPOINT_URI)
-// .process( new MockProcessor() );
-//
-// from("direct:http://localhost:9002/rest").process( new CxfrsProducer() ).
-// to( "cxfrs://http://localhost:9002/rest" );
-// }
-// };
-// }
-//
-// public static class MockProcessor implements Processor {
-//
-// public void process(Exchange exchange) throws Exception {
-// //System.out.println( exchange.getIn().get)
-// System.out.println( exchange.getIn().getBody( String.class ) );
-// exchange.getOut().setBody( "goodbye world" );
-// }
-//
-// }
-
- @Override
- protected void configureDroolsContext(Context jndiContext) {
- // TODO Auto-generated method stub
-
- }
-
-}
Deleted: labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfTest2.java
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfTest2.java 2010-08-18 17:28:31 UTC (rev 34781)
+++ labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfTest2.java 2010-08-18 19:36:07 UTC (rev 34782)
@@ -1,51 +0,0 @@
-/**
- * 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.camel.component.cxf;
-
-import java.io.InputStream;
-
-import javax.ws.rs.core.Response;
-
-import org.apache.camel.test.CamelSpringTestSupport;
-import org.drools.core.util.StringUtils;
-import org.springframework.context.support.AbstractXmlApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class CxfTest2 extends CamelSpringTestSupport {
-
- @Override
- protected AbstractXmlApplicationContext createApplicationContext() {
- return new ClassPathXmlApplicationContext("org/drools/camel/component/CxfRsSpring.xml");
- }
-
- public void test1() throws Exception {
- String cmd = "";
- cmd += "<batch-execution lookup=\"ksession1\">\n";
- cmd += " <insert out-identifier=\"salaboy\">\n";
- cmd += " <org.drools.pipeline.camel.Person>\n";
- cmd += " <name>salaboy</name>\n";
- cmd += " </org.drools.pipeline.camel.Person>\n";
- cmd += " </insert>\n";
- cmd += " <fire-all-rules/>\n";
- cmd += "</batch-execution>\n";
-
-
- Object object = this.context.createProducerTemplate().requestBody("direct://http", cmd);
- System.out.println( object );
- }
-
-}
Modified: labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/CxfRsSpring.xml
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/CxfRsSpring.xml 2010-08-18 17:28:31 UTC (rev 34781)
+++ labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/CxfRsSpring.xml 2010-08-18 19:36:07 UTC (rev 34782)
@@ -49,7 +49,7 @@
<!-- Defined the server endpoint to create the cxf-rs consumer -->
<cxf:rsServer id="rsServer"
- address="http://localhost:9002/rest"
+ address="http://localhost:9002/rest"
serviceClass="org.drools.jax.rs.CommandExecutorImpl">
<cxf:providers>
<bean class="org.drools.jax.rs.CommandMessageBodyReader"/>
Added: labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/CxfSoapSpring.xml
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/CxfSoapSpring.xml (rev 0)
+++ labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/CxfSoapSpring.xml 2010-08-18 19:36:07 UTC (rev 34782)
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:cxf="http://camel.apache.org/schema/cxf"
+ xmlns:jaxrs="http://cxf.apache.org/jaxrs"
+ xmlns:drools="http://drools.org/schema/drools-spring"
+ xsi:schemaLocation="
+ http://drools.org/schema/drools-spring http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.0.0.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd
+ http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/cxfEndpoint.xsd
+ http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ ">
+
+
+ <drools:connection id="connection1" type="local" />
+
+ <drools:execution-node id="node1" connection="connection1" />
+
+ <drools:kbase id="kbase1" node="node1">
+ <drools:resources>
+ <drools:resource type="DRL" source="classpath:org/drools/camel/component/testSpring.drl"/>
+ </drools:resources>
+ </drools:kbase>
+
+ <drools:ksession id="ksession1" type="stateful" name="ksession1" kbase="kbase1" node="node1">
+ <drools:script>
+ <drools:set-global identifier="list" >
+ <bean class="java.util.ArrayList" />
+ </drools:set-global>
+ </drools:script>
+ </drools:ksession>
+
+ <cxf:cxfEndpoint id="soapServer"
+ address="http://localhost:9002/soap"
+ serviceName="ns:CommandExecutor"
+ endpointName="ns:CommandExecutorPort"
+ wsdlURL="src/test/resources/org/drools/camel/component/soap.wsdl"
+ xmlns:ns="http://soap.jax.drools.org/" >
+ <cxf:properties>
+ <entry key="dataFormat" value="MESSAGE"/>
+ <entry key="defaultOperationName" value="execute"/>
+ </cxf:properties>
+ </cxf:cxfEndpoint>
+
+ <bean id="droolsPolicy" class="org.drools.camel.component.DroolsPolicy" />
+
+ <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+
+ <route>
+ <from uri="cxf://bean://soapServer"/>
+ <policy ref="droolsPolicy">
+ <unmarshal ref="xstream" />
+ <to uri="drools:node1/ksession1" />
+ <marshal ref="xstream" />
+ </policy>
+ </route>
+
+ <route id="x1">
+ <from uri="direct://http"/>
+ <policy ref="droolsPolicy">
+ <to uri="cxf://bean://soapServer"/>
+ </policy>
+ </route>
+
+ </camelContext>
+
+</beans>
Property changes on: labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/CxfSoapSpring.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/soap.wsdl
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/soap.wsdl (rev 0)
+++ labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/soap.wsdl 2010-08-18 19:36:07 UTC (rev 34782)
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions name="CommandExecutor" targetNamespace="http://soap.jax.drools.org/" xmlns:ns1="http://cxf.apache.org/bindings/xformat" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://soap.jax.drools.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://soap.jax.drools.org/" xmlns:tns="http://soap.jax.drools.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+<xsd:element name="execute" type="tns:execute"/>
+<xsd:complexType name="execute">
+<xsd:sequence>
+<xsd:element minOccurs="0" name="arg0"/>
+</xsd:sequence>
+</xsd:complexType>
+<xsd:element name="executeResponse" type="tns:executeResponse"/>
+<xsd:complexType name="executeResponse">
+<xsd:sequence>
+<xsd:element minOccurs="0" name="return" type="xsd:anyType"/>
+</xsd:sequence>
+</xsd:complexType>
+</xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="execute">
+ <wsdl:part element="tns:execute" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="executeResponse">
+ <wsdl:part element="tns:executeResponse" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="CommandExecutorPortType">
+ <wsdl:operation name="execute">
+ <wsdl:input message="tns:execute" name="execute">
+ </wsdl:input>
+ <wsdl:output message="tns:executeResponse" name="executeResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="CommandExecutorSoapBinding" type="tns:CommandExecutorPortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="execute">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="execute">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="executeResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="CommandExecutor">
+ <wsdl:port binding="tns:CommandExecutorSoapBinding" name="CommandExecutorPort">
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
\ No newline at end of file
Property changes on: labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/soap.wsdl
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/management/DroolsManagementAgentBean.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/management/DroolsManagementAgentBean.java (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/management/DroolsManagementAgentBean.java 2010-08-18 19:36:07 UTC (rev 34782)
@@ -0,0 +1,62 @@
+/**
+ * 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.management;
+
+import java.util.List;
+
+import org.drools.KnowledgeBase;
+import org.drools.impl.KnowledgeBaseImpl;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
+import org.drools.reteoo.ReteooRuleBase;
+import org.drools.runtime.StatefulKnowledgeSession;
+
+/**
+ * Simple POJO that encapsulates DroolsManagmentAgent to make it work with Spring Framework
+ * @author Lucas Amador
+ *
+ */
+public class DroolsManagementAgentBean {
+
+ private DroolsManagementAgent instance;
+ private List<KnowledgeBase> knowledgeBases;
+ private List<StatefulKnowledgeSession> statefulKnowledgeSessions;
+
+ public DroolsManagementAgentBean() {
+ }
+
+ public void start() {
+ instance = DroolsManagementAgent.getInstance();
+ if (knowledgeBases!= null) {
+ for (KnowledgeBase kbase : knowledgeBases) {
+ instance.registerKnowledgeBase((ReteooRuleBase) ((KnowledgeBaseImpl)kbase).getRuleBase());
+ }
+ }
+ if (statefulKnowledgeSessions!=null) {
+ for (StatefulKnowledgeSession ksession : statefulKnowledgeSessions) {
+ instance.registerKnowledgeSession(((StatefulKnowledgeSessionImpl)ksession).getInternalWorkingMemory());
+ }
+ }
+ }
+
+ public void setKnowledgeBases(List<KnowledgeBase> knowledgeBases) {
+ this.knowledgeBases = knowledgeBases;
+ }
+
+ public void setStatefulKnowledgeSessions(List<StatefulKnowledgeSession> statefulKnowledgeSessions) {
+ this.statefulKnowledgeSessions = statefulKnowledgeSessions;
+ }
+
+}
Property changes on: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/management/DroolsManagementAgentBean.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/Test.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/Test.java 2010-08-18 17:28:31 UTC (rev 34781)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/Test.java 2010-08-18 19:36:07 UTC (rev 34782)
@@ -16,57 +16,63 @@
package org.drools.server;
-import java.io.InputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
-import javax.ws.rs.core.Response;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
import org.apache.camel.CamelContext;
-import org.apache.camel.test.CamelSpringTestSupport;
-import org.drools.core.util.StringUtils;
-import org.drools.impl.StatelessKnowledgeSessionImpl;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.AbstractXmlApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Test {
-
- public static void main(String[] args) {
- String msg = "Hello World";
-
- System.out.println( "Sending Message:\n" + msg);
-
- Test test = new Test();
- String response = test.send( msg );
-
- System.out.println( );
- System.out.println( );
-
- System.out.println( "Received Response:\n" + response);
- }
-
- public String send(String msg) {
- ClassPathXmlApplicationContext springContext = new ClassPathXmlApplicationContext("classpath:camel-client.xml");
- String batch = "";
- batch += "<batch-execution lookup=\"ksession1\">\n";
- batch += " <insert out-identifier=\"message\">\n";
- batch += " <org.test.Message>\n";
- batch += " <text>" + msg + "</text>\n";
- batch += " </org.test.Message>\n";
- batch += " </insert>\n";
- batch += "</batch-execution>\n";
-
-
- Test test = new Test();
- String response = test.execute( batch,
- ( CamelContext ) springContext.getBean( "camel" ) );
-
- return response;
- }
-
- public String execute(String msg, CamelContext camelContext) {
-
- String response = camelContext.createProducerTemplate().requestBody( "direct://kservice", msg, String.class );
-
- return response;
- }
+
+ public static void main(String[] args) {
+ String msg = "Hello World";
+
+ System.out.println( "Sending Message:\n" + msg);
+
+ Test test = new Test();
+ String response = test.send( msg );
+
+ System.out.println( );
+ System.out.println( );
+
+ System.out.println( "Received Response:\n" + response);
+ }
+
+ public String send(String msg) {
+ ClassPathXmlApplicationContext springContext = new ClassPathXmlApplicationContext("classpath:camel-client.xml");
+ String batch = "";
+ batch += "<batch-execution lookup=\"ksession1\">\n";
+ batch += " <insert out-identifier=\"message\">\n";
+ batch += " <org.test.Message>\n";
+ batch += " <text>" + msg + "</text>\n";
+ batch += " </org.test.Message>\n";
+ batch += " </insert>\n";
+ batch += "</batch-execution>\n";
+
+
+ Test test = new Test();
+ String response = test.execute( batch,
+ ( CamelContext ) springContext.getBean( "camel" ) );
+
+ return response;
+ }
+
+ public String execute(String msg, CamelContext camelContext) {
+
+ String response = camelContext.createProducerTemplate().requestBody( "direct://kservice/rest", msg, String.class );
+
+ return response;
+ }
+
+ public String execute(SOAPMessage soapMessage, CamelContext camelContext) throws SOAPException, IOException {
+ Object object = camelContext.createProducerTemplate().requestBody( "direct://kservice/soap", soapMessage);
+ OutputStream out = new ByteArrayOutputStream();
+ SOAPMessage soapResponse = (SOAPMessage) object;
+ soapResponse.writeTo(out);
+ return out.toString();
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-server/src/main/resources/camel-server.xml
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/resources/camel-server.xml 2010-08-18 17:28:31 UTC (rev 34781)
+++ labs/jbossrules/trunk/drools-server/src/main/resources/camel-server.xml 2010-08-18 19:36:07 UTC (rev 34782)
@@ -28,6 +28,7 @@
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"/>
+ <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<!--
@@ -42,13 +43,30 @@
! Different Camel routes can handle different end point paths.
-->
<cxf:rsServer id="rsServer"
- address="/kservice/rest"
+ address="/rest"
serviceClass="org.drools.jax.rs.CommandExecutorImpl">
<cxf:providers>
<bean class="org.drools.jax.rs.CommandMessageBodyReader"/>
</cxf:providers>
</cxf:rsServer>
+ <cxf:cxfEndpoint id="soapServer"
+ address="/soap"
+ serviceName="ns:CommandExecutor"
+ endpointName="ns:CommandExecutorPort"
+ wsdlURL="soap.wsdl"
+ xmlns:ns="http://soap.jax.drools.org/" >
+ <cxf:properties>
+ <entry key="dataFormat" value="MESSAGE"/>
+ <entry key="defaultOperationName" value="execute"/>
+ </cxf:properties>
+ </cxf:cxfEndpoint>
+
+ <!-- Beans to transform the soap invocation -->
+ <bean id="preCxfSoapProcessor" class="org.drools.jax.soap.PreCxfSoapProcessor" />
+
+ <bean id="postCxfSoapProcessor" class="org.drools.jax.soap.PostCxfSoapProcessor" />
+
<!-- Leave this, as it's needed to make Camel "drools" aware -->
<bean id="droolsPolicy" class="org.drools.camel.component.DroolsPolicy" />
@@ -67,7 +85,18 @@
<marshal ref="xstream" />
</policy>
</route>
+
+ <route>
+ <from uri="cxf://bean://soapServer"/>
+ <process ref="preCxfSoapProcessor" />
+ <policy ref="droolsPolicy">
+ <unmarshal ref="xstream" />
+ <to uri="drools:node1/ksession1" />
+ <marshal ref="xstream" />
+ </policy>
+ <process ref="postCxfSoapProcessor" />
+ </route>
</camelContext>
-
+
</beans>
Modified: labs/jbossrules/trunk/drools-server/src/main/resources/knowledge-services.xml
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/resources/knowledge-services.xml 2010-08-18 17:28:31 UTC (rev 34781)
+++ labs/jbossrules/trunk/drools-server/src/main/resources/knowledge-services.xml 2010-08-18 19:36:07 UTC (rev 34782)
@@ -31,5 +31,5 @@
</drools:kbase>
<drools:ksession id="ksession1" type="stateless" kbase="kbase1" node="node1"/>
-
+
</beans>
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-server/src/main/resources/soap.wsdl
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/resources/soap.wsdl (rev 0)
+++ labs/jbossrules/trunk/drools-server/src/main/resources/soap.wsdl 2010-08-18 19:36:07 UTC (rev 34782)
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions name="CommandExecutor" targetNamespace="http://soap.jax.drools.org/" xmlns:ns1="http://cxf.apache.org/bindings/xformat" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://soap.jax.drools.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://soap.jax.drools.org/" xmlns:tns="http://soap.jax.drools.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+<xsd:element name="execute" type="tns:execute"/>
+<xsd:complexType name="execute">
+<xsd:sequence>
+<xsd:element minOccurs="0" name="arg0"/>
+</xsd:sequence>
+</xsd:complexType>
+<xsd:element name="executeResponse" type="tns:executeResponse"/>
+<xsd:complexType name="executeResponse">
+<xsd:sequence>
+<xsd:element minOccurs="0" name="return" type="xsd:anyType"/>
+</xsd:sequence>
+</xsd:complexType>
+</xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="execute">
+ <wsdl:part element="tns:execute" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="executeResponse">
+ <wsdl:part element="tns:executeResponse" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="CommandExecutorPortType">
+ <wsdl:operation name="execute">
+ <wsdl:input message="tns:execute" name="execute">
+ </wsdl:input>
+ <wsdl:output message="tns:executeResponse" name="executeResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="CommandExecutorSoapBinding" type="tns:CommandExecutorPortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="execute">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="execute">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="executeResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="CommandExecutor">
+ <wsdl:port binding="tns:CommandExecutorSoapBinding" name="CommandExecutorPort">
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
\ No newline at end of file
Property changes on: labs/jbossrules/trunk/drools-server/src/main/resources/soap.wsdl
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossrules/trunk/drools-server/src/test/java/org/drools/server/CxfRsClientServerTest.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/test/java/org/drools/server/CxfRsClientServerTest.java 2010-08-18 17:28:31 UTC (rev 34781)
+++ labs/jbossrules/trunk/drools-server/src/test/java/org/drools/server/CxfRsClientServerTest.java 2010-08-18 19:36:07 UTC (rev 34782)
@@ -22,7 +22,6 @@
import junit.framework.TestCase;
public class CxfRsClientServerTest extends TestCase {
-
public void test1() throws Exception {
ClassPathXmlApplicationContext springContext = new ClassPathXmlApplicationContext("classpath:beans-test.xml");
Added: labs/jbossrules/trunk/drools-server/src/test/java/org/drools/server/CxfSoapClientServerTest.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/test/java/org/drools/server/CxfSoapClientServerTest.java (rev 0)
+++ labs/jbossrules/trunk/drools-server/src/test/java/org/drools/server/CxfSoapClientServerTest.java 2010-08-18 19:36:07 UTC (rev 34782)
@@ -0,0 +1,58 @@
+/**
+ * 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.server;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPMessage;
+
+import junit.framework.TestCase;
+
+import org.apache.camel.CamelContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class CxfSoapClientServerTest extends TestCase {
+
+ public void test1() throws Exception {
+ ClassPathXmlApplicationContext springContext = new ClassPathXmlApplicationContext("classpath:beans-test.xml");
+
+ SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
+ SOAPBody body = soapMessage.getSOAPPart().getEnvelope().getBody();
+ QName payloadName = new QName("http://soap.jax.drools.org", "execute", "ns1");
+
+ body.addBodyElement(payloadName);
+
+ String cmd = "";
+ cmd += "<batch-execution lookup=\"ksession1\">\n";
+ cmd += " <insert out-identifier=\"message\">\n";
+ cmd += " <org.test.Message>\n";
+ cmd += " <text>Helllo World</text>\n";
+ cmd += " </org.test.Message>\n";
+ cmd += " </insert>\n";
+ cmd += "</batch-execution>\n";
+
+ body.addTextNode(cmd);
+
+ Test test = new Test();
+ String response = test.execute( soapMessage, ( CamelContext ) springContext.getBean( "camel-client-ctx" ) );
+
+ assertTrue( response.contains( "execution-results" ) );
+ assertTrue( response.contains( "echo" ) );
+ }
+
+}
Property changes on: labs/jbossrules/trunk/drools-server/src/test/java/org/drools/server/CxfSoapClientServerTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossrules/trunk/drools-server/src/test/resources/camel-client-test.xml
===================================================================
--- labs/jbossrules/trunk/drools-server/src/test/resources/camel-client-test.xml 2010-08-18 17:28:31 UTC (rev 34781)
+++ labs/jbossrules/trunk/drools-server/src/test/resources/camel-client-test.xml 2010-08-18 19:36:07 UTC (rev 34782)
@@ -33,12 +33,19 @@
<camelContext id="camel-client-ctx" xmlns="http://camel.apache.org/schema/spring">
<route>
- <from uri="direct://kservice"/>
+ <from uri="direct://kservice/rest"/>
<policy ref="droolsPolicy">
<to uri="cxfrs://http://localhost:9002/rest"/>
</policy>
+ </route>
+
+ <route>
+ <from uri="direct://kservice/soap"/>
+ <policy ref="droolsPolicy">
+ <to uri="cxf://bean://soapServer"/>
+ </policy>
</route>
-
+
</camelContext>
</beans>
Modified: labs/jbossrules/trunk/drools-server/src/test/resources/camel-embedded-server-test.xml
===================================================================
--- labs/jbossrules/trunk/drools-server/src/test/resources/camel-embedded-server-test.xml 2010-08-18 17:28:31 UTC (rev 34781)
+++ labs/jbossrules/trunk/drools-server/src/test/resources/camel-embedded-server-test.xml 2010-08-18 19:36:07 UTC (rev 34782)
@@ -28,6 +28,7 @@
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"/>
+ <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml"/>
@@ -37,12 +38,25 @@
<cxf:providers>
<bean class="org.drools.jax.rs.CommandMessageBodyReader"/>
</cxf:providers>
- </cxf:rsServer>
+ </cxf:rsServer>
+ <cxf:cxfEndpoint id="soapServer"
+ address="http://localhost:9002/soap"
+ serviceName="ns:CommandExecutor"
+ endpointName="ns:CommandExecutorPort"
+ wsdlURL="soap.wsdl"
+ xmlns:ns="http://soap.jax.drools.org/" >
+ <cxf:properties>
+ <entry key="dataFormat" value="MESSAGE"/>
+ <entry key="defaultOperationName" value="execute"/>
+ </cxf:properties>
+ </cxf:cxfEndpoint>
+
<!-- Leave this, as it's needed to make Camel "drools" aware -->
<bean id="droolsPolicy" class="org.drools.camel.component.DroolsPolicy" />
<camelContext id="camel-server-ctx" xmlns="http://camel.apache.org/schema/spring">
+
<route>
<from uri="cxfrs://bean://rsServer"/>
<policy ref="droolsPolicy">
@@ -51,7 +65,16 @@
<marshal ref="xstream" />
</policy>
</route>
-
+
+ <route>
+ <from uri="cxf://bean://soapServer"/>
+ <policy ref="droolsPolicy">
+ <unmarshal ref="xstream" />
+ <to uri="drools:node1/ksession1" />
+ <marshal ref="xstream" />
+ </policy>
+ </route>
+
</camelContext>
</beans>
More information about the jboss-svn-commits
mailing list