本文整理匯總了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();
}