本文整理汇总了Java中org.apache.thrift.TBase.getClass方法的典型用法代码示例。如果您正苦于以下问题:Java TBase.getClass方法的具体用法?Java TBase.getClass怎么用?Java TBase.getClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.thrift.TBase
的用法示例。
在下文中一共展示了TBase.getClass方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: asTBase
import org.apache.thrift.TBase; //导入方法依赖的package包/类
private static TBase<?, ?> asTBase(Object exampleRequest) {
final TBase<?, ?> exampleTBase = (TBase<?, ?>) exampleRequest;
final Class<?> type = exampleTBase.getClass();
if (!type.getName().endsWith(REQUEST_STRUCT_SUFFIX)) {
return null;
}
final Class<?> serviceType = type.getEnclosingClass();
if (serviceType == null) {
return null;
}
if (serviceType.getEnclosingClass() != null) {
return null;
}
return exampleTBase;
}
示例2: headerLookup
import org.apache.thrift.TBase; //导入方法依赖的package包/类
@Override
public Header headerLookup(TBase<?, ?> tbase) throws TException {
if (tbase == null) {
throw new IllegalArgumentException("tbase must not be null");
}
// Should we preload commandTBaseList for performance?
Collection<TCommandType> commandTBaseList = commandTBaseRepository.values();
for (TCommandType commandTBase : commandTBaseList) {
if (commandTBase.isInstanceOf(tbase)) {
return commandTBase.getHeader();
}
}
throw new TException("Unsupported Type" + tbase.getClass());
}
示例3: headerLookup
import org.apache.thrift.TBase; //导入方法依赖的package包/类
public Header headerLookup(TBase<?, ?> tbase) throws TException {
if (tbase == null) {
throw new IllegalArgumentException("tbase must not be null");
}
if (tbase instanceof TSpan) {
return SPAN_HEADER;
}
if (tbase instanceof TSpanChunk) {
return SPANCHUNK_HEADER;
}
if (tbase instanceof TAgentInfo) {
return AGENT_INFO_HEADER;
}
if (tbase instanceof TAgentStat) {
return AGENT_STAT_HEADER;
}
if (tbase instanceof TAgentStatBatch) {
return AGENT_STAT_BATCH_HEADER;
}
if (tbase instanceof TSqlMetaData) {
return SQLMETADATA_HEADER;
}
if (tbase instanceof TApiMetaData) {
return APIMETADATA_HEADER;
}
if (tbase instanceof TResult) {
return RESULT_HEADER;
}
if (tbase instanceof TStringMetaData) {
return STRINGMETADATA_HEADER;
}
if (tbase instanceof NetworkAvailabilityCheckPacket) {
return NETWORK_CHECK_HEADER;
}
throw new TException("Unsupported Type" + tbase.getClass());
}
示例4: ThriftFunction
import org.apache.thrift.TBase; //导入方法依赖的package包/类
private ThriftFunction(
Class<?> serviceType, String name, Object func, Type type,
TFieldIdEnum[] argFields, TBase<?, ?> result, Class<?>[] declaredExceptions) throws Exception {
this.func = func;
this.type = type;
this.serviceType = serviceType;
this.name = name;
this.argFields = argFields;
this.result = result;
this.declaredExceptions = declaredExceptions;
// Determine the success and exception fields of the function.
final ImmutableMap.Builder<Class<Throwable>, TFieldIdEnum> exceptionFieldsBuilder =
ImmutableMap.builder();
TFieldIdEnum successField = null;
if (result != null) { // if not oneway
@SuppressWarnings("unchecked")
final Class<? extends TBase<?, ?>> resultType = (Class<? extends TBase<?, ?>>) result.getClass();
@SuppressWarnings("unchecked")
final Map<TFieldIdEnum, FieldMetaData> metaDataMap =
(Map<TFieldIdEnum, FieldMetaData>) FieldMetaData.getStructMetaDataMap(resultType);
for (Entry<TFieldIdEnum, FieldMetaData> e : metaDataMap.entrySet()) {
final TFieldIdEnum key = e.getKey();
final String fieldName = key.getFieldName();
if ("success".equals(fieldName)) {
successField = key;
continue;
}
Class<?> fieldType = resultType.getField(fieldName).getType();
if (Throwable.class.isAssignableFrom(fieldType)) {
@SuppressWarnings("unchecked")
Class<Throwable> exceptionFieldType = (Class<Throwable>) fieldType;
exceptionFieldsBuilder.put(exceptionFieldType, key);
}
}
}
this.successField = successField;
exceptionFields = exceptionFieldsBuilder.build();
}