21 package org.opensplice.dds.core;
23 import java.util.EventListener;
25 import java.util.concurrent.atomic.AtomicInteger;
37 private final OLDPARENT oldParent;
40 private AtomicInteger refCount;
41 private static java.util.HashMap<String, Integer> references =
new java.util.HashMap<String, Integer>();
43 private static boolean addReference(String name) {
44 synchronized (references) {
45 Integer refs = references.get(name);
48 references.put(name, 1);
50 references.put(name, refs.intValue() + 1);
56 private static boolean removeReference(String name) {
57 synchronized (references) {
58 Integer refs = references.get(name);
60 assert (refs != null);
61 references.put(name, refs.intValue() - 1);
67 boolean noMoreRefs =
true;
69 synchronized (references) {
70 for (String name : references.keySet()) {
71 int count = references.get(name);
75 System.out.println(name +
"=" + count);
78 System.out.println(
"----------------");
80 for (String name : references.keySet()) {
81 int count = references.get(name);
85 System.out.println(name +
"=" + count);
87 System.out.println(
"----------------");
95 this.oldParent = oldParent;
97 this.refCount =
new AtomicInteger(1);
99 assert (addReference(this.getClass().getSimpleName()));
103 final OLD old = this.old;
107 "Entity already closed.");
117 return this.oldParent;
127 int newValue = this.refCount.incrementAndGet();
130 int refCount = this.refCount.decrementAndGet();
132 "Entity already closed. refcount:" + refCount);
134 assert (newValue > newValue - 1);
135 assert (newValue > 1);
140 int newValue = this.refCount.decrementAndGet();
145 assert (removeReference(this.getClass().getSimpleName()));
146 }
else if (newValue < 0) {
148 "Entity already closed.");
154 int rc = this.old.enable();
156 "Entity.enable() failed.");
162 this.old.get_status_changes());
168 old.get_instance_handle());
171 protected abstract void destroy();
175 if (this.listener != null) {
176 return this.listener.getRealListener();
183 int rc = this.old.set_property(
new DDS.Property(key, value));
185 "Properties.setProperty() failed.");
190 DDS.PropertyHolder holder =
new DDS.PropertyHolder();
191 holder.value =
new DDS.Property(key, null);
192 int rc = this.old.get_property(holder);
194 "Properties.getProperty() failed.");
195 return holder.value.value;
void setProperty(String key, String value)
This method sets the property specified by the key to the value given by the value.
static boolean printReferences()
final Set< Class<? extends Status > > getStatusChanges()
static Set< Class<? extends Status > > convertMask(OsplServiceEnvironment environment, int state)
An opaque handle that can be used to refer to a local or remote entity.
final InstanceHandle getInstanceHandle()
static void checkReturnCode(int retCode, OsplServiceEnvironment environment, String message)
ServiceEnvironment getEnvironment()
This class is the abstract base class for all the DCPS objects that support QoS policies, a listener and a status condition.
String getProperty(String key)
Provides access to the current value for a given property.
EntityImpl(OsplServiceEnvironment environment, OLDPARENT oldParent)
final transient OsplServiceEnvironment environment
DDS implementations are rooted in this class, a concrete subclass of which can be instantiated based ...
The Data-Distribution Service (DDS) relies on the use of QoS.
final LISTENER getListener()
Status is the abstract root class for all communication status objects.
This type is implemented by all OpenSplice org.omg.dds.core.Entity classes to allow setting and getti...