Skip to content

[New Feature]: Runtime API to start the new Runtime and call ballerina function #42128

Description

@warunalakshitha

Description

I have a ballerina program. I will compile it and generate a jar file. Then I will add that jar as dependency to another Java Project. Then I need to start the ballerina program from the external Java Project and call the functions.

Describe your problem(s)

No response

Describe your solution(s)

Provide an Runtime API as below.

import io.ballerina.runtime.api.Runtime;

Runtime balRuntime = Runtime.start(“org”, “module”, 1.0.0);
Object[] args = [];
balRuntime.invokeMethodAsync(“myFunction”, args, callback);
Runtime.stop(“org”, “module”, 1.0.0);

Runtime Class

Class initClass;

public static void start(String orgName, String moduleName, String version) {
String initClassName = orgNAme + “$” + moduleName + “$” + version
	initClass = Class.load(initClassName);
Scheduler s = new Scheduler();
s.schedule(moduleInitFunction);
	initClass.invoke(“moduleInit”); 
}


public static void stop(String orgName, String moduleName, String version) {
	initClass.invoke(“moduleStop”);
}

Related area

-> Runtime

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

Metadata

Metadata

Assignees

Labels

Team/jBallerinaAll the issues related to BIR, JVM backend code generation and runtimeType/NewFeature

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions