I am struggling with the following:
- The class is constructed through Spring
- It implements the interface that consist of two methods (process, shutdown)
- It also implements Callable
The problem: process() returns a Type and it is called inside the call(), the problem is that process has input parameters which call() signature doesn’t allow. So I referred to this question: Is there a way to take an argument in a callable method?, unfortunately that wouldn't work for me as my object constructed through Spring, process() gets called from the JSP and the input parameters are variable, depending on the user action.
Will include some code for clarification, bellow:
public class MyClass implements MyClassInterface, Callable<Results> {
private String fileLocation;
private final SMTPMailer smtpMalier;
public MyClass(String fileLocation, SMTPMailer smtpMalier) {
this.fileLocation = fileLocation;
this.smtpMalier = smtpMalier;
}
public Results call() {
// to return process(arg1, arg2) here, need to cater for input parameters
}
public Results process(String arg1, String arg2) {
// does some proceeding, returns Results
}
public void shutdown() {
// shut down implementation
}
}
How can I go around this?