I'm creating a Java application that depending on certain conditions/configurations it instantiates a SpringBoot application to receive some HTTP messages.
My problem is that I have a ReceiverService that needs to use some variables that are created outside of the SpringBoot application. Is there a way to pass local java variables (from inside the application, not outside like the shell or files) to SpringBoot components?
Example:
I have a Manager object that, depending on some conditions, it defines a variable param that I want to use in the SpringBoot Component ReceiverService.
public class Manager {
public Manager(bool condition) {
String param = "foo";
if (condition) {
param = "bar";
}
ReceiverApp receiver = new ReceiverApp(); // init SpringBoot app
}
}
The SpringBoot app:
@SpringBootApplication
public class ReceiverApp {
public ReceiverApp() {
SpringApplication.run(ReceiverApp.class);
}
@Component
public class ReceiverService implements InitializingBean {
final CustomObject obj1 = new CustomObject(param);
@Override
public void aFunction() throws Exception {
MyConfig config = MyConfig.build(param);
}
}
