[jboss-svn-commits] JBL Code SVN: r34688 - in labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src: main/java/org/drools/jax and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Aug 12 16:31:57 EDT 2010
Author: lucazamador
Date: 2010-08-12 16:31:56 -0400 (Thu, 12 Aug 2010)
New Revision: 34688
Added:
labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/
labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/CommandExecutorSoap.java
labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/CommandExecutorSoapImpl.java
labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/PostCxfSoap.java
labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/PreCxfSoap.java
labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfRestTest.java
labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfSoapTest.java
labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/test/resources/org/drools/camel/component/CxfSoapSpring.xml
Removed:
labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfTest.java
labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfTest2.java
Modified:
labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/camel/component/DroolsPolicy.java
Log:
[JBRULES-2664] Soap support in drools-camel
- added WS, spring configuration & tests
Modified: labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/camel/component/DroolsPolicy.java
===================================================================
--- labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/camel/component/DroolsPolicy.java 2010-08-12 20:11:52 UTC (rev 34687)
+++ labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/camel/component/DroolsPolicy.java 2010-08-12 20:31:56 UTC (rev 34688)
@@ -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 cxfrs
+ beanDef = new BeanDefinition();
+ beanDef.setBeanType( PostCxfSoap.class );
+ outputs.add( i+2, beanDef ); // insert after cxfrs
+ 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/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/CommandExecutorSoap.java
===================================================================
--- labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/CommandExecutorSoap.java (rev 0)
+++ labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/CommandExecutorSoap.java 2010-08-12 20:31:56 UTC (rev 34688)
@@ -0,0 +1,8 @@
+package org.drools.jax.soap;
+
+
+public interface CommandExecutorSoap {
+
+ public String invoke(String command);
+
+}
Property changes on: labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/CommandExecutorSoap.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/CommandExecutorSoapImpl.java
===================================================================
--- labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/CommandExecutorSoapImpl.java (rev 0)
+++ labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/CommandExecutorSoapImpl.java 2010-08-12 20:31:56 UTC (rev 34688)
@@ -0,0 +1,15 @@
+package org.drools.jax.soap;
+
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceProvider;
+
+ at WebServiceProvider()
+ at ServiceMode(Mode.MESSAGE)
+public class CommandExecutorSoapImpl implements CommandExecutorSoap {
+
+ public String invoke(String command) {
+ throw new UnsupportedOperationException( "This should never be called, as it's handled by camel" );
+ }
+
+}
Property changes on: labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/CommandExecutorSoapImpl.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/PostCxfSoap.java
===================================================================
--- labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/PostCxfSoap.java (rev 0)
+++ labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/PostCxfSoap.java 2010-08-12 20:31:56 UTC (rev 34688)
@@ -0,0 +1,32 @@
+/**
+ * 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 org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+public class PostCxfSoap implements Processor {
+
+ public void process(Exchange exchange) throws Exception {
+ // TODO: Implement PostCxfSoap processor
+ System.out.println("PostCxfSoap Processor invoked");
+ }
+
+}
\ No newline at end of file
Property changes on: labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/PostCxfSoap.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/PreCxfSoap.java
===================================================================
--- labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/PreCxfSoap.java (rev 0)
+++ labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/PreCxfSoap.java 2010-08-12 20:31:56 UTC (rev 34688)
@@ -0,0 +1,45 @@
+/**
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *
+ */
+package org.drools.jax.soap;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.component.cxf.CxfConstants;
+import org.apache.cxf.service.model.BindingOperationInfo;
+
+public class PreCxfSoap implements Processor {
+ public void process(Exchange exchange) throws Exception {
+ BindingOperationInfo boi = (BindingOperationInfo)exchange.getProperty(BindingOperationInfo.class.toString());
+ if (boi == null) {
+ boi = new BindingOperationInfo();
+ boi.setProperty(CxfConstants.OPERATION_NAME, "invoke");
+ }
+ exchange.setProperty(BindingOperationInfo.class.toString(), boi);
+ exchange.setPattern(ExchangePattern.InOut);
+ // is this necesary?
+ Message inMessage = exchange.getIn();
+ inMessage.setHeader(CxfConstants.OPERATION_NAME, "invoke");
+ inMessage.setHeader(Exchange.SOAP_ACTION, "execute");
+ inMessage.setHeader(Exchange.ACCEPT_CONTENT_TYPE, "text/plain");
+ inMessage.setHeader(Exchange.CONTENT_TYPE, "text/plain");
+ }
+}
\ No newline at end of file
Property changes on: labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/main/java/org/drools/jax/soap/PreCxfSoap.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfRestTest.java
===================================================================
--- labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfRestTest.java (rev 0)
+++ labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfRestTest.java 2010-08-12 20:31:56 UTC (rev 34688)
@@ -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/branches/camel_soap_support-lucaz/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfRestTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfSoapTest.java
===================================================================
--- labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfSoapTest.java (rev 0)
+++ labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfSoapTest.java 2010-08-12 20:31:56 UTC (rev 34688)
@@ -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 CxfSoapTest extends CamelSpringTestSupport {
+
+ @Override
+ protected AbstractXmlApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/drools/camel/component/CxfSoapSpring.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/branches/camel_soap_support-lucaz/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfSoapTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted: labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfTest.java
===================================================================
--- labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfTest.java 2010-08-12 20:11:52 UTC (rev 34687)
+++ labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfTest.java 2010-08-12 20:31:56 UTC (rev 34688)
@@ -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/branches/camel_soap_support-lucaz/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfTest2.java
===================================================================
--- labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfTest2.java 2010-08-12 20:11:52 UTC (rev 34687)
+++ labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/test/java/org/drools/camel/component/cxf/CxfTest2.java 2010-08-12 20:31:56 UTC (rev 34688)
@@ -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 );
- }
-
-}
Added: labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/test/resources/org/drools/camel/component/CxfSoapSpring.xml
===================================================================
--- labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/test/resources/org/drools/camel/component/CxfSoapSpring.xml (rev 0)
+++ labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/test/resources/org/drools/camel/component/CxfSoapSpring.xml 2010-08-12 20:31:56 UTC (rev 34688)
@@ -0,0 +1,81 @@
+<?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"
+ serviceClass="org.drools.jax.soap.CommandExecutorSoap"
+ address="http://localhost:9002/soap" >
+ <cxf:properties>
+ <entry key="dataFormat" value="POJO"/> <!-- POJO is default -->
+ <entry key="defaultOperationName" value="invoke"/>
+ </cxf:properties>
+ </cxf:cxfEndpoint>
+
+ <bean id="droolsPolicy" class="org.drools.camel.component.DroolsPolicy" />
+
+ <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+
+ <route id="x1">
+ <from uri="direct://http"/>
+ <policy ref="droolsPolicy">
+ <to uri="cxf:bean:soapServer"/>
+ </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>
Property changes on: labs/jbossrules/branches/camel_soap_support-lucaz/drools-camel/src/test/resources/org/drools/camel/component/CxfSoapSpring.xml
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the jboss-svn-commits
mailing list