本文整理汇总了Java中com.alibaba.dubbo.rpc.Invocation.getParameterTypes方法的典型用法代码示例。如果您正苦于以下问题:Java Invocation.getParameterTypes方法的具体用法?Java Invocation.getParameterTypes怎么用?Java Invocation.getParameterTypes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.dubbo.rpc.Invocation
的用法示例。
在下文中一共展示了Invocation.getParameterTypes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encodeRequest
import com.alibaba.dubbo.rpc.Invocation; //导入方法依赖的package包/类
protected void encodeRequest(Channel channel, ChannelBuffer buffer, Request request)
throws IOException {
Invocation invocation = (Invocation) request.getData();
TProtocol protocol = newProtocol(channel.getUrl(), buffer);
try {
protocol.writeMessageBegin(new TMessage(
invocation.getMethodName(), TMessageType.CALL,
thriftSeq.getAndIncrement()));
protocol.writeStructBegin(new TStruct(invocation.getMethodName() + "_args"));
for(int i = 0; i < invocation.getParameterTypes().length; i++) {
Class<?> type = invocation.getParameterTypes()[i];
}
} catch (TException e) {
throw new IOException(e.getMessage(), e);
}
}
示例2: 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();
}
示例3: getMethodSignature
import com.alibaba.dubbo.rpc.Invocation; //导入方法依赖的package包/类
private String getMethodSignature(Invocation invocation) {
StringBuilder buf = new StringBuilder(invocation.getMethodName());
buf.append("(");
Class<?>[] types = invocation.getParameterTypes();
if (types != null && types.length > 0) {
boolean first = true;
for (Class<?> type : types) {
if (first) {
first = false;
} else {
buf.append(", ");
}
buf.append(type.getSimpleName());
}
}
buf.append(")");
return buf.toString();
}
示例4: buildOperationName
import com.alibaba.dubbo.rpc.Invocation; //导入方法依赖的package包/类
public static String buildOperationName(Invoker<?> invoker, Invocation inv) {
String version = invoker.getUrl().getParameter(Constants.VERSION_KEY);
String group = invoker.getUrl().getParameter(Constants.GROUP_KEY);
StringBuilder sn = new StringBuilder("Dubbo_");
sn.append(group).append(":").append(version);
sn.append("_");
sn.append(invoker.getInterface().getName()).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(") ");
return sn.toString();
}
示例5: 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);
}