This simple class shows how to register RTSJ properties with the domain participant factory. It is not functional by itself; it merely demonstrates the APIs.
package com.rti.ndds.rtsj.example.simple;
import javax.realtime.HeapMemory;
import javax.realtime.ImmortalMemory;
import com.rti.dds.domain.DomainParticipant;
import com.rti.dds.domain.DomainParticipantFactory;
import com.rti.dds.infrastructure.RETCODE_INCONSISTENT_POLICY;
import com.rti.dds.infrastructure.StatusKind;
import com.rti.ndds.rtsj.RtsjProperty_t;
import com.rti.ndds.rtsj.RtsjThreadSupport;
import com.rti.ndds.rtsj.ThreadKind;
public class RtsjSimpleExample {
public static void main(String[] args) {
RtsjProperty_t thread_properties = new RtsjProperty_t();
thread_properties.event_thread.memory_area =
ImmortalMemory.instance();
thread_properties.event_thread.thread_kind =
ThreadKind.NO_HEAP_REALTIME_THREAD_KIND;
thread_properties.receive_thread.memory_area =
ImmortalMemory.instance();
thread_properties.receive_thread.thread_kind =
ThreadKind.NO_HEAP_REALTIME_THREAD_KIND;
thread_properties.database_thread.memory_area = HeapMemory.instance();
thread_properties.database_thread.thread_kind =
ThreadKind.NON_REALTIME_THREAD_KIND;
DomainParticipantFactory known_factory =
DomainParticipantFactory.get_instance();
try {
RtsjThreadSupport.register(known_factory, thread_properties);
} catch (RETCODE_INCONSISTENT_POLICY e) {
System.out.println("RTSJ feature error: incompatible JVM");
}
DomainParticipant participant = known_factory.create_participant(
0,
DomainParticipantFactory.PARTICIPANT_QOS_DEFAULT,
null,
StatusKind.STATUS_MASK_NONE);
thread_properties = new RtsjProperty_t();
RtsjThreadSupport.register(known_factory, thread_properties);
}
}