21 package org.opensplice.dds.domain;
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;
29 import java.util.concurrent.TimeUnit;
30 import java.util.concurrent.TimeoutException;
86 import DDS.DomainParticipantQosHolder;
87 import DDS.Time_tHolder;
91 EntityImpl<DDS.DomainParticipant, DDS.DomainParticipantFactory, DomainParticipantQos, DomainParticipantListener, DomainParticipantListenerImpl>
95 private final HashMap<DDS.Publisher,
PublisherImpl> publishers;
101 Collection<Class<? extends Status>> statuses) {
102 super(environment, DDS.DomainParticipantFactory.get_instance());
103 this.factory = factory;
105 this.publishers =
new HashMap<DDS.Publisher,
PublisherImpl>();
110 "Supplied DomainParticipantQos is null.");
113 DDS.DomainParticipantQos oldQos;
117 }
catch (ClassCastException e) {
119 "Cannot create participant with non-OpenSplice qos");
121 if (listener != null) {
123 this, listener,
true);
125 this.listener = null;
127 DDS.DomainParticipant old = this.
getOldParent().create_participant(
138 if (this.listener != null) {
139 this.listener.setInitialised();
143 @SuppressWarnings(
"unchecked")
144 public <TYPE>
Topic<TYPE> getTopic(DDS.Topic oldTopic) {
145 synchronized (this.topics) {
150 private void setListener(
159 wrapperListener = null;
162 rc = this.
getOld().set_listener(wrapperListener, mask);
165 "DomainParticipant.setListener() failed.");
172 DomainParticipantQosHolder holder;
175 holder =
new DomainParticipantQosHolder();
176 rc = this.
getOld().get_qos(holder);
178 "DomainParticipant.getQos() failed.");
185 DDS.DomainParticipantQos oldQos;
190 "Supplied DomainParticipantQos is null.");
194 }
catch (ClassCastException e) {
196 "Setting non-OpenSplice Qos not supported.");
198 rc = this.
getOld().set_qos(oldQos);
200 "DomainParticipant.setQos() failed.");
211 new HashSet<Class<? extends Status>>());
217 Collection<Class<? extends Status>> statuses) {
220 synchronized (this.publishers) {
223 this.publishers.put(publisher.
getOld(), publisher);
242 new HashSet<Class<? extends Status>>());
248 Collection<Class<? extends Status>> statuses) {
251 synchronized (this.subscribers) {
254 this.subscribers.put(subscriber.
getOld(), subscriber);
269 synchronized (this.subscribers) {
270 DDS.Subscriber old = this.
getOld().get_builtin_subscriber();
275 result = this.subscribers.get(old);
277 if (result == null) {
279 this.subscribers.put(old, result);
286 public <TYPE>
Topic<TYPE> createTopic(String topicName, Class<TYPE> type) {
288 null,
new HashSet<Class<? extends Status>>());
292 public <TYPE>
Topic<TYPE> createTopic(String topicName, Class<TYPE> type,
294 Collection<Class<? extends Status>> statuses) {
298 .getSPI().newTypeSupport(type, null);
300 synchronized (this.topics) {
301 topic = typeSupport.
createTopic(
this, topicName, qos, listener,
303 this.topics.put(topic.
getOld(), topic);
309 public <TYPE>
Topic<TYPE> createTopic(String topicName, Class<TYPE> type,
311 Class<? extends Status>... statuses) {
312 return createTopic(topicName, type, qos, listener,
313 Arrays.asList(statuses));
317 public <TYPE>
Topic<TYPE> createTopic(String topicName,
320 null,
new HashSet<Class<? extends Status>>());
324 public <TYPE>
Topic<TYPE> createTopic(String topicName,
326 Collection<Class<? extends Status>> statuses) {
329 synchronized (this.topics) {
332 qos, listener, statuses);
333 this.topics.put(topic.
getOld(), topic);
339 public <TYPE>
Topic<TYPE> createTopic(String topicName,
341 Class<? extends Status>... statuses) {
342 return createTopic(topicName, type, qos, listener,
343 Arrays.asList(statuses));
349 null,
new HashSet<Class<? extends Status>>());
355 Collection<Class<? extends Status>> statuses) {
357 "Dynamic types have not been implemented yet.");
363 Class<? extends Status>... statuses) {
365 "Dynamic types have not been implemented yet.");
371 return this.createTopic(topicName, type, typeSupport,
373 new HashSet<Class<? extends Status>>());
380 Collection<Class<? extends Status>> statuses) {
382 "Dynamic types have not been implemented yet.");
389 Class<? extends Status>... statuses) {
391 "Dynamic types have not been implemented yet.");
394 @SuppressWarnings(
"unchecked")
397 throws TimeoutException {
399 DDS.Topic old = this.
getOld().find_topic(topicName,
404 synchronized (this.topics) {
407 if (result == null) {
410 this.topics.put(old, result);
413 }
catch (ClassCastException e) {
415 "Type of Topic does not match provided Type.");
422 public <TYPE>
Topic<TYPE> findTopic(String topicName,
long timeout,
423 TimeUnit unit)
throws TimeoutException {
424 return this.findTopic(topicName,
433 synchronized (this.topics) {
435 if (topic.getName().equals(name)) {
440 DDS.TopicDescription builtinTopic = this.
getOld()
441 .lookup_topicdescription(name);
443 if (builtinTopic != null) {
448 (DDS.Topic) builtinTopic);
450 this.topics.put(builtinTopic, wrapper);
452 }
catch (ClassCastException cce) {
462 @SuppressWarnings(
"unchecked")
466 String filterExpression, List<String> expressionParameters) {
471 synchronized (this.topics) {
475 expressionParameters);
476 this.topics.put(cfTopic.
getOld(), cfTopic);
479 }
catch (ClassCastException e) {
481 "Cannot create ContentFilteredTopic which relates to non-OpenSplice Topic.");
489 String filterExpression, String... expressionParameters) {
490 if (expressionParameters.length == 0) {
491 return createContentFilteredTopic(name, relatedTopic,
492 filterExpression, (List<String>) null);
494 return createContentFilteredTopic(name, relatedTopic, filterExpression,
495 Arrays.asList(expressionParameters));
500 Class<TYPE> type, String subscriptionExpression,
501 List<String> expressionParameters) {
503 "MultiTopics have not been implemented yet.");
509 List<String> expressionParameters) {
511 "MultiTopics have not been implemented yet.");
516 Class<TYPE> type, String subscriptionExpression,
517 String... expressionParameters) {
519 "MultiTopics have not been implemented yet.");
525 String... expressionParameters) {
527 "MultiTopics have not been implemented yet.");
532 synchronized (this.publishers) {
542 synchronized (this.subscribers) {
557 synchronized (this.topics) {
563 }
else if (topic instanceof MultiTopicImpl) {
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.");
598 int rc = this.
getOld().ignore_topic(
603 "DomainParticipant.ignoreTopic() failed");
604 }
catch (ClassCastException cce) {
606 "Usage of non OpenSplice InstanceHandle not supported.");
613 int rc = this.
getOld().ignore_publication(
615 this.environment, handle));
618 "DomainParticipant.ignorePublication() failed");
619 }
catch (ClassCastException cce) {
621 "Usage of non OpenSplice InstanceHandle not supported.");
628 int rc = this.
getOld().ignore_subscription(
630 this.environment, handle));
633 "DomainParticipant.ignoreSubscription() failed");
634 }
catch (ClassCastException cce) {
636 "Usage of non OpenSplice InstanceHandle not supported.");
642 return this.
getOld().get_domain_id();
647 int rc = this.
getOld().assert_liveliness();
649 "DomainParticipant.assertLiveliness() failed.");
655 DDS.PublisherQosHolder holder =
new DDS.PublisherQosHolder();
656 int rc = this.
getOld().get_default_publisher_qos(holder);
658 "DomainParticipant.getDefaultPublisherQos() failed.");
666 "Supplied PublisherQos is null.");
669 this.
getOld().set_default_publisher_qos(
672 }
catch (ClassCastException e) {
674 "Non-OpenSplice PublisherQos not supported.");
680 DDS.SubscriberQosHolder holder =
new DDS.SubscriberQosHolder();
681 int rc = this.
getOld().get_default_subscriber_qos(holder);
683 "DomainParticipant.getDefaultSubscriberQos() failed.");
691 "Supplied SubscriberQos is null.");
694 this.
getOld().set_default_subscriber_qos(
697 }
catch (ClassCastException e) {
699 "Non-OpenSplice SubscriberQos not supported.");
705 DDS.TopicQosHolder holder =
new DDS.TopicQosHolder();
706 int rc = this.
getOld().get_default_topic_qos(holder);
708 "DomainParticipant.getDefaultTopicQos() failed.");
717 "Supplied TopicQos is null.");
721 }
catch (ClassCastException e) {
723 "Non-OpenSplice TopicQos not supported.");
729 DDS.InstanceHandleSeqHolder holder =
new DDS.InstanceHandleSeqHolder();
730 int rc = this.
getOld().get_discovered_participants(holder);
733 "DomainParticipant.getDiscoveredParticipants() failed.");
735 HashSet<InstanceHandle> handles =
new HashSet<InstanceHandle>(
736 holder.value.length);
738 for (
long handle : holder.value) {
747 DDS.ParticipantBuiltinTopicDataHolder holder =
new DDS.ParticipantBuiltinTopicDataHolder();
748 int rc = this.
getOld().get_discovered_participant_data(holder,
751 "DomainParticipant.getDiscoveredParticipantData() failed.");
752 if (holder.value != null) {
757 "No data for this instanceHandle.");
763 DDS.InstanceHandleSeqHolder holder =
new DDS.InstanceHandleSeqHolder();
764 int rc = this.
getOld().get_discovered_topics(holder);
767 "DomainParticipant.getDiscoveredTopics() failed.");
769 HashSet<InstanceHandle> handles =
new HashSet<InstanceHandle>(
770 holder.value.length);
772 for (
long handle : holder.value) {
781 DDS.TopicBuiltinTopicDataHolder holder =
new DDS.TopicBuiltinTopicDataHolder();
782 int rc = this.
getOld().get_discovered_topic_data(holder,
785 "DomainParticipant.getDiscoveredTopicData() failed.");
786 if (holder.value != null) {
790 "No data for this instanceHandle.");
795 return this.
getOld().contains_entity(
803 Time_tHolder holder =
new Time_tHolder();
804 int rc = this.
getOld().get_current_time(holder);
806 "DomainParticipant.getCurrentTime() failed.");
808 if (currentTime == null) {
810 holder.value.nanosec);
813 holder.value.sec, holder.value.nanosec));
814 result = currentTime;
821 Time_tHolder holder =
new Time_tHolder();
822 int rc = this.
getOld().get_current_time(holder);
824 "DomainParticipant.getCurrentTime() failed.");
827 holder.value.nanosec);
832 DDS.StatusCondition oldCondition = this.
getOld().get_statuscondition();
834 if (oldCondition == null) {
857 Collection<Class<? extends Status>> statuses) {
858 this.setListener(listener,
864 Class<? extends Status>... statuses) {
865 this.setListener(listener,
872 synchronized (this.publishers) {
874 writer = p.lookupDataWriter(old);
876 if (writer != null) {
886 boolean seenBuiltin =
false;
888 synchronized (this.subscribers) {
890 reader = s.lookupDataReader(classic);
892 if (reader != null) {
904 return sub.lookupDataReader(classic);
915 synchronized (this.subscribers) {
916 subscriber = this.subscribers.get(subs);
918 if (subscriber == null) {
925 if (builtinSub != null) {
926 subscriber = builtinSub;
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);
941 "Publisher.close() failed.");
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);
952 "Subscriber.close() failed.");
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);
965 public <TYPE>
void destroyContentFilteredTopic(
967 DDS.TopicDescription old = child.
getOld();
968 synchronized (this.topics) {
970 if (removed == null) {
972 "ContentFilteredTopic already closed.");
975 int rc = this.
getOld().delete_contentfilteredtopic(
976 (DDS.ContentFilteredTopic) old);
978 "ContentFilteredTopic.close() failed.");
985 int rc = this.
getOld().delete_historical_data(partitionExpression, topicExpression);
992 if (domain != null) {
993 int rc = domain.create_persistent_snapshot(partitionExpression, topicExpression, uri);
997 "Invalid domain used.");
1003 int rc = this.
getOld().set_property(
new DDS.Property(key, value));
1005 "Properties.setProperty() failed.");
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;
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.
DDS.TopicDescription getOld()
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...
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.
void destroyPublisher(PublisherImpl child)
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...
DDS.TopicDescription getOld()
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)
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...
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.
void setQos(DomainParticipantQos qos)
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)
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...
ServiceProviderInterface getSPI()
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...
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.
TypeSupport is an abstract interface that has to be specialized for each concrete type that will be u...
void destroySubscriber(SubscriberImpl child)
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.
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
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)
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.
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 ...
void destroyParticipant(DomainParticipantImpl participant)
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)...
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.
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.