Author: ningjiang
Date: Mon Nov 2 10:34:56 2009
New Revision: 831852
URL: http://svn.apache.org/viewvc?rev=831852&view=rev
Log:
CAMEL-2118 Created the spring CamelContext to hold the routes for
camel-example-loan-broker
Added:
camel/trunk/examples/camel-example-loan-broker/src/main/resources/META-INF/spring/
camel/trunk/examples/camel-example-loan-broker/src/main/resources/META-INF/spring/queueCamelContext.xml
(with props)
camel/trunk/examples/camel-example-loan-broker/src/main/resources/META-INF/spring/webServiceCamelContext.xml
(with props)
camel/trunk/examples/camel-example-loan-broker/src/test/java/org/apache/camel/loanbroker/queue/version/LoanBrokerServerTest.java
(with props)
Modified:
camel/trunk/examples/camel-example-loan-broker/pom.xml
camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/Client.java
camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/JmsBroker.java
camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/LoanBroker.java
camel/trunk/examples/camel-example-loan-broker/src/test/java/org/apache/camel/loanbroker/webservice/version/LoadBrokerTest.java
Modified: camel/trunk/examples/camel-example-loan-broker/pom.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-loan-broker/pom.xml?rev=831852&r1=831851&r2=831852&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-loan-broker/pom.xml (original)
+++ camel/trunk/examples/camel-example-loan-broker/pom.xml Mon Nov 2 10:34:56
2009
@@ -60,6 +60,20 @@
<artifactId>activemq-core</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-camel</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-spring</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
Modified:
camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/Client.java
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/Client.java?rev=831852&r1=831851&r2=831852&view=diff
==============================================================================
---
camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/Client.java
(original)
+++
camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/Client.java
Mon Nov 2 10:34:56 2009
@@ -33,7 +33,7 @@
public static void main(String args[]) throws Exception {
CamelContext context = new DefaultCamelContext();
// Set up the ActiveMQ JMS Components
- ConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("tcp://localhost:61616");
+ ConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("tcp://localhost:51616");
// Note we can explicit name of the component
context.addComponent("jms",
JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
Modified:
camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/JmsBroker.java
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/JmsBroker.java?rev=831852&r1=831851&r2=831852&view=diff
==============================================================================
---
camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/JmsBroker.java
(original)
+++
camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/JmsBroker.java
Mon Nov 2 10:34:56 2009
@@ -24,7 +24,7 @@
public final class JmsBroker {
JMSEmbeddedBroker jmsBrokerThread;
- String jmsBrokerUrl = "tcp://localhost:61616";
+ String jmsBrokerUrl = "tcp://localhost:51616";
String activeMQStorageDir;
public JmsBroker() {
}
Modified:
camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/LoanBroker.java
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/LoanBroker.java?rev=831852&r1=831851&r2=831852&view=diff
==============================================================================
---
camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/LoanBroker.java
(original)
+++
camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/LoanBroker.java
Mon Nov 2 10:34:56 2009
@@ -42,7 +42,7 @@
JmsBroker broker = new JmsBroker();
broker.start();
// Set up the ActiveMQ JMS Components
- ConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("tcp://localhost:61616");
+ ConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("tcp://localhost:51616");
// Note we can explicitly name the component
context.addComponent("jms",
JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
Added:
camel/trunk/examples/camel-example-loan-broker/src/main/resources/META-INF/spring/queueCamelContext.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-loan-broker/src/main/resources/META-INF/spring/queueCamelContext.xml?rev=831852&view=auto
==============================================================================
---
camel/trunk/examples/camel-example-loan-broker/src/main/resources/META-INF/spring/queueCamelContext.xml
(added)
+++
camel/trunk/examples/camel-example-loan-broker/src/main/resources/META-INF/spring/queueCamelContext.xml
Mon Nov 2 10:34:56 2009
@@ -0,0 +1,47 @@
+<?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:camel="http://camel.apache.org/schema/spring"
+ xmlns:broker="http://activemq.apache.org/schema/core"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
+ http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core-5.3.0.xsd">
+
+ <!-- lets configure the ActiveMQ JMS broker server to listen on TCP 51616
-->
+ <broker:broker useJmx="false" persistent="false" brokerName="localhost">
+ <broker:transportConnectors>
+ <broker:transportConnector name="tcp" uri="tcp://localhost:51616"/>
+ </broker:transportConnectors>
+ </broker:broker>
+
+ <!-- lets configure the Camel ActiveMQ to use the ActiveMQ broker declared
above -->
+ <bean id="jms"
class="org.apache.activemq.camel.component.ActiveMQComponent">
+ <property name="brokerURL" value="tcp://localhost:51616"/>
+ </bean>
+
+ <bean id="loanBroker"
class="org.apache.camel.loanbroker.queue.version.LoanBroker"/>
+
+ <camel:camelContext>
+ <camel:routeBuilder ref="loanBroker"/>
+ </camel:camelContext>
+
+
+</beans>
Propchange:
camel/trunk/examples/camel-example-loan-broker/src/main/resources/META-INF/spring/queueCamelContext.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/examples/camel-example-loan-broker/src/main/resources/META-INF/spring/queueCamelContext.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
camel/trunk/examples/camel-example-loan-broker/src/main/resources/META-INF/spring/queueCamelContext.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added:
camel/trunk/examples/camel-example-loan-broker/src/main/resources/META-INF/spring/webServiceCamelContext.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-loan-broker/src/main/resources/META-INF/spring/webServiceCamelContext.xml?rev=831852&view=auto
==============================================================================
---
camel/trunk/examples/camel-example-loan-broker/src/main/resources/META-INF/spring/webServiceCamelContext.xml
(added)
+++
camel/trunk/examples/camel-example-loan-broker/src/main/resources/META-INF/spring/webServiceCamelContext.xml
Mon Nov 2 10:34:56 2009
@@ -0,0 +1,64 @@
+<?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:camel="http://camel.apache.org/schema/spring"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
+ http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
+
+ <jaxws:endpoint id="creditAgent"
+
implementor="org.apache.camel.loanbroker.webservice.version.credit.CreditAgency"
+ address="http://localhost:9006/creditAgency"/>
+
+ <bean id="bank1"
class="org.apache.camel.loanbroker.webservice.version.bank.Bank">
+ <constructor-arg index="0"><value>bank1</value></constructor-arg>
+ </bean>
+
+ <bean id="bank2"
class="org.apache.camel.loanbroker.webservice.version.bank.Bank">
+ <constructor-arg index="0"><value>bank2</value></constructor-arg>
+ </bean>
+
+ <bean id="bank3"
class="org.apache.camel.loanbroker.webservice.version.bank.Bank">
+ <constructor-arg index="0"><value>bank3</value></constructor-arg>
+ </bean>
+
+
+ <jaxws:endpoint id="bankService1"
+ implementor="#bank1"
+ address="http://localhost:9001/bank1"/>
+
+ <jaxws:endpoint id="bankService2"
+ implementor="#bank2"
+ address="http://localhost:9002/bank2"/>
+
+ <jaxws:endpoint id="bankService3"
+ implementor="#bank3"
+ address="http://localhost:9003/bank3"/>
+
+ <camel:camelContext>
+ <camel:routeBuilder ref="loanBroker"/>
+ </camel:camelContext>
+
+ <bean id="loanBroker"
class="org.apache.camel.loanbroker.webservice.version.LoanBroker"/>
+
+
+</beans>
Propchange:
camel/trunk/examples/camel-example-loan-broker/src/main/resources/META-INF/spring/webServiceCamelContext.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/examples/camel-example-loan-broker/src/main/resources/META-INF/spring/webServiceCamelContext.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
camel/trunk/examples/camel-example-loan-broker/src/main/resources/META-INF/spring/webServiceCamelContext.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added:
camel/trunk/examples/camel-example-loan-broker/src/test/java/org/apache/camel/loanbroker/queue/version/LoanBrokerServerTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-loan-broker/src/test/java/org/apache/camel/loanbroker/queue/version/LoanBrokerServerTest.java?rev=831852&view=auto
==============================================================================
---
camel/trunk/examples/camel-example-loan-broker/src/test/java/org/apache/camel/loanbroker/queue/version/LoanBrokerServerTest.java
(added)
+++
camel/trunk/examples/camel-example-loan-broker/src/test/java/org/apache/camel/loanbroker/queue/version/LoanBrokerServerTest.java
Mon Nov 2 10:34:56 2009
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.loanbroker.queue.version;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class LoanBrokerServerTest extends Assert {
+
+ @Test
+ public void startLoanBroker() throws Exception {
+ AbstractApplicationContext context =
+ new ClassPathXmlApplicationContext(new
String[]{"/META-INF/spring/queueCamelContext.xml"});
+ Thread.sleep(4000);
+ context.start();
+ }
+
+}
Propchange:
camel/trunk/examples/camel-example-loan-broker/src/test/java/org/apache/camel/loanbroker/queue/version/LoanBrokerServerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/examples/camel-example-loan-broker/src/test/java/org/apache/camel/loanbroker/queue/version/LoanBrokerServerTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
camel/trunk/examples/camel-example-loan-broker/src/test/java/org/apache/camel/loanbroker/webservice/version/LoadBrokerTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-loan-broker/src/test/java/org/apache/camel/loanbroker/webservice/version/LoadBrokerTest.java?rev=831852&r1=831851&r2=831852&view=diff
==============================================================================
---
camel/trunk/examples/camel-example-loan-broker/src/test/java/org/apache/camel/loanbroker/webservice/version/LoadBrokerTest.java
(original)
+++
camel/trunk/examples/camel-example-loan-broker/src/test/java/org/apache/camel/loanbroker/webservice/version/LoadBrokerTest.java
Mon Nov 2 10:34:56 2009
@@ -16,6 +16,8 @@
*/
package org.apache.camel.loanbroker.webservice.version;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.apache.camel.CamelContext;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.loanbroker.webservice.version.bank.BankServer;
@@ -26,36 +28,17 @@
import org.junit.Test;
public class LoadBrokerTest extends Assert {
- CamelContext camelContext;
- CreditAgencyServer creditAgencyServer;
- BankServer bankServer;
+ AbstractApplicationContext applicationContext;
@Before
public void startServices() throws Exception {
- camelContext = new DefaultCamelContext();
- creditAgencyServer = new CreditAgencyServer();
- // Start the credit server
- creditAgencyServer.start();
-
- // Start the bank server
- bankServer = new BankServer();
- bankServer.start();
-
- // Start the camel context
- camelContext.addRoutes(new LoanBroker());
- camelContext.start();
+ applicationContext = new ClassPathXmlApplicationContext(new
String[]{"/META-INF/spring/webServiceCamelContext.xml"});
}
@After
public void stopServices() throws Exception {
- if (camelContext != null) {
- camelContext.stop();
- }
- if (bankServer != null) {
- bankServer.stop();
- }
- if (creditAgencyServer != null) {
- creditAgencyServer.stop();
+ if (applicationContext != null) {
+ applicationContext.stop();
}
}