CAMEL-6488: camel-netty-http. Added example for blueprint.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d553a925 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d553a925 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d553a925 Branch: refs/heads/master Commit: d553a925cb677e679c728165ddc56a48c9893694 Parents: 97a91a0 Author: Claus Ibsen <[email protected]> Authored: Wed Jun 26 11:25:36 2013 +0200 Committer: Claus Ibsen <[email protected]> Committed: Wed Jun 26 11:25:36 2013 +0200 ---------------------------------------------------------------------- .../camel-example-netty-http/myapp-one/pom.xml | 30 ++++++++ .../resources/OSGI-INF/blueprint/camel-one.xml | 37 ++++++++++ .../camel-example-netty-http/myapp-two/pom.xml | 30 ++++++++ .../resources/OSGI-INF/blueprint/camel-two.xml | 37 ++++++++++ examples/camel-example-netty-http/pom.xml | 72 ++++++++++++++++++++ .../shared-netty-http-server/pom.xml | 56 +++++++++++++++ .../OSGI-INF/blueprint/http-server.xml | 40 +++++++++++ examples/pom.xml | 1 + 8 files changed, 303 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/d553a925/examples/camel-example-netty-http/myapp-one/pom.xml ---------------------------------------------------------------------- diff --git a/examples/camel-example-netty-http/myapp-one/pom.xml b/examples/camel-example-netty-http/myapp-one/pom.xml new file mode 100644 index 0000000..9a05c18 --- /dev/null +++ b/examples/camel-example-netty-http/myapp-one/pom.xml @@ -0,0 +1,30 @@ +<?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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>camel-example-netty-http</artifactId> + <groupId>org.apache.camel</groupId> + <version>2.12-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>camel-example-netty-myapp-one</artifactId> + <name>Camel :: Example :: Netty HTTP :: My Application One</name> + <packaging>bundle</packaging> + +</project> http://git-wip-us.apache.org/repos/asf/camel/blob/d553a925/examples/camel-example-netty-http/myapp-one/src/main/resources/OSGI-INF/blueprint/camel-one.xml ---------------------------------------------------------------------- diff --git a/examples/camel-example-netty-http/myapp-one/src/main/resources/OSGI-INF/blueprint/camel-one.xml b/examples/camel-example-netty-http/myapp-one/src/main/resources/OSGI-INF/blueprint/camel-one.xml new file mode 100644 index 0000000..6371b35 --- /dev/null +++ b/examples/camel-example-netty-http/myapp-one/src/main/resources/OSGI-INF/blueprint/camel-one.xml @@ -0,0 +1,37 @@ +<?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. +--> +<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"> + + <!-- reference the shared http server --> + <reference id="sharedNettyHttpServer" interface="org.apache.camel.component.netty.http.NettySharedHttpServer"/> + + <camelContext xmlns="http://camel.apache.org/schema/blueprint"> + + <route id="http-route-one"> + <from uri="netty-http:http://0.0.0.0/one?matchOnUriPrefix=true&nettySharedHttpServer=#sharedNettyHttpServer"/> + <transform> + <simple>Response from camel one: ${body}</simple> + </transform> + </route> + + </camelContext> + +</blueprint> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/d553a925/examples/camel-example-netty-http/myapp-two/pom.xml ---------------------------------------------------------------------- diff --git a/examples/camel-example-netty-http/myapp-two/pom.xml b/examples/camel-example-netty-http/myapp-two/pom.xml new file mode 100644 index 0000000..6e0ae27 --- /dev/null +++ b/examples/camel-example-netty-http/myapp-two/pom.xml @@ -0,0 +1,30 @@ +<?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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>camel-example-netty-http</artifactId> + <groupId>org.apache.camel</groupId> + <version>2.12-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>camel-example-netty-myapp-two</artifactId> + <name>Camel :: Example :: Netty HTTP :: My Application Two</name> + <packaging>bundle</packaging> + +</project> http://git-wip-us.apache.org/repos/asf/camel/blob/d553a925/examples/camel-example-netty-http/myapp-two/src/main/resources/OSGI-INF/blueprint/camel-two.xml ---------------------------------------------------------------------- diff --git a/examples/camel-example-netty-http/myapp-two/src/main/resources/OSGI-INF/blueprint/camel-two.xml b/examples/camel-example-netty-http/myapp-two/src/main/resources/OSGI-INF/blueprint/camel-two.xml new file mode 100644 index 0000000..b34a983 --- /dev/null +++ b/examples/camel-example-netty-http/myapp-two/src/main/resources/OSGI-INF/blueprint/camel-two.xml @@ -0,0 +1,37 @@ +<?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. +--> +<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"> + + <!-- reference the shared http server --> + <reference id="sharedNettyHttpServer" interface="org.apache.camel.component.netty.http.NettySharedHttpServer"/> + + <camelContext xmlns="http://camel.apache.org/schema/blueprint"> + + <route id="http-route-two"> + <from uri="netty-http:http://0.0.0.0/two?matchOnUriPrefix=true&nettySharedHttpServer=#sharedNettyHttpServer"/> + <transform> + <simple>Response from camel two: ${body}</simple> + </transform> + </route> + + </camelContext> + +</blueprint> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/d553a925/examples/camel-example-netty-http/pom.xml ---------------------------------------------------------------------- diff --git a/examples/camel-example-netty-http/pom.xml b/examples/camel-example-netty-http/pom.xml new file mode 100644 index 0000000..a1b9aa5 --- /dev/null +++ b/examples/camel-example-netty-http/pom.xml @@ -0,0 +1,72 @@ +<?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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.camel</groupId> + <artifactId>examples</artifactId> + <version>2.12-SNAPSHOT</version> + </parent> + + <artifactId>camel-example-netty-http</artifactId> + <packaging>pom</packaging> + <name>Camel :: Example :: Netty Shared HTTP Server</name> + <description>An example showing how to use a shared Netty HTTP server with multiple Camel applications in OSGi container</description> + + <properties> + <camel.osgi.export.pkg>org.apache.camel.example.netty.*</camel.osgi.export.pkg> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-blueprint</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-netty-http</artifactId> + </dependency> + + <!-- logging --> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + </dependency> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + </dependency> + + <!-- for testing --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + + </dependencies> + + <modules> + <module>shared-netty-http-server</module> + <module>myapp-one</module> + <module>myapp-two</module> + </modules> + +</project> http://git-wip-us.apache.org/repos/asf/camel/blob/d553a925/examples/camel-example-netty-http/shared-netty-http-server/pom.xml ---------------------------------------------------------------------- diff --git a/examples/camel-example-netty-http/shared-netty-http-server/pom.xml b/examples/camel-example-netty-http/shared-netty-http-server/pom.xml new file mode 100644 index 0000000..af85beb --- /dev/null +++ b/examples/camel-example-netty-http/shared-netty-http-server/pom.xml @@ -0,0 +1,56 @@ +<?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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>camel-example-netty-http</artifactId> + <groupId>org.apache.camel</groupId> + <version>2.12-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>camel-example-netty-http-shared</artifactId> + <name>Camel :: Example :: Netty HTTP :: Shared Netty HTTP Server</name> + <packaging>bundle</packaging> + + <build> + <plugins> + + <!-- to generate the MANIFEST-FILE of the bundle --> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <manifestLocation>target/META-INF</manifestLocation> + <instructions> + <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName> + <Import-Package> + org.apache.camel.component.netty, + org.apache.camel.component.netty.http, + org.osgi.service.blueprint + </Import-Package> + </instructions> + </configuration> + </plugin> + + + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/camel/blob/d553a925/examples/camel-example-netty-http/shared-netty-http-server/src/main/resources/OSGI-INF/blueprint/http-server.xml ---------------------------------------------------------------------- diff --git a/examples/camel-example-netty-http/shared-netty-http-server/src/main/resources/OSGI-INF/blueprint/http-server.xml b/examples/camel-example-netty-http/shared-netty-http-server/src/main/resources/OSGI-INF/blueprint/http-server.xml new file mode 100755 index 0000000..54a7cf4 --- /dev/null +++ b/examples/camel-example-netty-http/shared-netty-http-server/src/main/resources/OSGI-INF/blueprint/http-server.xml @@ -0,0 +1,40 @@ +<?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. +--> +<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"> + + <!-- netty http bootstrap configuration --> + <!--<bean id="configuration" class="org.apache.camel.component.netty.http.NettySharedHttpServerBootstrapConfiguration">--> + <bean id="configuration" class="org.apache.camel.component.netty.NettyServerBootstrapConfiguration"> + <!-- the port number is mandatory and must be set --> + <property name="port" value="8888"/> + <property name="backlog" value="20"/> + </bean> + + <!-- the netty http server --> + <bean id="httpServer" class="org.apache.camel.component.netty.http.DefaultNettySharedHttpServer" + init-method="start" destroy-method="stop"> + <property name="nettyServerBootstrapConfiguration" ref="configuration"/> + </bean> + + <!-- and exported in the OSGi server registry so we can use it from the Camel application bundles --> + <service id="sharedNettyHttpServer" ref="httpServer" interface="org.apache.camel.component.netty.http.NettySharedHttpServer"/> + +</blueprint> http://git-wip-us.apache.org/repos/asf/camel/blob/d553a925/examples/pom.xml ---------------------------------------------------------------------- diff --git a/examples/pom.xml b/examples/pom.xml index 9fbf957..1acb3cb 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -53,6 +53,7 @@ <module>camel-example-loadbalancing</module> <module>camel-example-loan-broker</module> <module>camel-example-management</module> + <module>camel-example-netty-http</module> <module>camel-example-osgi</module> <module>camel-example-osgi-rmi</module> <module>camel-example-pojo-messaging</module>
