POA poa = POAHelper.narrow(orb
.resolve_initial_references("RootPOA"));
poa.the_POAManager().activate();
DomainParticipantFactory domainpartiFactory;
DomainParticipant domainparticipant;
TemperatureDataWriter temperatureDW;
org.omg.dds.Topic topic;
Publisher publisher;
DataWriter datawriter;
PublisherQos publisherqos;
DataWriterQos datawriterqos;
Subscriber suscriber;
DataReader datareader;
org.omg.dds.Topic topicMessage;
SubscriberQos suscriberqos;
DataReaderQos datareaderqos;
org.omg.CORBA.Object objRef = orb
.resolve_initial_references("NameService");
// Use NamingContextExt which is part of the Interoperable
// Naming Service (INS) specification.
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
// resolve the Object Reference in Naming
String rname = "DomainParticipantFactory";
byte tab[] = new byte[1];
tab[0] = 1;
org.omg.dds.UserDataQosPolicy UDQP = new UserDataQosPolicy(tab);
DomainParticipantQos DPQOS = new DomainParticipantQos(UDQP,
new EntityFactoryQosPolicy());
domainpartiFactory = DomainParticipantFactoryHelper.narrow(ncRef
.resolve_str(rname));
TopicQos tq = new TopicQos(
new TopicDataQosPolicy(tab),
new DurabilityQosPolicy(
DurabilityQosPolicyKind.from_int(0),
new Duration_t(0, 0)),
new DeadlineQosPolicy(new Duration_t(0, 0)),
new org.omg.dds.LatencyBudgetQosPolicy(new Duration_t(0, 0)),
new org.omg.dds.LivelinessQosPolicy(LivelinessQosPolicyKind
.from_int(0), new Duration_t(0, 0)),
new org.omg.dds.ReliabilityQosPolicy(
ReliabilityQosPolicyKind.from_int(0),
new Duration_t(0, 0)),
new org.omg.dds.DestinationOrderQosPolicy(
DestinationOrderQosPolicyKind.from_int(0)),
new org.omg.dds.HistoryQosPolicy(
org.omg.dds.HistoryQosPolicyKind.from_int(0), 0),
new org.omg.dds.ResourceLimitsQosPolicy(0, 0, 0),
new org.omg.dds.TransportPriorityQosPolicy(0),
new org.omg.dds.LifespanQosPolicy(new Duration_t(0, 0)),
new org.omg.dds.OwnershipQosPolicy(
org.omg.dds.OwnershipQosPolicyKind.from_int(0)));
domainparticipant = domainpartiFactory.create_participant(0, DPQOS,
null);
topic = domainparticipant.create_topic("tamperature",
"demo.dds.dcps.temperaturesample.Temperature",
tq, null);
topicMessage = domainparticipant.create_topic("messsage",
"demo.dds.dcps.temperaturesample.Message", tq,
null);
String st[] = new String[1];
st[0] = "";
publisherqos = new PublisherQos(
new org.omg.dds.PresentationQosPolicy(
org.omg.dds.PresentationQosPolicyAccessScopeKind
.from_int(0), false, false),
new PartitionQosPolicy(st), new GroupDataQosPolicy(tab),
new org.omg.dds.EntityFactoryQosPolicy(false));
publisher = domainparticipant.create_publisher(publisherqos, null);
datawriterqos = new DataWriterQos(
new DurabilityQosPolicy(
DurabilityQosPolicyKind.from_int(0),
new Duration_t(0, 0)),
new DeadlineQosPolicy(new Duration_t(0, 0)),
new org.omg.dds.LatencyBudgetQosPolicy(new Duration_t(0, 0)),
new org.omg.dds.LivelinessQosPolicy(LivelinessQosPolicyKind
.from_int(0), new Duration_t(0, 0)),
new org.omg.dds.ReliabilityQosPolicy(
ReliabilityQosPolicyKind.from_int(0),
new Duration_t(0, 0)),
new org.omg.dds.DestinationOrderQosPolicy(
DestinationOrderQosPolicyKind.from_int(0)),
new org.omg.dds.HistoryQosPolicy(
org.omg.dds.HistoryQosPolicyKind.from_int(0), 0),
new org.omg.dds.ResourceLimitsQosPolicy(0, 0, 0),
new TransportPriorityQosPolicy(0), new LifespanQosPolicy(
new Duration_t(0, 0)),
new org.omg.dds.UserDataQosPolicy(tab),
new OwnershipStrengthQosPolicy(0),
new org.omg.dds.WriterDataLifecycleQosPolicy(true));
datawriter = publisher
.create_datawriter(topic, datawriterqos, null);
temperatureDW = TemperatureDataWriterHelper.narrow(datawriter);
// a producer suscribe for topic message
suscriberqos = new SubscriberQos(
new org.omg.dds.PresentationQosPolicy(
org.omg.dds.PresentationQosPolicyAccessScopeKind
.from_int(0), false, false),
new PartitionQosPolicy(st), new GroupDataQosPolicy(tab),
new org.omg.dds.EntityFactoryQosPolicy(false));
suscriber = domainparticipant.create_subscriber(suscriberqos, null);
datareaderqos = new DataReaderQos(
new DurabilityQosPolicy(
DurabilityQosPolicyKind.from_int(0),
new Duration_t(0, 0)),
new DeadlineQosPolicy(new Duration_t(0, 0)),