环境:JBoss Fuse 6.2.0 + Maven 3.2.2
本实验跟上一个实验有关。
1. 学习重点
(1)从零开始构建 camel route。
2. 修改 settings.xml,内容如下:
参见《Fuse_012:基础入门之一:cxf-basic 》。
3. 使用 Maven 构建
(1)mvn archetype:generate -DarchetypeGroupId=io.fabric8.archetypes -DarchetypeArtifactId=karaf-camel-cbr-archetype -DarchetypeVersion=1.2.0.redhat-133 -DgroupId=org.fusesource.example -DartifactId=camel-basic -Dversion=1.0-SNAPSHOT -Dfabric8-profile=camel-basic-profile
(2)修改 camel-basic/pom.xml,增加 camel-jetty artifact
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jetty</artifactId>
</dependency>
(3)修改 camel-basic/src/main/resources/OSGI-INF/blueprint/cbr.xml
<?xml version="1.0"?>
<!-- JBoss, Home of Professional Open Source Copyright 2014, Red Hat, Inc.
and/or its affiliates, and individual contributors by the @authors tag. See
the copyright.txt in the distribution for a full listing of individual contributors.
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. -->
<!-- This is the OSGi Blueprint XML file defining the Camel context and routes.
Because the file is in the OSGI-INF/blueprint directory inside our JAR, it
will be automatically activated as soon as the bundle is installed. The root
element for any OSGi Blueprint file is 'blueprint' - you also see the namespace
definitions for both the Blueprint and the Camel namespaces. -->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<!-- The namespace for the camelContext element in Blueprint is 'http://camel.apache.org/schema/blueprint'.
Additionally, we can also define namespace prefixes we want to use them in
the XPath expressions in our CBR. While it is not required to assign id's
to the <camelContext/> and <route/> elements, it is a good idea to set those
for runtime management purposes (logging, JMX MBeans, ...) -->
<camelContext id="blueprintContext" trace="false"
xmlns="http://camel.apache.org/schema/blueprint">
<route id="httpBridge">
<from uri="jetty:http://0.0.0.0:8282/cxf/HelloWorld?matchOnUriPrefix=true" />
<delay>
<constant>5000 </constant>
</delay>
<to uri="jetty:http://localhost:8181/cxf/HelloWorld?bridgeEndpoint=true&throwExceptionOnFailure=false" />
</route>
</camelContext>
</blueprint>
(4)mvn clean install
4. 修改 cxf-basic/src/test/java/org/fusesource/example/SoapTest.java
5. 部署 、卸载
(1)./fuse
(2)osgi:install -s mvn:org.fusesource.example/camel-basic/1.0-SNAPSHOT
(3)osgi:list
(4)cd ../cxf-basic
(5)mvn -Ptest
(6)http://localhost:8181/cxf
(7)http://localhost:8181/cxf/HelloWorld?wsdl
(8)osgi:uninstall <id>
参考文献:
1. Red_Hat_JBoss_Fuse-6.2-Getting_Started-en-US.pdf
本实验跟上一个实验有关。
1. 学习重点
(1)从零开始构建 camel route。
2. 修改 settings.xml,内容如下:
参见《Fuse_012:基础入门之一:cxf-basic 》。
3. 使用 Maven 构建
(1)mvn archetype:generate -DarchetypeGroupId=io.fabric8.archetypes -DarchetypeArtifactId=karaf-camel-cbr-archetype -DarchetypeVersion=1.2.0.redhat-133 -DgroupId=org.fusesource.example -DartifactId=camel-basic -Dversion=1.0-SNAPSHOT -Dfabric8-profile=camel-basic-profile
(2)修改 camel-basic/pom.xml,增加 camel-jetty artifact
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jetty</artifactId>
</dependency>
(3)修改 camel-basic/src/main/resources/OSGI-INF/blueprint/cbr.xml
<?xml version="1.0"?>
<!-- JBoss, Home of Professional Open Source Copyright 2014, Red Hat, Inc.
and/or its affiliates, and individual contributors by the @authors tag. See
the copyright.txt in the distribution for a full listing of individual contributors.
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. -->
<!-- This is the OSGi Blueprint XML file defining the Camel context and routes.
Because the file is in the OSGI-INF/blueprint directory inside our JAR, it
will be automatically activated as soon as the bundle is installed. The root
element for any OSGi Blueprint file is 'blueprint' - you also see the namespace
definitions for both the Blueprint and the Camel namespaces. -->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<!-- The namespace for the camelContext element in Blueprint is 'http://camel.apache.org/schema/blueprint'.
Additionally, we can also define namespace prefixes we want to use them in
the XPath expressions in our CBR. While it is not required to assign id's
to the <camelContext/> and <route/> elements, it is a good idea to set those
for runtime management purposes (logging, JMX MBeans, ...) -->
<camelContext id="blueprintContext" trace="false"
xmlns="http://camel.apache.org/schema/blueprint">
<route id="httpBridge">
<from uri="jetty:http://0.0.0.0:8282/cxf/HelloWorld?matchOnUriPrefix=true" />
<delay>
<constant>5000 </constant>
</delay>
<to uri="jetty:http://localhost:8181/cxf/HelloWorld?bridgeEndpoint=true&throwExceptionOnFailure=false" />
</route>
</camelContext>
</blueprint>
(4)mvn clean install
4. 修改 cxf-basic/src/test/java/org/fusesource/example/SoapTest.java
把8181端口改成8282端口,修改如下:
URLConnection connection = new URL("http://localhost:8282/cxf/HelloWorld").openConnection();
URLConnection connection = new URL("http://localhost:8282/cxf/HelloWorld").openConnection();
(1)./fuse
(2)osgi:install -s mvn:org.fusesource.example/camel-basic/1.0-SNAPSHOT
(3)osgi:list
(4)cd ../cxf-basic
(5)mvn -Ptest
(6)http://localhost:8181/cxf
(7)http://localhost:8181/cxf/HelloWorld?wsdl
(8)osgi:uninstall <id>
参考文献:
1. Red_Hat_JBoss_Fuse-6.2-Getting_Started-en-US.pdf
1 条评论:
java计算机编程代码片段
使用BitSet来展示eratosthenes的筛子
发表评论