Skip to content

Commit aeee100

Browse files
authored
0.49.0
- DSInfo - Hidden -> Private - Default on copy - DSStatusNode - DSEnabledNode - DSTimeRange - Another topic refactor. - DSNode subscription refactor. - DynamicActions -> VirtualActions - ActionTable metadata
2 parents 80e3807 + 3539354 commit aeee100

40 files changed

+1343
-836
lines changed

build.gradle

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ subprojects {
55
apply plugin: 'maven'
66

77
group 'org.iot-dsa'
8-
version '0.48.0'
8+
version '0.49.0'
99

1010
sourceCompatibility = 1.8
1111
targetCompatibility = 1.8
@@ -38,11 +38,9 @@ subprojects {
3838

3939
}
4040

41-
if (JavaVersion.current().isJava8Compatible()) {
42-
allprojects {
43-
tasks.withType(Javadoc) {
44-
options.addStringOption('Xdoclint:none', '-quiet')
45-
}
41+
allprojects {
42+
tasks.withType(Javadoc) {
43+
options.addStringOption('Xdoclint:none', '-quiet')
4644
}
4745
}
4846

dslink-v2-poc/src/main/java/org/iot/dsa/dslink/poc/MainNode.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class MainNode extends DSMainNode implements Runnable {
5353
///////////////////////////////////////////////////////////////////////////
5454

5555
@Override
56-
public DSInfo getDynamicAction(DSInfo target, String name) {
56+
public DSInfo getVirtualAction(DSInfo target, String name) {
5757
if (target == incrementingInt) {
5858
if (name.equals("Reset")) {
5959
return actionInfo(name, new DSAction.Parameterless() {
@@ -75,27 +75,27 @@ public ActionResult invoke(DSInfo target, ActionInvocation invocation) {
7575
});
7676
}
7777
}
78-
return super.getDynamicAction(target, name);
78+
return super.getVirtualAction(target, name);
7979
}
8080

8181
@Override
82-
public void getDynamicActions(DSInfo target, Collection<String> bucket) {
82+
public void getVirtualActions(DSInfo target, Collection<String> bucket) {
8383
if (target == incrementingInt) {
8484
bucket.add("Reset");
8585
} else if (target.get() == this) {
8686
bucket.add("Foobar");
8787
}
88-
super.getDynamicActions(target, bucket);
88+
super.getVirtualActions(target, bucket);
8989
}
9090

9191
@Override
92-
public ActionResult invoke(DSInfo action, DSInfo target, ActionInvocation invocation) {
92+
public ActionResult invoke(DSInfo action, DSInfo target, ActionInvocation request) {
9393
if (action == this.reset) {
9494
put(incrementingInt, DSElement.make(0));
95-
DSMap map = invocation.getParameters();
95+
DSMap map = request.getParameters();
9696
DSElement arg = null;
9797
if (map != null) {
98-
arg = invocation.getParameters().get("Arg");
98+
arg = request.getParameters().get("Arg");
9999
put("Message", arg);
100100
}
101101
clear();
@@ -108,7 +108,7 @@ public ActionResult invoke(DSInfo action, DSInfo target, ActionInvocation invoca
108108
.addResult(DSBool.TRUE)
109109
.addResult(DSLong.valueOf(1234));
110110
}
111-
return super.invoke(action, target, invocation);
111+
return super.invoke(action, target, request);
112112
}
113113

114114
/**

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/protocol/DSSession.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public boolean isRequesterAllowed() {
132132
}
133133

134134
@Override
135-
public void onChange(DSConnection connection) {
135+
public void onConnectionChange(DSConnection connection) {
136136
switch (connection.getConnectionState()) {
137137
case CONNECTED:
138138
onConnected();

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/protocol/message/DSTarget.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ private void advance(int nameIndex) {
156156
node = (DSNode) target;
157157
targetInfo = node.getInfo(names[nameIndex]);
158158
} else {
159-
targetInfo = node.getDynamicAction(targetInfo, names[nameIndex]);
159+
targetInfo = node.getVirtualAction(targetInfo, names[nameIndex]);
160160
}
161161
if (targetInfo == null) {
162162
//TODO - need to undo this

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/protocol/responder/DSInboundInvoke.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,15 @@ private boolean isClosePending() {
356356
private void writeColumns(MessageWriter writer) {
357357
DSIWriter out = writer.getWriter();
358358
if (result instanceof ActionTable) {
359+
DSMap tableMeta = ((ActionTable) result).getMetadata();
360+
if (tableMeta == null) {
361+
tableMeta = new DSMap();
362+
}
359363
ActionSpec action = result.getAction();
360364
out.key("meta")
361365
.beginMap()
362366
.key("mode").value(action.getResultType().isStream() ? "stream" : "append")
363-
.key("meta").beginMap().endMap()
367+
.key("meta").value(tableMeta)
364368
.endMap();
365369
out.key("columns").beginList();
366370
ActionTable tbl = (ActionTable) result;

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/protocol/responder/DSInboundList.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.iot.dsa.node.action.DSAction;
2727
import org.iot.dsa.node.event.DSIEvent;
2828
import org.iot.dsa.node.event.DSISubscriber;
29-
import org.iot.dsa.node.event.DSITopic;
29+
import org.iot.dsa.node.event.DSISubscription;
3030
import org.iot.dsa.node.event.DSNodeTopic;
3131
import org.iot.dsa.security.DSPermission;
3232

@@ -64,6 +64,7 @@ public class DSInboundList extends DSInboundRequest
6464
private OutboundListResponse response;
6565
private int state = STATE_INIT;
6666
private boolean stream = true;
67+
private DSISubscription subscription;
6768
private DSTarget target;
6869
private Update updateHead;
6970
private Update updateTail;
@@ -127,8 +128,9 @@ public boolean isOpen() {
127128

128129
@Override
129130
public void onClose() {
130-
if (node != null) {
131-
node.unsubscribe(null, null, this);
131+
if (subscription != null) {
132+
subscription.close();
133+
subscription = null;
132134
}
133135
}
134136

@@ -145,6 +147,12 @@ public void onClose(Integer requestId) {
145147
doClose();
146148
}
147149

150+
@Override
151+
public void onClosed(DSISubscription subscription) {
152+
subscription = null;
153+
close();
154+
}
155+
148156
@Override
149157
public void onEvent(DSNode node, DSInfo child, DSIEvent event) {
150158
switch ((DSNodeTopic) event.getTopic()) {
@@ -165,11 +173,6 @@ public void onEvent(DSNode node, DSInfo child, DSIEvent event) {
165173
}
166174
}
167175

168-
@Override
169-
public void onUnsubscribed(DSITopic topic, DSNode node, DSInfo child) {
170-
close();
171-
}
172-
173176
@Override
174177
public void run() {
175178
try {
@@ -185,7 +188,7 @@ public void run() {
185188
}
186189
if (info.isNode()) {
187190
node = info.getNode();
188-
node.subscribe(null, null, null, this);
191+
this.subscription = node.subscribe(null, null, null, this);
189192
}
190193
response = this;
191194
}
@@ -366,10 +369,10 @@ protected String encodeName(String name, StringBuilder buf) {
366369
*/
367370
protected void encodeUpdate(Update update, MessageWriter writer, StringBuilder buf) {
368371
if (update instanceof AddUpdate) {
369-
encodeChild(((AddUpdate)update).child, writer);
372+
encodeChild(((AddUpdate) update).child, writer);
370373
} else {
371374
writer.getWriter().beginMap()
372-
.key("name").value(encodeName(((RemoveUpdate)update).name, buf))
375+
.key("name").value(encodeName(((RemoveUpdate) update).name, buf))
373376
.key("change").value("remove")
374377
.endMap();
375378
}

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/protocol/responder/DSInboundSubscription.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.iot.dsa.node.DSStatus;
1616
import org.iot.dsa.node.event.DSIEvent;
1717
import org.iot.dsa.node.event.DSISubscriber;
18+
import org.iot.dsa.node.event.DSISubscription;
1819
import org.iot.dsa.node.event.DSITopic;
1920
import org.iot.dsa.time.DSTime;
2021

@@ -40,6 +41,7 @@ public class DSInboundSubscription extends DSInboundRequest
4041
private boolean open = true;
4142
private int qos = 0;
4243
private Integer sid;
44+
private DSISubscription subscription;
4345
private Update updateHead;
4446
private Update updateTail;
4547

@@ -117,7 +119,8 @@ public void onEvent(DSNode node, DSInfo child, DSIEvent event) {
117119
}
118120

119121
@Override
120-
public void onUnsubscribed(DSITopic topic, DSNode node, DSInfo info) {
122+
public void onClosed(DSISubscription subscription) {
123+
this.subscription = null;
121124
close();
122125
}
123126

@@ -218,13 +221,13 @@ protected void init() {
218221
DSIObject obj = path.getTarget();
219222
if (obj instanceof DSNode) {
220223
node = (DSNode) obj;
221-
node.subscribe(DSNode.VALUE_CHANGED, null, null, this);
224+
this.subscription = node.subscribe(DSNode.VALUE_CHANGED, null, null, this);
222225
onEvent(node, null, DSNode.VALUE_CHANGED);
223226
} else {
224227
DSInfo info = path.getTargetInfo();
225228
node = path.getNode();
226229
child = info;
227-
node.subscribe(DSNode.VALUE_CHANGED, info, null, this);
230+
this.subscription = node.subscribe(DSNode.VALUE_CHANGED, info, null, this);
228231
onEvent(node, info, DSNode.VALUE_CHANGED);
229232
}
230233
}
@@ -308,15 +311,16 @@ void onClose() {
308311
open = false;
309312
}
310313
try {
311-
if (closeHandler != null) {
312-
closeHandler.onClose(getSubscriptionId());
314+
if (subscription != null) {
315+
subscription.close();
316+
subscription = null;
313317
}
314318
} catch (Exception x) {
315319
manager.debug(manager.getPath(), x);
316320
}
317321
try {
318-
if (node != null) {
319-
node.unsubscribe(DSNode.VALUE_CHANGED, child, this);
322+
if (closeHandler != null) {
323+
closeHandler.onClose(getSubscriptionId());
320324
}
321325
} catch (Exception x) {
322326
manager.debug(manager.getPath(), x);

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/protocol/v1/DS1LinkConnection.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ public void updateSalt(String salt) {
9393

9494
@Override
9595
protected void checkConfig() {
96-
configOk();
9796
}
9897

9998
protected DS1ConnectionInit initializeConnection() {

0 commit comments

Comments
 (0)