camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Quinn Stevenson (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-9570) Blueprint Proxies are not used when injected into Java RouteBuilders
Date Fri, 05 Feb 2016 21:18:39 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-9570?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15135018#comment-15135018
] 

Quinn Stevenson commented on CAMEL-9570:
----------------------------------------

Here's the example that I started the discussion ( http://camel.465427.n5.nabble.com/Invoking-Dynamic-OSGi-Blueprint-services-from-a-Java-RouteBuilder-td5776755.html#a5776848
) with that demonstrates the issue:

Java Interface (service-interface bundle):
public interface Echo {
    String execute(String body);
}

Java Implementation:
public class EchoServiceOne implements Echo {
    Logger log = LoggerFactory.getLogger(this.getClass());

    @Override
    public String execute(String body) {
        log.info( "{}:{} -> execute", this.getClass().getSimpleName(), this.hashCode()
);
        return body;
    }
}


Blueprint Registering the service (service-one bundle):
<?xml version="1.0" encoding="UTF-8"?>
<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">

    <service interface="com.pronoia.test.osgi.service.Echo" >
        <service-properties>
            <entry key="instance" value="one" />
        </service-properties>
        <bean class="com.pronoia.test.osgi.service.impl.EchoServiceOne" />
    </service>

</blueprint>

Java RouteBuilder (route-builder bundle):
public class VerySimpleBuilder extends RouteBuilder {
    Echo blueprintServiceReference;

    @Override
    public void configure() throws Exception {
        from("timer://very-simple-builder?period=5000").routeId( "very-simple-route" )
                .setBody( simple( "${exchangeProperty[" + Exchange.TIMER_FIRED_TIME + "]}")
)
                .log("Calling Service via Reference: ${body}" )
                .bean(blueprintServiceReference,false)
                .to( "mock://result")
                .log("Finished" );
    }

    public Echo getBlueprintServiceReference() {
        return blueprintServiceReference;
    }

    public void setBlueprintServiceReference(Echo blueprintServiceReference) {
        this.blueprintServiceReference = blueprintServiceReference;
    }
}

Blueprint constructing the Camel context (camel-context bundle):
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
           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"
>

    <reference id="echo-service" interface="com.pronoia.test.osgi.service.Echo" filter="instance=one"
timeout="2000" />

    <bean id="very-simple-route-builder" class="com.pronoia.test.camel.builder.VerySimpleBuilder">
        <property name="blueprintServiceReference" ref="echo-service" />
    </bean>

    <camelContext id="very-simple-context" xmlns="http://camel.apache.org/schema/blueprint">
        <routeBuilder ref="very-simple-route-builder" />
    </camelContext>

</blueprint>

> Blueprint Proxies are not used when injected into Java RouteBuilders
> --------------------------------------------------------------------
>
>                 Key: CAMEL-9570
>                 URL: https://issues.apache.org/jira/browse/CAMEL-9570
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-blueprint, camel-core
>    Affects Versions: 2.16.2
>            Reporter: Quinn Stevenson
>
> Basic Conditions:
> - Java interface used for OSGi Services
> - Implementation of the Java interface registered as a OSGi service.  Note that the package
containing implementation is NOT exported
> - A Java RouteBuilder that uses the Java interface via bean(...) DSL calls, with a setter
for the bean implementing the interface
> - Wire everything together with Blueprint - create a <reference ...> for the service,
a <bean ...> for the RouteBuilder and inject the service reference, and use the RouteBuilder
in a CamelContext.
> After all this is deployed, stop the bundle implementing the service.  A ServiceUnavailableException
should be thrown after a timeout, but the object that was injected into the RouteBuilder process
the request - so the Blueprint Proxy is not used.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message