本文整理汇总了Java中com.rti.dds.util.LoanableSequence类的典型用法代码示例。如果您正苦于以下问题:Java LoanableSequence类的具体用法?Java LoanableSequence怎么用?Java LoanableSequence使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LoanableSequence类属于com.rti.dds.util包,在下文中一共展示了LoanableSequence类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import com.rti.dds.util.LoanableSequence; //导入依赖的package包/类
@Override
public <T> TypeAdapter<T> create(
final Gson gson,
final TypeToken<T> typeToken
) {
// get raw type
Class rawType = typeToken.getRawType();
// check if the type applies to this factory
if (!LoanableSequence.class.isAssignableFrom(rawType)) {
return null;
}
try {
// we need the nested type of the sequence but since RTI is using generics
// or any other proper interface, we need to get the class from the method
// "<NestedType> get(int)" that is generated into every sequence
// get method
Method getMethod = rawType.getMethod("get", int.class);
// get nested type
Class nestedType = getMethod.getReturnType();
// get type adapter for nested type
TypeAdapter<?> nestedTypeAdapter = gson.getAdapter(nestedType);
// return new type adapter
return (TypeAdapter<T>) new SequenceTypeAdapter(
rawType,
nestedTypeAdapter
);
} catch (NoSuchMethodException e) {
// if method '<NestedType> get(int)' is not found,
// we cannot provide a type adapter
return null;
}
}
示例2: doStart
import com.rti.dds.util.LoanableSequence; //导入依赖的package包/类
@Override
protected void doStart() throws Exception {
ddsContext = ((RtiEndpoint)getEndpoint()).createDdsContext();
if (ddsContext == null) {
throw new CamelException("Cannot start RtiPollingConsumer: invalid setup.");
}
// Create the data reader using the default subscriber
DomainParticipant p = ddsContext.getParticipant().getValue();
typeSupport = ddsContext.getParticipant().getRegisteredTypeSupport(ddsContext.getEndpoint().getRegisteredType());
subscriber = p.create_subscriber(
getSubscriberQos(p, ((DdsInstanceData)getEndpoint()).getSubscriberQos()),
null,
StatusKind.STATUS_MASK_NONE);
if (subscriber == null) {
throw new CamelException("Cannot start RtiPollingConsumer: invalid setup.");
}
// create the data reader -- no listener
reader = subscriber.create_datareader(
ddsContext.getTopic().getValue(),
getDataReaderQos(p, ((DdsInstanceData)getEndpoint()).getDataReaderQos()),
null,
StatusKind.STATUS_MASK_NONE);
if (reader == null) {
throw new CamelException("Cannot start RtiPollingConsumer: invalid setup.");
}
// create the WaitSet infrastructure
waitSet = new WaitSet();
statusCond = reader.get_statuscondition();
statusCond.set_enabled_statuses(StatusKind.DATA_AVAILABLE_STATUS);
waitSet.attach_condition(statusCond);
// create object that can be reused when retrieving an instance handle
keyHolder = typeSupport.create_data();
dataSeq = new LoanableSequence(keyHolder.getClass());
infoSeq = new SampleInfoSeq();
LOG.info("RtiPollingConsumer(" + reader.get_topicdescription().get_name() + ") started...");
}