OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
ReflectionDataWriter.java
Go to the documentation of this file.
1 /*
2  * Vortex OpenSplice
3  *
4  * This software and documentation are Copyright 2006 to 2024 ADLINK
5  * Technology Limited, its affiliated companies and licensors. All rights
6  * reserved.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 package org.opensplice.dds.pub;
22 
23 import java.lang.reflect.Field;
24 import java.lang.reflect.InvocationTargetException;
25 import java.lang.reflect.Method;
26 import java.util.HashSet;
27 import java.util.Set;
28 import java.util.concurrent.TimeUnit;
29 import java.util.concurrent.TimeoutException;
30 
31 import org.omg.dds.core.DDSObject;
32 import org.omg.dds.core.Duration;
35 import org.omg.dds.core.Time;
40 import org.omg.dds.pub.DataWriterQos;
51 
52 public class ReflectionDataWriter<TYPE> extends AbstractDDSObject implements
53  DDSObject {
54  private final OsplServiceEnvironment environment;
55  private final DDS.DataWriter old;
56  private final Method registerInstance;
57  private final Method registerInstanceTimestamp;
58  private final Method unregisterInstance;
59  private final Method unregisterInstanceTimestamp;
60  private final Method write;
61  private final Method writeTimestamp;
62  private final Method dispose;
63  private final Method disposeTimestamp;
64  private final Method writeDispose;
65  private final Method writeDisposeTimestamp;
66  private final Method getKeyValue;
67  private final Method lookupInstance;
68  private final Class<?> sampleHolderClz;
69  private final Field samplHolderValueField;
70 
72  DDS.DataWriter writer, Class<TYPE> typeClz) {
73  Class<?> typedWriterClz;
74  String typedWriterClzName;
75 
76  this.old = writer;
77  this.environment = environment;
78 
79  typedWriterClzName = typeClz.getName() + "DataWriterImpl";
80 
81  try {
82  typedWriterClz = Class.forName(typedWriterClzName);
83 
84  this.sampleHolderClz = Class.forName(typeClz.getName() + "Holder");
85  this.samplHolderValueField = this.sampleHolderClz
86  .getDeclaredField("value");
87 
88  this.registerInstance = typedWriterClz.getMethod(
89  "register_instance", typeClz);
90  this.registerInstanceTimestamp = typedWriterClz.getMethod(
91  "register_instance_w_timestamp", typeClz, DDS.Time_t.class);
92  this.unregisterInstance = typedWriterClz.getMethod(
93  "unregister_instance", typeClz, long.class);
94  this.unregisterInstanceTimestamp = typedWriterClz.getMethod(
95  "unregister_instance_w_timestamp", typeClz, long.class,
96  DDS.Time_t.class);
97  this.write = typedWriterClz.getMethod("write", typeClz, long.class);
98  this.writeTimestamp = typedWriterClz.getMethod("write_w_timestamp",
99  typeClz, long.class, DDS.Time_t.class);
100  this.dispose = typedWriterClz.getMethod("dispose", typeClz,
101  long.class);
102  this.disposeTimestamp = typedWriterClz.getMethod(
103  "dispose_w_timestamp", typeClz, long.class,
104  DDS.Time_t.class);
105  this.writeDispose = typedWriterClz.getMethod("writedispose",
106  typeClz, long.class);
107  this.writeDisposeTimestamp = typedWriterClz.getMethod(
108  "writedispose_w_timestamp", typeClz, long.class,
109  DDS.Time_t.class);
110  this.getKeyValue = typedWriterClz.getMethod("get_key_value",
111  this.sampleHolderClz, long.class);
112  this.lookupInstance = typedWriterClz.getMethod("lookup_instance",
113  typeClz);
114 
115  } catch (ClassNotFoundException e) {
117  this.environment,
118  "Cannot find Typed DataWriter '"
119  + typedWriterClzName
120  + "' that should be generated with OpenSplice idlpp");
121  } catch (NoSuchMethodException e) {
123  this.environment,
124  "Cannot find correct methods in '"
125  + typedWriterClzName
126  + "' that should be generated with OpenSplice idlpp ( "
127  + e.getMessage() + ").");
128  } catch (NoSuchFieldException e) {
130  this.environment,
131  "Cannot find 'value' field in "
132  + "the typed sampleHolderClass "
133  + "that should be generated with OpenSplice idlpp ( "
134  + e.getMessage() + ").");
135  } catch (SecurityException e) {
137  this.environment,
138  "Cannot find 'value' field in "
139  + "the typed sampleHolderClass "
140  + "that should be generated with OpenSplice idlpp ( "
141  + e.getMessage() + ").");
142  }
143  }
144 
145  @Override
147  return this.environment;
148  }
149 
150  public InstanceHandle registerInstance(TYPE instanceData)
151  throws TimeoutException {
152  long handle;
153 
154  if (instanceData == null) {
155  throw new IllegalArgumentExceptionImpl(this.environment,
156  "Illegal instanceData (null) provided.");
157  }
158  try {
159  handle = (Long) this.registerInstance
160  .invoke(this.old, instanceData);
161  } catch (IllegalAccessException e) {
162  throw new DDSExceptionImpl(this.environment,
163  "DataWriter.registerInstance() failed (" + e.getMessage()
164  + ").");
165  } catch (IllegalArgumentExceptionImpl e) {
166  throw e;
167  } catch (IllegalArgumentException e) {
168  throw new DDSExceptionImpl(this.environment,
169  "DataWriter.registerInstance() failed (" + e.getMessage()
170  + ").");
171  } catch (InvocationTargetException e) {
172  throw new DDSExceptionImpl(this.environment,
173  "DataWriter.registerInstance() failed (" + e.getMessage()
174  + ").");
175  }
176  return Utilities.convert(this.environment, handle);
177  }
178 
179  public InstanceHandle registerInstance(TYPE instanceData,
180  Time sourceTimestamp) throws TimeoutException {
181  long handle;
182 
183  if (instanceData == null) {
184  throw new IllegalArgumentExceptionImpl(this.environment,
185  "Illegal instanceData (null) provided.");
186  }
187  try {
188  handle = (Long) this.registerInstanceTimestamp.invoke(this.old,
189  instanceData,
190  Utilities.convert(this.environment, sourceTimestamp));
191  } catch (IllegalAccessException e) {
192  throw new DDSExceptionImpl(this.environment,
193  "DataWriter.registerInstance() failed (" + e.getMessage()
194  + ").");
195  } catch (IllegalArgumentExceptionImpl e) {
196  throw e;
197  } catch (IllegalArgumentException e) {
198  throw new DDSExceptionImpl(this.environment,
199  "DataWriter.registerInstance() failed (" + e.getMessage()
200  + ").");
201  } catch (InvocationTargetException e) {
202  throw new DDSExceptionImpl(this.environment,
203  "DataWriter.registerInstance() failed (" + e.getMessage()
204  + ").");
205  }
206  return Utilities.convert(this.environment, handle);
207  }
208 
209  public InstanceHandle registerInstance(TYPE instanceData,
210  long sourceTimestamp, TimeUnit unit) throws TimeoutException {
211  return this.registerInstance(instanceData, new TimeImpl(
212  this.environment, sourceTimestamp, unit));
213  }
214 
215  public void unregisterInstance(InstanceHandle handle)
216  throws TimeoutException {
217  this.unregisterInstance(handle, null);
218  }
219 
220  public void unregisterInstance(InstanceHandle handle, TYPE instanceData)
221  throws TimeoutException {
222  try {
223  int rc = (Integer) this.unregisterInstance.invoke(this.old,
224  instanceData, Utilities.convert(this.environment, handle));
225  Utilities.checkReturnCodeWithTimeout(rc, this.environment,
226  "Datawriter.unregisterInstance() failed.");
227  } catch (IllegalAccessException e) {
228  throw new DDSExceptionImpl(this.environment,
229  "DataWriter.unregisterInstance() failed (" + e.getMessage()
230  + ").");
231  } catch (IllegalArgumentExceptionImpl e) {
232  throw e;
233  } catch (IllegalArgumentException e) {
234  throw new DDSExceptionImpl(this.environment,
235  "DataWriter.unregisterInstance() failed (" + e.getMessage()
236  + ").");
237  } catch (InvocationTargetException e) {
238  throw new DDSExceptionImpl(this.environment,
239  "DataWriter.unregisterInstance() failed (" + e.getMessage()
240  + ").");
241  }
242  }
243 
244  public void unregisterInstance(InstanceHandle handle, TYPE instanceData,
245  Time sourceTimestamp) throws TimeoutException {
246  try {
247  int rc = (Integer) this.unregisterInstanceTimestamp.invoke(
248  this.old, instanceData,
249  Utilities.convert(this.environment, handle),
250  Utilities.convert(this.environment, sourceTimestamp));
251  Utilities.checkReturnCodeWithTimeout(rc, this.environment,
252  "Datawriter.unregisterInstance() failed.");
253  } catch (IllegalAccessException e) {
254  throw new DDSExceptionImpl(this.environment,
255  "DataWriter.unregisterInstance() failed (" + e.getMessage()
256  + ").");
257  } catch (IllegalArgumentExceptionImpl e) {
258  throw e;
259  } catch (IllegalArgumentException e) {
260  throw new DDSExceptionImpl(this.environment,
261  "DataWriter.unregisterInstance() failed (" + e.getMessage()
262  + ").");
263  } catch (InvocationTargetException e) {
264  throw new DDSExceptionImpl(this.environment,
265  "DataWriter.unregisterInstance() failed (" + e.getMessage()
266  + ").");
267  }
268  }
269 
270  public void unregisterInstance(InstanceHandle handle, TYPE instanceData,
271  long sourceTimestamp, TimeUnit unit) throws TimeoutException {
272  this.unregisterInstance(handle, instanceData, new TimeImpl(
273  this.environment, sourceTimestamp, unit));
274 
275  }
276 
277  public void write(TYPE instanceData) throws TimeoutException {
278  this.write(instanceData, this.environment.getSPI().nilHandle());
279  }
280 
281  public void write(TYPE instanceData, Time sourceTimestamp)
282  throws TimeoutException {
283  this.write(instanceData, this.environment.getSPI().nilHandle(),
284  sourceTimestamp);
285  }
286 
287  public void write(TYPE instanceData, long sourceTimestamp, TimeUnit unit)
288  throws TimeoutException {
289  this.write(instanceData, new TimeImpl(this.environment,
290  sourceTimestamp, unit));
291 
292  }
293 
294  public void write(TYPE instanceData, InstanceHandle handle)
295  throws TimeoutException {
296  try {
297  int rc = (Integer) this.write.invoke(this.old, instanceData,
298  Utilities.convert(this.environment, handle));
299  Utilities.checkReturnCodeWithTimeout(rc, this.environment,
300  "DataWriter.write() failed.");
301  } catch (IllegalAccessException e) {
302  throw new DDSExceptionImpl(this.environment,
303  "DataWriter.write() failed (" + e.getMessage() + ").");
304  } catch (IllegalArgumentExceptionImpl e) {
305  throw e;
306  } catch (IllegalArgumentException e) {
307  throw new DDSExceptionImpl(this.environment,
308  "DataWriter.write() failed (" + e.getMessage() + ").");
309  } catch (InvocationTargetException e) {
310  throw new DDSExceptionImpl(this.environment,
311  "DataWriter.write() failed (" + e.getMessage() + ").");
312  }
313  }
314 
315  public void write(TYPE instanceData, InstanceHandle handle,
316  Time sourceTimestamp) throws TimeoutException {
317  try {
318  int rc = (Integer) this.writeTimestamp.invoke(this.old,
319  instanceData, Utilities.convert(this.environment, handle),
320  Utilities.convert(this.environment, sourceTimestamp));
321  Utilities.checkReturnCodeWithTimeout(rc, this.environment,
322  "DataWriter.write() failed.");
323  } catch (IllegalAccessException e) {
324  throw new DDSExceptionImpl(this.environment,
325  "DataWriter.write() failed (" + e.getMessage() + ").");
326  } catch (IllegalArgumentExceptionImpl e) {
327  throw e;
328  } catch (IllegalArgumentException e) {
329  throw new DDSExceptionImpl(this.environment,
330  "DataWriter.write() failed (" + e.getMessage() + ").");
331  } catch (InvocationTargetException e) {
332  throw new DDSExceptionImpl(this.environment,
333  "DataWriter.write() failed (" + e.getMessage() + ").");
334  }
335  }
336 
337  public void write(TYPE instanceData, InstanceHandle handle,
338  long sourceTimestamp, TimeUnit unit) throws TimeoutException {
339  this.write(instanceData, handle, new TimeImpl(this.environment,
340  sourceTimestamp, unit));
341  }
342 
343  public void dispose(InstanceHandle instanceHandle) throws TimeoutException {
344  this.dispose(instanceHandle, null);
345  }
346 
347  public void dispose(InstanceHandle instanceHandle, TYPE instanceData)
348  throws TimeoutException {
349  try {
350  int rc = (Integer) this.dispose.invoke(this.old, instanceData,
351  Utilities.convert(this.environment, instanceHandle));
352  Utilities.checkReturnCodeWithTimeout(rc, this.environment,
353  "DataWriter.dispose() failed.");
354  } catch (IllegalAccessException e) {
355  throw new DDSExceptionImpl(this.environment,
356  "DataWriter.dispose() failed (" + e.getMessage() + ").");
357  } catch (IllegalArgumentExceptionImpl e) {
358  throw e;
359  } catch (IllegalArgumentException e) {
360  throw new DDSExceptionImpl(this.environment,
361  "DataWriter.dispose() failed (" + e.getMessage() + ").");
362  } catch (InvocationTargetException e) {
363  throw new DDSExceptionImpl(this.environment,
364  "DataWriter.dispose() failed (" + e.getMessage() + ").");
365  }
366  }
367 
368  public void dispose(InstanceHandle instanceHandle, TYPE instanceData,
369  Time sourceTimestamp) throws TimeoutException {
370  try {
371  int rc = (Integer) this.disposeTimestamp.invoke(this.old,
372  instanceData,
373  Utilities.convert(this.environment, instanceHandle),
374  Utilities.convert(this.environment, sourceTimestamp));
375  Utilities.checkReturnCodeWithTimeout(rc, this.environment,
376  "DataWriter.dispose() failed.");
377  } catch (IllegalAccessException e) {
378  throw new DDSExceptionImpl(this.environment,
379  "DataWriter.dispose() failed (" + e.getMessage() + ").");
380  } catch (IllegalArgumentExceptionImpl e) {
381  throw e;
382  } catch (IllegalArgumentException e) {
383  throw new DDSExceptionImpl(this.environment,
384  "DataWriter.dispose() failed (" + e.getMessage() + ").");
385  } catch (InvocationTargetException e) {
386  throw new DDSExceptionImpl(this.environment,
387  "DataWriter.dispose() failed (" + e.getMessage() + ").");
388  }
389 
390  }
391 
392  public void dispose(InstanceHandle instanceHandle, TYPE instanceData,
393  long sourceTimestamp, TimeUnit unit) throws TimeoutException {
394  this.dispose(instanceHandle, instanceData, new TimeImpl(
395  this.environment, sourceTimestamp, unit));
396 
397  }
398 
399  @SuppressWarnings("unchecked")
400  public TYPE getKeyValue(TYPE keyHolder, InstanceHandle handle) {
401  Object holder;
402  TYPE result;
403 
404  if (keyHolder == null) {
405  return this.getKeyValue(handle);
406  }
407 
408  try {
409  holder = this.sampleHolderClz.newInstance();
410  this.samplHolderValueField.set(holder, keyHolder);
411  int rc = (Integer) this.getKeyValue.invoke(this.old, holder,
412  Utilities.convert(this.environment, handle));
413  Utilities.checkReturnCode(rc, this.environment,
414  "DataWriter.getKeyValue() failed.");
415  result = (TYPE) this.samplHolderValueField.get(holder);
416  } catch (IllegalAccessException e) {
417  throw new DDSExceptionImpl(this.environment,
418  "DataWriter.getKeyValue() failed (" + e.getMessage() + ").");
419  } catch (IllegalArgumentExceptionImpl e) {
420  throw e;
421  } catch (IllegalArgumentException e) {
422  throw new DDSExceptionImpl(this.environment,
423  "DataWriter.getKeyValue() failed (" + e.getMessage() + ").");
424  } catch (InvocationTargetException e) {
425  throw new DDSExceptionImpl(this.environment,
426  "DataWriter.getKeyValue() failed (" + e.getMessage() + ").");
427  } catch (InstantiationException e) {
428  throw new DDSExceptionImpl(this.environment,
429  "DataWriter.getKeyValue() failed (" + e.getMessage() + ").");
430  }
431  return result;
432  }
433 
434  @SuppressWarnings("unchecked")
435  public TYPE getKeyValue(InstanceHandle handle) {
436  Object holder;
437  TYPE result;
438 
439  try {
440  holder = this.sampleHolderClz.newInstance();
441  int rc = (Integer) this.getKeyValue.invoke(this.old, holder,
442  Utilities.convert(this.environment, handle));
443  Utilities.checkReturnCode(rc, this.environment,
444  "DataWriter.getKeyValue() failed.");
445  result = (TYPE) this.samplHolderValueField.get(holder);
446  } catch (IllegalAccessException e) {
447  throw new DDSExceptionImpl(this.environment,
448  "DataWriter.getKeyValue() failed (" + e.getMessage() + ").");
449  } catch (IllegalArgumentExceptionImpl e) {
450  throw e;
451  } catch (IllegalArgumentException e) {
452  throw new DDSExceptionImpl(this.environment,
453  "DataWriter.getKeyValue() failed (" + e.getMessage() + ").");
454  } catch (InvocationTargetException e) {
455  throw new DDSExceptionImpl(this.environment,
456  "DataWriter.getKeyValue() failed (" + e.getMessage() + ").");
457  } catch (InstantiationException e) {
458  throw new DDSExceptionImpl(this.environment,
459  "DataWriter.getKeyValue() failed (" + e.getMessage() + ").");
460  }
461  return result;
462  }
463 
464  public InstanceHandle lookupInstance(TYPE keyHolder) {
465  InstanceHandle handle;
466 
467  if (keyHolder == null) {
468  throw new IllegalArgumentExceptionImpl(this.environment,
469  "Illegal keyHolder (null) provided.");
470  }
471  try {
472  long result = (Long) this.lookupInstance
473  .invoke(this.old, keyHolder);
474  handle = Utilities.convert(this.environment, result);
475  } catch (IllegalAccessException e) {
476  throw new DDSExceptionImpl(this.environment,
477  "DataWriter.lookupInstance() failed (" + e.getMessage()
478  + ").");
479  } catch (IllegalArgumentExceptionImpl e) {
480  throw e;
481  } catch (IllegalArgumentException e) {
482  throw new DDSExceptionImpl(this.environment,
483  "DataWriter.lookupInstance() failed (" + e.getMessage()
484  + ").");
485  } catch (InvocationTargetException e) {
486  throw new DDSExceptionImpl(this.environment,
487  "DataWriter.lookupInstance() failed (" + e.getMessage()
488  + ").");
489  }
490  return handle;
491  }
492 
493  public void writeDispose(TYPE instanceData) throws TimeoutException {
494  this.writeDispose(instanceData, this.environment.getSPI().nilHandle());
495 
496  }
497 
498  public void writeDispose(TYPE instanceData, Time sourceTimestamp)
499  throws TimeoutException {
500  this.writeDispose(instanceData, this.environment.getSPI().nilHandle(),
501  sourceTimestamp);
502  }
503 
504  public void writeDispose(TYPE instanceData, long sourceTimestamp,
505  TimeUnit unit) throws TimeoutException {
506  this.writeDispose(instanceData, this.environment.getSPI().nilHandle(),
507  new TimeImpl(this.environment, sourceTimestamp, unit));
508  }
509 
510  public void writeDispose(TYPE instanceData, InstanceHandle handle)
511  throws TimeoutException {
512  try {
513  int rc = (Integer) this.writeDispose.invoke(this.old, instanceData,
514  Utilities.convert(this.environment, handle));
515  Utilities.checkReturnCodeWithTimeout(rc, this.environment,
516  "DataWriter.writeDispose() failed.");
517  } catch (IllegalAccessException e) {
518  throw new DDSExceptionImpl(this.environment,
519  "DataWriter.writeDispose() failed (" + e.getMessage()
520  + ").");
521  } catch (IllegalArgumentExceptionImpl e) {
522  throw e;
523  } catch (IllegalArgumentException e) {
524  throw new DDSExceptionImpl(this.environment,
525  "DataWriter.writeDispose() failed (" + e.getMessage()
526  + ").");
527  } catch (InvocationTargetException e) {
528  throw new DDSExceptionImpl(this.environment,
529  "DataWriter.writeDispose() failed (" + e.getMessage()
530  + ").");
531  }
532 
533  }
534 
535  public void writeDispose(TYPE instanceData, InstanceHandle handle,
536  Time sourceTimestamp) throws TimeoutException {
537  try {
538  int rc = (Integer) this.writeDisposeTimestamp.invoke(this.old,
539  instanceData, Utilities.convert(this.environment, handle),
540  Utilities.convert(this.environment, sourceTimestamp));
541  Utilities.checkReturnCodeWithTimeout(rc, this.environment,
542  "DataWriter.writeDispose() failed.");
543  } catch (IllegalAccessException e) {
544  throw new DDSExceptionImpl(this.environment,
545  "DataWriter.writeDispose() failed (" + e.getMessage()
546  + ").");
547  } catch (IllegalArgumentExceptionImpl e) {
548  throw e;
549  } catch (IllegalArgumentException e) {
550  throw new DDSExceptionImpl(this.environment,
551  "DataWriter.writeDispose() failed (" + e.getMessage()
552  + ").");
553  } catch (InvocationTargetException e) {
554  throw new DDSExceptionImpl(this.environment,
555  "DataWriter.writeDispose() failed (" + e.getMessage()
556  + ").");
557  }
558  }
559 
560  public void writeDispose(TYPE instanceData, InstanceHandle handle,
561  long sourceTimestamp, TimeUnit unit) throws TimeoutException {
562  this.writeDispose(instanceData, handle, new TimeImpl(this.environment,
563  sourceTimestamp, unit));
564 
565  }
566 
567  public void assertLiveliness() {
568  int rc = this.old.assert_liveliness();
569  Utilities.checkReturnCode(rc, this.environment,
570  "DataWriter.assertLiveliness() failed.");
571  }
572 
573  public Set<InstanceHandle> getMatchedSubscriptions() {
574  DDS.InstanceHandleSeqHolder holder = new DDS.InstanceHandleSeqHolder();
575  Set<InstanceHandle> handles;
576 
577  int rc = this.old.get_matched_subscriptions(holder);
578  Utilities.checkReturnCode(rc, this.environment,
579  "DataWriter.getMatchedSubscriptions() failed.");
580 
581  handles = new HashSet<InstanceHandle>();
582 
583  for (long handle : holder.value) {
584  handles.add(Utilities.convert(this.environment, handle));
585  }
586  return handles;
587  }
588 
590  InstanceHandle subscriptionHandle) {
591  DDS.SubscriptionBuiltinTopicDataHolder holder = new DDS.SubscriptionBuiltinTopicDataHolder();
592  int rc = this.old.get_matched_subscription_data(holder,
593  Utilities.convert(this.environment, subscriptionHandle));
594  Utilities.checkReturnCode(rc, this.environment,
595  "DataWriter.getMatchedSubscriptionData() failed.");
596  if (holder.value != null) {
597  return new SubscriptionBuiltinTopicDataImpl(this.environment,
598  holder.value);
599  }
600  throw new PreconditionNotMetExceptionImpl(this.environment,
601  "No data for this instanceHandle.");
602  }
603 
605  DDS.DataWriterQosHolder holder = new DDS.DataWriterQosHolder();
606  int rc = this.old.get_qos(holder);
607  Utilities.checkReturnCode(rc, this.environment,
608  "DataWriter.getQos() failed.");
609 
610  return DataWriterQosImpl.convert(this.environment, holder.value);
611  }
612 
613  public void setQos(DataWriterQos qos) {
615 
616  if (qos == null) {
617  throw new IllegalArgumentExceptionImpl(this.environment,
618  "Supplied DataWriterQos is null.");
619  }
620  try {
621  q = (DataWriterQosImpl) qos;
622  } catch (ClassCastException e) {
623  throw new IllegalArgumentExceptionImpl(this.environment,
624  "Setting non-OpenSplice Qos not supported.");
625  }
626  int rc = this.old.set_qos(q.convert());
627  Utilities.checkReturnCode(rc, this.environment,
628  "DataWriter.setQos() failed.");
629  }
630 
631  public void waitForAcknowledgments(Duration maxWait)
632  throws TimeoutException {
633  int rc = this.old.wait_for_acknowledgments(Utilities.convert(this.environment,
634  maxWait));
635  Utilities.checkReturnCodeWithTimeout(rc, this.environment,
636  "DataWriter.waitForAcknowledgments() failed.");
637  }
638 
639  public void waitForAcknowledgments(long maxWait, TimeUnit unit)
640  throws TimeoutException {
641  this.waitForAcknowledgments(this.environment.getSPI().newDuration(
642  maxWait, unit));
643  }
644 
646  DDS.LivelinessLostStatusHolder holder = new DDS.LivelinessLostStatusHolder();
647 
648  int rc = this.old.get_liveliness_lost_status(holder);
649  Utilities.checkReturnCode(rc, this.environment,
650  "DataWriter.getLivelinessLostStatus() failed.");
651 
652  return StatusConverter.convert(this.environment, holder.value);
653  }
654 
656  DDS.OfferedDeadlineMissedStatusHolder holder = new DDS.OfferedDeadlineMissedStatusHolder();
657 
658  int rc = this.old.get_offered_deadline_missed_status(holder);
659  Utilities.checkReturnCode(rc, this.environment,
660  "DataWriter.getOfferedDeadlineMissedStatus() failed.");
661 
662  return StatusConverter.convert(this.environment, holder.value);
663  }
664 
666  DDS.OfferedIncompatibleQosStatusHolder holder = new DDS.OfferedIncompatibleQosStatusHolder();
667 
668  int rc = this.old.get_offered_incompatible_qos_status(holder);
669  Utilities.checkReturnCode(rc, this.environment,
670  "DataWriter.getOfferedIncompatibleQosStatus() failed.");
671 
672  return StatusConverter.convert(this.environment, holder.value);
673  }
674 
676  DDS.PublicationMatchedStatusHolder holder = new DDS.PublicationMatchedStatusHolder();
677 
678  int rc = this.old.get_publication_matched_status(holder);
679  Utilities.checkReturnCode(rc, this.environment,
680  "DataWriter.getPublicationMatchedStatus() failed.");
681 
682  return StatusConverter.convert(this.environment, holder.value);
683  }
684 }
OfferedDeadlineMissedStatus getOfferedDeadlineMissedStatus()
This class contains the statistics about the discovered number of org.omg.dds.sub.DataReaders that are compatible with the org.omg.dds.pub.DataWriter to which the Status is attached.
static void checkReturnCodeWithTimeout(int retCode, OsplServiceEnvironment environment, String message)
Definition: Utilities.java:176
void writeDispose(TYPE instanceData, InstanceHandle handle)
OfferedIncompatibleQosStatus getOfferedIncompatibleQosStatus()
void dispose(InstanceHandle instanceHandle)
void write(TYPE instanceData, InstanceHandle handle, long sourceTimestamp, TimeUnit unit)
static DDS.Duration_t convert(OsplServiceEnvironment environment, Duration d)
Definition: Utilities.java:232
void write(TYPE instanceData, InstanceHandle handle)
void writeDispose(TYPE instanceData, InstanceHandle handle, long sourceTimestamp, TimeUnit unit)
static QosPolicyCount [] convert(OsplServiceEnvironment env, DDS.QosPolicyCount[] old)
void write(TYPE instanceData, InstanceHandle handle, Time sourceTimestamp)
void unregisterInstance(InstanceHandle handle, TYPE instanceData)
static DataWriterQosImpl convert(OsplServiceEnvironment env, DDS.DataWriterQos oldQos)
void unregisterInstance(InstanceHandle handle, TYPE instanceData, Time sourceTimestamp)
The DCPSSubscription topic communicates the existence of datareaders by means of the SubscriptionBuil...
The liveliness that the org.omg.dds.pub.DataWriter has committed through its org.omg.dds.core.policy.Liveliness was not respected; thus org.omg.dds.sub.DataReader entities will consider the DataWriter as no longer "active.".
void write(TYPE instanceData, Time sourceTimestamp)
InstanceHandle registerInstance(TYPE instanceData)
An opaque handle that can be used to refer to a local or remote entity.
void writeDispose(TYPE instanceData, InstanceHandle handle, Time sourceTimestamp)
static void checkReturnCode(int retCode, OsplServiceEnvironment environment, String message)
Definition: Utilities.java:33
void dispose(InstanceHandle instanceHandle, TYPE instanceData)
void waitForAcknowledgments(long maxWait, TimeUnit unit)
void dispose(InstanceHandle instanceHandle, TYPE instanceData, Time sourceTimestamp)
InstanceHandle registerInstance(TYPE instanceData, Time sourceTimestamp)
A supertype of all DDS classes and interfaces.
Definition: DDSObject.java:25
void writeDispose(TYPE instanceData, long sourceTimestamp, TimeUnit unit)
A org.omg.dds.core.policy.QosPolicy value was incompatible with what was requested.
SubscriptionBuiltinTopicData getMatchedSubscriptionData(InstanceHandle subscriptionHandle)
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.
Definition: Duration.java:35
void unregisterInstance(InstanceHandle handle, TYPE instanceData, long sourceTimestamp, TimeUnit unit)
ReflectionDataWriter(OsplServiceEnvironment environment, DDS.DataWriter writer, Class< TYPE > typeClz)
DDS implementations are rooted in this class, a concrete subclass of which can be instantiated based ...
InstanceHandle registerInstance(TYPE instanceData, long sourceTimestamp, TimeUnit unit)
void writeDispose(TYPE instanceData, Time sourceTimestamp)
The deadline that the org.omg.dds.pub.DataWriter has committed through its org.omg.dds.core.policy.Deadline was not respected for a specific instance.
void dispose(InstanceHandle instanceHandle, TYPE instanceData, long sourceTimestamp, TimeUnit unit)
void write(TYPE instanceData, long sourceTimestamp, TimeUnit unit)
A moment in time expressed with nanosecond precision (though not necessarily nanosecond accuracy)...
Definition: Time.java:34