Skip to content

Commit 15cd909

Browse files
committed
1. Added blocking and non-blocking annotations to sync and async methods
2. Removed liveobject batching operation specific interfaces
1 parent d87b365 commit 15cd909

10 files changed

Lines changed: 28 additions & 141 deletions

File tree

lib/src/main/java/io/ably/lib/objects/LiveCounter.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package io.ably.lib.objects;
22

33
import io.ably.lib.types.Callback;
4+
import org.jetbrains.annotations.Blocking;
5+
import org.jetbrains.annotations.NonBlocking;
46
import org.jetbrains.annotations.NotNull;
57
import org.jetbrains.annotations.Contract;
68

@@ -18,6 +20,7 @@ public interface LiveCounter {
1820
* the published COUNTER_INC operation is echoed back to the client and applied to the object following the regular
1921
* operation application procedure.
2022
*/
23+
@Blocking
2124
void increment();
2225

2326
/**
@@ -29,12 +32,14 @@ public interface LiveCounter {
2932
*
3033
* @param callback the callback to be invoked upon completion of the operation.
3134
*/
35+
@NonBlocking
3236
void incrementAsync(@NotNull Callback<Void> callback);
3337

3438
/**
3539
* Decrements the value of the counter by 1.
3640
* An alias for calling {@link LiveCounter#increment()} with a negative amount.
3741
*/
42+
@Blocking
3843
void decrement();
3944

4045
/**
@@ -43,6 +48,7 @@ public interface LiveCounter {
4348
*
4449
* @param callback the callback to be invoked upon completion of the operation.
4550
*/
51+
@NonBlocking
4652
void decrementAsync(@NotNull Callback<Void> callback);
4753

4854
/**

lib/src/main/java/io/ably/lib/objects/LiveMap.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package io.ably.lib.objects;
22

33
import io.ably.lib.types.Callback;
4+
import org.jetbrains.annotations.Blocking;
5+
import org.jetbrains.annotations.NonBlocking;
46
import org.jetbrains.annotations.Contract;
57
import org.jetbrains.annotations.NotNull;
68
import org.jetbrains.annotations.Nullable;
@@ -66,6 +68,7 @@ public interface LiveMap {
6668
* @param keyName the key to be set.
6769
* @param value the value to be associated with the key.
6870
*/
71+
@Blocking
6972
void set(@NotNull String keyName, @NotNull Object value);
7073

7174
/**
@@ -77,6 +80,7 @@ public interface LiveMap {
7780
*
7881
* @param keyName the key to be removed.
7982
*/
83+
@Blocking
8084
void remove(@NotNull String keyName);
8185

8286
/**
@@ -99,6 +103,7 @@ public interface LiveMap {
99103
* @param value the value to be associated with the key.
100104
* @param callback the callback to handle the result or any errors.
101105
*/
106+
@NonBlocking
102107
void setAsync(@NotNull String keyName, @NotNull Object value, @NotNull Callback<Void> callback);
103108

104109
/**
@@ -111,5 +116,6 @@ public interface LiveMap {
111116
* @param keyName the key to be removed.
112117
* @param callback the callback to handle the result or any errors.
113118
*/
119+
@NonBlocking
114120
void removeAsync(@NotNull String keyName, @NotNull Callback<Void> callback);
115121
}

lib/src/main/java/io/ably/lib/objects/LiveObjects.java

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package io.ably.lib.objects;
22

3-
import io.ably.lib.objects.batch.BatchContextBuilder;
43
import io.ably.lib.types.Callback;
4+
import org.jetbrains.annotations.Blocking;
5+
import org.jetbrains.annotations.NonBlocking;
56
import org.jetbrains.annotations.NotNull;
67

78

@@ -25,18 +26,10 @@ public interface LiveObjects {
2526
*
2627
* @return the root LiveMap instance.
2728
*/
29+
@Blocking
2830
@NotNull
2931
LiveMap getRoot();
3032

31-
/**
32-
* Initiates a batch operation and provides a BatchContext through a callback.
33-
* Provides access to the synchronous write API for Objects that can be used to batch multiple operations
34-
* together in a single channel message.
35-
*
36-
* @param batchContextCallback the builder to configure the batch operation.
37-
*/
38-
void batch(@NotNull BatchContextBuilder batchContextCallback);
39-
4033
/**
4134
* Creates a new LiveMap based on an existing LiveMap.
4235
* Send a MAP_CREATE operation to the realtime system to create a new map object in the pool.
@@ -47,6 +40,7 @@ public interface LiveObjects {
4740
* @param liveMap the existing LiveMap to base the new LiveMap on.
4841
* @return the newly created LiveMap instance.
4942
*/
43+
@Blocking
5044
@NotNull
5145
LiveMap createMap(@NotNull LiveMap liveMap);
5246

@@ -60,6 +54,7 @@ public interface LiveObjects {
6054
* @param liveCounter the LiveCounter to base the new LiveMap on.
6155
* @return the newly created LiveMap instance.
6256
*/
57+
@Blocking
6358
@NotNull
6459
LiveMap createMap(@NotNull LiveCounter liveCounter);
6560

@@ -73,6 +68,7 @@ public interface LiveObjects {
7368
* @param map the Java Map to base the new LiveMap on.
7469
* @return the newly created LiveMap instance.
7570
*/
71+
@Blocking
7672
@NotNull
7773
LiveMap createMap(@NotNull Map<String, Object> map);
7874

@@ -86,6 +82,7 @@ public interface LiveObjects {
8682
* @param initialValue the initial value of the LiveCounter.
8783
* @return the newly created LiveCounter instance.
8884
*/
85+
@Blocking
8986
@NotNull
9087
LiveCounter createCounter(@NotNull Long initialValue);
9188

@@ -97,18 +94,9 @@ public interface LiveObjects {
9794
*
9895
* @param callback the callback to handle the result or error.
9996
*/
97+
@NonBlocking
10098
void getRootAsync(@NotNull Callback<@NotNull LiveMap> callback);
10199

102-
/**
103-
* Initiates a batch operation asynchronously.
104-
* Provides access to the synchronous write API for Objects that can be used to batch multiple operations
105-
* together in a single channel message.
106-
*
107-
* @param batchContextCallback the builder to configure the batch operation.
108-
* @param callback the Callback to handle the completion or error of the batch operation.
109-
*/
110-
void batchAsync(@NotNull BatchContextBuilder batchContextCallback, @NotNull Callback<Void> callback);
111-
112100
/**
113101
* Asynchronously creates a new LiveMap based on an existing LiveMap.
114102
* Send a MAP_CREATE operation to the realtime system to create a new map object in the pool.
@@ -119,6 +107,7 @@ public interface LiveObjects {
119107
* @param liveMap the existing LiveMap to base the new LiveMap on.
120108
* @param callback the callback to handle the result or error.
121109
*/
110+
@NonBlocking
122111
void createMapAsync(@NotNull LiveMap liveMap, @NotNull Callback<@NotNull LiveMap> callback);
123112

124113
/**
@@ -131,6 +120,7 @@ public interface LiveObjects {
131120
* @param liveCounter the LiveCounter to base the new LiveMap on.
132121
* @param callback the callback to handle the result or error.
133122
*/
123+
@NonBlocking
134124
void createMapAsync(@NotNull LiveCounter liveCounter, @NotNull Callback<@NotNull LiveMap> callback);
135125

136126
/**
@@ -143,6 +133,7 @@ public interface LiveObjects {
143133
* @param map the Java Map to base the new LiveMap on.
144134
* @param callback the callback to handle the result or error.
145135
*/
136+
@NonBlocking
146137
void createMapAsync(@NotNull Map<String, Object> map, @NotNull Callback<@NotNull LiveMap> callback);
147138

148139
/**
@@ -155,5 +146,6 @@ public interface LiveObjects {
155146
* @param initialValue the initial value of the LiveCounter.
156147
* @param callback the callback to handle the result or error.
157148
*/
149+
@NonBlocking
158150
void createCounterAsync(@NotNull Long initialValue, @NotNull Callback<@NotNull LiveCounter> callback);
159151
}

lib/src/main/java/io/ably/lib/objects/LiveObjectsPlugin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public interface LiveObjectsPlugin extends PluginInstance {
1818
* @param channelName the name of the channel for which the LiveObjects instance is to be retrieved.
1919
* @return the LiveObjects instance associated with the specified channel name.
2020
*/
21+
@NotNull
2122
LiveObjects getInstance(@NotNull String channelName);
2223

2324
/**

lib/src/main/java/io/ably/lib/objects/batch/BatchContext.java

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

lib/src/main/java/io/ably/lib/objects/batch/BatchContextBuilder.java

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

lib/src/main/java/io/ably/lib/objects/batch/BatchContextLiveMap.java

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

lib/src/main/java/io/ably/lib/realtime/AblyRealtime.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ private LiveObjectsPlugin tryInitializeLiveObjectsPlugin() {
192192
.newInstance(this.connection.connectionManager);
193193
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException |
194194
InvocationTargetException e) {
195-
Log.w(TAG, "LiveObjects plugin not found in classpath. LiveObjects functionality will not be available.", e);
195+
Log.i(TAG, "LiveObjects plugin not found in classpath. LiveObjects functionality will not be available.", e);
196196
return null;
197197
}
198198
}

lib/src/main/java/io/ably/lib/realtime/ChannelBase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ public abstract class ChannelBase extends EventEmitter<ChannelEvent, ChannelStat
9898
public LiveObjects getObjects() throws AblyException {
9999
if (liveObjectsPlugin == null) {
100100
throw AblyException.fromErrorInfo(
101-
new ErrorInfo("LiveObjects plugin hasn't been installed, add runtimeOnly('io.ably:live-objects:<ably-version>') to your dependency tree", 400, 40000)
101+
new ErrorInfo("LiveObjects plugin hasn't been installed, " +
102+
"add runtimeOnly('io.ably:live-objects:<ably-version>') to your dependency tree", 400, 40019)
102103
);
103104
}
104105
return liveObjectsPlugin.getInstance(name);

live-objects/src/main/kotlin/io/ably/lib/objects/DefaultLiveObjects.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ internal class DefaultLiveObjects(private val channelName: String): LiveObjects
88
TODO("Not yet implemented")
99
}
1010

11-
override fun batch(batchContextCallback: BatchContextBuilder) {
12-
TODO("Not yet implemented")
13-
}
14-
1511
override fun createMap(liveMap: LiveMap): LiveMap {
1612
TODO("Not yet implemented")
1713
}
@@ -28,10 +24,6 @@ internal class DefaultLiveObjects(private val channelName: String): LiveObjects
2824
TODO("Not yet implemented")
2925
}
3026

31-
override fun batchAsync(batchContextCallback: BatchContextBuilder, callback: Callback<Void>) {
32-
TODO("Not yet implemented")
33-
}
34-
3527
override fun createMapAsync(liveMap: LiveMap, callback: Callback<LiveMap>) {
3628
TODO("Not yet implemented")
3729
}

0 commit comments

Comments
 (0)