OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
DomainParticipantListenerImpl.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.io.Serializable;
24 
45 
46 import DDS.AllDataDisposedTopicStatusHolder;
47 import DDS.DataReader;
48 import DDS.DataWriter;
49 import DDS.InconsistentTopicStatus;
50 import DDS.LivelinessChangedStatus;
51 import DDS.LivelinessLostStatus;
52 import DDS.OfferedDeadlineMissedStatus;
53 import DDS.OfferedIncompatibleQosStatus;
54 import DDS.PublicationMatchedStatus;
55 import DDS.RequestedDeadlineMissedStatus;
56 import DDS.RequestedIncompatibleQosStatus;
57 import DDS.SampleLostStatus;
58 import DDS.SampleRejectedStatus;
59 import DDS.Subscriber;
60 import DDS.SubscriptionMatchedStatus;
61 import DDS.Topic;
62 
63 public class DomainParticipantListenerImpl extends
64  Listener<DomainParticipantListener> implements
65  DDS.ExtDomainParticipantListener, Serializable {
66  private static final long serialVersionUID = -3531755144455417494L;
67  private final transient DomainParticipantImpl participant;
68  private final transient org.opensplice.dds.domain.DomainParticipantListener extListener;
69 
71  DomainParticipantImpl participant,
73  this(environment, participant, listener, false);
74  }
75 
77  DomainParticipantImpl participant,
79  super(environment, listener, waitUntilInitialised);
80  this.participant = participant;
81 
82  if (listener instanceof org.opensplice.dds.domain.DomainParticipantListener) {
83  this.extListener = (org.opensplice.dds.domain.DomainParticipantListener) listener;
84  } else {
85  this.extListener = null;
86  }
87 
88  }
89 
90  @Override
91  public void on_inconsistent_topic(Topic the_topic,
92  InconsistentTopicStatus status) {
93  try {
94  org.omg.dds.topic.Topic<Object> found = participant
95  .getTopic(the_topic);
96 
97  if (found != null) {
98  this.waitUntilInitialised();
99  this.listener
100  .onInconsistentTopic(new InconsistentTopicEventImpl<Object>(
101  this.environment, found, StatusConverter
102  .convert(this.environment, status)));
103  }
104  } catch (ClassCastException e) {
105  }
106  }
107 
108  @Override
110  OfferedDeadlineMissedStatus status) {
111 
112  org.omg.dds.pub.DataWriter<Object> found = this.participant
113  .lookupDataWriter(writer);
114 
115  if (found != null) {
116  this.waitUntilInitialised();
117  this.listener
118  .onOfferedDeadlineMissed(new OfferedDeadlineMissedEventImpl<Object>(
119  this.environment, found, StatusConverter.convert(
120  this.environment, status)));
121  }
122  }
123 
124  @Override
126  OfferedIncompatibleQosStatus status) {
127 
128  org.omg.dds.pub.DataWriter<Object> found = this.participant
129  .lookupDataWriter(writer);
130 
131  if (found != null) {
132  this.waitUntilInitialised();
133  this.listener
134  .onOfferedIncompatibleQos(new OfferedIncompatibleQosEventImpl<Object>(
135  this.environment, found, StatusConverter.convert(
136  this.environment, status)));
137  }
138  }
139 
140  @Override
141  public void on_liveliness_lost(DataWriter writer,
142  LivelinessLostStatus status) {
143  org.omg.dds.pub.DataWriter<Object> found = this.participant
144  .lookupDataWriter(writer);
145 
146  if (found != null) {
147  this.waitUntilInitialised();
148  this.listener.onLivelinessLost(new LivelinessLostEventImpl<Object>(
149  this.environment, found, StatusConverter.convert(
150  this.environment, status)));
151  }
152  }
153 
154  @Override
155  public void on_publication_matched(DataWriter writer,
156  PublicationMatchedStatus status) {
157  org.omg.dds.pub.DataWriter<Object> found = this.participant
158  .lookupDataWriter(writer);
159 
160  if (found != null) {
161  this.waitUntilInitialised();
162  this.listener
163  .onPublicationMatched(new PublicationMatchedEventImpl<Object>(
164  this.environment, found, StatusConverter.convert(
165  this.environment, status)));
166  }
167  }
168 
169  @Override
170  public void on_data_on_readers(Subscriber subs) {
171  org.omg.dds.sub.Subscriber found = this.participant
172  .lookupSubscriber(subs);
173 
174  if (found != null) {
175  this.waitUntilInitialised();
176  this.listener.onDataOnReaders(new DataOnReadersEventImpl(
177  this.environment, found, new DataOnReadersStatusImpl(
178  this.environment)));
179  }
180  }
181 
182  @Override
184  RequestedDeadlineMissedStatus status) {
185  org.omg.dds.sub.DataReader<Object> found = this.participant
186  .lookupDataReader(reader);
187 
188  if (found != null) {
189  this.waitUntilInitialised();
190  this.listener
191  .onRequestedDeadlineMissed(new RequestedDeadlineMissedEventImpl<Object>(
192  this.environment, found, StatusConverter.convert(
193  this.environment, status)));
194  }
195  }
196 
197  @Override
199  RequestedIncompatibleQosStatus status) {
200  org.omg.dds.sub.DataReader<Object> found = this.participant
201  .lookupDataReader(reader);
202 
203  if (found != null) {
204  this.waitUntilInitialised();
205  this.listener
206  .onRequestedIncompatibleQos(new RequestedIncompatibleQosEventImpl<Object>(
207  this.environment, found, StatusConverter.convert(
208  this.environment, status)));
209  }
210  }
211 
212  @Override
213  public void on_sample_rejected(DataReader reader,
214  SampleRejectedStatus status) {
215  org.omg.dds.sub.DataReader<Object> found = this.participant
216  .lookupDataReader(reader);
217 
218  if (found != null) {
219  this.waitUntilInitialised();
220  this.listener.onSampleRejected(new SampleRejectedEventImpl<Object>(
221  this.environment, found, StatusConverter.convert(
222  this.environment, status)));
223  }
224  }
225 
226  @Override
227  public void on_liveliness_changed(DataReader reader,
228  LivelinessChangedStatus status) {
229  org.omg.dds.sub.DataReader<Object> found = this.participant
230  .lookupDataReader(reader);
231 
232  if (found != null) {
233  this.waitUntilInitialised();
234  this.listener
235  .onLivelinessChanged(new LivelinessChangedEventImpl<Object>(
236  this.environment, found, StatusConverter.convert(
237  this.environment, status)));
238  }
239  }
240 
241  @Override
242  public void on_data_available(DataReader reader) {
243  org.omg.dds.sub.DataReader<Object> found = this.participant
244  .lookupDataReader(reader);
245 
246  if (found != null) {
247  this.waitUntilInitialised();
248  this.listener.onDataAvailable(new DataAvailableEventImpl<Object>(
249  this.environment, found, new DataAvailableStatusImpl(
250  this.environment)));
251  }
252  }
253 
254  @Override
256  SubscriptionMatchedStatus status) {
257  org.omg.dds.sub.DataReader<Object> found = this.participant
258  .lookupDataReader(reader);
259 
260  if (found != null) {
261  this.waitUntilInitialised();
262  this.listener
263  .onSubscriptionMatched(new SubscriptionMatchedEventImpl<Object>(
264  this.environment, found, StatusConverter.convert(
265  this.environment, status)));
266  }
267  }
268 
269  @Override
270  public void on_sample_lost(DataReader reader, SampleLostStatus status) {
271  org.omg.dds.sub.DataReader<Object> found = this.participant
272  .lookupDataReader(reader);
273 
274  if (found != null) {
275  this.waitUntilInitialised();
276  this.listener.onSampleLost(new SampleLostEventImpl<Object>(
277  this.environment, found, StatusConverter.convert(
278  this.environment, status)));
279  }
280  }
281 
282  @Override
283  public void on_all_data_disposed(Topic arg0) {
284  org.omg.dds.topic.Topic<Object> topic;
285  AllDataDisposedTopicStatusHolder holder = new AllDataDisposedTopicStatusHolder();
286  int rc = arg0.get_all_data_disposed_topic_status(holder);
287 
288  if (rc != DDS.RETCODE_OK.value) {
289  return;
290  }
291 
292  try {
293  topic = participant.getTopic(arg0);
294 
295  if (this.extListener != null) {
296  this.waitUntilInitialised();
297 
298  if (holder.value != null) {
299  this.extListener
300  .onAllDataDisposed(new AllDataDisposedEventImpl<Object>(
301  this.environment, topic, StatusConverter
302  .convert(this.environment,
303  holder.value)));
304  } else {
305  this.extListener
306  .onAllDataDisposed(new AllDataDisposedEventImpl<Object>(
307  this.environment, topic, null));
308  }
309  }
310  } catch (ClassCastException e) {
311  }
312  }
313 }
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.
A Subscriber is the object responsible for the actual reception of the data resulting from its subscr...
Definition: Subscriber.java:69
void on_liveliness_lost(DataWriter writer, LivelinessLostStatus status)
void on_sample_rejected(DataReader reader, SampleRejectedStatus status)
Extension of org.omg.dds.domain.DomainParticipantListener to provide callback to notify AllDataDispos...
static QosPolicyCount [] convert(OsplServiceEnvironment env, DDS.QosPolicyCount[] old)
DataWriter allows the application to set the value of the data to be published under a given org...
Definition: DataWriter.java:86
DomainParticipantListenerImpl(OsplServiceEnvironment environment, DomainParticipantImpl participant, DomainParticipantListener listener)
OsplServiceEnvironment environment
Definition: Listener.java:33
void on_sample_lost(DataReader reader, SampleLostStatus status)
void on_requested_deadline_missed(DataReader reader, RequestedDeadlineMissedStatus status)
void on_offered_incompatible_qos(DataWriter writer, OfferedIncompatibleQosStatus status)
void on_requested_incompatible_qos(DataReader reader, RequestedIncompatibleQosStatus status)
void on_liveliness_changed(DataReader reader, LivelinessChangedStatus status)
void on_subscription_matched(DataReader reader, SubscriptionMatchedStatus status)
DomainParticipantListenerImpl(OsplServiceEnvironment environment, DomainParticipantImpl participant, DomainParticipantListener listener, boolean waitUntilInitialised)
This is the interface that can be implemented by an application-provided class and then registered wi...
void on_publication_matched(DataWriter writer, PublicationMatchedStatus status)
void on_inconsistent_topic(Topic the_topic, InconsistentTopicStatus status)
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)
void on_offered_deadline_missed(DataWriter writer, OfferedDeadlineMissedStatus status)