camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luca Burgazzoli (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CAMEL-10584) spring boot auto configuration mojo: use Class.isAssignableFrom instead of instanceof as the later may fail at compile time in case of final classes
Date Fri, 09 Dec 2016 14:28:58 GMT
Luca Burgazzoli created CAMEL-10584:
---------------------------------------

             Summary: spring boot auto configuration mojo: use Class.isAssignableFrom instead
of instanceof as the later may fail at compile time in case of final classes
                 Key: CAMEL-10584
                 URL: https://issues.apache.org/jira/browse/CAMEL-10584
             Project: Camel
          Issue Type: Improvement
          Components: tooling
            Reporter: Luca Burgazzoli
            Assignee: Luca Burgazzoli
             Fix For: 2.19.0


In *AutoConfiguration classes generated by camel-package-plugin, there is a check like 

{code:java}
if (myInstance instanceof CamelContextAware) {
    ((CamelContextAware) dataformat).setCamelContext(camelContext);
}
{code}

This check may fail at compile time if myInstance is final and it is not an instance of CamelContextAware
which make not possible to write final classes.

We should do something like:

{code:java}
if (CamelContextAware.class.isAssignableFrom(MyInstanceType.class)) {
    CamelContext context = CamelContextAware.cast(myInstance);
    if (context != null) {
        context.setCamelContext(camelContext);
    }
}
{code}





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

Mime
View raw message