use of org.ballerinalang.natives.NativeElementRepository.NativeFunctionDef in project ballerina by ballerina-lang.
the class NativeUnitLoader method loadNativeAction.
public NativeCallableUnit loadNativeAction(String pkgName, String connectorName, String actionName) {
String key = NativeElementRepository.actionToKey(pkgName, connectorName, actionName);
NativeCallableUnit result = this.nativeUnitsCache.get(key);
if (result == null) {
NativeFunctionDef actionDef = this.nativeElementRepo.lookupNativeAction(pkgName, connectorName, actionName);
if (actionDef != null) {
try {
result = (NativeCallableUnit) Class.forName(actionDef.getClassName()).newInstance();
this.nativeUnitsCache.put(key, result);
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new RuntimeException("Error in loading native action: " + e.getMessage(), e);
}
}
}
return result;
}
use of org.ballerinalang.natives.NativeElementRepository.NativeFunctionDef in project ballerina by ballerina-lang.
the class NativeUnitLoader method loadNativeFunction.
public NativeCallableUnit loadNativeFunction(String pkgName, String functionName) {
String key = NativeElementRepository.functionToKey(pkgName, functionName);
NativeCallableUnit result = this.nativeUnitsCache.get(key);
if (result == null) {
NativeFunctionDef functionDef = this.nativeElementRepo.lookupNativeFunction(pkgName, functionName);
if (functionDef != null) {
try {
result = (NativeCallableUnit) Class.forName(functionDef.getClassName()).newInstance();
this.nativeUnitsCache.put(key, result);
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new RuntimeException("Error in loading native function: " + e.getMessage(), e);
}
}
}
return result;
}
Aggregations