Skip to content

Commit da92337

Browse files
authored
0.70.0
* Responder list refactored for true async. * Added AsyncActionResults and changed how action results are handled. * Added DSBoolRange * DSIEnum now extends DSIMetadata * Fix NPE in DS1Requester
1 parent 63ccdb9 commit da92337

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1082
-861
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
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.69.0'
8+
version '0.70.0'
99

1010
targetCompatibility = JavaVersion.VERSION_1_8
1111
sourceCompatibility = JavaVersion.VERSION_1_8

dslink-v2-api/src/main/java/org/iot/dsa/dslink/Action.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
package org.iot.dsa.dslink;
22

33
import org.iot.dsa.node.DSMap;
4-
import org.iot.dsa.security.DSPermission;
54

65
/**
76
* Defines an invokable node in the DSA model.
87
*
98
* @author Aaron Hansen
109
*/
11-
public interface Action {
10+
public interface Action extends Node {
1211

1312
/**
1413
* Only needed for a VALUES type actions, and optional even then.
@@ -41,17 +40,17 @@ public default void getParameterMetadata(int idx, DSMap bucket) {
4140
}
4241

4342
/**
44-
* Minimum permission level required to invoke, returns WRITE by default.
43+
* What the action returns, returns VOID by default.
4544
*/
46-
public default DSPermission getPermission() {
47-
return DSPermission.WRITE;
45+
public default ResultsType getResultsType() {
46+
return ResultsType.VOID;
4847
}
4948

5049
/**
51-
* What the action returns, returns VOID by default.
50+
* Whether or not the action the action requires write permission. Returns false by default.
5251
*/
53-
public default ResultsType getResultsType() {
54-
return ResultsType.VOID;
52+
public default boolean isReadOnly() {
53+
return false;
5554
}
5655

5756
/**

dslink-v2-api/src/main/java/org/iot/dsa/dslink/ActionRequest.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,36 @@
55
import org.iot.dsa.security.DSPermission;
66

77
/**
8-
* Encapsulates the details of an action invocation and provides the mechanism for updating an open
9-
* stream.
8+
* Encapsulates the details of an action invocation and provides the mechanism for async
9+
* updates.
1010
*
1111
* @author Aaron Hansen
1212
*/
1313
public interface ActionRequest {
1414

1515
/**
16-
* For use with streams and open tables, will have no effect if the stream is already closed.
16+
* For use with streams and AsyncActionResults, will have no effect if already closed.
1717
*/
1818
public void close();
1919

2020
/**
21-
* Close and send an error. For use with streams and open tables, will have no effect if the
22-
* stream is already closed.
21+
* Close and send an error. For use with streams and AsyncActionResults, will have no effect
22+
* if already closed.
2323
*/
2424
public void close(Exception reason);
2525

2626
/**
27-
* This needs to be called when there are more results after ActionsResults.next()
28-
* returns false.
27+
* A convenience for getting a single parameter out of the parameters map.
2928
*/
30-
public void enqueueResults();
29+
public default DSElement getParameter(String key) {
30+
return getParameters().get(key);
31+
}
3132

3233
/**
3334
* The parameters supplied by the invoker, or null.
3435
*/
3536
public DSMap getParameters();
3637

37-
/**
38-
* A convenience for getting a single parameter out of the parameters map.
39-
*/
40-
public default DSElement getParameter(String key) {
41-
return getParameters().get(key);
42-
}
43-
4438
/**
4539
* The permission level of the invoker.
4640
*/
@@ -51,4 +45,13 @@ public default DSElement getParameter(String key) {
5145
*/
5246
public boolean isOpen();
5347

48+
/**
49+
* This is for streams and AsyncActionResults. Call this after returning false
50+
* ActionResults.next() and there are more results. AsyncActionResults implementors also
51+
* need to call this to send the initial columns.
52+
*
53+
* @see AsyncActionResults
54+
*/
55+
public void sendResults();
56+
5457
}

dslink-v2-api/src/main/java/org/iot/dsa/dslink/ActionResults.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@
66

77
/**
88
* The results of an action request. This is implemented as a cursor for all result types.
9-
* The implementation can return false from next() and resume later. After returning
10-
* false from next(), the implementation must call ActionRequest.close() or
11-
* ActionRequest.enqueueResults().
12-
* <p>
13-
* If the result type is VALUES, next() will only be called once. The implementation does not
14-
* need to call any other methods on ActionRequest.
9+
* For async results, implement AsyncActionResults instead.
1510
*
1611
* @author Aaron Hansen
12+
* @see AsyncActionResults
1713
*/
1814
public interface ActionResults {
1915

@@ -23,14 +19,13 @@ public interface ActionResults {
2319
public int getColumnCount();
2420

2521
/**
26-
* Only needed if the column count is greater than 0. Throws an IllegalStateException by
27-
* default.
22+
* Only needed if the column count is greater than 0.
2823
*/
2924
public void getColumnMetadata(int idx, DSMap bucket);
3025

3126
/**
32-
* The implementation should add the values of the current result set to the given bucket. The
33-
* bucket may be reused across calls, the implementation should not cache references to it.
27+
* The implementation should add the values of the current row to the given bucket. The
28+
* bucket can be reused across calls, the implementation should not cache references to it.
3429
*/
3530
public void getResults(DSList bucket);
3631

@@ -41,9 +36,11 @@ public interface ActionResults {
4136

4237
/**
4338
* Initially, this cursor must be positioned before the first set of results. Return true to
44-
* advance the next set of results. The implementation is responsible for calling
45-
* DIActionRequest.enqueueResults() or DIActionRequest.close(). This will only
46-
* be called once for a result type of VALUES.
39+
* advance the next set of results. If the implementation is a stream or AsyncActionResults,
40+
* this can return false and later have more rows, the implementor is responsible for calling
41+
* ActionRequest.sendResults() or ActionRequest.close(). If not a stream or async, the request
42+
* will be closed once this returns false. This will only be called once for a results
43+
* type of VALUES.
4744
*/
4845
public boolean next();
4946

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.iot.dsa.dslink;
2+
3+
/**
4+
* This is a marker interface that indicates ActionResults are async.
5+
* <p>
6+
* Implementors are required to call ActionRequest.sendResults() for sending
7+
* the initial column definitions, as well as after returning false from next().
8+
* <p>
9+
* Implementors are also required to call ActionRequest.close().
10+
*
11+
* @author Aaron Hansen
12+
*/
13+
public interface AsyncActionResults extends ActionResults {
14+
15+
}

dslink-v2-api/src/main/java/org/iot/dsa/dslink/DSIResponder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import org.iot.dsa.dslink.responder.InboundListRequest;
55
import org.iot.dsa.dslink.responder.InboundSetRequest;
66
import org.iot.dsa.dslink.responder.InboundSubscribeRequest;
7-
import org.iot.dsa.dslink.responder.OutboundListResponse;
7+
import org.iot.dsa.dslink.responder.ListCloseHandler;
88
import org.iot.dsa.dslink.responder.SubscriptionCloseHandler;
99

1010
/**
@@ -42,7 +42,7 @@ public interface DSIResponder {
4242
* @param request The details of the request and the mechanism for providing updates.
4343
* @return The initial response and close mechanism.
4444
*/
45-
public OutboundListResponse onList(InboundListRequest request);
45+
public ListCloseHandler onList(InboundListRequest request);
4646

4747
/**
4848
* The implementation should do no processing of it on the calling thread. Simply throw a
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.iot.dsa.dslink;
2+
3+
import org.iot.dsa.node.DSMap;
4+
5+
/**
6+
* Used in DSIResponder list responses.
7+
*
8+
* @author Aaron Hansen
9+
*/
10+
public interface Node {
11+
12+
/**
13+
* Add all metadata for the object. Does nothing by default.
14+
*/
15+
public default void getMetadata(DSMap bucket) {
16+
}
17+
18+
/**
19+
* Whether or not the object requires admin level permission. Returns false
20+
* by default.
21+
*/
22+
public default boolean isAdmin() {
23+
return false;
24+
}
25+
26+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.iot.dsa.dslink;
2+
3+
import org.iot.dsa.node.DSIValue;
4+
5+
/**
6+
* Used in DSIResponder list responses.
7+
*
8+
* @author Aaron Hansen
9+
*/
10+
public interface Value extends Node {
11+
12+
/**
13+
* Whether or not the value can be written.
14+
*/
15+
public boolean isReadOnly();
16+
17+
/**
18+
* Does not have to be the current value, used to determine the type
19+
* of the value.
20+
* @return
21+
*/
22+
public DSIValue toValue();
23+
24+
}

dslink-v2-api/src/main/java/org/iot/dsa/dslink/responder/ApiObject.java

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)