21 package org.opensplice.dds.pub;
23 import java.util.Arrays;
24 import java.util.Collection;
25 import java.util.HashMap;
26 import java.util.HashSet;
27 import java.util.concurrent.TimeUnit;
28 import java.util.concurrent.TimeoutException;
57 DomainEntityImpl<DDS.Publisher, DomainParticipantImpl, DDS.DomainParticipant, PublisherQos, PublisherListener, PublisherListenerImpl>
64 Collection<Class<? extends Status>> statuses) {
65 super(environment, parent, parent.
getOld());
66 DDS.PublisherQos oldQos;
70 "Supplied PublisherQos is null.");
75 }
catch (ClassCastException e) {
77 "Cannot create Publisher with non-OpenSplice qos");
80 if (listener != null) {
86 DDS.Publisher old = this.parent.
getOld().create_publisher(oldQos,
96 if (this.listener != null) {
97 this.listener.setInitialised();
105 if (listener != null) {
109 wrapperListener = null;
111 rc = this.
getOld().set_listener(wrapperListener, mask);
113 "Publisher.setListener() failed.");
115 this.listener = wrapperListener;
125 Collection<Class<? extends Status>> statuses) {
126 this.setListener(listener,
132 Class<? extends Status>... statuses) {
133 this.setListener(listener,
139 DDS.PublisherQosHolder holder =
new DDS.PublisherQosHolder();
140 int rc = this.
getOld().get_qos(holder);
142 "Publisher.getQos() failed.");
153 "Supplied PublisherQos is null.");
157 }
catch (ClassCastException e) {
159 "Setting non-OpenSplice Qos not supported.");
163 "Publisher.setQos() failed.");
170 null,
new HashSet<Class<? extends Status>>());
176 Collection<Class<? extends Status>> statuses) {
182 "Supplied Topic is null.");
184 synchronized(this.writers){
189 }
catch (ClassCastException e) {
191 "Cannot create DataWriter with non-OpenSplice Topic");
193 this.writers.put(writer.
getOld(), writer);
201 Class<? extends Status>... statuses) {
202 return createDataWriter(topic, qos, listener, Arrays.asList(statuses));
208 return this.createDataWriter(topic, qos, null,
209 new HashSet<Class<? extends Status>>());
215 synchronized (this.writers) {
216 dw = this.writers.get(writer);
224 @SuppressWarnings(
"unchecked")
227 if (topicName == null) {
229 "Supplied topicName is null.");
231 synchronized (this.writers) {
233 if (topicName.equals(writer.getTopic().getName())) {
236 }
catch (ClassCastException e) {
239 "Cannot cast DataWriter to desired type.");
247 @SuppressWarnings(
"unchecked")
252 "Supplied Topic is null.");
254 synchronized (this.writers) {
256 if (topic.equals(writer.getTopic())) {
259 }
catch (ClassCastException e) {
262 "Cannot cast DataWriter to desired type.");
272 synchronized(this.writers){
286 int rc = this.
getOld().suspend_publications();
288 "Publisher.suspendPublications() failed.");
294 int rc = this.
getOld().resume_publications();
296 "Publisher.resumePublications() failed.");
301 int rc = this.
getOld().begin_coherent_changes();
303 "Publisher.beginCoherentChanges() failed.");
308 int rc = this.
getOld().end_coherent_changes();
310 "Publisher.endCoherentChanges() failed.");
315 throws TimeoutException {
316 int rc = this.
getOld().wait_for_acknowledgments(
320 "Publisher.waitForAcknowledgments() failed.");
325 throws TimeoutException {
332 DDS.DataWriterQosHolder holder =
new DDS.DataWriterQosHolder();
333 int rc = this.
getOld().get_default_datawriter_qos(holder);
335 "Publisher.getDefaultDataWriterQos() failed.");
344 "Supplied DataWriterQos is null.");
347 this.
getOld().set_default_datawriter_qos(
350 }
catch (ClassCastException e) {
352 "Non-OpenSplice DataWriterQos not supported.");
363 "Supplied TopicQos is null.");
367 "Supplied DataWriterQos is null.");
371 }
catch (ClassCastException e) {
373 "Non-OpenSplice DataWriterQos not supported.");
382 DDS.StatusCondition oldCondition = this.
getOld().get_statuscondition();
384 if (oldCondition == null) {
399 this.
parent.destroyPublisher(
this);
404 DDS.DataWriter old = dataWriter.
getOld();
405 int rc = this.
getOld().delete_datawriter(old);
406 synchronized(this.writers){
407 this.writers.remove(old);
410 "DataWriter.close() failed.");
static PublisherQosImpl convert(OsplServiceEnvironment env, DDS.PublisherQos oldQos)
void destroyDataWriter(EntityImpl< DDS.DataWriter, ?, ?, ?, ?> dataWriter)
abstract void close()
Halt communication and dispose the resources held by this Entity.
static void checkReturnCodeWithTimeout(int retCode, OsplServiceEnvironment environment, String message)
The DomainParticipant object plays several roles:
A StatusCondition object is an immutable object that specifies Condition that is associated with each...
void waitForAcknowledgments(long maxWait, TimeUnit unit)
This operation blocks the calling thread until either all data written by the reliable org...
void setListener(PublisherListener listener, Collection< Class<? extends Status >> statuses)
public< OTHER > DataWriter< OTHER > cast()
Cast this data writer to the given type, or throw an exception if the cast fails. ...
void endCoherentChanges()
This operation terminates the 'coherent set' initiated by the matching call to beginCoherentChanges()...
static DDS.Duration_t convert(OsplServiceEnvironment environment, Duration d)
void setQos(PublisherQos qos)
org.omg.dds.domain.DomainParticipant getParent()
DataWriter allows the application to set the value of the data to be published under a given org...
void beginCoherentChanges()
This operation requests that the application will begin a 'coherent set' of modifications using org...
static DataWriterQosImpl convert(OsplServiceEnvironment env, DDS.DataWriterQos oldQos)
void waitForAcknowledgments(Duration maxWait)
This operation blocks the calling thread until either all data written by the reliable org...
static Set< Class<? extends Status > > convertMask(OsplServiceEnvironment environment, int state)
void setListener(PublisherListener listener, Class<? extends Status >... statuses)
StatusCondition< Publisher > getStatusCondition()
abstract AbstractDataWriter< TYPE > createDataWriter(PublisherImpl publisher, AbstractTopic< TYPE > topic, DataWriterQos qos, DataWriterListener< TYPE > listener, Collection< Class<? extends Status >> statuses)
void closeContainedEntities()
This operation closes all the entities that were created by means of the "create" operations on the P...
static void checkReturnCode(int retCode, OsplServiceEnvironment environment, String message)
DataWriterQos getDefaultDataWriterQos()
This operation retrieves the default value of the DataWriter QoS, that is, the QoS policies which wil...
TypeSupport< TYPE > getTypeSupport()
Returns the org.omg.dds.type.TypeSupport used to create this TopicDescription.
ServiceProviderInterface getSPI()
Since a org.omg.dds.pub.DataWriter is a kind of org.omg.dds.core.Entity, it has the ability to have a...
The target object was previously closed and therefore cannot process the operation.
void setListener(PublisherListener listener)
PublisherImpl(OsplServiceEnvironment environment, DomainParticipantImpl parent, PublisherQos qos, PublisherListener listener, Collection< Class<? extends Status >> statuses)
DataWriterQos copyFromTopicQos(DataWriterQos dwQos, TopicQos tQos)
This operation copies the policies in the org.omg.dds.topic.Topic QoS to the corresponding policies i...
A Publisher is the object responsible for the actual dissemination of publications.
Duration newDuration(long duration, TimeUnit unit)
Construct a org.omg.dds.core.Duration of the given magnitude.
A span of elapsed time expressed with nanosecond precision.
final transient OsplServiceEnvironment environment
void resumePublications()
This operation indicates to the Service that the application has completed the multiple changes initi...
void suspendPublications()
This operation indicates to the Service that the application is about to make multiple modifications ...
static void throwLastErrorException(OsplServiceEnvironment environment)
Topic is the most basic description of the data to be published and subscribed.
Since a org.omg.dds.pub.Publisher is a kind of org.omg.dds.core.Entity, it has the ability to have a ...
void mergeTopicQos(TopicQos topicQos)
void setDefaultDataWriterQos(DataWriterQos qos)
This operation sets a default value of the DataWriter QoS policies, which will be used for newly crea...
Status is the abstract root class for all communication status objects.