OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
WriterDataLifecycleImpl.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.core.policy;
22 
23 import java.util.concurrent.TimeUnit;
24 
25 import org.omg.dds.core.Duration;
29 
30 public class WriterDataLifecycleImpl extends QosPolicyImpl implements
32  private static final long serialVersionUID = -3230343206569872870L;
33  private final boolean autoDisposeUnregisteredInstances;
34  private final Duration autoPurgeSuspendedSamplesDelay;
35  private final Duration autoUnregisterInstanceDelay;
36 
38  super(environment);
39  this.autoDisposeUnregisteredInstances = true;
40  this.autoPurgeSuspendedSamplesDelay = this.environment.getSPI()
42  this.autoUnregisterInstanceDelay = this.environment.getSPI()
44  }
45 
47  boolean autoDisposeUnregisteredInstances,
48  Duration autoPurgeSuspendedSamplesDelay,
49  Duration autoUnregisterInstanceDelay) {
50  super(environment);
51  this.autoDisposeUnregisteredInstances = autoDisposeUnregisteredInstances;
52 
53  if (autoPurgeSuspendedSamplesDelay == null) {
54  throw new IllegalArgumentExceptionImpl(environment,
55  "Supplied autoPurgeSuspendedSamplesDelay duration invalid.");
56  }
57  if (autoUnregisterInstanceDelay == null) {
58  throw new IllegalArgumentExceptionImpl(environment,
59  "Supplied autoUnregisterInstanceDelay duration invalid.");
60  }
61  this.autoPurgeSuspendedSamplesDelay = autoPurgeSuspendedSamplesDelay;
62  this.autoUnregisterInstanceDelay = autoUnregisterInstanceDelay;
63  }
64 
65  @Override
67  return this.autoDisposeUnregisteredInstances;
68  }
69 
70  @Override
72  boolean autoDisposeUnregisteredInstances) {
73  return new WriterDataLifecycleImpl(this.environment,
74  autoDisposeUnregisteredInstances,
75  this.autoPurgeSuspendedSamplesDelay,
76  this.autoUnregisterInstanceDelay);
77  }
78 
79  @Override
80  public Class<? extends QosPolicy> getPolicyClass() {
81  return WriterDataLifecycle.class;
82  }
83 
84  @Override
86  return this.autoPurgeSuspendedSamplesDelay;
87  }
88 
89  @Override
91  return this.autoUnregisterInstanceDelay;
92  }
93 
94  @Override
96  Duration duration) {
97  return new WriterDataLifecycleImpl(this.environment,
98  this.autoDisposeUnregisteredInstances, duration,
99  this.autoUnregisterInstanceDelay);
100  }
101 
102  @Override
104  long duration, TimeUnit unit) {
106  .newDuration(duration, unit));
107  }
108 
109  @Override
111  return new WriterDataLifecycleImpl(this.environment,
112  this.autoDisposeUnregisteredInstances,
113  this.autoPurgeSuspendedSamplesDelay, duration);
114  }
115 
116  @Override
118  TimeUnit unit) {
120  .newDuration(duration, unit));
121  }
122 
123  @Override
124  public boolean equals(Object other) {
125  if (!(other instanceof WriterDataLifecycleImpl)) {
126  return false;
127  }
128  WriterDataLifecycleImpl w = (WriterDataLifecycleImpl) other;
129 
130  if (w.autoDisposeUnregisteredInstances != this.autoDisposeUnregisteredInstances) {
131  return false;
132  }
133  if (!w.autoPurgeSuspendedSamplesDelay
134  .equals(this.autoPurgeSuspendedSamplesDelay)) {
135  return false;
136  }
137  return w.autoUnregisterInstanceDelay
138  .equals(this.autoUnregisterInstanceDelay);
139  }
140 
141  @Override
142  public int hashCode() {
143  final int prime = 31;
144  int result = 17;
145 
146  result = prime * result
147  + (this.autoDisposeUnregisteredInstances ? 1 : 0);
148  result = prime * result
149  + this.autoPurgeSuspendedSamplesDelay.hashCode();
150 
151  return prime * result + this.autoUnregisterInstanceDelay.hashCode();
152  }
153 
154 }
WriterDataLifecycle withAutoPurgeSuspendedSamplesDelay(long duration, TimeUnit unit)
Specifies the behavior of the org.omg.dds.pub.DataWriter with regards to the life cycle of the data i...
WriterDataLifecycle withAutoUnregisterInstanceDelay(long duration, TimeUnit unit)
WriterDataLifecycleImpl(OsplServiceEnvironment environment, boolean autoDisposeUnregisteredInstances, Duration autoPurgeSuspendedSamplesDelay, Duration autoUnregisterInstanceDelay)
WriterDataLifecycle withAutDisposeUnregisteredInstances(boolean autoDisposeUnregisteredInstances)
Copy this policy and override the value of the property.
WriterDataLifecycle withAutoPurgeSuspendedSamplesDelay(Duration duration)
This class is the abstract root for all the QoS policies.
Definition: QosPolicy.java:118
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
WriterDataLifecycle withAutoUnregisterInstanceDelay(Duration duration)