[jboss-svn-commits] JBL Code SVN: r33995 - in labs/jbossrules/trunk/drools-server: drools-server-app/src/main/java/org/apache/camel and 7 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Jul 18 02:47:30 EDT 2010
Author: mark.proctor at jboss.com
Date: 2010-07-18 02:47:29 -0400 (Sun, 18 Jul 2010)
New Revision: 33995
Added:
labs/jbossrules/trunk/drools-server/drools-server-app/src/main/java/org/drools/server/Test.java
labs/jbossrules/trunk/drools-server/drools-server-app/src/main/resources/beans.xml
labs/jbossrules/trunk/drools-server/drools-server-app/src/main/resources/camel-client.xml
labs/jbossrules/trunk/drools-server/drools-server-app/src/main/resources/camel-server.xml
labs/jbossrules/trunk/drools-server/drools-server-app/src/main/resources/knowledge-services.xml
labs/jbossrules/trunk/drools-server/drools-server-app/src/main/resources/test.drl
labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/test.jsp
labs/jbossrules/trunk/drools-server/drools-server-app/src/test/java/org/drools/server/CxfRsClientServerTest.java
labs/jbossrules/trunk/drools-server/drools-server-app/src/test/resources/beans-test.xml
labs/jbossrules/trunk/drools-server/drools-server-app/src/test/resources/camel-client-test.xml
labs/jbossrules/trunk/drools-server/drools-server-app/src/test/resources/camel-embedded-server-test.xml
Removed:
labs/jbossrules/trunk/drools-server/drools-server-app/src/main/java/org/apache/camel/jboss/
labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/beans.xml
labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/camel.xml
labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/knowledge-services.xml
labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/test.drl
labs/jbossrules/trunk/drools-server/drools-server-app/src/test/java/org/drools/pipeline/camel/
labs/jbossrules/trunk/drools-server/drools-server-spring/
Modified:
labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/web.xml
Log:
JBRULES-2347 Camel
-Getting Drools Server working with camel
Added: labs/jbossrules/trunk/drools-server/drools-server-app/src/main/java/org/drools/server/Test.java
===================================================================
--- labs/jbossrules/trunk/drools-server/drools-server-app/src/main/java/org/drools/server/Test.java (rev 0)
+++ labs/jbossrules/trunk/drools-server/drools-server-app/src/main/java/org/drools/server/Test.java 2010-07-18 06:47:29 UTC (rev 33995)
@@ -0,0 +1,56 @@
+package org.drools.server;
+
+import java.io.InputStream;
+
+import javax.ws.rs.core.Response;
+
+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;
+ }
+}
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-server/drools-server-app/src/main/resources/beans.xml (from rev 33942, labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/beans.xml)
===================================================================
--- labs/jbossrules/trunk/drools-server/drools-server-app/src/main/resources/beans.xml (rev 0)
+++ labs/jbossrules/trunk/drools-server/drools-server-app/src/main/resources/beans.xml 2010-07-18 06:47:29 UTC (rev 33995)
@@ -0,0 +1,32 @@
+<?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:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
+ default-autowire="byName">
+
+
+ <!-- loads the kbases and ksessions into the ApplicationContext -->
+ <import resource="classpath:knowledge-services.xml" />
+
+ <!-- Builds the routes that makes the ksessesions available as services -->
+ <import resource="classpath:camel-server.xml" />
+
+</beans>
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-server/drools-server-app/src/main/resources/camel-client.xml
===================================================================
--- labs/jbossrules/trunk/drools-server/drools-server-app/src/main/resources/camel-client.xml (rev 0)
+++ labs/jbossrules/trunk/drools-server/drools-server-app/src/main/resources/camel-client.xml 2010-07-18 06:47:29 UTC (rev 33995)
@@ -0,0 +1,44 @@
+<?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"
+ xsi:schemaLocation="
+ 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://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
+ ">
+
+
+ <!-- Leave this, as it's needed to make Camel "drools" aware -->
+ <bean id="droolsPolicy" class="org.drools.camel.component.DroolsPolicy" />
+
+ <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+
+ <route>
+ <from uri="direct://kservice"/>
+ <policy ref="droolsPolicy">
+ <to uri="cxfrs://http://localhost:8080/drools-server-app/kservice/rest"/>
+ </policy>
+ </route>
+
+ </camelContext>
+
+</beans>
Copied: labs/jbossrules/trunk/drools-server/drools-server-app/src/main/resources/camel-server.xml (from rev 33942, labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/camel.xml)
===================================================================
--- labs/jbossrules/trunk/drools-server/drools-server-app/src/main/resources/camel-server.xml (rev 0)
+++ labs/jbossrules/trunk/drools-server/drools-server-app/src/main/resources/camel-server.xml 2010-07-18 06:47:29 UTC (rev 33995)
@@ -0,0 +1,68 @@
+<?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"
+ xsi:schemaLocation="
+ 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://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
+ ">
+
+ <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-servlet.xml" />
+
+
+ <!--
+ ! Define the server end point.
+ ! Copy and paste this element, changing id and the address, to expose services on different urls.
+ ! Different Camel routes can handle different end point paths.
+ -->
+ <cxf:rsServer id="rsServer"
+ address="/kservice/rest"
+ serviceClass="org.drools.jax.rs.CommandExecutorImpl">
+ <cxf:providers>
+ <bean class="org.drools.jax.rs.CommandMessageBodyReader"/>
+ </cxf:providers>
+ </cxf:rsServer>
+
+ <!-- Leave this, as it's needed to make Camel "drools" aware -->
+ <bean id="droolsPolicy" class="org.drools.camel.component.DroolsPolicy" />
+
+ <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+ <!--
+ ! Routes incoming messages from end point id="rsServer".
+ ! Example route unmarshals the messages with xstream and executes against ksession1.
+ ! Copy and paste this element, changing marshallers and the 'to' uri, to target different sessions, as needed.
+ !-->
+
+ <route>
+ <from uri="cxfrs://bean://rsServer"/>
+ <policy ref="droolsPolicy">
+ <unmarshal ref="xstream" />
+ <to uri="drools:node1/ksession1" />
+ <marshal ref="xstream" />
+ </policy>
+ </route>
+
+ </camelContext>
+
+</beans>
Copied: labs/jbossrules/trunk/drools-server/drools-server-app/src/main/resources/knowledge-services.xml (from rev 33942, labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/knowledge-services.xml)
===================================================================
--- labs/jbossrules/trunk/drools-server/drools-server-app/src/main/resources/knowledge-services.xml (rev 0)
+++ labs/jbossrules/trunk/drools-server/drools-server-app/src/main/resources/knowledge-services.xml 2010-07-18 06:47:29 UTC (rev 33995)
@@ -0,0 +1,35 @@
+<?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:drools="http://drools.org/schema/drools-spring"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://drools.org/schema/drools-spring http://drools.org/schema/drools-spring.xsd">
+
+ <drools:execution-node id="node1" />
+
+ <drools:kbase id="kbase1" node="node1">
+ <drools:resources>
+ <drools:resource type="DRL" source="classpath:test.drl"/>
+ </drools:resources>
+ </drools:kbase>
+
+ <drools:ksession id="ksession1" type="stateless" kbase="kbase1" node="node1"/>
+
+</beans>
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-server/drools-server-app/src/main/resources/test.drl (from rev 33942, labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/test.drl)
===================================================================
--- labs/jbossrules/trunk/drools-server/drools-server-app/src/main/resources/test.drl (rev 0)
+++ labs/jbossrules/trunk/drools-server/drools-server-app/src/main/resources/test.drl 2010-07-18 06:47:29 UTC (rev 33995)
@@ -0,0 +1,13 @@
+package org.test
+
+declare Message
+ text : String
+end
+
+
+rule "echo" dialect "mvel"
+when
+ $m : Message();
+then
+ $m.text = "echo:" + $m.text;
+end
\ No newline at end of file
Deleted: labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/beans.xml
===================================================================
--- labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/beans.xml 2010-07-18 05:02:12 UTC (rev 33994)
+++ labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/beans.xml 2010-07-18 06:47:29 UTC (rev 33995)
@@ -1,33 +0,0 @@
-<?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:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
- default-autowire="byName">
-
-
- <!-- loads the kbases and ksessions into the ApplicationContext -->
- <import resource="classpath:services-test.xml" />
-
- <!-- Builds the routes that makes the ksessesions available as services -->
- <import resource="classpath:knowledge-services.xml" />
-
-
-</beans>
\ No newline at end of file
Deleted: labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/camel.xml
===================================================================
--- labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/camel.xml 2010-07-18 05:02:12 UTC (rev 33994)
+++ labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/camel.xml 2010-07-18 06:47:29 UTC (rev 33995)
@@ -1,64 +0,0 @@
-<?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"
- xsi:schemaLocation="
- 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://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
- ">
-
- <!--
- ! Define the server end point.
- ! Copy and paste this element, changing id and the path for the address to expose services on different urls.
- ! Different Camel routes can handle different end point paths.
- -->
- <cxf:rsServer id="rsServer"
- address="/"
- serviceClass="org.drools.jax.rs.CommandExecutorImpl">
- <cxf:providers>
- <bean class="org.drools.jax.rs.CommandMessageBodyReader"/>
- </cxf:providers>
- </cxf:rsServer>
-
- <!-- Leave this, as it's needed to make Camel "drools" aware -->
- <bean id="droolsPolicy" class="org.drools.camel.component.DroolsPolicy" />
-
- <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
-
- <!--
- ! Routes incoming messages from end point id="rsServer"
- ! Example route unmarshals the messages with xstream and executes against ksession1
- ! Copy and paste this element, changing marsalls and the to uri, to target different sessions, as needed
- !-->
-
- <route>
- <from uri="cxfrs://bean://rsServer"/>
- <policy ref="droolsPolicy">
- <unmarshal ref="xstream" />
- <to uri="drools:node1/ksession1" />
- <marshal ref="xstream" />
- </policy>
- </route>
-
- </camelContext>
-
-</beans>
Deleted: labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/knowledge-services.xml
===================================================================
--- labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/knowledge-services.xml 2010-07-18 05:02:12 UTC (rev 33994)
+++ labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/knowledge-services.xml 2010-07-18 06:47:29 UTC (rev 33995)
@@ -1,35 +0,0 @@
-<?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:drools="http://drools.org/schema/drools-spring"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
- http://drools.org/schema/drools-spring http://drools.org/schema/drools-spring.xsd">
-
- <drools:execution-node id="node1" />
-
- <drools:kbase id="kbase1" node="node1">
- <drools:resources>
- <drools:resource type="DRL" source="classpath:test.drl"/>
- </drools:resources>
- </drools:kbase>
-
- <drools:ksession id="ksession1" type="stateless" kbase="kbase1" node="node1"/>
-
-</beans>
\ No newline at end of file
Deleted: labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/test.drl
===================================================================
--- labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/test.drl 2010-07-18 05:02:12 UTC (rev 33994)
+++ labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/test.drl 2010-07-18 06:47:29 UTC (rev 33995)
@@ -1,13 +0,0 @@
-package org.test
-
-declare Message
- text : String
-end
-
-
-rule "echo" dialect "mvel"
-when
- $m : Message();
-then
- $m.text = "echo:" + $m.text;
-end
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/web.xml
===================================================================
--- labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/web.xml 2010-07-18 05:02:12 UTC (rev 33994)
+++ labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/WEB-INF/web.xml 2010-07-18 06:47:29 UTC (rev 33995)
@@ -1,30 +1,30 @@
-<?xml version="1.0"?>
-<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
-
- <display-name>JBoss Drools Execution Server</display-name>
-
<context-param>
<param-name>contextConfigLocation</param-name>
- <param-value>/WEB-INF/configuration.xml</param-value>
+ <param-value>classpath:beans.xml</param-value>
</context-param>
-
+
<listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ <listener-class>
+ org.springframework.web.context.ContextLoaderListener
+ </listener-class>
</listener>
-
+
<servlet>
<servlet-name>CXFServlet</servlet-name>
- <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
+ <display-name>CXF Servlet</display-name>
+ <servlet-class>
+ org.apache.cxf.transport.servlet.CXFServlet
+ </servlet-class>
+ <load-on-startup>1</load-on-startup>
</servlet>
-
+
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
- <url-pattern>/services/*</url-pattern>
+ <url-pattern>/kservice/*</url-pattern>
</servlet-mapping>
-
+
<session-config>
<session-timeout>10</session-timeout>
- </session-config>
-
+ </session-config>
</web-app>
Added: labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/test.jsp
===================================================================
--- labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/test.jsp (rev 0)
+++ labs/jbossrules/trunk/drools-server/drools-server-app/src/main/webapp/test.jsp 2010-07-18 06:47:29 UTC (rev 33995)
@@ -0,0 +1,24 @@
+<%@ page contentType="text/html; charset=UTF-8" %>
+<html>
+ <head>
+ <title>Test Server</title>
+ </head>
+ <body>
+ <h1>Sending Test Message</h1>
+ <%
+ org.drools.server.Test test = new org.drools.server.Test();
+ String msg = request.getParameter("msg");
+
+ if ( msg == null ) {
+ msg = "Hello World";
+ }
+ %>
+
+ Sending Message: "<%=msg%>"
+ </br>
+ <%
+ String res = test.send( msg );
+ %>
+ Response: "<%=res%>"
+ </body>
+</html>
Added: labs/jbossrules/trunk/drools-server/drools-server-app/src/test/java/org/drools/server/CxfRsClientServerTest.java
===================================================================
--- labs/jbossrules/trunk/drools-server/drools-server-app/src/test/java/org/drools/server/CxfRsClientServerTest.java (rev 0)
+++ labs/jbossrules/trunk/drools-server/drools-server-app/src/test/java/org/drools/server/CxfRsClientServerTest.java 2010-07-18 06:47:29 UTC (rev 33995)
@@ -0,0 +1,31 @@
+package org.drools.server;
+
+import org.apache.camel.CamelContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import junit.framework.TestCase;
+
+public class CxfRsClientServerTest extends TestCase {
+
+
+ public void test1() throws Exception {
+ ClassPathXmlApplicationContext springContext = new ClassPathXmlApplicationContext("classpath:beans-test.xml");
+
+ 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";
+
+ Test test = new Test();
+ String response = test.execute( cmd,
+ ( CamelContext ) springContext.getBean( "camel-client-ctx" ) );
+
+ assertTrue( response.contains( "execution-results" ) );
+ assertTrue( response.contains( "echo" ) );
+ }
+
+}
Added: labs/jbossrules/trunk/drools-server/drools-server-app/src/test/resources/beans-test.xml
===================================================================
--- labs/jbossrules/trunk/drools-server/drools-server-app/src/test/resources/beans-test.xml (rev 0)
+++ labs/jbossrules/trunk/drools-server/drools-server-app/src/test/resources/beans-test.xml 2010-07-18 06:47:29 UTC (rev 33995)
@@ -0,0 +1,36 @@
+<?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://drools.org/schema/drools-spring.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://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">
+
+ <import resource="classpath:knowledge-services.xml" />
+
+ <import resource="classpath:camel-embedded-server-test.xml" />
+
+ <import resource="classpath:camel-client-test.xml" />
+
+</beans>
Added: labs/jbossrules/trunk/drools-server/drools-server-app/src/test/resources/camel-client-test.xml
===================================================================
--- labs/jbossrules/trunk/drools-server/drools-server-app/src/test/resources/camel-client-test.xml (rev 0)
+++ labs/jbossrules/trunk/drools-server/drools-server-app/src/test/resources/camel-client-test.xml 2010-07-18 06:47:29 UTC (rev 33995)
@@ -0,0 +1,44 @@
+<?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"
+ xsi:schemaLocation="
+ 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://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
+ ">
+
+
+ <!-- Leave this, as it's needed to make Camel "drools" aware -->
+ <bean id="droolsPolicy" class="org.drools.camel.component.DroolsPolicy" />
+
+ <camelContext id="camel-client-ctx" xmlns="http://camel.apache.org/schema/spring">
+
+ <route>
+ <from uri="direct://kservice"/>
+ <policy ref="droolsPolicy">
+ <to uri="cxfrs://http://localhost:9002/rest"/>
+ </policy>
+ </route>
+
+ </camelContext>
+
+</beans>
Added: labs/jbossrules/trunk/drools-server/drools-server-app/src/test/resources/camel-embedded-server-test.xml
===================================================================
--- labs/jbossrules/trunk/drools-server/drools-server-app/src/test/resources/camel-embedded-server-test.xml (rev 0)
+++ labs/jbossrules/trunk/drools-server/drools-server-app/src/test/resources/camel-embedded-server-test.xml 2010-07-18 06:47:29 UTC (rev 33995)
@@ -0,0 +1,52 @@
+<?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"
+ xsi:schemaLocation="
+ 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://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
+ ">
+
+ <cxf:rsServer id="rsServer"
+ address="http://localhost:9002/rest"
+ serviceClass="org.drools.jax.rs.CommandExecutorImpl">
+ <cxf:providers>
+ <bean class="org.drools.jax.rs.CommandMessageBodyReader"/>
+ </cxf:providers>
+ </cxf:rsServer>
+
+ <!-- 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">
+ <unmarshal ref="xstream" />
+ <to uri="drools:node1/ksession1" />
+ <marshal ref="xstream" />
+ </policy>
+ </route>
+
+ </camelContext>
+
+</beans>
More information about the jboss-svn-commits
mailing list