You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Claus Ibsen (JIRA)" <ji...@apache.org> on 2011/04/21 20:26:05 UTC

[jira] [Commented] (CAMEL-3889) ProxyHelper and ProxyBuilder methods generate warnings and are pretty much unusable

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

Claus Ibsen commented on CAMEL-3889:
------------------------------------

#1 looks fine to me.
The JDK java.lang.reflect.Proxy uses this also, which is what Camel uses under the hood.

> ProxyHelper and ProxyBuilder methods generate warnings and are pretty much unusable
> -----------------------------------------------------------------------------------
>
>                 Key: CAMEL-3889
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3889
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Daniel Kulp
>         Attachments: patch1.txt, patch2.txt, patch3.txt
>
>
> The ProxyHelper/Builder methods that look like:
> <T> T createProxy(Endpoint endpoint, Class<T>... interfaceClasses)
> will generate a compile warning whenever you try to use them.   Part of the reason is that they are completely broken when written that way.   The intention is to be able to specify multiple interface classes.  However, you cannot with the above signature  as you can ONLY pass the T.class.     Thus, something like createProxy(ep, Foo.class, Foo.class) will work (but is useless), but something like createProxy(ep, Foo.class, Bar.class) will not, even if Bar extends Foo.    THUS, the way it's written, you can really only effectively pass in a single interfaceClass and have it work.
> There are three alternatives (I'll attach patches for all three for consideration) (all three would require javadoc updates, let me know which alternative is preferred and I'll happily provide the javadoc updates):
> 1) Change to:   <T> T createProxy(Endpoint endpoint, Class<?>... interfaceClasses)
> Very simple, it works.   No warnings.  
> 2) Add a method like:   <T> T createProxy(Endpoint endpoint, Class<T> interfaceClass)
> to really handle the single interface case (which is all of the cases in Camel) and @Deprecate the broken version.
> 3) <T> T createProxy(Endpoint endpoint, Class<T> interfaceClass, Class<?> ... otherInterfaces)
> to separate out the "primary" interface and the "extras".
> I personally prefer either 1 or 2, leaning toward #2.  Maybe move to #1 for 3.0.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira