getStrandName();
-
- /**
- * Gets {@link StrandMetadata}.
- *
- * @return metadata of the strand.
- */
- public abstract StrandMetadata getStrandMetadata();
+ public abstract String getStrandName();
/**
* Sets given local key value pair in strand.
*
* @param key string key
- * @param value value to be store in the strand
+ * @param value value to be stored in the strand
*/
public abstract void setStrandLocal(String key, Object value);
/**
- * Gets the value stored in the strand on given key.
+ * Gets the value stored in the strand on a given key.
*
* @param key key
* @return value stored in the strand.
*/
public abstract Object getStrandLocal(String key);
+ /**
+ * Gets the current environment repository.
+ *
+ * @return repository.
+ */
public abstract Repository getRepository();
}
diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Module.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Module.java
index 4573b76c3d0e..79ae48530c56 100644
--- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Module.java
+++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Module.java
@@ -62,11 +62,6 @@ public String getName() {
return name;
}
- @Deprecated
- public String getVersion() {
- return majorVersion;
- }
-
public String getMajorVersion() {
return majorVersion;
}
diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Runtime.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Runtime.java
index 186331ad0e6d..d241d690ea1f 100644
--- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Runtime.java
+++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Runtime.java
@@ -17,17 +17,10 @@
package io.ballerina.runtime.api;
-import io.ballerina.runtime.api.async.Callback;
-import io.ballerina.runtime.api.async.StrandMetadata;
-import io.ballerina.runtime.api.types.Type;
+import io.ballerina.runtime.api.concurrent.StrandMetadata;
import io.ballerina.runtime.api.values.BFunctionPointer;
-import io.ballerina.runtime.api.values.BFuture;
import io.ballerina.runtime.api.values.BObject;
import io.ballerina.runtime.internal.BalRuntime;
-import io.ballerina.runtime.internal.scheduling.Scheduler;
-import io.ballerina.runtime.internal.scheduling.Strand;
-
-import java.util.Map;
/**
* External API to be used by the interop users to control Ballerina runtime behavior.
@@ -36,24 +29,11 @@
*/
public abstract class Runtime {
- // TODO: remove this with https://github.com/ballerina-platform/ballerina-lang/issues/40175
- /**
- * Gets the instance of Ballerina runtime.
- *
- * @return Ballerina runtime instance.
- * @deprecated use {@link Environment#getRuntime()} instead.
- */
- @Deprecated(forRemoval = true)
- public static Runtime getCurrentRuntime() {
- Strand strand = Scheduler.getStrand();
- return new BalRuntime(strand.scheduler, null);
- }
-
/**
* Returns an instance of Ballerina runtime for the given module.
*
- * @param module Module instance.
- * @return Ballerina runtime instance.
+ * @param module Module instance.
+ * @return Ballerina runtime instance.
*/
public static Runtime from(Module module) {
return new BalRuntime(module);
@@ -62,12 +42,12 @@ public static Runtime from(Module module) {
/**
* Performs the module initialization.
*/
- public abstract void init();
+ public abstract Object init();
/**
- * Starts the listening phase.
+ * Start the listening phase.
*/
- public abstract void start();
+ public abstract Object start();
/**
* Gracefully shuts down the Ballerina runtime.
@@ -77,115 +57,42 @@ public static Runtime from(Module module) {
public abstract void stop();
/**
- * Invoke Object method asynchronously and sequentially. This method will ensure that the object methods are
- * invoked in the same thread where other object methods are executed. So, the methods will be executed
- * sequentially per object level.
+ * call a Ballerina function.
*
- * @param object Object Value.
- * @param methodName Name of the method.
- * @param strandName Name for newly created strand which is used to execute the function pointer. This is
- * optional and can be null.
- * @param metadata Meta data of new strand.
- * @param callback Callback which will get notified once the method execution is done.
- * @param properties Set of properties for strand.
- * @param returnType Expected return type of this method.
- * @param args Ballerina function arguments.
- * @return {@link BFuture} containing return value for executing this method.
- *
- * This method needs to be called if object.getType().isIsolated() or
- * object.getType().isIsolated(methodName) returns false.
+ * @param module Module of the function.
+ * @param functionName Name of the function.
+ * @param metadata Meta data of new strand.
+ * @param args Arguments of the Ballerina function.
*/
- public abstract BFuture invokeMethodAsyncSequentially(BObject object, String methodName, String strandName,
- StrandMetadata metadata, Callback callback, Map properties,
- Type returnType, Object... args);
+ public abstract Object callFunction(Module module, String functionName, StrandMetadata metadata,
+ Object... args);
/**
- * Invoke Object method asynchronously and concurrently. Caller needs to ensure that no data race is possible for
- * the mutable state with given object method and with arguments. So, the method can be concurrently run with
- * different os threads.
+ * Call a Ballerina object method.
*
- * @param object Object Value.
- * @param methodName Name of the method.
- * @param strandName Name for newly created strand which is used to execute the function pointer. This is
- * optional and can be null.
- * @param metadata Meta data of new strand.
- * @param callback Callback which will get notified once the method execution is done.
- * @param properties Set of properties for strand.
- * @param returnType Expected return type of this method.
- * @param args Ballerina function arguments.
- * @return {@link BFuture} containing return value for executing this method.
- *
- * This method needs to be called if both object.getType().isIsolated() and
- * object.getType().isIsolated(methodName) returns true.
+ * @param object Object Value.
+ * @param methodName Name of the method.
+ * @param metadata Meta data of new strand.
+ * @param args Arguments of the Ballerina function.
*/
- public abstract BFuture invokeMethodAsyncConcurrently(BObject object, String methodName, String strandName,
- StrandMetadata metadata, Callback callback, Map properties,
- Type returnType, Object... args);
+ public abstract Object callMethod(BObject object, String methodName, StrandMetadata metadata,
+ Object... args);
/**
- * Invoke Object method asynchronously. This will schedule the function and block the strand.
- * This API checks whether the object or object method is isolated. So, if an object method is isolated, method
- * will be concurrently executed in different os threads.
- *
- * Caller needs to ensure that no data race is possible for the mutable state with given arguments. So, the
- * method can be concurrently run with different os threads.
- *
- * @param object Object Value.
- * @param methodName Name of the method.
- * @param strandName Name for newly creating strand which is used to execute the function pointer. This is
- * optional and can be null.
- * @param metadata Meta data of new strand.
- * @param callback Callback which will get notify once method execution done.
- * @param properties Set of properties for strand
- * @param returnType Expected return type of this method
- * @param args Ballerina function arguments.
- * @return {@link BFuture} containing return value for executing this method.
- * @deprecated If caller can ensure that given object and object method is isolated and no data race is possible
- * for the mutable state with given arguments, use @invokeMethodAsyncConcurrently
- * otherwise @invokeMethodAsyncSequentially .
- *
- * We can decide the object method isolation if and only if both object.getType().isIsolated() and
- * object.getType().isIsolated(methodName) returns true.
+ * Register a Ballerina listener object in runtime.
+ * @param listener Ballerina Listener object.
*/
- @Deprecated
- public abstract BFuture invokeMethodAsync(BObject object, String methodName, String strandName,
- StrandMetadata metadata, Callback callback,
- Map properties, Type returnType, Object... args);
+ public abstract void registerListener(BObject listener);
/**
- * Invoke Object method asynchronously. This will schedule the function and block the strand.
- *
- * @param object Object Value.
- * @param methodName Name of the method.
- * @param strandName Name for newly created strand which is used to execute the function pointer. This is optional
- * and can be null.
- * @param metadata Meta data of new strand.
- * @param callback Callback which will get notified once the method execution is done.
- * @param args Ballerina function arguments.
- * @return the result of the function invocation.
- * @deprecated If caller can ensure that given object and object method is isolated and no data race is possible
- * for the mutable state with given arguments, use @invokeMethodAsyncConcurrently
- * otherwise @invokeMethodAsyncSequentially .
- *
- * We can decide the object method isolation if both object.getType().isIsolated() and
- * object.getType().isIsolated(methodName) returns true.
+ * Deregister a Ballerina listener object in runtime.
+ * @param listener Ballerina Listener object.
*/
- @Deprecated
- public abstract Object invokeMethodAsync(BObject object, String methodName, String strandName,
- StrandMetadata metadata, Callback callback, Object... args);
-
- public abstract void registerListener(BObject listener);
-
public abstract void deregisterListener(BObject listener);
- public abstract void registerStopHandler(BFunctionPointer