当前位置: 首页>>代码示例>>Java>>正文


Java TBase.getClass方法代码示例

本文整理汇总了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;
}
 
开发者ID:line,项目名称:armeria,代码行数:19,代码来源:ThriftDocServicePlugin.java

示例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());
}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:18,代码来源:TCommandRegistry.java

示例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());
}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:38,代码来源:DefaultTBaseLocator.java

示例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();
}
 
开发者ID:line,项目名称:armeria,代码行数:45,代码来源:ThriftFunction.java


注:本文中的org.apache.thrift.TBase.getClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。