本文整理汇总了Java中com.alibaba.dubbo.rpc.Invocation.getArguments方法的典型用法代码示例。如果您正苦于以下问题:Java Invocation.getArguments方法的具体用法?Java Invocation.getArguments怎么用?Java Invocation.getArguments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.dubbo.rpc.Invocation
的用法示例。
在下文中一共展示了Invocation.getArguments方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getParameterTypes
import com.alibaba.dubbo.rpc.Invocation; //导入方法依赖的package包/类
public static Class<?>[] getParameterTypes(Invocation invocation){
if(Constants.$INVOKE.equals(invocation.getMethodName())
&& invocation.getArguments() != null
&& invocation.getArguments().length > 1
&& invocation.getArguments()[1] instanceof String[]){
String[] types = (String[]) invocation.getArguments()[1];
if (types == null) {
return new Class<?>[0];
}
Class<?>[] parameterTypes = new Class<?>[types.length];
for (int i = 0; i < types.length; i ++) {
parameterTypes[i] = ReflectUtils.forName(types[0]);
}
return parameterTypes;
}
return invocation.getParameterTypes();
}
示例2: invoke
import com.alibaba.dubbo.rpc.Invocation; //导入方法依赖的package包/类
@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
DubboEasyTransRpcProviderImpl instance = DubboEasyTransRpcProviderImpl.getInstance();
if(checkEasyTransRequest(invocation)){
EasyTransRequest<?, ?> easyTransRequest = (EasyTransRequest<?, ?>) ((Object[])invocation.getArguments()[2])[0];
@SuppressWarnings("unchecked")
Map<String,Object> header = (Map<String,Object>) ((Object[])invocation.getArguments()[2])[1];
BusinessIdentifer businessIdentifer = ReflectUtil.getBusinessIdentifer(easyTransRequest.getClass());
EasyTransFilterChain filterChain = instance.getFilterChainFactory().getFilterChainByFilters(businessIdentifer.appId(), businessIdentifer.busCode(), (String)(invocation.getArguments()[0]),instance.getFilters());
filterChain.addFilter(new EasyTransFilterAdapter(invoker, invocation));
EasyTransResult result;
try {
result = filterChain.invokeFilterChain(header,easyTransRequest);
} catch (Exception e) {
LOG.error("RPC EasyTrans FilterChain execute Error!",e);
throw e;
}
if(result.hasException()){
return new RpcResult(result.getException());
}else{
return new RpcResult(result.getValue());
}
}else{
return invoker.invoke(invocation);
}
}
示例3: checkEasyTransRequest
import com.alibaba.dubbo.rpc.Invocation; //导入方法依赖的package包/类
private boolean checkEasyTransRequest(Invocation invocation) {
if(invocation.getArguments().length == 3){
Object param3 = invocation.getArguments()[2];
if(param3 != null && param3.getClass().isArray()){
Object[] array = (Object[]) param3;
if(array.length == 2 && array[0] instanceof EasyTransRequest && array[1] instanceof Map){
return true;
}
}
}
return false;
}
示例4: getMethodName
import com.alibaba.dubbo.rpc.Invocation; //导入方法依赖的package包/类
public static String getMethodName(Invocation invocation){
if(Constants.$INVOKE.equals(invocation.getMethodName())
&& invocation.getArguments() != null
&& invocation.getArguments().length > 0
&& invocation.getArguments()[0] instanceof String){
return (String) invocation.getArguments()[0];
}
return invocation.getMethodName();
}
示例5: getArguments
import com.alibaba.dubbo.rpc.Invocation; //导入方法依赖的package包/类
public static Object[] getArguments(Invocation invocation){
if(Constants.$INVOKE.equals(invocation.getMethodName())
&& invocation.getArguments() != null
&& invocation.getArguments().length > 2
&& invocation.getArguments()[2] instanceof Object[]){
return (Object[]) invocation.getArguments()[2];
}
return invocation.getArguments();
}
示例6: invoke
import com.alibaba.dubbo.rpc.Invocation; //导入方法依赖的package包/类
public Result invoke(Invoker<?> invoker, Invocation inv) throws RpcException {
if(inv.getMethodName().equals(Constants.$ECHO) && inv.getArguments() != null && inv.getArguments().length == 1 )
return new RpcResult(inv.getArguments()[0]);
return invoker.invoke(inv);
}
示例7: invoke
import com.alibaba.dubbo.rpc.Invocation; //导入方法依赖的package包/类
public Result invoke(Invoker<?> invoker, Invocation inv) throws RpcException {
try {
String accesslog = invoker.getUrl().getParameter(Constants.ACCESS_LOG_KEY);
if (ConfigUtils.isNotEmpty(accesslog)) {
RpcContext context = RpcContext.getContext();
String serviceName = invoker.getInterface().getName();
String version = invoker.getUrl().getParameter(Constants.VERSION_KEY);
String group = invoker.getUrl().getParameter(Constants.GROUP_KEY);
StringBuilder sn = new StringBuilder();
sn.append("[").append(new SimpleDateFormat(MESSAGE_DATE_FORMAT).format(new Date())).append("] ").append(context.getRemoteHost()).append(":").append(context.getRemotePort())
.append(" -> ").append(context.getLocalHost()).append(":").append(context.getLocalPort())
.append(" - ");
if (null != group && group.length() > 0) {
sn.append(group).append("/");
}
sn.append(serviceName);
if (null != version && version.length() > 0) {
sn.append(":").append(version);
}
sn.append(" ");
sn.append(inv.getMethodName());
sn.append("(");
Class<?>[] types = inv.getParameterTypes();
if (types != null && types.length > 0) {
boolean first = true;
for (Class<?> type : types) {
if (first) {
first = false;
} else {
sn.append(",");
}
sn.append(type.getName());
}
}
sn.append(") ");
Object[] args = inv.getArguments();
if (args != null && args.length > 0) {
sn.append(JSON.json(args));
}
String msg = sn.toString();
if (ConfigUtils.isDefault(accesslog)) {
LoggerFactory.getLogger(ACCESS_LOG_KEY + "." + invoker.getInterface().getName()).info(msg);
} else {
log(accesslog, msg);
}
}
} catch (Throwable t) {
logger.warn("Exception in AcessLogFilter of service(" + invoker + " -> " + inv + ")", t);
}
return invoker.invoke(inv);
}
示例8: fireThrowCallback
import com.alibaba.dubbo.rpc.Invocation; //导入方法依赖的package包/类
private void fireThrowCallback(final Invoker<?> invoker, final Invocation invocation, final Throwable exception) {
final Method onthrowMethod = (Method)StaticContext.getSystemContext().get(StaticContext.getKey(invoker.getUrl(), invocation.getMethodName(), Constants.ON_THROW_METHOD_KEY));
final Object onthrowInst = StaticContext.getSystemContext().get(StaticContext.getKey(invoker.getUrl(), invocation.getMethodName(), Constants.ON_THROW_INSTANCE_KEY));
//没有设置onthrow callback.
if (onthrowMethod == null && onthrowInst == null ){
return ;
}
if (onthrowMethod == null || onthrowInst == null ){
throw new IllegalStateException("service:" + invoker.getUrl().getServiceKey() +" has a onthrow callback config , but no such "+(onthrowMethod == null ? "method" : "instance")+" found. url:"+invoker.getUrl());
}
if (onthrowMethod != null && ! onthrowMethod.isAccessible()) {
onthrowMethod.setAccessible(true);
}
Class<?>[] rParaTypes = onthrowMethod.getParameterTypes() ;
if (rParaTypes[0].isAssignableFrom(exception.getClass())){
try {
Object[] args = invocation.getArguments();
Object[] params;
if (rParaTypes.length >1 ) {
if (rParaTypes.length == 2 && rParaTypes[1].isAssignableFrom(Object[].class)){
params = new Object[2];
params[0] = exception;
params[1] = args ;
}else {
params = new Object[args.length + 1];
params[0] = exception;
System.arraycopy(args, 0, params, 1, args.length);
}
} else {
params = new Object[] { exception };
}
onthrowMethod.invoke(onthrowInst,params);
} catch (Throwable e) {
logger.error(invocation.getMethodName() +".call back method invoke error . callback method :" + onthrowMethod + ", url:"+ invoker.getUrl(), e);
}
} else {
logger.error(invocation.getMethodName() +".call back method invoke error . callback method :" + onthrowMethod + ", url:"+ invoker.getUrl(), exception);
}
}