Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add examples #1078

Merged
merged 2 commits into from
Nov 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
//
// To run this integrations use:
//
// kamel run --name=rest-with-restlet --dependency=camel-rest --dependency=camel-restlet examples/RestWithRestlet.java
// kamel run --name=rest-with-undertow --dependency=camel-rest --dependency=camel-undertow examples/RestWithUndertow.java
//
import org.apache.camel.Exchange;

public class RestWithRestlet extends org.apache.camel.builder.RouteBuilder {
public class RestWithUndertow extends org.apache.camel.builder.RouteBuilder {
@Override
public void configure() throws Exception {
restConfiguration()
.component("restlet")
.component("undertow")
.host("0.0.0.0")
.port("8080");

Expand Down
31 changes: 31 additions & 0 deletions examples/polyglot/JavaRoute.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.
*/

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.BindToRegistry;
import org.apache.camel.Processor;

public class JavaRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
}

@BindToRegistry
public static Processor javaProcessor() {
return e -> e.getMessage().setHeader("MyHeader", "HelloFromJava");
}
}
8 changes: 8 additions & 0 deletions examples/polyglot/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
= Example of route built using multiple DSl

To run it:

[source,shell]
----
$ kamel run --name polyglot routes.xml beans.groovy JavaRoute.java
----
23 changes: 23 additions & 0 deletions examples/polyglot/beans.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// camel-k: language=groovy
/*
* 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 {
groovyProcessor = {
it.in.body = 'Hello from Groovy'
} as org.apache.camel.Processor
}
29 changes: 29 additions & 0 deletions examples/polyglot/routes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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.
-->
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">

<route id="polyglot">
<from uri="timer:hello?period=3s"/>
<process ref="javaProcessor"/>
<process ref="groovyProcessor"/>
<to uri="log:info?showAll=true&amp;multiline=true"/>
</route>

</routes>