Java Code Examples for com.alibaba.dubbo.rpc.Invocation#getInvoker()

The following examples show how to use com.alibaba.dubbo.rpc.Invocation#getInvoker() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RpcUtils.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
public static Class<?> getReturnType(Invocation invocation) {
    try {
        if (invocation != null && invocation.getInvoker() != null
                && invocation.getInvoker().getUrl() != null
                && !invocation.getMethodName().startsWith("$")) {
            String service = invocation.getInvoker().getUrl().getServiceInterface();
            if (service != null && service.length() > 0) {
                Class<?> cls = ReflectUtils.forName(service);
                Method method = cls.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
                if (method.getReturnType() == void.class) {
                    return null;
                }
                return method.getReturnType();
            }
        }
    } catch (Throwable t) {
        logger.warn(t.getMessage(), t);
    }
    return null;
}
 
Example 2
Source File: RpcUtils.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
public static Type[] getReturnTypes(Invocation invocation) {
    try {
        if (invocation != null && invocation.getInvoker() != null
                && invocation.getInvoker().getUrl() != null
                && !invocation.getMethodName().startsWith("$")) {
            String service = invocation.getInvoker().getUrl().getServiceInterface();
            if (service != null && service.length() > 0) {
                Class<?> cls = ReflectUtils.forName(service);
                Method method = cls.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
                if (method.getReturnType() == void.class) {
                    return null;
                }
                return new Type[]{method.getReturnType(), method.getGenericReturnType()};
            }
        }
    } catch (Throwable t) {
        logger.warn(t.getMessage(), t);
    }
    return null;
}
 
Example 3
Source File: RpcUtils.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public static Class<?> getReturnType(Invocation invocation) {
    try {
        if (invocation != null && invocation.getInvoker() != null
                && invocation.getInvoker().getUrl() != null
                && ! invocation.getMethodName().startsWith("$")) {
            String service = invocation.getInvoker().getUrl().getServiceInterface();
            if (service != null && service.length() > 0) {
                Class<?> cls = ReflectUtils.forName(service);
                Method method = cls.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
                if (method.getReturnType() == void.class) {
                    return null;
                }
                return method.getReturnType();
            }
        }
    } catch (Throwable t) {
        logger.warn(t.getMessage(), t);
    }
    return null;
}
 
Example 4
Source File: RpcUtils.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public static Type[] getReturnTypes(Invocation invocation) {
    try {
        if (invocation != null && invocation.getInvoker() != null
                && invocation.getInvoker().getUrl() != null
                && ! invocation.getMethodName().startsWith("$")) {
            String service = invocation.getInvoker().getUrl().getServiceInterface();
            if (service != null && service.length() > 0) {
                Class<?> cls = ReflectUtils.forName(service);
                Method method = cls.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
                if (method.getReturnType() == void.class) {
                    return null;
                }
                return new Type[]{method.getReturnType(), method.getGenericReturnType()};
            }
        }
    } catch (Throwable t) {
        logger.warn(t.getMessage(), t);
    }
    return null;
}
 
Example 5
Source File: RpcUtils.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
public static Class<?> getReturnType(Invocation invocation) {
    try {
        if (invocation != null && invocation.getInvoker() != null
                && invocation.getInvoker().getUrl() != null
                && ! invocation.getMethodName().startsWith("$")) {
            String service = invocation.getInvoker().getUrl().getServiceInterface();
            if (service != null && service.length() > 0) {
                Class<?> cls = ReflectUtils.forName(service);
                Method method = cls.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
                if (method.getReturnType() == void.class) {
                    return null;
                }
                return method.getReturnType();
            }
        }
    } catch (Throwable t) {
        logger.warn(t.getMessage(), t);
    }
    return null;
}
 
Example 6
Source File: RpcUtils.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
public static Type[] getReturnTypes(Invocation invocation) {
    try {
        if (invocation != null && invocation.getInvoker() != null
                && invocation.getInvoker().getUrl() != null
                && ! invocation.getMethodName().startsWith("$")) {
            String service = invocation.getInvoker().getUrl().getServiceInterface();
            if (service != null && service.length() > 0) {
                Class<?> cls = ReflectUtils.forName(service);
                Method method = cls.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
                if (method.getReturnType() == void.class) {
                    return null;
                }
                return new Type[]{method.getReturnType(), method.getGenericReturnType()};
            }
        }
    } catch (Throwable t) {
        logger.warn(t.getMessage(), t);
    }
    return null;
}
 
Example 7
Source File: RpcUtils.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
public static Class<?> getReturnType(Invocation invocation) {
    try {
        if (invocation != null && invocation.getInvoker() != null
                && invocation.getInvoker().getUrl() != null
                && !invocation.getMethodName().startsWith("$")) {
            String service = invocation.getInvoker().getUrl().getServiceInterface();
            if (service != null && service.length() > 0) {
                Class<?> cls = ReflectUtils.forName(service);
                Method method = cls.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
                if (method.getReturnType() == void.class) {
                    return null;
                }
                return method.getReturnType();
            }
        }
    } catch (Throwable t) {
        logger.warn(t.getMessage(), t);
    }
    return null;
}
 
Example 8
Source File: RpcUtils.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
public static Type[] getReturnTypes(Invocation invocation) {
    try {
        if (invocation != null && invocation.getInvoker() != null
                && invocation.getInvoker().getUrl() != null
                && !invocation.getMethodName().startsWith("$")) {
            String service = invocation.getInvoker().getUrl().getServiceInterface();
            if (service != null && service.length() > 0) {
                Class<?> cls = ReflectUtils.forName(service);
                Method method = cls.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
                if (method.getReturnType() == void.class) {
                    return null;
                }
                return new Type[]{method.getReturnType(), method.getGenericReturnType()};
            }
        }
    } catch (Throwable t) {
        logger.warn(t.getMessage(), t);
    }
    return null;
}
 
Example 9
Source File: RpcUtils.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public static Class<?> getReturnType(Invocation invocation) {
    try {
        if (invocation != null && invocation.getInvoker() != null
                && invocation.getInvoker().getUrl() != null
                && ! invocation.getMethodName().startsWith("$")) {
            String service = invocation.getInvoker().getUrl().getServiceInterface();
            if (service != null && service.length() > 0) {
                Class<?> cls = ReflectUtils.forName(service);
                Method method = cls.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
                if (method.getReturnType() == void.class) {
                    return null;
                }
                return method.getReturnType();
            }
        }
    } catch (Throwable t) {
        logger.warn(t.getMessage(), t);
    }
    return null;
}
 
Example 10
Source File: RpcUtils.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public static Type[] getReturnTypes(Invocation invocation) {
    try {
        if (invocation != null && invocation.getInvoker() != null
                && invocation.getInvoker().getUrl() != null
                && ! invocation.getMethodName().startsWith("$")) {
            String service = invocation.getInvoker().getUrl().getServiceInterface();
            if (service != null && service.length() > 0) {
                Class<?> cls = ReflectUtils.forName(service);
                Method method = cls.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
                if (method.getReturnType() == void.class) {
                    return null;
                }
                return new Type[]{method.getReturnType(), method.getGenericReturnType()};
            }
        }
    } catch (Throwable t) {
        logger.warn(t.getMessage(), t);
    }
    return null;
}
 
Example 11
Source File: RpcUtils.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public static Class<?> getReturnType(Invocation invocation) {
    try {
        if (invocation != null && invocation.getInvoker() != null
                && invocation.getInvoker().getUrl() != null
                && ! invocation.getMethodName().startsWith("$")) {
            String service = invocation.getInvoker().getUrl().getServiceInterface();
            if (service != null && service.length() > 0) {
                Class<?> cls = ReflectUtils.forName(service);
                Method method = cls.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
                if (method.getReturnType() == void.class) {
                    return null;
                }
                return method.getReturnType();
            }
        }
    } catch (Throwable t) {
        logger.warn(t.getMessage(), t);
    }
    return null;
}
 
Example 12
Source File: RpcUtils.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public static Type[] getReturnTypes(Invocation invocation) {
    try {
        if (invocation != null && invocation.getInvoker() != null
                && invocation.getInvoker().getUrl() != null
                && ! invocation.getMethodName().startsWith("$")) {
            String service = invocation.getInvoker().getUrl().getServiceInterface();
            if (service != null && service.length() > 0) {
                Class<?> cls = ReflectUtils.forName(service);
                Method method = cls.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
                if (method.getReturnType() == void.class) {
                    return null;
                }
                return new Type[]{method.getReturnType(), method.getGenericReturnType()};
            }
        }
    } catch (Throwable t) {
        logger.warn(t.getMessage(), t);
    }
    return null;
}
 
Example 13
Source File: TransactionConsumerFilter.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public Participant buildParticipant(Invocation invocation) {
	Invoker<?> invoker = invocation.getInvoker();
	Object[] arguments = RpcUtils.getArguments(invocation);
	String methodName = RpcUtils.getMethodName(invocation);
	Class<?>[] parameterTypes = RpcUtils.getParameterTypes(invocation);
	
	Method method = ClassUtils.getMethod(invoker.getInterface(), methodName, parameterTypes);
	String targetObjectId = BeanFactoryUtil.getBeanName(invoker.toString()); //  interface me.cungu.transactiontreetest.case3.Client -> dubbo://10.144.33.31:20880/me.cungu.transactiontreetest.case3.Client?anyhost=true&application=me.cungu.transactiontree&check=false&default.check=false&default.delay=-1&delay=-1&dubbo=2.5.5.cat-SNAPSHOT&generic=false&interface=me.cungu.transactiontreetest.case3.Client&logger=slf4j&methods=m1_confirm,m1,r1_cannel&pid=8336&providerside=me.cungu.transactiontree&side=consumer&timestamp=1451379561390
	
	return ParticipantBuilder.build(targetObjectId, invoker.getInterface(), method, arguments);
}