OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
SubscriberQosImpl.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.sub;
22 
28 import org.omg.dds.sub.SubscriberQos;
38 
39 public class SubscriberQosImpl extends EntityQosImpl<ForSubscriber> implements
40  org.opensplice.dds.sub.SubscriberQos {
41  private static final long serialVersionUID = 5350093533137522289L;
42 
45  super(environment, policies);
46  }
47 
49  super(environment);
50  }
51 
52  private SubscriberQosImpl(SubscriberQosImpl source, ForSubscriber... policy) {
53  super(source.environment, source.policies.values());
54  setupPolicies(policy);
55  }
56 
57  @Override
58  protected void setupMissingPolicies() {
59  synchronized(this.policies) {
60  if (!this.policies.containsKey(Presentation.class)) {
61  this.policies.put(Presentation.class, new PresentationImpl(
62  this.environment));
63  }
64  if (!this.policies.containsKey(Partition.class)) {
65  this.policies.put(Partition.class, new PartitionImpl(
66  this.environment));
67  }
68  if (!this.policies.containsKey(GroupData.class)) {
69  this.policies.put(GroupData.class, new GroupDataImpl(
70  this.environment));
71  }
72  if (!this.policies.containsKey(EntityFactory.class)) {
73  this.policies.put(EntityFactory.class, new EntityFactoryImpl(
74  this.environment));
75  }
76  }
77  }
78 
79  @Override
81  synchronized(this.policies) {
82  return (Presentation) this.policies.get(Presentation.class);
83  }
84  }
85 
86  @Override
88  synchronized(this.policies) {
89  return (Partition) this.policies.get(Partition.class);
90  }
91  }
92 
93  @Override
95  synchronized(this.policies) {
96  return (GroupData) this.policies.get(GroupData.class);
97  }
98  }
99 
100  @Override
102  synchronized(this.policies) {
103  return (EntityFactory) this.policies.get(EntityFactory.class);
104  }
105  }
106 
107  @Override
108  public Share getShare() {
109  synchronized(this.policies) {
110  return (Share) this.policies.get(Share.class);
111  }
112  }
113 
114  @Override
116  return this.withPolicies(policy);
117  }
118 
119  @Override
121  synchronized (this.policies) {
122  return new SubscriberQosImpl(this, policy);
123  }
124  }
125 
127  DDS.SubscriberQos oldQos) {
128  if (oldQos == null) {
129  throw new IllegalArgumentExceptionImpl(env,
130  "oldQos parameter is null.");
131  }
132 
133  SubscriberQosImpl qos = new SubscriberQosImpl(env);
134 
135  qos.put(EntityFactory.class,
136  PolicyConverter.convert(env, oldQos.entity_factory));
137  qos.put(GroupData.class,
138  PolicyConverter.convert(env, oldQos.group_data));
139  qos.put(Partition.class, PolicyConverter.convert(env, oldQos.partition));
140  qos.put(Presentation.class,
141  PolicyConverter.convert(env, oldQos.presentation));
142 
143  Share share = PolicyConverter.convert(env, oldQos.share);
144 
145  if (share != null) {
146  qos.put(Share.class, share);
147  }
148 
149  return qos;
150  }
151 
152  public DDS.SubscriberQos convert() {
153  DDS.SubscriberQos old = new DDS.SubscriberQos();
154 
155  synchronized (this.policies) {
156  old.entity_factory = PolicyConverter
157 .convert(this.environment,
158  ((EntityFactory) this.policies
159  .get(EntityFactory.class)));
160  old.group_data = PolicyConverter.convert(this.environment,
161  ((GroupData) this.policies
162  .get(GroupData.class)));
163 
164  old.partition = PolicyConverter.convert(this.environment,
165  ((Partition) this.policies
166  .get(Partition.class)));
167  old.presentation = PolicyConverter
168 .convert(this.environment,
169  ((Presentation) this.policies
170  .get(Presentation.class)));
171  old.share = PolicyConverter.convert(this.environment,
172  ((Share) this.policies
173  .get(Share.class)));
174  }
175  return old;
176  }
177 
178 }
SubscriberQos withPolicy(ForSubscriber policy)
static SubscriberQosImpl convert(OsplServiceEnvironment env, DDS.SubscriberQos oldQos)
SubscriberQos withPolicies(ForSubscriber... policy)
SubscriberQosImpl(OsplServiceEnvironment environment, ForSubscriber... policies)
This policy allows the introduction of a logical partition concept inside the "physical" partition in...
Definition: Partition.java:86
void setupPolicies(Collection< T > policies)
SubscriberQosImpl(OsplServiceEnvironment environment)
This QosPolicy allows sharing of entities by multiple processes or threads.
Definition: Share.java:46
T put(Class<? extends T > arg0, T arg1)
Specifies how the samples representing changes to data instances are presented to the subscribing app...
User data not known by the middleware, but distributed by means of built-in topics.
Definition: GroupData.java:44
static DDS.UserDataQosPolicy convert(OsplServiceEnvironment env, UserData p)
This class is the abstract root for all the QoS policies.
Definition: QosPolicy.java:118
final OsplServiceEnvironment environment
HashMap< Class<? extends T >, T > policies
Controls the behavior of the org.omg.dds.core.Entity when acting as a factory for other entities...
A QosPolicy interface that implements this marker interface applies to org.omg.dds.sub.Subscriber Entities.
Definition: QosPolicy.java:151