Strong Type Casting vs. invokeMethod for Custom AM Methods in Controller
Scenario:
We have implemented a custom OAF page utilizing a custom Application Module (AM) and a custom Controller (CO). Within our Application Module implementation class (BankStmtAMImpl), we have defined a custom business logic method to process bank statements:
AM Method: // Contained within BankStmtAMImpl.java
public String bankStmtImportNonMT940(int bankId, int branchId) {
BankStmtVOImpl vo = getBankStmtVO1();
String retMsg = null;
// Business logic implementation...
return retMsg;
}
Calling it form controler:
Approach 1.
BankStmtAMImpl objBankStmtAM = (BankStmtAMImpl)pageContext.getApplicationModule(webBean);
String retMsg = objBankStmtAM.bankStmtImportNonMT940(123, 456);
Approach 2
OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean);
java.io.Serializable[] params = { Integer.valueOf(123), Integer.valueOf(456) };
String retMsg = (String)am.invokeMethod("bankStmtImportNonMT940", params);
Which of these two approaches is efficient and recommended considering all are custoom objects including the AM and its function.