camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bart Horré <b...@anova.be>
Subject Re: inject OSGi service into Camel Route
Date Fri, 16 Jun 2017 08:52:48 GMT
Hi,

in the below code example you'll find a blueprint file containing a
reference to the service which is then inserted in a camel route.
This can of course  also be done in Spring.
I hope this is of any use to you.


<?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.
-->
<!-- Configures the Camel Context-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">


    <reference id="service" interface="com.example.MyService"/>

    <bean id="routes" class="com.example.MyRoute">
        <argument ref="service"/>
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/blueprint">
        <routeBuilder ref="routes"/>
    </camelContext>
</blueprint>


public class MyRoute extends RouteBuilder {

    private MyService service;

    public MyRoute(MyService service) {
        this.service = service;
    }

    public void configure() {
        /////
    }

}

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message