OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
DomainParticipantImpl.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.domain;
22 
23 import java.util.Arrays;
24 import java.util.Collection;
25 import java.util.HashMap;
26 import java.util.HashSet;
27 import java.util.List;
28 import java.util.Set;
29 import java.util.concurrent.TimeUnit;
30 import java.util.concurrent.TimeoutException;
31 
33 import org.omg.dds.core.Duration;
37 import org.omg.dds.core.Time;
38 import org.omg.dds.core.status.Status;
42 import org.omg.dds.pub.DataWriter;
43 import org.omg.dds.pub.Publisher;
45 import org.omg.dds.pub.PublisherQos;
46 import org.omg.dds.sub.DataReader;
47 import org.omg.dds.sub.Subscriber;
49 import org.omg.dds.sub.SubscriberQos;
51 import org.omg.dds.topic.MultiTopic;
53 import org.omg.dds.topic.Topic;
57 import org.omg.dds.topic.TopicQos;
58 import org.omg.dds.type.TypeSupport;
72 import org.opensplice.dds.dcps.MultiTopicImpl;
85 
86 import DDS.DomainParticipantQosHolder;
87 import DDS.Time_tHolder;
88 
90  extends
91  EntityImpl<DDS.DomainParticipant, DDS.DomainParticipantFactory, DomainParticipantQos, DomainParticipantListener, DomainParticipantListenerImpl>
92  implements DomainParticipant, org.opensplice.dds.domain.DomainParticipant {
93  private final DomainParticipantFactoryImpl factory;
94  private final HashMap<DDS.TopicDescription, TopicDescriptionExt<?>> topics;
95  private final HashMap<DDS.Publisher, PublisherImpl> publishers;
96  private final HashMap<DDS.Subscriber, SubscriberImpl> subscribers;
97 
99  DomainParticipantFactoryImpl factory, int domainId,
101  Collection<Class<? extends Status>> statuses) {
102  super(environment, DDS.DomainParticipantFactory.get_instance());
103  this.factory = factory;
104  this.topics = new HashMap<DDS.TopicDescription, TopicDescriptionExt<?>>();
105  this.publishers = new HashMap<DDS.Publisher, PublisherImpl>();
106  this.subscribers = new HashMap<DDS.Subscriber, SubscriberImpl>();
107 
108  if (qos == null) {
109  throw new IllegalArgumentExceptionImpl(environment,
110  "Supplied DomainParticipantQos is null.");
111  }
112 
113  DDS.DomainParticipantQos oldQos;
114 
115  try {
116  oldQos = ((DomainParticipantQosImpl) qos).convert();
117  } catch (ClassCastException e) {
118  throw new IllegalArgumentExceptionImpl(environment,
119  "Cannot create participant with non-OpenSplice qos");
120  }
121  if (listener != null) {
122  this.listener = new DomainParticipantListenerImpl(this.environment,
123  this, listener, true);
124  } else {
125  this.listener = null;
126  }
127  DDS.DomainParticipant old = this.getOldParent().create_participant(
128  domainId,
129  oldQos,
130  this.listener,
131  StatusConverter.convertMask(this.environment, statuses));
132 
133  if (old == null) {
134  Utilities.throwLastErrorException(this.environment);
135  }
136  this.setOld(old);
137 
138  if (this.listener != null) {
139  this.listener.setInitialised();
140  }
141  }
142 
143  @SuppressWarnings("unchecked")
144  public <TYPE> Topic<TYPE> getTopic(DDS.Topic oldTopic) {
145  synchronized (this.topics) {
146  return (Topic<TYPE>) this.topics.get(oldTopic);
147  }
148  }
149 
150  private void setListener(
152  DomainParticipantListenerImpl wrapperListener;
153  int rc;
154 
155  if (listener != null) {
156  wrapperListener = new DomainParticipantListenerImpl(
157  this.environment, this, listener);
158  } else {
159  wrapperListener = null;
160  }
161 
162  rc = this.getOld().set_listener(wrapperListener, mask);
163 
165  "DomainParticipant.setListener() failed.");
166 
167  this.listener = wrapperListener;
168  }
169 
170  @Override
172  DomainParticipantQosHolder holder;
173  int rc;
174 
175  holder = new DomainParticipantQosHolder();
176  rc = this.getOld().get_qos(holder);
178  "DomainParticipant.getQos() failed.");
179 
180  return DomainParticipantQosImpl.convert(this.environment, holder.value);
181  }
182 
183  @Override
184  public void setQos(DomainParticipantQos qos) {
185  DDS.DomainParticipantQos oldQos;
186  int rc;
187 
188  if (qos == null) {
190  "Supplied DomainParticipantQos is null.");
191  }
192  try {
193  oldQos = ((DomainParticipantQosImpl) qos).convert();
194  } catch (ClassCastException e) {
196  "Setting non-OpenSplice Qos not supported.");
197  }
198  rc = this.getOld().set_qos(oldQos);
200  "DomainParticipant.setQos() failed.");
201  }
202 
203  @Override
205  return this.createPublisher(this.getDefaultPublisherQos());
206  }
207 
208  @Override
210  return this.createPublisher(qos, null,
211  new HashSet<Class<? extends Status>>());
212  }
213 
214  @Override
217  Collection<Class<? extends Status>> statuses) {
218  PublisherImpl publisher;
219 
220  synchronized (this.publishers) {
221  publisher = new PublisherImpl(this.environment, this, qos,
222  listener, statuses);
223  this.publishers.put(publisher.getOld(), publisher);
224  }
225  return publisher;
226  }
227 
228  @Override
230  PublisherListener listener, Class<? extends Status>... statuses) {
231  return createPublisher(qos, listener, Arrays.asList(statuses));
232  }
233 
234  @Override
236  return this.createSubscriber(this.getDefaultSubscriberQos());
237  }
238 
239  @Override
241  return this.createSubscriber(qos, null,
242  new HashSet<Class<? extends Status>>());
243  }
244 
245  @Override
248  Collection<Class<? extends Status>> statuses) {
249  SubscriberImpl subscriber;
250 
251  synchronized (this.subscribers) {
252  subscriber = new SubscriberImpl(this.environment, this, qos,
253  listener, statuses);
254  this.subscribers.put(subscriber.getOld(), subscriber);
255  }
256  return subscriber;
257  }
258 
259  @Override
261  SubscriberListener listener, Class<? extends Status>... statuses) {
262  return createSubscriber(qos, listener, Arrays.asList(statuses));
263  }
264 
265  @Override
267  SubscriberImpl result;
268 
269  synchronized (this.subscribers) {
270  DDS.Subscriber old = this.getOld().get_builtin_subscriber();
271 
272  if (old == null) {
274  }
275  result = this.subscribers.get(old);
276 
277  if (result == null) {
278  result = new SubscriberImpl(this.environment, this, old);
279  this.subscribers.put(old, result);
280  }
281  }
282  return result;
283  }
284 
285  @Override
286  public <TYPE> Topic<TYPE> createTopic(String topicName, Class<TYPE> type) {
287  return this.createTopic(topicName, type, this.getDefaultTopicQos(),
288  null, new HashSet<Class<? extends Status>>());
289  }
290 
291  @Override
292  public <TYPE> Topic<TYPE> createTopic(String topicName, Class<TYPE> type,
294  Collection<Class<? extends Status>> statuses) {
295  AbstractTopic<TYPE> topic;
296 
298  .getSPI().newTypeSupport(type, null);
299 
300  synchronized (this.topics) {
301  topic = typeSupport.createTopic(this, topicName, qos, listener,
302  statuses);
303  this.topics.put(topic.getOld(), topic);
304  }
305  return topic;
306  }
307 
308  @Override
309  public <TYPE> Topic<TYPE> createTopic(String topicName, Class<TYPE> type,
310  TopicQos qos, TopicListener<TYPE> listener,
311  Class<? extends Status>... statuses) {
312  return createTopic(topicName, type, qos, listener,
313  Arrays.asList(statuses));
314  }
315 
316  @Override
317  public <TYPE> Topic<TYPE> createTopic(String topicName,
318  TypeSupport<TYPE> type) {
319  return this.createTopic(topicName, type, this.getDefaultTopicQos(),
320  null, new HashSet<Class<? extends Status>>());
321  }
322 
323  @Override
324  public <TYPE> Topic<TYPE> createTopic(String topicName,
325  TypeSupport<TYPE> type, TopicQos qos, TopicListener<TYPE> listener,
326  Collection<Class<? extends Status>> statuses) {
327  AbstractTopic<TYPE> topic;
328 
329  synchronized (this.topics) {
330  topic = ((AbstractTypeSupport<TYPE>) type).createTopic(this,
331  topicName,
332  qos, listener, statuses);
333  this.topics.put(topic.getOld(), topic);
334  }
335  return topic;
336  }
337 
338  @Override
339  public <TYPE> Topic<TYPE> createTopic(String topicName,
340  TypeSupport<TYPE> type, TopicQos qos, TopicListener<TYPE> listener,
341  Class<? extends Status>... statuses) {
342  return createTopic(topicName, type, qos, listener,
343  Arrays.asList(statuses));
344  }
345 
346  @Override
347  public Topic<DynamicType> createTopic(String topicName, DynamicType type) {
348  return this.createTopic(topicName, type, this.getDefaultTopicQos(),
349  null, new HashSet<Class<? extends Status>>());
350  }
351 
352  @Override
353  public Topic<DynamicType> createTopic(String topicName, DynamicType type,
354  TopicQos qos, TopicListener<DynamicType> listener,
355  Collection<Class<? extends Status>> statuses) {
357  "Dynamic types have not been implemented yet.");
358  }
359 
360  @Override
361  public Topic<DynamicType> createTopic(String topicName, DynamicType type,
362  TopicQos qos, TopicListener<DynamicType> listener,
363  Class<? extends Status>... statuses) {
365  "Dynamic types have not been implemented yet.");
366  }
367 
368  @Override
369  public Topic<DynamicType> createTopic(String topicName, DynamicType type,
370  TypeSupport<DynamicType> typeSupport) {
371  return this.createTopic(topicName, type, typeSupport,
372  this.getDefaultTopicQos(), null,
373  new HashSet<Class<? extends Status>>());
374  }
375 
376  @Override
377  public Topic<DynamicType> createTopic(String topicName, DynamicType type,
378  TypeSupport<DynamicType> typeSupport, TopicQos qos,
380  Collection<Class<? extends Status>> statuses) {
382  "Dynamic types have not been implemented yet.");
383  }
384 
385  @Override
386  public Topic<DynamicType> createTopic(String topicName, DynamicType type,
387  TypeSupport<DynamicType> typeSupport, TopicQos qos,
389  Class<? extends Status>... statuses) {
391  "Dynamic types have not been implemented yet.");
392  }
393 
394  @SuppressWarnings("unchecked")
395  @Override
396  public <TYPE> Topic<TYPE> findTopic(String topicName, Duration timeout)
397  throws TimeoutException {
398  TopicImpl<TYPE> result = null;
399  DDS.Topic old = this.getOld().find_topic(topicName,
400  Utilities.convert(this.environment, timeout));
401 
402  if (old != null) {
403  try {
404  synchronized (this.topics) {
405  result = (TopicImpl<TYPE>) this.topics.get(old);
406 
407  if (result == null) {
408  result = new TopicImpl<TYPE>(this.environment, this,
409  topicName, old);
410  this.topics.put(old, result);
411  }
412  }
413  } catch (ClassCastException e) {
415  "Type of Topic does not match provided Type.");
416  }
417  }
418  return result;
419  }
420 
421  @Override
422  public <TYPE> Topic<TYPE> findTopic(String topicName, long timeout,
423  TimeUnit unit) throws TimeoutException {
424  return this.findTopic(topicName,
425  this.environment.getSPI().newDuration(timeout, unit));
426  }
427 
428  @Override
429  public <TYPE> TopicDescription<TYPE> lookupTopicDescription(String name) {
430  TopicDescription<TYPE> td = null;
431 
432  if (name != null) {
433  synchronized (this.topics) {
434  for (TopicDescriptionExt<?> topic : this.topics.values()) {
435  if (topic.getName().equals(name)) {
436  td = topic.cast();
437  }
438  }
439  if (td == null) {
440  DDS.TopicDescription builtinTopic = this.getOld()
441  .lookup_topicdescription(name);
442 
443  if (builtinTopic != null) {
444 
445  try {
446  TopicImpl<TYPE> wrapper = new TopicImpl<TYPE>(
447  this.environment, this, name,
448  (DDS.Topic) builtinTopic);
449 
450  this.topics.put(builtinTopic, wrapper);
451  td = wrapper;
452  } catch (ClassCastException cce) {
453  /* Ignore this */
454  }
455  }
456  }
457  }
458  }
459  return td;
460  }
461 
462  @SuppressWarnings("unchecked")
463  @Override
464  public <TYPE> ContentFilteredTopic<TYPE> createContentFilteredTopic(
465  String name, Topic<? extends TYPE> relatedTopic,
466  String filterExpression, List<String> expressionParameters) {
467  ContentFilteredTopic<TYPE> result = null;
468  try {
469  ContentFilteredTopicImpl<TYPE> cfTopic = null;
470 
471  synchronized (this.topics) {
472  cfTopic = new ContentFilteredTopicImpl<TYPE>(
473  this.environment, this, name,
474  (AbstractTopic<TYPE>) relatedTopic, filterExpression,
475  expressionParameters);
476  this.topics.put(cfTopic.getOld(), cfTopic);
477  }
478  result = cfTopic;
479  } catch (ClassCastException e) {
481  "Cannot create ContentFilteredTopic which relates to non-OpenSplice Topic.");
482  }
483  return result;
484  }
485 
486  @Override
487  public <TYPE> ContentFilteredTopic<TYPE> createContentFilteredTopic(
488  String name, Topic<? extends TYPE> relatedTopic,
489  String filterExpression, String... expressionParameters) {
490  if (expressionParameters.length == 0) {
491  return createContentFilteredTopic(name, relatedTopic,
492  filterExpression, (List<String>) null);
493  }
494  return createContentFilteredTopic(name, relatedTopic, filterExpression,
495  Arrays.asList(expressionParameters));
496  }
497 
498  @Override
499  public <TYPE> MultiTopic<TYPE> createMultiTopic(String name,
500  Class<TYPE> type, String subscriptionExpression,
501  List<String> expressionParameters) {
503  "MultiTopics have not been implemented yet.");
504  }
505 
506  @Override
507  public <TYPE> MultiTopic<TYPE> createMultiTopic(String name,
508  TypeSupport<TYPE> type, String subscriptionExpression,
509  List<String> expressionParameters) {
511  "MultiTopics have not been implemented yet.");
512  }
513 
514  @Override
515  public <TYPE> MultiTopic<TYPE> createMultiTopic(String name,
516  Class<TYPE> type, String subscriptionExpression,
517  String... expressionParameters) {
519  "MultiTopics have not been implemented yet.");
520  }
521 
522  @Override
523  public <TYPE> MultiTopic<TYPE> createMultiTopic(String name,
524  TypeSupport<TYPE> type, String subscriptionExpression,
525  String... expressionParameters) {
527  "MultiTopics have not been implemented yet.");
528  }
529 
530  @Override
531  public void closeContainedEntities() {
532  synchronized (this.publishers) {
533  HashMap<DDS.Publisher, PublisherImpl> copyPub = new HashMap<DDS.Publisher, PublisherImpl>(this.publishers);
534  for (PublisherImpl publisher : copyPub.values()) {
535  try{
536  publisher.close();
537  } catch (AlreadyClosedException a) {
538  /* Entity may be closed concurrently by application */
539  }
540  }
541  }
542  synchronized (this.subscribers) {
543  HashMap<DDS.Subscriber, SubscriberImpl> copySub = new HashMap<DDS.Subscriber, SubscriberImpl>(this.subscribers);
544  for (SubscriberImpl subscriber : copySub.values()) {
545  try {
546  subscriber.close();
547  } catch (AlreadyClosedException a) {
548  /* Entity may be closed concurrently by application */
549  }
550  }
551  }
552 
553  /*
554  * Topics cannot be deleted in case ContentFilteredTopic or MultiTopic
555  * entities still refer to them, so close the latter two first.
556  */
557  synchronized (this.topics) {
558  HashMap<DDS.TopicDescription, TopicDescriptionExt<?>> copyTop = new HashMap<DDS.TopicDescription, TopicDescriptionExt<?>>(this.topics);
559  for (TopicDescriptionExt<?> topic : copyTop.values()) {
560  try {
561  if (topic instanceof ContentFilteredTopicImpl) {
562  topic.close();
563  } else if (topic instanceof MultiTopicImpl) {
564  topic.close();
565  }
566  } catch (AlreadyClosedException a) {
567  /* Entity may be closed concurrently by application */
568  }
569  }
570  copyTop = new HashMap<DDS.TopicDescription, TopicDescriptionExt<?>>(this.topics);
571  for (TopicDescriptionExt<?> topic : copyTop.values()) {
572  try {
573  topic.close();
574  } catch (AlreadyClosedException a) {
575  /* Entity may be closed concurrently by application */
576  }
577  }
578  }
579  }
580 
581  @Override
582  public void ignoreParticipant(InstanceHandle handle) {
583  try {
584  int rc = this.getOld().ignore_participant(
586  this.environment, handle));
588  "DomainParticipant.ignoreParticipant() failed");
589  } catch (ClassCastException cce) {
591  "Usage of non OpenSplice InstanceHandle not supported.");
592  }
593  }
594 
595  @Override
596  public void ignoreTopic(InstanceHandle handle) {
597  try {
598  int rc = this.getOld().ignore_topic(
599  Utilities.convert(this.environment,
600  handle));
601 
603  "DomainParticipant.ignoreTopic() failed");
604  } catch (ClassCastException cce) {
606  "Usage of non OpenSplice InstanceHandle not supported.");
607  }
608  }
609 
610  @Override
611  public void ignorePublication(InstanceHandle handle) {
612  try {
613  int rc = this.getOld().ignore_publication(
615  this.environment, handle));
616 
618  "DomainParticipant.ignorePublication() failed");
619  } catch (ClassCastException cce) {
621  "Usage of non OpenSplice InstanceHandle not supported.");
622  }
623  }
624 
625  @Override
626  public void ignoreSubscription(InstanceHandle handle) {
627  try {
628  int rc = this.getOld().ignore_subscription(
630  this.environment, handle));
631 
633  "DomainParticipant.ignoreSubscription() failed");
634  } catch (ClassCastException cce) {
636  "Usage of non OpenSplice InstanceHandle not supported.");
637  }
638  }
639 
640  @Override
641  public int getDomainId() {
642  return this.getOld().get_domain_id();
643  }
644 
645  @Override
646  public void assertLiveliness() {
647  int rc = this.getOld().assert_liveliness();
649  "DomainParticipant.assertLiveliness() failed.");
650 
651  }
652 
653  @Override
655  DDS.PublisherQosHolder holder = new DDS.PublisherQosHolder();
656  int rc = this.getOld().get_default_publisher_qos(holder);
658  "DomainParticipant.getDefaultPublisherQos() failed.");
659  return PublisherQosImpl.convert(this.environment, holder.value);
660  }
661 
662  @Override
664  if (qos == null) {
666  "Supplied PublisherQos is null.");
667  }
668  try {
669  this.getOld().set_default_publisher_qos(
670  ((PublisherQosImpl) qos)
671  .convert());
672  } catch (ClassCastException e) {
674  "Non-OpenSplice PublisherQos not supported.");
675  }
676  }
677 
678  @Override
680  DDS.SubscriberQosHolder holder = new DDS.SubscriberQosHolder();
681  int rc = this.getOld().get_default_subscriber_qos(holder);
683  "DomainParticipant.getDefaultSubscriberQos() failed.");
684  return SubscriberQosImpl.convert(this.environment, holder.value);
685  }
686 
687  @Override
689  if (qos == null) {
691  "Supplied SubscriberQos is null.");
692  }
693  try {
694  this.getOld().set_default_subscriber_qos(
695  ((SubscriberQosImpl) qos)
696  .convert());
697  } catch (ClassCastException e) {
699  "Non-OpenSplice SubscriberQos not supported.");
700  }
701  }
702 
703  @Override
705  DDS.TopicQosHolder holder = new DDS.TopicQosHolder();
706  int rc = this.getOld().get_default_topic_qos(holder);
708  "DomainParticipant.getDefaultTopicQos() failed.");
709 
710  return TopicQosImpl.convert(this.environment, holder.value);
711  }
712 
713  @Override
714  public void setDefaultTopicQos(TopicQos qos) {
715  if (qos == null) {
717  "Supplied TopicQos is null.");
718  }
719  try {
720  this.getOld().set_default_topic_qos(((TopicQosImpl) qos).convert());
721  } catch (ClassCastException e) {
723  "Non-OpenSplice TopicQos not supported.");
724  }
725  }
726 
727  @Override
728  public Set<InstanceHandle> getDiscoveredParticipants() {
729  DDS.InstanceHandleSeqHolder holder = new DDS.InstanceHandleSeqHolder();
730  int rc = this.getOld().get_discovered_participants(holder);
731 
733  "DomainParticipant.getDiscoveredParticipants() failed.");
734 
735  HashSet<InstanceHandle> handles = new HashSet<InstanceHandle>(
736  holder.value.length);
737 
738  for (long handle : holder.value) {
739  handles.add(new InstanceHandleImpl(this.environment, handle));
740  }
741  return handles;
742  }
743 
744  @Override
746  InstanceHandle participantHandle) {
747  DDS.ParticipantBuiltinTopicDataHolder holder = new DDS.ParticipantBuiltinTopicDataHolder();
748  int rc = this.getOld().get_discovered_participant_data(holder,
749  Utilities.convert(this.environment, participantHandle));
751  "DomainParticipant.getDiscoveredParticipantData() failed.");
752  if (holder.value != null) {
754  holder.value);
755  }
757  "No data for this instanceHandle.");
758 
759  }
760 
761  @Override
762  public Set<InstanceHandle> getDiscoveredTopics() {
763  DDS.InstanceHandleSeqHolder holder = new DDS.InstanceHandleSeqHolder();
764  int rc = this.getOld().get_discovered_topics(holder);
765 
767  "DomainParticipant.getDiscoveredTopics() failed.");
768 
769  HashSet<InstanceHandle> handles = new HashSet<InstanceHandle>(
770  holder.value.length);
771 
772  for (long handle : holder.value) {
773  handles.add(new InstanceHandleImpl(this.environment, handle));
774  }
775  return handles;
776  }
777 
778  @Override
780  InstanceHandle topicHandle) {
781  DDS.TopicBuiltinTopicDataHolder holder = new DDS.TopicBuiltinTopicDataHolder();
782  int rc = this.getOld().get_discovered_topic_data(holder,
783  Utilities.convert(this.environment, topicHandle));
785  "DomainParticipant.getDiscoveredTopicData() failed.");
786  if (holder.value != null) {
787  return new TopicBuiltinTopicDataImpl(this.environment, holder.value);
788  }
790  "No data for this instanceHandle.");
791  }
792 
793  @Override
794  public boolean containsEntity(InstanceHandle handle) {
795  return this.getOld().contains_entity(
796  Utilities.convert(this.environment,
797  handle));
798  }
799 
800  @Override
802  ModifiableTime result;
803  Time_tHolder holder = new Time_tHolder();
804  int rc = this.getOld().get_current_time(holder);
806  "DomainParticipant.getCurrentTime() failed.");
807 
808  if (currentTime == null) {
809  result = new ModifiableTimeImpl(this.environment, holder.value.sec,
810  holder.value.nanosec);
811  } else {
812  currentTime.copyFrom(new TimeImpl(this.environment,
813  holder.value.sec, holder.value.nanosec));
814  result = currentTime;
815  }
816  return result;
817  }
818 
819  @Override
820  public Time getCurrentTime() {
821  Time_tHolder holder = new Time_tHolder();
822  int rc = this.getOld().get_current_time(holder);
824  "DomainParticipant.getCurrentTime() failed.");
825 
826  return new TimeImpl(this.environment, holder.value.sec,
827  holder.value.nanosec);
828  }
829 
830  @Override
832  DDS.StatusCondition oldCondition = this.getOld().get_statuscondition();
833 
834  if (oldCondition == null) {
836  }
838  oldCondition, this);
839  }
840 
841  @Override
842  protected void destroy() {
843  this.closeContainedEntities();
844  this.factory.destroyParticipant(this);
845  }
846 
847  @Override
848  public void setListener(
850  this.setListener(listener, StatusConverter.getAnyMask());
851 
852  }
853 
854  @Override
855  public void setListener(
857  Collection<Class<? extends Status>> statuses) {
858  this.setListener(listener,
859  StatusConverter.convertMask(this.environment, statuses));
860  }
861 
862  @Override
864  Class<? extends Status>... statuses) {
865  this.setListener(listener,
866  StatusConverter.convertMask(this.environment, statuses));
867  }
868 
869  public <TYPE> DataWriter<TYPE> lookupDataWriter(DDS.DataWriter old) {
870  DataWriter<TYPE> writer;
871 
872  synchronized (this.publishers) {
873  for (PublisherImpl p : this.publishers.values()) {
874  writer = p.lookupDataWriter(old);
875 
876  if (writer != null) {
877  return writer;
878  }
879  }
880  }
881  return null;
882  }
883 
884  public <TYPE> DataReader<TYPE> lookupDataReader(DDS.DataReader classic) {
885  DataReader<TYPE> reader;
886  boolean seenBuiltin = false;
887 
888  synchronized (this.subscribers) {
889  for (SubscriberImpl s : this.subscribers.values()) {
890  reader = s.lookupDataReader(classic);
891 
892  if (reader != null) {
893  return reader;
894  }
895  if (s.isBuiltin()) {
896  seenBuiltin = true;
897  }
898  }
899  if (!seenBuiltin) {
900  SubscriberImpl sub = (SubscriberImpl) this
902 
903  if (sub != null) {
904  return sub.lookupDataReader(classic);
905  }
906  }
907  }
908  return null;
909  }
910 
911  public org.omg.dds.sub.Subscriber lookupSubscriber(DDS.Subscriber subs) {
912  SubscriberImpl subscriber;
913  SubscriberImpl builtinSub;
914 
915  synchronized (this.subscribers) {
916  subscriber = this.subscribers.get(subs);
917 
918  if (subscriber == null) {
919  /*
920  * If subscriber is unknown it'll have to be the built-in
921  * subscriber
922  */
923  builtinSub = (SubscriberImpl) this.getBuiltinSubscriber();
924 
925  if (builtinSub != null) {
926  subscriber = builtinSub;
927  }
928  }
929  }
930  return subscriber;
931  }
932 
933  public void destroyPublisher(PublisherImpl child) {
934  DDS.Publisher old = child.getOld();
935  old.delete_contained_entities();
936  int rc = this.getOld().delete_publisher(old);
937  synchronized (this.publishers) {
938  this.publishers.remove(old);
939  }
941  "Publisher.close() failed.");
942  }
943 
944  public void destroySubscriber(SubscriberImpl child) {
945  DDS.Subscriber old = child.getOld();
946  old.delete_contained_entities();
947  int rc = this.getOld().delete_subscriber(old);
948  synchronized (this.subscribers) {
949  this.subscribers.remove(old);
950  }
952  "Subscriber.close() failed.");
953  }
954 
955  public <TYPE> void destroyTopic(TopicDescriptionExt<TYPE> child) {
956  DDS.TopicDescription old = child.getOld();
957  int rc = this.getOld().delete_topic((DDS.Topic) old);
958  synchronized (this.topics) {
959  this.topics.remove(old);
960  }
961  Utilities
962  .checkReturnCode(rc, this.environment, "Topic.close() failed.");
963  }
964 
965  public <TYPE> void destroyContentFilteredTopic(
967  DDS.TopicDescription old = child.getOld();
968  synchronized (this.topics) {
969  TopicDescriptionExt<?> removed = this.topics.remove(old);
970  if (removed == null) {
972  "ContentFilteredTopic already closed.");
973  }
974  }
975  int rc = this.getOld().delete_contentfilteredtopic(
976  (DDS.ContentFilteredTopic) old);
978  "ContentFilteredTopic.close() failed.");
979  child.getRelatedTopic().close();
980 
981  }
982 
983  @Override
984  public void deleteHistoricalData(String partitionExpression,String topicExpression) {
985  int rc = this.getOld().delete_historical_data(partitionExpression, topicExpression);
986  Utilities.checkReturnCode(rc, this.environment,"deleteHistoricalData operation failed.");
987  }
988 
989  @Override
990  public void createPersistentSnapshot(String partitionExpression,String topicExpression,String uri) {
991  DDS.Domain domain = this.getOldParent().lookup_domain(this.getDomainId());
992  if (domain != null) {
993  int rc = domain.create_persistent_snapshot(partitionExpression, topicExpression, uri);
994  Utilities.checkReturnCode(rc, this.environment,"createPersistenSnapshot operation failed.");
995  } else {
997  "Invalid domain used.");
998  }
999  }
1000 
1001  @Override
1002  public void setProperty(String key, String value) {
1003  int rc = this.getOld().set_property(new DDS.Property(key, value));
1005  "Properties.setProperty() failed.");
1006  }
1007 
1008  @Override
1009  public String getProperty(String key) {
1010  DDS.PropertyHolder holder = new DDS.PropertyHolder();
1011  holder.value = new DDS.Property(key, null);
1012  int rc = this.getOld().get_property(holder);
1014  "Properties.getProperty() failed.");
1015  return holder.value.value;
1016  }
1017 }
static PublisherQosImpl convert(OsplServiceEnvironment env, DDS.PublisherQos oldQos)
The DCPSTopic topic communicates the existence of topics by means of the TopicBuiltinTopicData dataty...
DomainParticipantImpl(OsplServiceEnvironment environment, DomainParticipantFactoryImpl factory, int domainId, DomainParticipantQos qos, DomainParticipantListener listener, Collection< Class<? extends Status >> statuses)
A DataReader allows the application (1) to declare the data it wishes to receive (i.e., make a subscription) and (2) to access the data received by the attached org.omg.dds.sub.Subscriber.
Time getCurrentTime()
This operation returns the current value of the time that the service uses to time stamp data writes ...
A Subscriber is the object responsible for the actual reception of the data resulting from its subscr...
Definition: Subscriber.java:69
The DomainParticipant object plays several roles:
void createPersistentSnapshot(String partitionExpression, String topicExpression, String uri)
Set< InstanceHandle > getDiscoveredTopics()
This operation retrieves the list of org.omg.dds.topic.Topics that have been discovered in the domain...
A StatusCondition object is an immutable object that specifies Condition that is associated with each...
Subscriber createSubscriber(SubscriberQos qos, SubscriberListener listener, Class<? extends Status >... statuses)
This operation creates a Subscriber.
void setDefaultTopicQos(TopicQos qos)
This operation sets a default value of the Topic QoS policies, which will be used for newly created o...
Subscriber createSubscriber(SubscriberQos qos, SubscriberListener listener, Collection< Class<? extends Status >> statuses)
This operation creates a Subscriber.
Topic< DynamicType > createTopic(String topicName, DynamicType type)
This operation creates a Topic with default QoS policies and no TopicListener.
Topic<? extends TYPE > getRelatedTopic()
The org.omg.dds.topic.Topic associated with the ContentFilteredTopic, that is, the Topic specified wh...
StatusCondition< DomainParticipant > getStatusCondition()
This operation allows access to the org.omg.dds.core.StatusCondition associated with the Entity...
static SubscriberQosImpl convert(OsplServiceEnvironment env, DDS.SubscriberQos oldQos)
Topic< DynamicType > createTopic(String topicName, DynamicType type, TypeSupport< DynamicType > typeSupport)
This operation creates a Topic with default QoS policies and no TopicListener.
Subscriber getBuiltinSubscriber()
This operation allows access to the built-in Subscriber.
Topic< DynamicType > createTopic(String topicName, DynamicType type, TopicQos qos, TopicListener< DynamicType > listener, Collection< Class<? extends Status >> statuses)
This operation creates a Topic with the desired QoS policies and attaches to it the specified TopicLi...
void close()
Dispose the resources held by this object.
void setDefaultSubscriberQos(SubscriberQos qos)
This operation sets a default value of the Subscriber QoS policies that will be used for newly create...
static DDS.Duration_t convert(OsplServiceEnvironment environment, Duration d)
Definition: Utilities.java:232
int getDomainId()
This operation retrieves the domain ID used to create the DomainParticipant.
void ignoreParticipant(InstanceHandle handle)
This operation allows an application to instruct the Service to locally ignore a remote domain partic...
Publisher createPublisher()
This operation creates a Publisher with default QoS policies and no PublisherListener.
static TopicQosImpl convert(OsplServiceEnvironment env, DDS.TopicQos oldQos)
void ignorePublication(InstanceHandle handle)
This operation allows an application to instruct the Service to locally ignore a remote publication; ...
static DomainParticipantQosImpl convert(OsplServiceEnvironment env, DDS.DomainParticipantQos oldQos)
Subscriber createSubscriber()
This operation creates a Subscriber with default QoS policies and no SubscriberListener.
ModifiableTime getCurrentTime(ModifiableTime currentTime)
This operation returns the current value of the time that the service uses to time stamp data writes ...
DataWriter allows the application to set the value of the data to be published under a given org...
Definition: DataWriter.java:86
void setListener(org.omg.dds.domain.DomainParticipantListener listener, Collection< Class<? extends Status >> statuses)
static Set< Class<? extends Status > > convertMask(OsplServiceEnvironment environment, int state)
public< OTHER > TopicDescription< OTHER > cast()
Cast this topic description to the given type, or throw an exception if the cast fails.
SubscriberQos getDefaultSubscriberQos()
This operation retrieves the default value of the Subscriber QoS, that is, the QoS policies which wil...
abstract AbstractTopic< TYPE > createTopic(DomainParticipantImpl participant, String topicName, TopicQos qos, TopicListener< TYPE > listener, Collection< Class<? extends Status >> statuses)
An opaque handle that can be used to refer to a local or remote entity.
void setDefaultPublisherQos(PublisherQos qos)
This operation sets a default value of the Publisher QoS policies, which will be used for newly creat...
Since a org.omg.dds.sub.Subscriber is a kind of org.omg.dds.core.Entity, it has the ability to have a...
Set< InstanceHandle > getDiscoveredParticipants()
This operation retrieves the list of DomainParticipants that have been discovered in the domain and t...
void assertLiveliness()
This operation manually asserts the liveliness of the DomainParticipant.
static void checkReturnCode(int retCode, OsplServiceEnvironment environment, String message)
Definition: Utilities.java:33
Since org.omg.dds.topic.Topic is a kind of org.omg.dds.core.Entity, it has the ability to have an ass...
DomainParticipantQos getQos()
This operation allows access to the existing set of QoS policies for the Entity.
TopicBuiltinTopicData getDiscoveredTopicData(InstanceHandle topicHandle)
This operation retrieves information on a org.omg.dds.topic.Topic that has been discovered on the net...
abstract void copyFrom(Time src)
Overwrite the state of this object with that of the given object.
MultiTopic is a specialization of TopicDescription that allows subscriptions to combine/filter/rearra...
Definition: MultiTopic.java:73
ParticipantBuiltinTopicData getDiscoveredParticipantData(InstanceHandle participantHandle)
This operation retrieves information on a DomainParticipant that has been discovered on the network...
Topic< DynamicType > createTopic(String topicName, DynamicType type, TypeSupport< DynamicType > typeSupport, TopicQos qos, TopicListener< DynamicType > listener, Collection< Class<? extends Status >> statuses)
This operation creates a Topic with the desired QoS policies and attaches to it the specified TopicLi...
The target object was previously closed and therefore cannot process the operation.
String getProperty(String key)
Provides access to the current value for a given property.
void setListener(org.omg.dds.domain.DomainParticipantListener listener)
TopicQos getDefaultTopicQos()
This operation retrieves the default value of the Topic QoS, that is, the QoS policies which will be ...
A Publisher is the object responsible for the actual dissemination of publications.
Definition: Publisher.java:71
TypeSupport is an abstract interface that has to be specialized for each concrete type that will be u...
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
ContentFilteredTopic is a specialization of TopicDescription that allows for content-based subscripti...
void ignoreTopic(InstanceHandle handle)
This operation allows an application to instruct the Service to locally ignore a org.omg.dds.topic.Topic.
final transient OsplServiceEnvironment environment
Definition: EntityImpl.java:36
This is the interface that can be implemented by an application-provided class and then registered wi...
Publisher createPublisher(PublisherQos qos, PublisherListener listener, Class<? extends Status >... statuses)
This operation creates a Publisher.
Publisher createPublisher(PublisherQos qos)
This operation creates a Publisher.
void ignoreSubscription(InstanceHandle handle)
This operation allows an application to instruct the Service to locally ignore a remote subscription;...
void deleteHistoricalData(String partitionExpression, String topicExpression)
static void throwLastErrorException(OsplServiceEnvironment environment)
Definition: Utilities.java:182
void setListener(DomainParticipantListener listener, Class<? extends Status >... statuses)
This interface is the base for org.omg.dds.topic.Topic, org.omg.dds.topic.ContentFilteredTopic, and org.omg.dds.topic.MultiTopic.
Topic is the most basic description of the data to be published and subscribed.
Definition: Topic.java:55
org.omg.dds.sub.Subscriber lookupSubscriber(DDS.Subscriber subs)
Since a org.omg.dds.pub.Publisher is a kind of org.omg.dds.core.Entity, it has the ability to have a ...
Subscriber createSubscriber(SubscriberQos qos)
This operation creates a Subscriber.
Class that contains information about available DomainParticipants within the system.
Topic< DynamicType > createTopic(String topicName, DynamicType type, TopicQos qos, TopicListener< DynamicType > listener, Class<? extends Status >... statuses)
This operation creates a Topic with the desired QoS policies and attaches to it the specified TopicLi...
PublisherQos getDefaultPublisherQos()
This operation retrieves the default value of the Publisher QoS, that is, the QoS policies which will...
void closeContainedEntities()
This operation deletes all the entities that were created by means of the "create" operations on the ...
void setProperty(String key, String value)
This method sets the property specified by the key to the value given by the value.
A moment in time expressed with nanosecond precision (though not necessarily nanosecond accuracy)...
Definition: Time.java:34
Topic< DynamicType > createTopic(String topicName, DynamicType type, TypeSupport< DynamicType > typeSupport, TopicQos qos, TopicListener< DynamicType > listener, Class<? extends Status >... statuses)
This operation creates a Topic with the desired QoS policies and attaches to it the specified TopicLi...
Status is the abstract root class for all communication status objects.
Definition: Status.java:41
Publisher createPublisher(PublisherQos qos, PublisherListener listener, Collection< Class<? extends Status >> statuses)
This operation creates a Publisher.
boolean containsEntity(InstanceHandle handle)
This operation checks whether or not the given handle represents an org.omg.dds.core.Entity that was created from the DomainParticipant.