brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From neykov <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Determine type of entity in rest ...
Date Mon, 15 Jun 2015 20:53:42 GMT
Github user neykov commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/690#discussion_r32465480
  
    --- Diff: usage/rest-client/src/main/java/brooklyn/rest/client/BrooklynApi.java ---
    @@ -116,22 +119,26 @@ public BrooklynApi(URL endpoint, ClientExecutor clientExecutor)
{
             final T result0 = ProxyFactory.create(clazz, target, clientExecutor);
             return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class<?>[]
{ clazz }, new InvocationHandler() {
                 @Override
    -            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{
    -                Object result1;
    +            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{                 
                     try {
    -                    result1 = method.invoke(result0, args);
    +                    Object result1 = method.invoke(result0, args);
    +                    Class<?> type = String.class;
    +                    if (result1 instanceof Response) {
    +                        if(((Response)result1).getStatus()/100 == 2) {
    +                           String responseClass = method.getAnnotation(ApiOperation.class).responseClass();
    --- End diff --
    
    Looks like `responseClass` is used purely for documentation, can't rely on it for the
exact return type. Better get the return type from the method handle.
    For example:
      * `CatalogApi` doesn't include the fully qualified names
      * Some methods return collections, indicated by `multiValueResponse` in the annotation
      * Some have atomic values, not including a `responseClass`
      * Some methods have complex return types, but don't have `responseClass`
      * etc.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message